Constified many Graphics and Window methods

This commit is contained in:
Alex Szpakowski
2013-02-16 01:45:01 -04:00
parent eba8cbc0b5
commit a68bdfe7a2
5 changed files with 67 additions and 67 deletions
+20 -20
View File
@@ -60,7 +60,7 @@ const char *Graphics::getName() const
return "love.graphics.opengl";
}
bool Graphics::checkMode(int width, int height, bool fullscreen)
bool Graphics::checkMode(int width, int height, bool fullscreen) const
{
return currentWindow->checkWindowSize(width, height, fullscreen);
}
@@ -181,7 +181,7 @@ bool Graphics::setMode(int width, int height, bool fullscreen, bool vsync, int f
return success;
}
void Graphics::getMode(int &width, int &height, bool &fullscreen, bool &vsync, int &fsaa)
void Graphics::getMode(int &width, int &height, bool &fullscreen, bool &vsync, int &fsaa) const
{
currentWindow->getWindow(width, height, fullscreen, vsync, fsaa);
}
@@ -226,36 +226,36 @@ void Graphics::setCaption(const char *caption)
currentWindow->setWindowTitle(title);
}
int Graphics::getCaption(lua_State *L)
int Graphics::getCaption(lua_State *L) const
{
std::string title = currentWindow->getWindowTitle();
lua_pushstring(L, title.c_str());
return 1;
}
int Graphics::getWidth()
int Graphics::getWidth() const
{
return currentWindow->getWidth();
}
int Graphics::getHeight()
int Graphics::getHeight() const
{
return currentWindow->getHeight();
}
int Graphics::getRenderHeight()
int Graphics::getRenderHeight() const
{
if (Canvas::current)
return Canvas::current->getHeight();
return getHeight();
}
bool Graphics::isCreated()
bool Graphics::isCreated() const
{
return currentWindow->isCreated();
}
int Graphics::getModes(lua_State *L)
int Graphics::getModes(lua_State *L) const
{
int n;
love::window::Window::WindowSize **modes = currentWindow->getFullscreenSizes(n);
@@ -302,7 +302,7 @@ void Graphics::setScissor()
glDisable(GL_SCISSOR_TEST);
}
int Graphics::getScissor(lua_State *L)
int Graphics::getScissor(lua_State *L) const
{
if (glIsEnabled(GL_SCISSOR_TEST) == GL_FALSE)
return 0;
@@ -451,7 +451,7 @@ void Graphics::setColor(const Color &c)
glColor4ubv(&c.r);
}
Color Graphics::getColor()
Color Graphics::getColor() const
{
float c[4];
glGetFloatv(GL_CURRENT_COLOR, c);
@@ -470,7 +470,7 @@ void Graphics::setBackgroundColor(const Color &c)
glClearColor((float)c.r/255.0f, (float)c.g/255.0f, (float)c.b/255.0f, (float)c.a/255.0f);
}
Color Graphics::getBackgroundColor()
Color Graphics::getBackgroundColor() const
{
float c[4];
glGetFloatv(GL_COLOR_CLEAR_VALUE, c);
@@ -495,7 +495,7 @@ void Graphics::setFont(Font *font)
currentFont->retain();
}
Font *Graphics::getFont()
Font *Graphics::getFont() const
{
return currentFont;
}
@@ -549,7 +549,7 @@ void Graphics::setColorMode(Graphics::ColorMode mode)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
Graphics::BlendMode Graphics::getBlendMode()
Graphics::BlendMode Graphics::getBlendMode() const
{
GLint dst, src, equation;
glGetIntegerv(GL_BLEND_DST, &dst);
@@ -572,7 +572,7 @@ Graphics::BlendMode Graphics::getBlendMode()
return BLEND_MAX_ENUM; // Should never be reached.
}
Graphics::ColorMode Graphics::getColorMode()
Graphics::ColorMode Graphics::getColorMode() const
{
GLint mode;
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &mode);
@@ -614,12 +614,12 @@ void Graphics::setLine(float width, Graphics::LineStyle style)
setLineStyle(style);
}
float Graphics::getLineWidth()
float Graphics::getLineWidth() const
{
return lineWidth;
}
Graphics::LineStyle Graphics::getLineStyle()
Graphics::LineStyle Graphics::getLineStyle() const
{
return lineStyle;
}
@@ -647,14 +647,14 @@ void Graphics::setPoint(float size, Graphics::PointStyle style)
glPointSize((GLfloat)size);
}
float Graphics::getPointSize()
float Graphics::getPointSize() const
{
GLfloat size;
glGetFloatv(GL_POINT_SIZE, &size);
return (float)size;
}
Graphics::PointStyle Graphics::getPointStyle()
Graphics::PointStyle Graphics::getPointStyle() const
{
if (glIsEnabled(GL_POINT_SMOOTH) == GL_TRUE)
return POINT_SMOOTH;
@@ -662,7 +662,7 @@ Graphics::PointStyle Graphics::getPointStyle()
return POINT_ROUGH;
}
int Graphics::getMaxPointSize()
int Graphics::getMaxPointSize() const
{
GLint max;
glGetIntegerv(GL_POINT_SIZE_MAX, &max);
@@ -1113,7 +1113,7 @@ void Graphics::shear(float kx, float ky)
glMultMatrixf((const GLfloat *)t.getElements());
}
bool Graphics::hasFocus()
bool Graphics::hasFocus() const
{
return currentWindow->hasFocus();
}
+20 -20
View File
@@ -117,7 +117,7 @@ public:
* @param width The window width.
* @param height The window height.
**/
bool checkMode(int width, int height, bool fullscreen);
bool checkMode(int width, int height, bool fullscreen) const;
DisplayState saveState();
@@ -141,7 +141,7 @@ public:
* @param vsync Pointer to a boolean for the vsync status.
* @param fsaa Pointer to an integer for the current number of full scene anti-aliasing buffers.
**/
void getMode(int &width, int &height, bool &fullscreen, bool &vsync, int &fsaa);
void getMode(int &width, int &height, bool &fullscreen, bool &vsync, int &fsaa) const;
/**
* Toggles fullscreen. Note that this also needs to reload the
@@ -177,22 +177,22 @@ public:
**/
void setCaption(const char *caption);
int getCaption(lua_State *L);
int getCaption(lua_State *L) const;
/**
* Gets the width of the current display mode.
**/
int getWidth();
int getWidth() const;
/**
* Gets the height of the current display mode.
**/
int getHeight();
int getHeight() const;
/**
* True if some display mode is set.
**/
bool isCreated();
bool isCreated() const;
/**
* This native Lua function gets available modes
@@ -207,7 +207,7 @@ public:
* Only fullscreen modes are returned here, as all
* window sizes are supported (normally).
**/
int getModes(lua_State *L);
int getModes(lua_State *L) const;
/**
* Scissor defines a box such that everything outside that box is discarded and not drawn.
@@ -228,7 +228,7 @@ public:
* This native Lua function gets the current scissor box in the order of:
* x, y, width, height
**/
int getScissor(lua_State *L);
int getScissor(lua_State *L) const;
/**
* Enables the stencil buffer and set stencil function to fill it
@@ -281,7 +281,7 @@ public:
/**
* Gets current color.
**/
Color getColor();
Color getColor() const;
/**
* Sets the background Color.
@@ -291,7 +291,7 @@ public:
/**
* Gets the current background color.
**/
Color getBackgroundColor();
Color getBackgroundColor() const;
/**
* Sets the current font.
@@ -301,7 +301,7 @@ public:
/**
* Gets the current Font, or nil if none.
**/
Font *getFont();
Font *getFont() const;
/**
* Sets the current blend mode.
@@ -321,12 +321,12 @@ public:
/**
* Gets the current blend mode.
**/
BlendMode getBlendMode();
BlendMode getBlendMode() const;
/**
* Gets the current color mode.
**/
ColorMode getColorMode();
ColorMode getColorMode() const;
/**
* Gets the current image filter.
@@ -354,12 +354,12 @@ public:
/**
* Gets the line width.
**/
float getLineWidth();
float getLineWidth() const;
/**
* Gets the line style.
**/
LineStyle getLineStyle();
LineStyle getLineStyle() const;
/**
* Sets the size of points.
@@ -380,18 +380,18 @@ public:
/**
* Gets the point size.
**/
float getPointSize();
float getPointSize() const;
/**
* Gets the point style.
**/
PointStyle getPointStyle();
PointStyle getPointStyle() const;
/**
* Gets the maximum point size supported.
* This may vary from computer to computer.
**/
int getMaxPointSize();
int getMaxPointSize() const;
/**
* Draws text at the specified coordinates, with rotation and
@@ -511,7 +511,7 @@ public:
void translate(float x, float y);
void shear(float kx, float ky);
bool hasFocus();
bool hasFocus() const;
private:
Font *currentFont;
@@ -522,7 +522,7 @@ private:
GLint matrixLimit;
GLint userMatrices;
int getRenderHeight();
int getRenderHeight() const;
}; // Graphics
} // opengl