Browse Source

Android GL fixes.

tags/2021-05-28
jules 11 years ago
parent
commit
fa2b42a742
2 changed files with 11 additions and 10 deletions
  1. +3
    -4
      extras/Demo/Source/Demos/OpenGLDemo2D.cpp
  2. +8
    -6
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp

+ 3
- 4
extras/Demo/Source/Demos/OpenGLDemo2D.cpp View File

@@ -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"


+ 8
- 6
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp View File

@@ -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<CustomProgram> 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")
{
}


Loading…
Cancel
Save