diff --git a/extras/Demo/Source/Demos/OpenGLDemo2D.cpp b/extras/Demo/Source/Demos/OpenGLDemo2D.cpp index e94c6bea4d..1a8cdef61e 100644 --- a/extras/Demo/Source/Demos/OpenGLDemo2D.cpp +++ b/extras/Demo/Source/Demos/OpenGLDemo2D.cpp @@ -120,8 +120,7 @@ public: void selectPreset (int preset) { - const ShaderPreset& p = getPresets()[preset]; - fragmentDocument.replaceAllContent (p.fragmentShader); + fragmentDocument.replaceAllContent (getPresets()[preset].fragmentShader); startTimer (1); } @@ -212,8 +211,8 @@ private: " " JUCE_MEDIUMP " vec4 colour2 = vec4 (0.0, 0.8, 0.6, 1.0);\n" " " JUCE_MEDIUMP " float distance = distance (pixelPos, vec2 (600.0, 500.0));\n" "\n" - " " JUCE_MEDIUMP " const float innerRadius = 200.0;\n" - " " JUCE_MEDIUMP " const float outerRadius = 210.0;\n" + " " JUCE_MEDIUMP " float innerRadius = 200.0;\n" + " " JUCE_MEDIUMP " float outerRadius = 210.0;\n" "\n" " if (distance < innerRadius)\n" " gl_FragColor = colour1;\n" diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index b257841b25..b95a17956a 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -354,13 +354,15 @@ public: " gl_Position = vec4 (scaledPos.x - 1.0, 1.0 - scaledPos.y, 0, 1.0);" "}"); - compiledOk = program.addFragmentShader (fragmentShader); + if (! program.addFragmentShader (fragmentShader)) + lastError = program.getLastError(); + program.link(); JUCE_CHECK_OPENGL_ERROR } OpenGLShaderProgram program; - bool compiledOk; + String lastError; }; struct ShaderBase : public ShaderProgramHolder @@ -1786,7 +1788,9 @@ struct CustomProgram : public ReferenceCountedObject, { ReferenceCountedObjectPtr c (new CustomProgram (*sc, code)); - if (c->compiledOk) + errorMessage = c->lastError; + + if (errorMessage.isEmpty()) { if (OpenGLContext* context = OpenGLContext::getCurrentContext()) { @@ -1794,8 +1798,6 @@ struct CustomProgram : public ReferenceCountedObject, return c; } } - - errorMessage = c->program.getLastError(); } return nullptr; @@ -1807,7 +1809,7 @@ struct CustomProgram : public ReferenceCountedObject, OpenGLGraphicsContextCustomShader::OpenGLGraphicsContextCustomShader (const String& fragmentShaderCode) : code (String (JUCE_DECLARE_VARYING_COLOUR JUCE_DECLARE_VARYING_PIXELPOS - "\nfloat pixelAlpha = frontColour.a;\n") + fragmentShaderCode), + "\n" JUCE_MEDIUMP " float pixelAlpha = frontColour.a;\n") + fragmentShaderCode), hashName (String::toHexString (fragmentShaderCode.hashCode64()) + "_shader") { }