3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #define GL_GLEXT_PROTOTYPES
16 Shader::Shader(ShaderType t):
17 id(glCreateShader(t)),
21 Shader::Shader(ShaderType t, const string &src):
22 id(glCreateShader(t)),
34 void Shader::source(sizei count, const char **str, const int *len)
36 glShaderSource(id, count, str, len);
39 void Shader::source(const string &str)
41 source(str.data(), str.size());
44 void Shader::source(const char *str, int len)
46 source(1, &str, &len);
49 bool Shader::compile()
52 compiled=get_param(GL_COMPILE_STATUS);
56 int Shader::get_param(GLenum param) const
59 glGetShaderiv(id, param, &value);
63 string Shader::get_info_log() const
65 sizei len=get_param(GL_INFO_LOG_LENGTH);
67 glGetShaderInfoLog(id, len+1, reinterpret_cast<GLsizei *>(&len), log);
68 return string(log, len);