1 #include "arb_shader_objects.h"
11 Shader::Shader(ShaderType t)
16 Shader::Shader(ShaderType t, const string &src)
24 void Shader::init(ShaderType t)
28 if(t==FRAGMENT_SHADER)
29 static RequireExtension _ext("GL_ARB_fragment_shader");
30 else if(t==VERTEX_SHADER)
31 static RequireExtension _ext("GL_ARB_vertex_shader");
33 id = glCreateShaderObjectARB(t);
38 glDeleteObjectARB(id);
41 void Shader::source(unsigned count, const char **str, const int *len)
43 glShaderSourceARB(id, count, str, len);
46 void Shader::source(const string &str)
48 source(str.data(), str.size());
51 void Shader::source(const char *str, int len)
53 source(1, &str, &len);
56 void Shader::compile()
58 glCompileShaderARB(id);
60 glGetObjectParameterivARB(id, GL_OBJECT_COMPILE_STATUS_ARB, &value);
61 if(!(compiled = value))
62 throw compile_error(get_info_log());
65 string Shader::get_info_log() const
68 glGetObjectParameterivARB(id, GL_OBJECT_INFO_LOG_LENGTH_ARB, &len);
69 char *buf = new char[len+1];
70 glGetInfoLogARB(id, len+1, &len, buf);