]> git.tdb.fi Git - libs/gl.git/blobdiff - source/program.cpp
Add some hints for older compilers
[libs/gl.git] / source / program.cpp
index e65a703f77a8d1f5f4b2d769e7c85ca0d439b2bd..6313043ea84361c3f7fbc543324c997eb56d5fc6 100644 (file)
@@ -28,6 +28,8 @@ Program::Program()
        init();
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 Program::Program(const ProgramBuilder::StandardFeatures &features)
 {
        init();
@@ -36,6 +38,7 @@ Program::Program(const ProgramBuilder::StandardFeatures &features)
        builder.add_shaders(*this);
        link();
 }
+#pragma GCC diagnostic pop
 
 Program::Program(const std::string &source)
 {
@@ -143,6 +146,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()
@@ -310,10 +333,9 @@ bool Program::uniform_location_compare(const UniformInfo *uni1, const UniformInf
 string Program::get_info_log() const
 {
        GLsizei len = get_program_i(id, GL_INFO_LOG_LENGTH);
-       char *buf = new char[len+1];
-       glGetProgramInfoLog(id, len+1, &len, buf);
-       string log(buf, len);
-       delete[] buf;
+       string log(len+1, 0);
+       glGetProgramInfoLog(id, len+1, &len, &log[0]);
+       log.erase(len);
        return log;
 }
 
@@ -405,10 +427,13 @@ void Program::Loader::geometry_shader(const string &src)
 
 void Program::Loader::standard()
 {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
        ProgramBuilder::StandardFeatures feat;
        load_sub(feat);
        ProgramBuilder builder(feat);
        builder.add_shaders(obj);
+#pragma GCC diagnostic pop
 }
 
 void Program::Loader::vertex_shader(const string &src)