1. Robin Wellner
  2. selove

Commits

vrld  committed a6218e2

Add GLSL version number check to PixelEffect::isSupported()

  • Participants
  • Parent commits f00f0c1
  • Branches default

Comments (0)

Files changed (3)

File src/modules/graphics/opengl/PixelEffect.cpp

View file
 #include "GLee.h"
 #include <limits>
 #include <sstream>
+#include <iostream>
 
 namespace
 {
 		return _current_texture_unit;
 	}
 
-
 	PixelEffect::PixelEffect(const std::string& code)
 		: _program(0), _code(code)
 	{
 		glDeleteProgram(_program);
 	}
 
+	std::string PixelEffect::getGLSLVersion()
+	{
+		// GL_SHADING_LANGUAGE_VERSION is not available in OpenGL < 2.1.
+		// Be very pessimistic about the GLSL version in that case.
+		if (!GLEE_VERSION_2_1)
+			return "0.0";
+
+		// the version string always begins with a version number of the format
+		//   major_number.minor_number
+		// or
+		//   major_number.minor_number.release_number
+		std::string versionString((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION));
+		size_t minorEndPos = versionString.find(" ");
+		return versionString.substr(0, minorEndPos);
+	}
+
+
 	bool PixelEffect::isSupported()
 	{
-		return GLEE_VERSION_2_0 && GLEE_ARB_shader_objects && GLEE_ARB_fragment_shader;
+		return GLEE_VERSION_2_0 && GLEE_ARB_shader_objects && GLEE_ARB_fragment_shader && getGLSLVersion() >= "1.2";
 	}
 
 	std::string PixelEffect::getWarnings() const

File src/modules/graphics/opengl/PixelEffect.h

View file
 
 		void attach();
 		static void detach();
+		static std::string getGLSLVersion();
 		static bool isSupported();
 
 		void sendFloat(const std::string& name, int size, const GLfloat* vec, int count);

File src/modules/graphics/opengl/wrap_Graphics.h

View file
 	int w_getRenderTarget(lua_State * L);
 	int w_setPixelEffect(lua_State * L);
 	int w_isSupported(lua_State * L);
-	int w_getGLSLVersion(lua_State * L);
 	int w_draw(lua_State * L);
 	int w_drawq(lua_State * L);
 	int w_drawTest(lua_State * L);