I again am having issues with OpenGL, this time with the projection matrix. Using gl3n, I have the following code:
// model matrix
mat4 trans = mat4(0f);
trans.make_identity();
trans = trans.rotatex(radians(-55));
// view matrix:
mat4 view = mat4(0f);
view.make_identity();
view = view.translation(0f ,0f, -3f);
// projection matrix
mat4 projection;
projection.make_identity();
projection = projection.perspective(800f, 600f, radians(45f), .1f, 100f);
I am binding all of these matrices to the correct locations, and this seems to be the gl3n equivalent to what is given in the OpenGL tutorial:
// create transformations
glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
glm::mat4 view = glm::mat4(1.0f);
glm::mat4 projection = glm::mat4(1.0f);
model = glm::rotate(model, glm::radians(-55.0f), glm::vec3(1.0f, 0.0f, 0.0f));
view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f));
projection = glm::perspective(glm::radians(45.0f), 800f / 600f, 0.1f, 100.0f);
Everything displays fine (with orthographic projection, of course) if you leave the projection as the identity matrix, but setting it as I have done results in a blank screen. I assume it has to do with the values of
(projection * view * trans * vec4(vertex, 1)).w
not being 1. Should I just use a different library, and if so, how to use it to generate a perspective matrix?