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

This commit is contained in:
vrld
2011-10-26 21:17:40 +02:00
parent f296fbb903
commit cd66b01da3
3 changed files with 20 additions and 3 deletions
+19 -2
View File
@@ -2,6 +2,7 @@
#include "GLee.h"
#include <limits>
#include <sstream>
#include <iostream>
namespace
{
@@ -44,7 +45,6 @@ namespace opengl
return _current_texture_unit;
}
PixelEffect::PixelEffect(const std::string& code)
: _program(0), _code(code)
{
@@ -120,9 +120,26 @@ namespace opengl
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