1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

Added a shader workaround for GPUs on older Android devices

This commit is contained in:
hogliux 2017-03-15 13:21:11 +00:00
parent 501d7299a6
commit 2e08db47ff

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;