I'm really new to OpenGL and trying to learn from the 'modern' OpenGL tutorials.
I'm using C# and OpenTK.
I'm setting my projectionMatrix with this code:
_projectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver3, GetAspectRatio(), 0.1f, 100f);
After I set it, I upload it to the shaders, use for transformations, etc. Everything is working well this way, as the image below shows:
Now if I set my projection matrix this way, the result is very bad as the next image shows:
_projectionMatrix = Matrix4.CreateOrthographic(GLControl.ClientSize.Width, GLControl.ClientSize.Height, 0.1f, 100f);
Not only the new view is very strange, but if I move forward the scene, the objects starts to clipping, even having znear close to zero.
How can I set the orthographic projection correctly so I can have a view close to what I have in perspective?
It seems like you're having trouble understanding orthographic projections.
There are several reasons why your scene doesn't look right in an orthographic view:
CreateOrthographic
. But this won't solve everything; for instance, the floor will still remain "invisible".Note also:
zNear
, but probably not 0. This isn't the case for a perspective projection.