I'm adding 3D and some rotation on the z axis to my program which uses OpenGL, CGLM, STB, GLFW and GLAD. The program has no warnings or errors, and still the program's output is simply my clear colour.
The following is the part of my program loop where I apply transformations.
// Create transformations
mat4 model = {{1.0f}};
mat4 view = {{1.0f}};
mat4 projection = {{1.0f}};
glm_rotate(model, glm_rad(-55.0f), (vec3){1.0f, 0.0f, 0.0f});
// Translating the scene in the reverse direction of where the user wants to move
glm_translate(view, (vec3){0.0f, 0.0f, -3.0f});
glm_perspective(glm_rad(45.0f), (float)WINDOW_WIDTH / (float)WINDOW_HEIGHT, 0.1f, 100.0f, projection);
// Retrieve the matrix uniform locations and pass them to the shaders
GLint modelLoc = glGetUniformLocation(myShaderPtr->shaderID, "model");
GLint viewLoc = glGetUniformLocation(myShaderPtr->shaderID, "view");
GLint projectionLoc = glGetUniformLocation(myShaderPtr->shaderID, "projection");
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, &model[0][0]);
glUniformMatrix4fv(viewLoc, 1, GL_FALSE, &view[0][0]);
glUniformMatrix4fv(projectionLoc, 1, GL_FALSE, &projection[0][0]);
And this is my vertex shader:
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;
out vec2 TexCoord;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(aPos, 1.0);
TexCoord = vec2(aTexCoord.x, aTexCoord.y);
}
The program is up on github here if more code is required.
The intended output of the code is the image below but with my profile picture instead of the smiley face.
