Reputation: 24771
What does OpenGL do when it encounters this:
glVertexAttribPointer(m_shader_position, 2, ....
But the projection matrix is a Frustum, not orthogonal?
The 2
in this function indicates this is a 2D vector. Now if I setup my projection matrix using Ortho, I can get these vertices to draw. But if I merely change the projection to a Frustum, they no longer appear, but what is the technical cause of this?
A frustum indicates a 3D view, but what part of the pipeline prevents a 2D vertex from appearing?
Upvotes: 1
Views: 165
Reputation: 18966
Look at your shader program that you have bound to opengl before glVertexAttribPointer. You will see that your 2D points [x, y] are treat as vec4[x, y, z, w].
If you do not see the point on screen, that mean it is outside frustum.
Upvotes: 1
Reputation: 182083
If you leave off the z-coordinate like this, it defaults to 0. If your vertices (after transformation) are outside the frustum, they won't be drawn.
To solve this, you could modify your vertex shader to set the z-coordinate explicitly to a constant value (or supplied by a uniform).
Or, depending on how many points you have and your memory requirements, you could just supply an explicit z value from the beginning:
glVertexAttribPointer(m_shader_position, 3, ....
Upvotes: 1