Alex Szpakowski avatar Alex Szpakowski committed fce3ab8

Minor tweaks, balanced disable/enable clientstate calls in SpriteBatches

Comments (0)

Files changed (4)

src/modules/graphics/opengl/ShaderEffect.cpp

 	unloadVolatile();
 }
 
-GLuint ShaderEffect::createShader(const ShaderType &type, const std::string &code)
+GLuint ShaderEffect::createShader(ShaderType type, const std::string &code)
 {
-	GLenum shadertype;
+	GLenum glshadertype;
 	const char *shadertypename = NULL;
 
 	switch (type)
 	{
 	case TYPE_VERTEX:
-		shadertype = GL_VERTEX_SHADER;
+		glshadertype = GL_VERTEX_SHADER;
 		shadertypename = "vertex";
 		break;
 	case TYPE_TESSCONTROL:
-		shadertype = GL_TESS_CONTROL_SHADER;
+		glshadertype = GL_TESS_CONTROL_SHADER;
 		shadertypename = "tesselation control";
 		break;
 	case TYPE_TESSEVAL:
-		shadertype = GL_TESS_EVALUATION_SHADER;
+		glshadertype = GL_TESS_EVALUATION_SHADER;
 		shadertypename = "tesselation evaluation";
 		break;
 	case TYPE_GEOMETRY:
-		shadertype = GL_GEOMETRY_SHADER;
+		glshadertype = GL_GEOMETRY_SHADER;
 		shadertypename = "geometry";
 		break;
 	case TYPE_FRAGMENT:
-		shadertype = GL_FRAGMENT_SHADER;
+		glshadertype = GL_FRAGMENT_SHADER;
 		shadertypename = "fragment";
 		break;
 	default:
 	// clear existing errors
 	while (glGetError() != GL_NO_ERROR);
 
-	GLuint shaderid = glCreateShader(shadertype);
+	GLuint shaderid = glCreateShader(glshadertype);
 
 	if (shaderid == 0) // oh no!
 	{
 		shaderids.push_back(shaderid);
 	}
 
-	if (shaderids.size() == 0)
+	if (shaderids.empty())
 		throw love::Exception("Cannot create shader effect: no valid source code!");
 
 	createProgram(shaderids);

src/modules/graphics/opengl/ShaderEffect.h

 	 * Creates a new ShaderEffect using a list of source codes.
 	 * Must contain at least one vertex or fragment shader source.
 	 * 
-	 * @param shadersources map of shader source codes.
+	 * @param shadersources Map of shader types to source codes.
 	 **/
 	ShaderEffect(const ShaderSources &shadersources);
 
 	GLint getUniformLocation(const std::string &name);
 	void checkSetUniformError();
 	
-	GLuint createShader(const ShaderType &type, const std::string &code);
+	GLuint createShader(ShaderType type, const std::string &code);
 	void createProgram(const std::vector<GLuint> &shaderids);
 
 	GLint getTextureUnit(const std::string &name);

src/modules/graphics/opengl/SpriteBatch.cpp

 
 	glDisableClientState(GL_VERTEX_ARRAY);
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-	glDisableClientState(GL_COLOR_ARRAY);
+
+	if (color)
+		glDisableClientState(GL_COLOR_ARRAY);
 
 	glPopMatrix();
 }

src/modules/graphics/opengl/wrap_Graphics.cpp

 		// call effectCodeToGLSL, returned values will be at the top of the stack
 		lua_pcall(L, 2, 2, 0);
 
-		ShaderEffect::ShaderSources shadersources;
+		ShaderEffect::ShaderSources sources;
 
 		// vertex shader code
 		if (lua_isstring(L, -2))
 		{
 			std::string vertcode(luaL_checkstring(L, -2));
-			shadersources[ShaderEffect::TYPE_VERTEX] = vertcode;
+			sources[ShaderEffect::TYPE_VERTEX] = vertcode;
 		}
 
 		// fragment shader code
 		if (lua_isstring(L, -1))
 		{
 			std::string fragcode(luaL_checkstring(L, -1));
-			shadersources[ShaderEffect::TYPE_FRAGMENT] = fragcode;
+			sources[ShaderEffect::TYPE_FRAGMENT] = fragcode;
 		}
 
-		ShaderEffect *effect = instance->newShaderEffect(shadersources);
+		ShaderEffect *effect = instance->newShaderEffect(sources);
 		luax_newtype(L, "ShaderEffect", GRAPHICS_SHADEREFFECT_T, (void *)effect);
 	}
 	catch(const love::Exception &e)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.