Commits

Alex Szpakowski committed dc47f3b

Removed internal code support for multitexturing without shaders, since it's not currently used and there are no plans to do so

  • Participants
  • Parent commits 3f4ed5e

Comments (0)

Files changed (1)

src/modules/graphics/opengl/OpenGL.cpp

 #include "common/Exception.h"
 
 #include "OpenGL.h"
+#include "Shader.h"
 
 #include <vector>
 #include <algorithm>
 
 	textureUnits.clear();
 
-	// initialize multiple texture unit support, if available
-	if (GLEE_VERSION_1_3 || GLEE_ARB_multitexture)
+	// initialize multiple texture unit support for shaders, if available
+	if (Shader::isSupported())
 	{
 		GLint maxtextureunits;
-		glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxtextureunits);
-
-		// shaders/GL2.0 added "Texture Image Units." Total max texture units is the greater of the two
-		if (GLEE_VERSION_2_0 || GLEE_ARB_vertex_shader)
-		{
-			GLint maxtextureimageunits;
-			glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxtextureimageunits);
-			maxtextureunits = std::max(maxtextureunits, maxtextureimageunits);
-		}
+		glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxtextureunits);
 
 		textureUnits.resize(maxtextureunits, 0);
 
 		GLenum curgltextureunit;
-		glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint *)&curgltextureunit);
+		glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint *) &curgltextureunit);
 
 		curTextureUnit = curgltextureunit - GL_TEXTURE0;
 
-		// retrieve currently bound textures for each texture unit
-		for (size_t i = 0; i < textureUnits.size(); ++i)
+		// Retrieve currently bound textures for each texture unit
+		for (size_t i = 0; i < textureUnits.size(); i++)
 		{
-			if (GLEE_VERSION_1_3)
-				glActiveTexture(GL_TEXTURE0 + i);
-			else
-				glActiveTextureARB(GL_TEXTURE0 + i);
-
+			glActiveTexture(GL_TEXTURE0 + i);
 			glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *) &textureUnits[i]);
 		}
 
-		if (GLEE_VERSION_1_3)
-			glActiveTexture(curgltextureunit);
-		else
-			glActiveTextureARB(curgltextureunit);
+		glActiveTexture(curgltextureunit);
 	}
 	else
 	{
 		// multitexturing not supported, so we only have 1 texture unit
 		textureUnits.resize(1, 0);
 		curTextureUnit = 0;
-
 		glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *) &textureUnits[0]);
 	}
 
 
 void setActiveTextureUnit(int textureunit)
 {
-	initializeContext();
-
 	if (textureunit < 0 || (size_t) textureunit >= textureUnits.size())
 		throw love::Exception("Invalid texture unit index (%d).", textureunit);
 
 	if (textureunit != curTextureUnit)
 	{
-		if (GLEE_VERSION_1_3)
+		if (textureUnits.size() > 1)
 			glActiveTexture(GL_TEXTURE0 + textureunit);
-		else if (GLEE_ARB_multitexture)
-			glActiveTextureARB(GL_TEXTURE0 + textureunit);
 		else
 			throw love::Exception("Multitexturing not supported.");
 	}
 
 void bindTexture(GLuint texture)
 {
-	initializeContext();
-
 	if (texture != textureUnits[curTextureUnit])
 	{
 		textureUnits[curTextureUnit] = texture;
 
 void bindTextureToUnit(GLuint texture, int textureunit, bool restoreprev)
 {
-	initializeContext();
-
 	if (textureunit < 0 || (size_t) textureunit >= textureUnits.size())
 		throw love::Exception("Invalid texture unit index.");
 
 
 void deleteTexture(GLuint texture)
 {
-	initializeContext();
-
 	// glDeleteTextures binds texture 0 to all texture units the deleted texture was bound to
 	std::vector<GLuint>::iterator it;
 	for (it = textureUnits.begin(); it != textureUnits.end(); ++it)
 
 void setTextureFilter(const graphics::Image::Filter &f)
 {
-	initializeContext();
-
 	GLint gmin, gmag;
 
 	if (f.mipmap == Image::FILTER_NONE)
 
 graphics::Image::Filter getTextureFilter()
 {
-	initializeContext();
-
 	GLint gmin, gmag;
 	glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &gmin);
 	glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &gmag);
 
 void setTextureWrap(const graphics::Image::Wrap &w)
 {
-	initializeContext();
-
 	GLint gs, gt;
 
 	switch (w.s)
 
 graphics::Image::Wrap getTextureWrap()
 {
-	initializeContext();
-
 	GLint gs, gt;
 
 	glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, &gs);