Added support for GLSL 3 shaders (GLSL 3.30 and GLSL ES 3.00).

To use GLSL 3 in a shader, the first line of the shader has to be: #pragma language glsl3

glsl1 is the default language.

Added “glsl3” graphics feature as part of the table returned by love.graphics.getSupported().

Added love.graphics.validateShader(boolean gles, shadercode). It returns a boolean along with an error string if the shader code has errors for its target language and platform (gles or desktop).

Implemented support for Core Profile OpenGL 3.3 in love.graphics.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-01-22 18:54:04 -04:00
parent a6669a8bb2
commit 731b5d5cf0
85 changed files with 50255 additions and 299 deletions
+28 -6
View File
@@ -36,6 +36,8 @@ namespace love
namespace graphics
{
class Graphics;
// A GLSL shader
class Shader : public Object
{
@@ -43,6 +45,15 @@ public:
static love::Type type;
enum Language
{
LANGUAGE_GLSL1,
LANGUAGE_GLSLES1,
LANGUAGE_GLSL3,
LANGUAGE_GLSLES3,
LANGUAGE_MAX_ENUM
};
enum ShaderStage
{
STAGE_VERTEX,
@@ -122,6 +133,7 @@ public:
static Shader *defaultShader;
static Shader *defaultVideoShader;
Shader(const ShaderSource &source);
virtual ~Shader();
/**
@@ -158,26 +170,36 @@ public:
**/
virtual void setVideoTextures(ptrdiff_t ytexture, ptrdiff_t cbtexture, ptrdiff_t crtexture) = 0;
static bool validate(Graphics *gfx, bool gles, const ShaderSource &source, bool checkWithDefaults, std::string &err);
static bool initialize();
static void deinitialize();
static bool getConstant(const char *in, Language &out);
static bool getConstant(Language in, const char *&out);
static bool getConstant(const char *in, ShaderStage &out);
static bool getConstant(ShaderStage in, const char *&out);
static bool getConstant(const char *in, UniformType &out);
static bool getConstant(UniformType in, const char *&out);
static bool getConstant(const char *in, VertexAttribID &out);
static bool getConstant(VertexAttribID in, const char *&out);
static bool getConstant(const char *in, BuiltinUniform &out);
static bool getConstant(BuiltinUniform in, const char *&out);
protected:
// Source code used for this Shader.
ShaderSource shaderSource;
private:
static StringMap<Language, LANGUAGE_MAX_ENUM>::Entry languageEntries[];
static StringMap<Language, LANGUAGE_MAX_ENUM> languages;
static StringMap<ShaderStage, STAGE_MAX_ENUM>::Entry stageNameEntries[];
static StringMap<ShaderStage, STAGE_MAX_ENUM> stageNames;
static StringMap<UniformType, UNIFORM_MAX_ENUM>::Entry uniformTypeEntries[];
static StringMap<UniformType, UNIFORM_MAX_ENUM> uniformTypes;
// Names for the generic vertex attributes used by love.
static StringMap<VertexAttribID, ATTRIB_MAX_ENUM>::Entry attribNameEntries[];
static StringMap<VertexAttribID, ATTRIB_MAX_ENUM> attribNames;