wrapper for gl shader
#include <program.hpp>
Public Member Functions | |
shader (int shader_type, std::string const &source) | |
std::string const & | source () const |
int | gl_shader_object () const |
void | print_source () const |
Definition at line 107 of file program.hpp.
renderstack::shader::shader | ( | int | shader_type, | |
std::string const & | source | |||
) |
Definition at line 69 of file program.cpp.
00073 : m_source(source) 00074 , m_gl_shader_object((int)(~0)) 00075 { 00076 int status; 00077 const char *source0 = m_source.c_str(); 00078 const char **source_ptr = &source0; 00079 00080 m_gl_shader_object = ::rs_gl_create_shader(shader_type); 00081 00082 ::rs_gl_shader_source (m_gl_shader_object, 1, source_ptr, NULL); 00083 ::rs_gl_compile_shader(m_gl_shader_object); 00084 ::rs_gl_get_shader_iv (m_gl_shader_object, GL_COMPILE_STATUS, &status); 00085 00086 if(status == GL_FALSE) 00087 { 00088 char info_log[4096]; 00089 ::GLsizei length = 0; 00090 00091 ::memset(&info_log[0], 0, 4096); 00092 00093 ::rs_gl_get_shader_info_log(m_gl_shader_object, 4096, &length, &info_log[0]); 00094 ::rs_gl_delete_shader (m_gl_shader_object); 00095 00096 ::rs_log("shader compilation failed:\n%s", info_log); 00097 00098 print_source(); 00099 ::rs_log("\nerrors\n"); 00100 } 00101 }
std::string const& renderstack::shader::source | ( | ) | const [inline] |
Definition at line 115 of file program.hpp.
int renderstack::shader::gl_shader_object | ( | ) | const [inline] |
Definition at line 116 of file program.hpp.
void renderstack::shader::print_source | ( | ) | const |
Definition at line 44 of file program.cpp.
00045 { 00046 int line = 1; 00047 const char *head = m_source.c_str(); 00048 char c; 00049 00050 ::rs_log("%3d: ", line); 00051 for(;;) 00052 { 00053 c = *head; 00054 ++head; 00055 if(c == 0) 00056 { 00057 break; 00058 } 00059 if(c == '\n') 00060 { 00061 ++line; 00062 ::rs_log("\n%3d: ", line); 00063 continue; 00064 } 00065 ::rs_log("%c", c); 00066 } 00067 }