Skip to content

Instantly share code, notes, and snippets.

View EddyLuten's full-sized avatar

Eddy Luten EddyLuten

View GitHub Profile
@EddyLuten
EddyLuten / chapter.4.27.c
Created May 20, 2014 03:39
Chapter 4, Snippet 27 - OpenGLBook.com
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");
@EddyLuten
EddyLuten / chapter.4.26.c
Created May 20, 2014 03:39
Chapter 4, Snippet 26 - OpenGLBook.com
ModelMatrix = IDENTITY_MATRIX;
RotateAboutY(&ModelMatrix, CubeAngle);
RotateAboutX(&ModelMatrix, CubeAngle);
@EddyLuten
EddyLuten / chapter.4.25.c
Created May 20, 2014 03:38
Chapter 4, Snippet 25 - OpenGLBook.com
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;
@EddyLuten
EddyLuten / chapter.4.24.c
Created May 20, 2014 03:37
Chapter 4, Snippet 24 - OpenGLBook.com
void DrawCube(void)
{
}
@EddyLuten
EddyLuten / chapter.4.23.c
Created May 20, 2014 03:31
Chapter 4, Snippet 23
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]);
@EddyLuten
EddyLuten / chapter.4.22.c
Created May 20, 2014 03:30
Chapter 4, Snippet 22
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);
@EddyLuten
EddyLuten / chapter.4.21.c
Created May 20, 2014 03:29
Chapter 4, Snippet 21 - OpenGLBook.com
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");
@EddyLuten
EddyLuten / chapter.4.20.c
Created May 20, 2014 03:27
Chapter 4, Snippet 20 - OpenGLBook.com
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
ExitOnGLError("ERROR: Could not enable vertex attributes");
@EddyLuten
EddyLuten / chapter.4.19.c
Created May 20, 2014 03:24
Chapter 4, Snippet 19 - OpenGLBook.com
glGenVertexArrays(1, &BufferIds[0]);
ExitOnGLError("ERROR: Could not generate the VAO");
glBindVertexArray(BufferIds[0]);
ExitOnGLError("ERROR: Could not bind the VAO");
@EddyLuten
EddyLuten / chapter.4.18.c
Created May 20, 2014 03:23
Chapter 4, Snippet 18 - OpenGLBook.com
ModelMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ModelMatrix");
ViewMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ViewMatrix");
ProjectionMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ProjectionMatrix");
ExitOnGLError("ERROR: Could not get the shader uniform locations");