]> git.tdb.fi Git - libs/gl.git/blobdiff - source/program.cpp
Add support for non-square matrix uniforms
[libs/gl.git] / source / program.cpp
index d8827ab5d0f5f095fed0d53424571aff7147f472..37d72e94191b441a1b8be1fcbbd5317db58e794f 100644 (file)
@@ -129,7 +129,6 @@ void Program::link()
                        (*i)->compile();
 
        uniforms.clear();
-       legacy_vars = false;
 
        glLinkProgram(id);
        linked = get_program_i(id, GL_LINK_STATUS);
@@ -144,6 +143,26 @@ void Program::link()
 
        query_uniforms();
        query_attributes();
+
+       for(UniformMap::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
+               require_type(i->second.type);
+       for(AttributeMap::const_iterator i=attributes.begin(); i!=attributes.end(); ++i)
+               require_type(i->second.type);
+}
+
+void Program::require_type(GLenum t)
+{
+       switch(t)
+       {
+       case GL_FLOAT_MAT2x3:
+       case GL_FLOAT_MAT2x4:
+       case GL_FLOAT_MAT3x2:
+       case GL_FLOAT_MAT3x4:
+       case GL_FLOAT_MAT4x2:
+       case GL_FLOAT_MAT4x3:
+               { static Require _req(NV_non_square_matrices); }
+               break;
+       }
 }
 
 void Program::query_uniforms()
@@ -173,8 +192,6 @@ void Program::query_uniforms()
                        info.type = type;
                        uniforms_by_index[i] = &info;
                }
-               else
-                       legacy_vars = true;
        }
 
        if(ARB_uniform_buffer_object)
@@ -294,8 +311,6 @@ void Program::query_attributes()
                        info.size = size;
                        info.type = type;
                }
-               else
-                       legacy_vars = true;
        }
 }