]> git.tdb.fi Git - libs/gl.git/commitdiff
Legacy shader compatibility fixes for OpenGL ES
authorMikko Rasa <tdb@tdb.fi>
Sun, 19 Oct 2014 16:28:24 +0000 (19:28 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 19 Oct 2014 17:06:14 +0000 (20:06 +0300)
source/programbuilder.cpp

index 8215220081fd2cb6a32a543877bd208e3823fc7f..55d2cf22d9962e3ed1622119a31b1ae592ef761e 100644 (file)
@@ -374,6 +374,7 @@ string ProgramBuilder::create_source(const list<ShaderVariable *> &variables, Va
 {
        string source;
 
+       bool legacy_qualifiers = features.legacy || (get_gl_api()==OPENGL_ES2 && !(get_glsl_version()>=Version(3, 0)));
        bool use_blocks = !features.legacy && ARB_uniform_buffer_object;
 
        if(!features.legacy)
@@ -427,13 +428,13 @@ string ProgramBuilder::create_source(const list<ShaderVariable *> &variables, Va
 
                if(interface&INPUT)
                {
-                       const char *qualifier = (features.legacy ? scope==VERTEX ? "attribute" : "varying" : "in");
+                       const char *qualifier = (legacy_qualifiers ? scope==VERTEX ? "attribute" : "varying" : "in");
                        source += format("%s %s;\n", qualifier, (*i)->create_declaration(interfaces[scope-1]));
                }
 
                if(interface&OUTPUT)
                {
-                       const char *qualifier = (features.legacy ? "varying" : "out");
+                       const char *qualifier = (legacy_qualifiers ? "varying" : "out");
                        source += format("%s %s;\n", qualifier, (*i)->create_declaration(interfaces[scope]));
                }
        }
@@ -687,7 +688,7 @@ ProgramBuilder::StandardFeatures::StandardFeatures():
        normalmap(false),
        shadow(false),
        reflection(false),
-       legacy(!(get_glsl_version()>=Version(1, 30)))
+       legacy(get_gl_api()==OPENGL && !(get_glsl_version()>=Version(1, 30)))
 { }
 
 string ProgramBuilder::StandardFeatures::create_flags() const