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
glUseProgram(ShaderIds[0]); | |
ExitOnGLError("ERROR: Could not use the shader program"); | |
glUniformMatrix4fv(ModelMatrixUniformLocation, 1, GL_FALSE, ModelMatrix.m); | |
glUniformMatrix4fv(ViewMatrixUniformLocation, 1, GL_FALSE, ViewMatrix.m); | |
ExitOnGLError("ERROR: Could not set the shader uniforms"); |
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
ModelMatrix = IDENTITY_MATRIX; | |
RotateAboutY(&ModelMatrix, CubeAngle); | |
RotateAboutX(&ModelMatrix, CubeAngle); |
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
float CubeAngle; | |
clock_t Now = clock(); | |
if (LastTime == 0) | |
LastTime = Now; | |
CubeRotation += 45.0f * ((float)(Now - LastTime) / CLOCKS_PER_SEC); | |
CubeAngle = DegreesToRadians(CubeRotation); | |
LastTime = Now; |
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 DrawCube(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
void DestroyCube(void) | |
{ | |
glDetachShader(ShaderIds[0], ShaderIds[1]); | |
glDetachShader(ShaderIds[0], ShaderIds[2]); | |
glDeleteShader(ShaderIds[1]); | |
glDeleteShader(ShaderIds[2]); | |
glDeleteProgram(ShaderIds[0]); | |
ExitOnGLError("ERROR: Could not destroy the shaders"); | |
glDeleteBuffers(2, &BufferIds[1]); |
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
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferIds[2]); | |
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(INDICES), INDICES, GL_STATIC_DRAW); | |
ExitOnGLError("ERROR: Could not bind the IBO to the VAO"); | |
glBindVertexArray(0); |
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
glBindBuffer(GL_ARRAY_BUFFER, BufferIds[1]); | |
glBufferData(GL_ARRAY_BUFFER, sizeof(VERTICES), VERTICES, GL_STATIC_DRAW); | |
ExitOnGLError("ERROR: Could not bind the VBO to the VAO"); | |
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(VERTICES[0]), (GLvoid*)0); | |
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(VERTICES[0]), (GLvoid*)sizeof(VERTICES[0].Position)); | |
ExitOnGLError("ERROR: Could not set VAO attributes"); |
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
glEnableVertexAttribArray(0); | |
glEnableVertexAttribArray(1); | |
ExitOnGLError("ERROR: Could not enable vertex attributes"); |
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
glGenVertexArrays(1, &BufferIds[0]); | |
ExitOnGLError("ERROR: Could not generate the VAO"); | |
glBindVertexArray(BufferIds[0]); | |
ExitOnGLError("ERROR: Could not bind the VAO"); |
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
ModelMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ModelMatrix"); | |
ViewMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ViewMatrix"); | |
ProjectionMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ProjectionMatrix"); | |
ExitOnGLError("ERROR: Could not get the shader uniform locations"); |