-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGLUtils.cpp
68 lines (58 loc) · 1.49 KB
/
GLUtils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <fstream>
#include <stdio.h>
#include "GLUtils.h"
namespace GLUtils
{
bool CheckShaderStatus(GLuint shader, std::string type, const char* src)
{
GLint stat, compileStatus;
GLsizei length = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
if (!stat)
{
printf("Couldn't compile shader!\n");
glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
if (compileStatus != GL_TRUE || length > 1)
{
GLsizei charsWritten;
GLchar* infoLog = new GLchar[length];
glGetShaderInfoLog(shader, length, &charsWritten, infoLog);
printf("Error to compile: '%s'\n", infoLog);
std::ofstream myfile;
std::string filename = "bad_" + type;
myfile.open (filename);
myfile << src;
myfile << infoLog;
myfile.close();
delete[] infoLog;
exit(1);
}
return false;
}
std::ofstream myfile;
std::string filename = "good_" + type;
myfile.open (filename);
myfile << src;
myfile.close();
return true;
}
bool CheckProgramLinkStatus(GLuint pgm)
{
GLint linkStatus;
GLsizei length = 0;
glGetProgramiv(pgm, GL_LINK_STATUS, &linkStatus);
glGetProgramiv(pgm, GL_INFO_LOG_LENGTH, &length);
if (linkStatus != GL_TRUE || length > 1)
{
GLsizei charsWritten;
GLchar* infoLog = new GLchar[length];
glGetProgramInfoLog(pgm, length, &charsWritten, infoLog);
printf("Error to link: '%s'\n", infoLog);
delete[] infoLog;
return false;
}
return true;
}
}