X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fshader.cpp;h=0c356f5f460826f7e97877881d15f35ba3db36f0;hp=a1c576d8b3384c87fe31ff0e677e95224f21e44b;hb=0cacf19c2e6aaa182ae0fcc7dfaae345aedd0e74;hpb=619aae12e01f25e79626a94c973927e5599e99a5 diff --git a/source/shader.cpp b/source/shader.cpp index a1c576d8..0c356f5f 100644 --- a/source/shader.cpp +++ b/source/shader.cpp @@ -1,7 +1,10 @@ #include +#include #include #include +#include #include "error.h" +#include "misc.h" #include "shader.h" using namespace std; @@ -30,6 +33,8 @@ void Shader::init(GLenum t) static Require _req(ARB_fragment_shader); else if(t==GL_VERTEX_SHADER) static Require _req(ARB_vertex_shader); + else if(t==GL_GEOMETRY_SHADER) + static Require _req(ARB_geometry_shader4); id = glCreateShader(t); } @@ -57,16 +62,20 @@ void Shader::source(const char *str, int len) void Shader::compile() { glCompileShader(id); - int value = 0; - glGetShaderiv(id, GL_COMPILE_STATUS, &value); - if(!(compiled = value)) + compiled = get_shader_i(id, GL_COMPILE_STATUS); + if(!compiled) throw compile_error(get_info_log()); + +#ifdef DEBUG + string info_log = get_info_log(); + if(!info_log.empty()) + IO::print("Shader compile info log:\n%s", info_log); +#endif } string Shader::get_info_log() const { - GLsizei len = 0; - glGetShaderiv(id, GL_INFO_LOG_LENGTH, &len); + GLsizei len = get_shader_i(id, GL_INFO_LOG_LENGTH); char *buf = new char[len+1]; glGetShaderInfoLog(id, len+1, &len, buf); string log(buf, len); @@ -92,5 +101,14 @@ FragmentShader::FragmentShader(const string &src): Shader(GL_FRAGMENT_SHADER, src) { } + +GeometryShader::GeometryShader(): + Shader(GL_GEOMETRY_SHADER) +{ } + +GeometryShader::GeometryShader(const string &src): + Shader(GL_GEOMETRY_SHADER, src) +{ } + } // namespace GL } // namespace Msp