Browse Source

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

Alex Szpakowski 12 years ago
parent
commit
524368331d

+ 0 - 29
src/modules/graphics/opengl/Graphics.cpp

@@ -75,7 +75,6 @@ DisplayState Graphics::saveState()
 	s.backgroundColor = getBackgroundColor();
 	s.backgroundColor = getBackgroundColor();
 
 
 	s.blendMode = getBlendMode();
 	s.blendMode = getBlendMode();
-	s.colorMode = getColorMode();
 	//get line style
 	//get line style
 	s.lineStyle = lineStyle;
 	s.lineStyle = lineStyle;
 	//get the point size
 	//get the point size
@@ -96,7 +95,6 @@ void Graphics::restoreState(const DisplayState &s)
 	setColor(s.color);
 	setColor(s.color);
 	setBackgroundColor(s.backgroundColor);
 	setBackgroundColor(s.backgroundColor);
 	setBlendMode(s.blendMode);
 	setBlendMode(s.blendMode);
-	setColorMode(s.colorMode);
 	setLine(lineWidth, s.lineStyle);
 	setLine(lineWidth, s.lineStyle);
 	setPoint(s.pointSize, s.pointStyle);
 	setPoint(s.pointSize, s.pointStyle);
 	if (s.scissor)
 	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
 Graphics::BlendMode Graphics::getBlendMode() const
 {
 {
 	const int gl_1_4 = GLEE_VERSION_1_4;
 	const int gl_1_4 = GLEE_VERSION_1_4;
@@ -638,19 +622,6 @@ Graphics::BlendMode Graphics::getBlendMode() const
 	throw Exception("Unknown blend mode");
 	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)
 void Graphics::setDefaultImageFilter(const Image::Filter &f)
 {
 {
 	Image::setDefaultFilter(f);
 	Image::setDefaultFilter(f);

+ 1 - 13
src/modules/graphics/opengl/Graphics.h

@@ -63,9 +63,8 @@ struct DisplayState
 	Color color;
 	Color color;
 	Color backgroundColor;
 	Color backgroundColor;
 
 
-	// Blend and color modes.
+	// Blend mode.
 	Graphics::BlendMode blendMode;
 	Graphics::BlendMode blendMode;
-	Graphics::ColorMode colorMode;
 
 
 	// Line.
 	// Line.
 	Graphics::LineStyle lineStyle;
 	Graphics::LineStyle lineStyle;
@@ -91,7 +90,6 @@ struct DisplayState
 		backgroundColor.b = 0;
 		backgroundColor.b = 0;
 		backgroundColor.a = 255;
 		backgroundColor.a = 255;
 		blendMode = Graphics::BLEND_ALPHA;
 		blendMode = Graphics::BLEND_ALPHA;
-		colorMode = Graphics::COLOR_MODULATE;
 		lineStyle = Graphics::LINE_SMOOTH;
 		lineStyle = Graphics::LINE_SMOOTH;
 		pointSize = 1.0f;
 		pointSize = 1.0f;
 		pointStyle = Graphics::POINT_SMOOTH;
 		pointStyle = Graphics::POINT_SMOOTH;
@@ -306,11 +304,6 @@ public:
 	 **/
 	 **/
 	void setBlendMode(BlendMode mode);
 	void setBlendMode(BlendMode mode);
 
 
-	/**
-	 * Sets the current color mode.
-	 **/
-	void setColorMode(ColorMode mode);
-
 	/**
 	/**
 	 * Sets the current image filter.
 	 * Sets the current image filter.
 	 **/
 	 **/
@@ -321,11 +314,6 @@ public:
 	 **/
 	 **/
 	BlendMode getBlendMode() const;
 	BlendMode getBlendMode() const;
 
 
-	/**
-	 * Gets the current color mode.
-	 **/
-	ColorMode getColorMode() const;
-
 	/**
 	/**
 	 * Gets the current image filter.
 	 * Gets the current image filter.
 	 **/
 	 **/

+ 0 - 23
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -666,17 +666,6 @@ int w_setBlendMode(lua_State *L)
 	return 0;
 	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)
 int w_setDefaultImageFilter(lua_State *L)
 {
 {
 	Image::FilterMode min;
 	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)
 int w_getDefaultImageFilter(lua_State *L)
 {
 {
 	const Image::Filter &f = instance->getDefaultImageFilter();
 	const Image::Filter &f = instance->getDefaultImageFilter();
@@ -1321,10 +1300,8 @@ static const luaL_Reg functions[] =
 	{ "getFont", w_getFont },
 	{ "getFont", w_getFont },
 
 
 	{ "setBlendMode", w_setBlendMode },
 	{ "setBlendMode", w_setBlendMode },
-	{ "setColorMode", w_setColorMode },
 	{ "setDefaultImageFilter", w_setDefaultImageFilter },
 	{ "setDefaultImageFilter", w_setDefaultImageFilter },
 	{ "getBlendMode", w_getBlendMode },
 	{ "getBlendMode", w_getBlendMode },
-	{ "getColorMode", w_getColorMode },
 	{ "getDefaultImageFilter", w_getDefaultImageFilter },
 	{ "getDefaultImageFilter", w_getDefaultImageFilter },
 	{ "setLineWidth", w_setLineWidth },
 	{ "setLineWidth", w_setLineWidth },
 	{ "setLineStyle", w_setLineStyle },
 	{ "setLineStyle", w_setLineStyle },

+ 0 - 2
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_setFont(lua_State *L);
 int w_getFont(lua_State *L);
 int w_getFont(lua_State *L);
 int w_setBlendMode(lua_State *L);
 int w_setBlendMode(lua_State *L);
-int w_setColorMode(lua_State *L);
 int w_setDefaultImageFilter(lua_State *L);
 int w_setDefaultImageFilter(lua_State *L);
 int w_getBlendMode(lua_State *L);
 int w_getBlendMode(lua_State *L);
-int w_getColorMode(lua_State *L);
 int w_getDefaultImageFilter(lua_State *L);
 int w_getDefaultImageFilter(lua_State *L);
 int w_setLineWidth(lua_State *L);
 int w_setLineWidth(lua_State *L);
 int w_setLineStyle(lua_State *L);
 int w_setLineStyle(lua_State *L);