I seem to have a curious problem. I set up OpenGL like this:
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, height, 0, -width, width);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
Obviously, width and height are the size of my window, which is 600 by 400. Inside OpenGL everything is fine, I can move around the correct coordinate system. ie translating by 200 moves whatever is being drawn by 200 pixels.
Now, inside my vertex shader I can't seem to use the same coordinate system, I do the usual:
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_Position = pos;
inside main() and everything seems to be fine. However when I attempt something like this:
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
pos.x+= 1.0;
pos.y-= 1.0;
gl_Position = pos;
The vertex positions are translated not by 1 pixel in each direction but by 300 in the x and 200 in the y.
I understand that I could scale these values inside the shader, but that seems a bit dirty. Surely I must be doing something wrong in the setup. Any help is much appreciated.