Browse Source

Added a shader workaround for GPUs on older Android devices

tags/2021-05-28
hogliux 8 years ago
parent
commit
2e08db47ff
1 changed files with 27 additions and 2 deletions
  1. +27
    -2
      modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp

+ 27
- 2
modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp View File

@@ -81,8 +81,33 @@ String OpenGLHelpers::translateVertexShaderToV3 (const String& code)
{
#if JUCE_OPENGL3
if (OpenGLShaderProgram::getLanguageVersion() > 1.2)
return JUCE_GLSL_VERSION "\n" + code.replace ("attribute", "in")
.replace ("varying", "out");
{
String output;
#if JUCE_ANDROID
{
int numAttributes = 0;
for (int p = code.indexOf (0, "attribute "); p >= 0; p = code.indexOf (p + 1, "attribute "))
numAttributes++;
int last = 0;
for (int p = code.indexOf (0, "attribute "); p >= 0; p = code.indexOf (p + 1, "attribute "))
{
output += code.substring (last, p) + String ("layout(location=") + String (--numAttributes) + ") in ";
last = p + 10;
}
output += code.substring (last);
}
#else
output = code.replace ("attribute", "in");
#endif
return JUCE_GLSL_VERSION "\n" + output.replace ("varying", "out");
}
#endif
return code;


Loading…
Cancel
Save