# Blank screen after calling glm::perspective

Hi there!

This code works fine:

``````glm::mat4 proj = glm:: perspective(45.0f, 4.0f / 3.0f, 1.0f, 100.0f);
glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, 1.0f));
glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), i / (2 * glm:: pi&lt;float&gt;()), glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 scale = glm::scale(glm::mat4(1.0f), glm::vec3(0.3f));

glm::mat4 model = translate * rotate * scale;
``````

But when I multiply by the proj matrix:

``````glm::mat4 proj = glm:: perspective(45.0f, 4.0f / 3.0f, 1.0f, 100.0f);
glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, [b]5.0f[/b]));
glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), i / (2 * glm:: pi&lt;float&gt;()), glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 scale = glm::scale(glm::mat4(1.0f), glm::vec3(0.3f));

glm::mat4 model = [b]proj[/b] * translate * rotate * scale;
``````

it turns into a black screen. What could have possible gone wrong?

45 radians is a bit wide. Try:

``````
glm::mat4 proj = glm:: perspective(glm::radians(45.0f), 4.0f / 3.0f, 1.0f, 100.0f);

``````

GLM uses radians for angles, whereas OpenGL (and GLU) use degrees.

still blank

Try translating by (0,0,-5).

Conventional projection matrices (those generated by glOrtho, glFrustum, gluOrtho2D and gluPerspective, and their GLM counterparts) negate the Z direction. For a perspective projection, the near and far planes are always in front of the viewpoint, so only points with negative eye-space Z will be visible.

Bingo!!!

And is there a way to get rid of the negative sign? It feels a bit awkward to me having to enter -5.0f when my near and farZ are between 1.0 and 100f

You can rotate by 180 degrees about the Y axis, but then the positive X axis will point to the left.

Or you could add a scale(1,1,-1) after the perspective, but thatâ€™s going to give you a left-handed coordinate system, so any objects will be mirrored (e.g. a character holding something in their left hand will end up with it in their right hand), clockwise-ordered faces will become counter-clockwise, etc.