From 953f041e904e97c4435e0229b8d88eabe31e5c3d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 10 May 2011 07:34:16 +0000 Subject: [PATCH] Drop Shader::get_param and Program::get_param Rename Shader::get_compiled and Program::get_linked to is_* Use correct _ARB constants --- source/program.cpp | 16 ++++++---------- source/program.h | 3 +-- source/shader.cpp | 14 +++++--------- source/shader.h | 14 +++++++------- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/source/program.cpp b/source/program.cpp index eb9481f2..77fe7e75 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -212,24 +212,20 @@ void Program::bind_attribute(unsigned index, const string &name) void Program::link() { for(list::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); diff --git a/source/program.h b/source/program.h index 1e41e844..4ff3f53a 100644 --- a/source/program.h +++ b/source/program.h @@ -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; diff --git a/source/shader.cpp b/source/shader.cpp index 5ff2eb36..c7a08bfa 100644 --- a/source/shader.cpp +++ b/source/shader.cpp @@ -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); diff --git a/source/shader.h b/source/shader.h index 86a70be0..9482c4ad 100644 --- a/source/shader.h +++ b/source/shader.h @@ -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 -- 2.45.2