]> git.tdb.fi Git - libs/gl.git/commitdiff
Drop Shader::get_param and Program::get_param
authorMikko Rasa <tdb@tdb.fi>
Tue, 10 May 2011 07:34:16 +0000 (07:34 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 10 May 2011 07:34:16 +0000 (07:34 +0000)
Rename Shader::get_compiled and Program::get_linked to is_*
Use correct _ARB constants

source/program.cpp
source/program.h
source/shader.cpp
source/shader.h

index eb9481f2426ae7908f2a875aa9efa07ab7caed3e..77fe7e7510d9e09597712803ade770267486b26e 100644 (file)
@@ -212,24 +212,20 @@ void Program::bind_attribute(unsigned index, const string &name)
 void Program::link()
 {
        for(list<Shader *>::iterator i=shaders.begin(); i!=shaders.end(); ++i)
-               if(!(*i)->get_compiled())
+               if(!(*i)->is_compiled())
                        (*i)->compile();
 
        glLinkProgramARB(id);
-       if(!(linked = get_param(GL_LINK_STATUS)))
-               throw CompileError(get_info_log());
-}
-
-int Program::get_param(GLenum param) const
-{
        int value;
-       glGetObjectParameterivARB(id, param, &value);
-       return value;
+       glGetObjectParameterivARB(id, GL_OBJECT_LINK_STATUS_ARB, &value);
+       if(!(linked = value))
+               throw CompileError(get_info_log());
 }
 
 string Program::get_info_log() const
 {
-       GLsizei len = get_param(GL_INFO_LOG_LENGTH);
+       GLsizei len = 0;
+       glGetObjectParameterivARB(id, GL_OBJECT_INFO_LOG_LENGTH_ARB, &len);
        char log[len+1];
        glGetInfoLogARB(id, len+1, &len, log);
        return string(log, len);
index 1e41e84423f8680ba787a83d8ecea5c45d1bc7c7..4ff3f53a41c149a2e2d411d25cd52f4ae6873260 100644 (file)
@@ -81,8 +81,7 @@ public:
        void set_del_shaders(bool);
        void bind_attribute(unsigned, const std::string &);
        void link();
-       int get_param(GLenum param) const;
-       bool get_linked() const { return linked; }
+       bool is_linked() const { return linked; }
        std::string get_info_log() const;
        void bind() const;
        int get_uniform_location(const std::string &) const;
index 5ff2eb3609bd33a6fe1b30ae00eecd145f209a1f..c7a08bfac5e0b71f5371cf841506b21c463e845f 100644 (file)
@@ -63,20 +63,16 @@ void Shader::source(const char *str, int len)
 void Shader::compile()
 {
        glCompileShaderARB(id);
-       if(!(compiled = get_param(GL_COMPILE_STATUS)))
+       int value = 0;
+       glGetObjectParameterivARB(id, GL_OBJECT_COMPILE_STATUS_ARB, &value);
+       if(!(compiled = value))
                throw CompileError(get_info_log());
 }
 
-int Shader::get_param(GLenum param) const
-{
-       int value;
-       glGetObjectParameterivARB(id, param, &value);
-       return value;
-}
-
 string Shader::get_info_log() const
 {
-       GLsizei len = get_param(GL_INFO_LOG_LENGTH);
+       GLsizei len = 0;
+       glGetObjectParameterivARB(id, GL_OBJECT_INFO_LOG_LENGTH_ARB, &len);
        char log[len+1];
        glGetInfoLogARB(id, len+1, &len, log);
        return string(log, len);
index 86a70be0e10eb5716b2b296d17e7998c6a8c9e1a..9482c4ad3730b1c68e63494f433e1f604a487aca 100644 (file)
@@ -16,12 +16,16 @@ namespace GL {
 
 enum ShaderType
 {
-       FRAGMENT_SHADER = GL_FRAGMENT_SHADER,
-       VERTEX_SHADER   = GL_VERTEX_SHADER
+       FRAGMENT_SHADER = GL_FRAGMENT_SHADER_ARB,
+       VERTEX_SHADER   = GL_VERTEX_SHADER_ARB
 };
 
 class Shader
 {
+private:
+       unsigned id;
+       bool compiled;
+
 public:
        Shader(ShaderType t);
        Shader(ShaderType t, const std::string &);
@@ -35,12 +39,8 @@ public:
        void source(const char *str, int len);
        void compile();
        unsigned get_id() const { return id; }
-       bool get_compiled() const { return compiled; }
-       int get_param(GLenum param) const;
+       bool is_compiled() const { return compiled; }
        std::string get_info_log() const;
-private:
-       unsigned id;
-       bool compiled;
 };
 
 } // namespace GL