-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#define GL_GLEXT_PROTOTYPES
-#include "shader.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-Shader::Shader(ShaderType t):
- id(glCreateShader(t)),
- compiled(false)
-{ }
-
-Shader::Shader(ShaderType t, const string &src):
- id(glCreateShader(t)),
- compiled(false)
-{
- source(src);
- compile();
-}
-
-Shader::~Shader()
-{
- glDeleteShader(id);
-}
-
-void Shader::source(sizei count, const char **str, const int *len)
-{
- glShaderSource(id, count, str, len);
-}
-
-void Shader::source(const string &str)
-{
- source(str.data(), str.size());
-}
-
-void Shader::source(const char *str, int len)
-{
- source(1, &str, &len);
-}
-
-bool Shader::compile()
-{
- glCompileShader(id);
- compiled=get_param(GL_COMPILE_STATUS);
- return compiled;
-}
-
-int Shader::get_param(GLenum param) const
-{
- int value;
- glGetShaderiv(id, param, &value);
- return value;
-}
-
-string Shader::get_info_log() const
-{
- sizei len=get_param(GL_INFO_LOG_LENGTH);
- char log[len+1];
- glGetShaderInfoLog(id, len+1, reinterpret_cast<GLsizei *>(&len), log);
- return string(log, len);
-}
-
-} // namespace GL
-} // namespace Msp