17#ifndef __gui_opengl_shader_h__
18#define __gui_opengl_shader_h__
32 void print_log (
bool is_program,
const std::string& type_name, GLuint
index);
60 operator GLuint ()
const {
return (
index_); }
62 void compile (
const std::string& source) {
63 std::string code =
"#version 330 core\n" + source;
64 DEBUG (
"compiling OpenGL " + this->
type() +
" shader:\n" + code);
66 index_ = gl::CreateShader (TYPE);
69 const char* p = code.c_str();
70 gl::ShaderSource (
index_, 1, &p, NULL);
71 gl::CompileShader (
index_);
73 gl::GetShaderiv (
index_, gl::COMPILE_STATUS, &status);
74 if (status == gl::FALSE_) {
79 static const std::string
type() {
return TYPE == gl::VERTEX_SHADER ?
"vertex" : ( TYPE == gl::FRAGMENT_SHADER ?
"fragment" :
"geometry" ); }
115 gl::DeleteProgram (
index_);
119 operator GLuint ()
const {
124 index_ = gl::CreateProgram();
141 gl::GetProgramiv (
index_, gl::LINK_STATUS, &status);
142 if (status == gl::FALSE_) {
144 throw Exception (std::string (
"error linking OpenGL shader program ID " +
str(
index_)));
154 GL_DEBUG (
"using default OpenGL shader program");
void compile(const std::string &source)
Object & operator=(const Object &)=delete
Object(const std::string &source)
Object(const Object &)=delete
static const std::string type()
Program & operator=(const Program &)=delete
void detach(const Object< TYPE > &object)
Program(const Program &)=delete
void attach(const Object< TYPE > &object)
void print_log(bool is_program, const std::string &type_name, GLuint index)
std::string str(const T &value, int precision=0)