]> git.tdb.fi Git - libs/gl.git/commitdiff
Check and report the use of legacy built-in variables in a program
authorMikko Rasa <tdb@tdb.fi>
Mon, 25 Nov 2013 15:25:22 +0000 (17:25 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 25 Nov 2013 15:25:22 +0000 (17:25 +0200)
source/program.cpp
source/program.h

index 111cf64b1d31886e3d33cf831d89c01642a18a6e..ffdd3b6380e03180a6e3790ea730d57fcd6d8832 100644 (file)
@@ -94,6 +94,7 @@ void Program::link()
                        (*i)->compile();
 
        uniforms.clear();
+       legacy_vars = false;
 
        glLinkProgram(id);
        int value;
@@ -127,6 +128,20 @@ void Program::link()
                        info.type = type;
                        uniforms_by_index[i] = &info;
                }
+               else
+                       legacy_vars = true;
+       }
+
+       glGetProgramiv(id, GL_ACTIVE_ATTRIBUTES, &count);
+       for(int i=0; i<count; ++i)
+       {
+               char name[128];
+               int len = 0;
+               int size;
+               GLenum type;
+               glGetActiveAttrib(id, i, sizeof(name), &len, &size, &type, name);
+               if(len && !strncmp(name, "gl_", 3))
+                       legacy_vars = true;
        }
 
        if(ARB_uniform_buffer_object)
index 8cdfb6de44e561910b0f4e446d0d0095bab76b89..a7622ecbb586d42d83d9d2380bcdd5d3978d3e24 100644 (file)
@@ -64,6 +64,7 @@ private:
        UniformBlockMap uniform_blocks;
        UniformMap uniforms;
        unsigned uniform_layout_hash;
+       bool legacy_vars;
 
 public:
        Program();
@@ -96,6 +97,8 @@ public:
        const UniformInfo &get_uniform_info(const std::string &) const;
        int get_uniform_location(const std::string &) const;
 
+       bool uses_legacy_variables() const { return legacy_vars; }
+
        void bind() const;
        static void unbind();
 };