Polygons are not displayed when adding a view matrix. The square is at (0,0,0). Without a view matrix, it appears in the upper left corner. There is a shader:

#version 330 core layout (location = 0) in vec4 vertex; // <vec2 position, vec2 texCoords> out vec2 TexCoords; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() { TexCoords = vec2 (vertex.z, 1.0f - vertex.w); gl_Position = projection * view * model * vec4(vertex.xy, 0.0, 1.0); } 

I create the matrix like this:

 glm::vec3 cameraPos = glm::vec3 (m_ViewXPos, m_ViewYPos, -30.0f); glm::vec3 cameraFront = glm::vec3 (m_ViewXPos, m_ViewYPos, 30.0f); glm::vec3 cameraUp = glm::vec3 (0.0f, 1.0f, 0.0f); m_ViewMatrix = glm::lookAt (cameraPos, cameraFront, cameraUp); 

m_ViewXPos and m_ViewYPos are 0.0f

This is what happens:

 {-1.0, 0.0, -0.0, 0.0}, { 0.0, 1.0, -0.0, 0.0}, { 0.0, -0.0, -1.0, 0.0}, {-0.0, -0.0, -30.0, 1.0} 

Projection Matrix:

 m_ProjectionMatrix = glm::ortho (0.0f, (GLfloat) m_ViewportSize.x, (GLfloat)m_ViewportSize.y, 0.0f, -100.0f, 100.0f); 

I tried to change the dimensions of the projection matrix (set from -5000 to 5000). Nothing appears in this range.

What am I doing wrong to display with this matrix?

  • Try setting the penultimate parameter glm :: ortho to 0.1f. Do you pass the view matrix to the shader? Try setting cameraPos.z to 30.0, and cameraFront.z to -30.0. Perhaps we are just apparently the back of the invisible side of the square. - Unick
  • Maybe due to the fact that the direction of the camera cameraFront looks at x and y in the position of the camera. Try to specify the coordinates of the object in the cameraFront. - CJ1
  • Guys, thank you all) The problem turned out to be that I did not use (glUseProgram) a shader, but immediately passed the view matrix to it, so nothing was shown) - LIFEfreedom

0