Hi all,
I am having trouble creating an orthographic projection in opengl (without using glOrtho). And before anyone tells me to use glOrtho, lets just pretend I'm using opengl 3.0 as an exercise. Here is the way I have set up my matrix:
projectionMatrix.m00 = 2/WIDTH;
projectionMatrix.m11 = 2/HEIGHT;
projectionMatrix.m22 = -2/(far_plane - near_plane);
projectionMatrix.m32 = -((far_plane + near_plane)/(far_plane - near_plane));
projectionMatrix.m33 = 1;
This is your typical ortho projection matrix, taken straight from the opengl spec def. for glOrtho.
When I set up a frustrum and use a perspective matrix, this works fine, but I can't use my regular screen coordinates properly. But when I use the glOrtho matrix above, I see nothing but my background color. Anyone know what's going on? Is my matrix wrong?
My shader looks like this:
#version 150 core
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 modelMatrix;
in vec4 in_Position;
in vec4 in_Color;
in vec2 in_TextureCoord;
out vec4 pass_Color;
out vec2 pass_TextureCoord;
void main(void){
gl_Position = in_Position;
//override gl position with new calculated position
gl_Position = projectionMatrix * viewMatrix * modelMatrix * in_Position;
pass_Color = in_Color;
pass_TextureCoord = in_TextureCoord;
}
Any help appreciated.
Thanks!