From 524368331dd11cf9066aec4596697467840b080b Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 4 Mar 2013 13:58:14 -0400 Subject: [PATCH] Removed love.graphics.setColorMode - The "replace" color mode can easily be duplicated with love.graphics.setColor(255, 255, 255) - The current color mode has no effect when a shader is active - Color mode functionality can easily be replicated with shaders - OpenGL ES 2 (iOS, Android, etc) does not have the functions used by love.graphics.setColorMode --- src/modules/graphics/opengl/Graphics.cpp | 29 ------------------- src/modules/graphics/opengl/Graphics.h | 14 +-------- src/modules/graphics/opengl/wrap_Graphics.cpp | 23 --------------- src/modules/graphics/opengl/wrap_Graphics.h | 2 -- 4 files changed, 1 insertion(+), 67 deletions(-) diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 4a3376017..bb847c5da 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -75,7 +75,6 @@ DisplayState Graphics::saveState() s.backgroundColor = getBackgroundColor(); s.blendMode = getBlendMode(); - s.colorMode = getColorMode(); //get line style s.lineStyle = lineStyle; //get the point size @@ -96,7 +95,6 @@ void Graphics::restoreState(const DisplayState &s) setColor(s.color); setBackgroundColor(s.backgroundColor); setBlendMode(s.blendMode); - setColorMode(s.colorMode); setLine(lineWidth, s.lineStyle); setPoint(s.pointSize, s.pointStyle); if (s.scissor) @@ -576,20 +574,6 @@ void Graphics::setBlendMode(Graphics::BlendMode mode) } } -void Graphics::setColorMode(Graphics::ColorMode mode) -{ - if (mode == COLOR_MODULATE) - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - else if (mode == COLOR_COMBINE) - { - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD_SIGNED); - glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); - } - else // mode = COLOR_REPLACE - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); -} - Graphics::BlendMode Graphics::getBlendMode() const { const int gl_1_4 = GLEE_VERSION_1_4; @@ -638,19 +622,6 @@ Graphics::BlendMode Graphics::getBlendMode() const throw Exception("Unknown blend mode"); } -Graphics::ColorMode Graphics::getColorMode() const -{ - GLint mode; - glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &mode); - - if (mode == GL_MODULATE) - return COLOR_MODULATE; - else if (mode == GL_COMBINE) - return COLOR_COMBINE; - else // mode == GL_REPLACE - return COLOR_REPLACE; -} - void Graphics::setDefaultImageFilter(const Image::Filter &f) { Image::setDefaultFilter(f); diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index 50a40540a..e8429106a 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -63,9 +63,8 @@ struct DisplayState Color color; Color backgroundColor; - // Blend and color modes. + // Blend mode. Graphics::BlendMode blendMode; - Graphics::ColorMode colorMode; // Line. Graphics::LineStyle lineStyle; @@ -91,7 +90,6 @@ struct DisplayState backgroundColor.b = 0; backgroundColor.a = 255; blendMode = Graphics::BLEND_ALPHA; - colorMode = Graphics::COLOR_MODULATE; lineStyle = Graphics::LINE_SMOOTH; pointSize = 1.0f; pointStyle = Graphics::POINT_SMOOTH; @@ -306,11 +304,6 @@ public: **/ void setBlendMode(BlendMode mode); - /** - * Sets the current color mode. - **/ - void setColorMode(ColorMode mode); - /** * Sets the current image filter. **/ @@ -321,11 +314,6 @@ public: **/ BlendMode getBlendMode() const; - /** - * Gets the current color mode. - **/ - ColorMode getColorMode() const; - /** * Gets the current image filter. **/ diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 5e381c97d..a5ae23f8c 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -666,17 +666,6 @@ int w_setBlendMode(lua_State *L) return 0; } -int w_setColorMode(lua_State *L) -{ - Graphics::ColorMode mode; - const char *str = luaL_checkstring(L, 1); - if (!Graphics::getConstant(str, mode)) - return luaL_error(L, "Invalid color mode: %s", str); - - instance->setColorMode(mode); - return 0; -} - int w_setDefaultImageFilter(lua_State *L) { Image::FilterMode min; @@ -716,16 +705,6 @@ int w_getBlendMode(lua_State *L) } } -int w_getColorMode(lua_State *L) -{ - Graphics::ColorMode mode = instance->getColorMode(); - const char *str; - if (!Graphics::getConstant(mode, str)) - return luaL_error(L, "Unknown color mode"); - lua_pushstring(L, str); - return 1; -} - int w_getDefaultImageFilter(lua_State *L) { const Image::Filter &f = instance->getDefaultImageFilter(); @@ -1321,10 +1300,8 @@ static const luaL_Reg functions[] = { "getFont", w_getFont }, { "setBlendMode", w_setBlendMode }, - { "setColorMode", w_setColorMode }, { "setDefaultImageFilter", w_setDefaultImageFilter }, { "getBlendMode", w_getBlendMode }, - { "getColorMode", w_getColorMode }, { "getDefaultImageFilter", w_getDefaultImageFilter }, { "setLineWidth", w_setLineWidth }, { "setLineStyle", w_setLineStyle }, diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index fa934bcfb..b86e4abed 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/src/modules/graphics/opengl/wrap_Graphics.h @@ -71,10 +71,8 @@ int w_getBackgroundColor(lua_State *L); int w_setFont(lua_State *L); int w_getFont(lua_State *L); int w_setBlendMode(lua_State *L); -int w_setColorMode(lua_State *L); int w_setDefaultImageFilter(lua_State *L); int w_getBlendMode(lua_State *L); -int w_getColorMode(lua_State *L); int w_getDefaultImageFilter(lua_State *L); int w_setLineWidth(lua_State *L); int w_setLineStyle(lua_State *L);