]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programbuilder.cpp
Support OpenGL ES on Android
[libs/gl.git] / source / programbuilder.cpp
index 1e8f55773de8081a9ae99504289df7d7e5418f63..d8fe22ed14542fe8ce93fe670daeed566f122448 100644 (file)
@@ -345,7 +345,10 @@ void ProgramBuilder::add_shaders(Program &prog) const
 
        if(!features.legacy)
        {
-               prog.bind_fragment_data(0, "frag_color");
+               // OpenGL ES does not support binding fragment shader outputs
+               if(get_gl_api()!=OPENGL_ES2)
+                       prog.bind_fragment_data(0, "frag_color");
+
                prog.bind_attribute(VERTEX4, "vertex");
                if(features.lighting)
                        prog.bind_attribute(NORMAL3, "normal");
@@ -369,9 +372,17 @@ string ProgramBuilder::create_source(const list<ShaderVariable *> &variables, Va
 
        if(!features.legacy)
        {
-               source += "#version 130\n";
-               if(use_blocks)
-                       source += "#extension GL_ARB_uniform_buffer_object: require\n";
+               if(get_gl_api()==OPENGL_ES2)
+               {
+                       if(use_blocks)
+                               source += "#version 300 es\n";
+               }
+               else
+               {
+                       source += "#version 130\n";
+                       if(use_blocks)
+                               source += "#extension GL_ARB_uniform_buffer_object: require\n";
+               }
        }
 
        set<const VariableDefinition *> declared_types;