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);
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;
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);
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 &);
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