#ifndef RTS_GLSHADERS #define RTS_GLSHADERS #include //#include "windows.h" #include #include "rtsSourceCode.h" class rts_glShaderObject { private: void init() { id = 0; compiled = false; type = GL_FRAGMENT_SHADER; } public: bool compiled; GLenum type; rtsSourceCode source; GLuint id; string log; rts_glShaderObject(GLenum type, const char* filename) { init(); //initialize the shader SetType(type); //set the shader type LoadSource(filename); //load the source code } rts_glShaderObject(GLenum type, rtsSourceCode sourceCode) { init(); //initialize the shader SetType(type); //set the shader type source = sourceCode; } rts_glShaderObject() { init(); } rts_glShaderObject(GLenum type) { init(); SetType(type); } void LoadSource(const char* filename) { source = rtsSourceCode(filename); //get the shader source code } void SetType(GLenum type) { if(id != 0) //if a shader currently exists, delete it { glDeleteShader(id); id = 0; } type = type; id = glCreateShader(type); //create a shader object if(id == 0) //if a shader was not created, log an error { log = "Error getting shader ID from OpenGL"; return; } } void UploadSource() { //create the structure for the shader source code GLsizei count = source.source.size(); GLchar** code_string = new GLchar*[count]; GLint* length = new GLint[count]; for(int l = 0; l