This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GLchar* FragmentShader = | |
{ | |
"#version 400\n"\ | |
"in vec4 ex_Color;\n"\ | |
"out vec4 out_Color;\n"\ | |
"void main(void)\n"\ | |
"{\n"\ | |
" out_Color = ex_Color;\n"\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Cleanup(void); | |
void CreateVBO(void); | |
void DestroyVBO(void); | |
void CreateShaders(void); | |
void DestroyShaders(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CreateShaders(); | |
CreateVBO(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glutCloseFunc(Cleanup); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Cleanup(void) | |
{ | |
DestroyShaders(); | |
DestroyVBO(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glDrawArrays(GL_TRIANGLES, 0, 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CreateVBO(void) | |
{ | |
GLfloat Vertices[] = { | |
-0.8f, -0.8f, 0.0f, 1.0f, | |
0.0f, 0.8f, 0.0f, 1.0f, | |
0.8f, -0.8f, 0.0f, 1.0f | |
}; | |
GLfloat Colors[] = { | |
1.0f, 0.0f, 0.0f, 1.0f, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DestroyVBO(void) | |
{ | |
GLenum ErrorCheckValue = glGetError(); | |
glDisableVertexAttribArray(1); | |
glDisableVertexAttribArray(0); | |
glBindBuffer(GL_ARRAY_BUFFER, 0); | |
glDeleteBuffers(1, &ColorBufferId); | |
glDeleteBuffers(1, &VboId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CreateShaders(void) | |
{ | |
GLenum ErrorCheckValue = glGetError(); | |
VertexShaderId = glCreateShader(GL_VERTEX_SHADER); | |
glShaderSource(VertexShaderId, 1, &VertexShader, NULL); | |
glCompileShader(VertexShaderId); | |
FragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER); | |
glShaderSource(FragmentShaderId, 1, &FragmentShader, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void DestroyShaders(void) | |
{ | |
GLenum ErrorCheckValue = glGetError(); | |
glUseProgram(0); | |
glDetachShader(ProgramId, VertexShaderId); | |
glDetachShader(ProgramId, FragmentShaderId); | |
glDeleteShader(FragmentShaderId); |