21 #ifndef SUPER_BUBBA_AWESOME_SPACE_ISHADER_H 22 #define SUPER_BUBBA_AWESOME_SPACE_ISHADER_H 26 #include "glutil/glutil.h" 28 #define MAX_LOG_SIZE 1024 32 virtual void compile() = 0;
33 virtual void checkErrors() = 0;
34 virtual GLuint getGLId() = 0;
36 GLuint compileShader(GLenum type,
const char *source) {
37 GLuint compiledShader = glCreateShader(type);
38 glShaderSource(compiledShader, 1, &source, NULL);
39 glCompileShader(compiledShader);
40 return compiledShader;
43 void logCompileError(GLuint shader, std::string shaderType) {
44 GLchar compileLog[MAX_LOG_SIZE];
46 glGetShaderInfoLog(shader, MAX_LOG_SIZE, NULL, compileLog);
47 Logger::logError(
"Failed to compile shader of type " + shaderType +
"\n" + compileLog);
50 void checkCompileErrors(GLuint *shader, std::string shaderType) {
51 GLint successfullyCompiled =
false;
52 glGetShaderiv(*shader, GL_COMPILE_STATUS, &successfullyCompiled);
53 if (!successfullyCompiled) {
54 logCompileError(*shader, shaderType);
62 #endif //SUPER_BUBBA_AWESOME_SPACE_ISHADER_H