1 #include "arb_fragment_shader.h"
2 #include "arb_shader_objects.h"
3 #include "arb_vertex_shader.h"
12 Shader::Shader(GLenum t)
17 Shader::Shader(GLenum t, const string &src)
25 void Shader::init(GLenum t)
29 if(t==GL_FRAGMENT_SHADER)
30 static Require _req(ARB_fragment_shader);
31 else if(t==GL_VERTEX_SHADER)
32 static Require _req(ARB_vertex_shader);
34 id = glCreateShader(t);
42 void Shader::source(unsigned count, const char **str, const int *len)
44 glShaderSource(id, count, str, len);
47 void Shader::source(const string &str)
49 source(str.data(), str.size());
52 void Shader::source(const char *str, int len)
54 source(1, &str, &len);
57 void Shader::compile()
61 glGetShaderiv(id, GL_COMPILE_STATUS, &value);
62 if(!(compiled = value))
63 throw compile_error(get_info_log());
66 string Shader::get_info_log() const
69 glGetShaderiv(id, GL_INFO_LOG_LENGTH, &len);
70 char *buf = new char[len+1];
71 glGetShaderInfoLog(id, len+1, &len, buf);
78 VertexShader::VertexShader():
79 Shader(GL_VERTEX_SHADER)
82 VertexShader::VertexShader(const string &src):
83 Shader(GL_VERTEX_SHADER, src)
87 FragmentShader::FragmentShader():
88 Shader(GL_FRAGMENT_SHADER)
91 FragmentShader::FragmentShader(const string &src):
92 Shader(GL_FRAGMENT_SHADER, src)