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
+5 -10
View File
@@ -37,7 +37,7 @@ namespace opengl
{
Shader::Shader(const ShaderSource &source)
: shaderSource(source)
: love::graphics::Shader(source)
, program(0)
, builtinUniforms()
, builtinAttributes()
@@ -46,9 +46,6 @@ Shader::Shader(const ShaderSource &source)
, lastPointSize(0.0f)
, videoTextureUnits()
{
if (source.vertex.empty() && source.pixel.empty())
throw love::Exception("Cannot create shader: no source code!");
// load shader source and create program object
loadVolatile();
}
@@ -360,14 +357,12 @@ bool Shader::loadVolatile()
std::vector<GLuint> shaderids;
bool gammacorrect = graphics::isGammaCorrect();
const ShaderSource *defaults = &Graphics::defaultShaderCode[Graphics::RENDERER_OPENGL][gammacorrect ? 1 : 0];
if (GLAD_ES_VERSION_2_0)
defaults = &Graphics::defaultShaderCode[Graphics::RENDERER_OPENGLES][gammacorrect ? 1 : 0];
auto gfx = Module::getInstance<love::graphics::Graphics>(Module::M_GRAPHICS);
const ShaderSource &defaults = gfx->getCurrentDefaultShaderCode();
// The shader program must have both vertex and pixel shader stages.
const std::string &vertexcode = shaderSource.vertex.empty() ? defaults->vertex : shaderSource.vertex;
const std::string &pixelcode = shaderSource.pixel.empty() ? defaults->pixel : shaderSource.pixel;
const std::string &vertexcode = shaderSource.vertex.empty() ? defaults.vertex : shaderSource.vertex;
const std::string &pixelcode = shaderSource.pixel.empty() ? defaults.pixel : shaderSource.pixel;
try
{