-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbglshader.cpp
More file actions
43 lines (37 loc) · 1.1 KB
/
bglshader.cpp
File metadata and controls
43 lines (37 loc) · 1.1 KB
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
#include "bglshader.h"
#include <iostream>
BGLShader::BGLShader()
{
glewInit();
}
void BGLShader::run() {
const GLchar * data[] = {
"void main(void)"
"{"
" gl_FragColor = vec4(0.7, 1.0, 1.0, 1.0);"
"}"
};
GLuint fragment = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSourceARB(fragment, 1, data, 0);
glCompileShaderARB(fragment);
GLint compiled;
glGetObjectParameterivARB(fragment, GL_COMPILE_STATUS, &compiled);
if (!compiled) {
//GLint length;
//glGetObjectParameterivARB(fragment, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
//GLchar * log = new GLchar[length];
//glGetInfoLogARBARB(fragment, length, &length, log);
std::cout << "Compile log: " << std::endl;
}
GLint program = glCreateProgram();
glAttachShader(program, fragment);
glLinkProgram(program);
GLint linked;
glGetProgramiv(program, GL_LINK_STATUS, &linked);
if (linked) {
glUseProgram(program);
std::cout << "Baf" << std::endl;
} else {
std::cout << "error program" << std::endl;
}
}