mirror of
https://github.com/love2d/love.git
synced 2026-08-20 20:49:54 +02:00
Add GLSL version number check to PixelEffect::isSupported()
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include "GLee.h"
|
#include "GLee.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -44,7 +45,6 @@ namespace opengl
|
|||||||
return _current_texture_unit;
|
return _current_texture_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PixelEffect::PixelEffect(const std::string& code)
|
PixelEffect::PixelEffect(const std::string& code)
|
||||||
: _program(0), _code(code)
|
: _program(0), _code(code)
|
||||||
{
|
{
|
||||||
@@ -120,9 +120,26 @@ namespace opengl
|
|||||||
glDeleteProgram(_program);
|
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()
|
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
|
std::string PixelEffect::getWarnings() const
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace opengl
|
|||||||
|
|
||||||
void attach();
|
void attach();
|
||||||
static void detach();
|
static void detach();
|
||||||
|
static std::string getGLSLVersion();
|
||||||
static bool isSupported();
|
static bool isSupported();
|
||||||
|
|
||||||
void sendFloat(const std::string& name, int size, const GLfloat* vec, int count);
|
void sendFloat(const std::string& name, int size, const GLfloat* vec, int count);
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ namespace opengl
|
|||||||
int w_getRenderTarget(lua_State * L);
|
int w_getRenderTarget(lua_State * L);
|
||||||
int w_setPixelEffect(lua_State * L);
|
int w_setPixelEffect(lua_State * L);
|
||||||
int w_isSupported(lua_State * L);
|
int w_isSupported(lua_State * L);
|
||||||
int w_getGLSLVersion(lua_State * L);
|
|
||||||
int w_draw(lua_State * L);
|
int w_draw(lua_State * L);
|
||||||
int w_drawq(lua_State * L);
|
int w_drawq(lua_State * L);
|
||||||
int w_drawTest(lua_State * L);
|
int w_drawTest(lua_State * L);
|
||||||
|
|||||||
Reference in New Issue
Block a user