Following on from my previous problem (drawing a bitmap) Im having trouble with actually drawing it to a fixed part of the screen.
I draw my 3D scene, then switch to 2D and then draw the bitmap to the lower left corner. The problem is I find the bitmap stays at the corner and it wont draw anywhere else on the screen.
I guess I should work on my english then, but I am trying to help…
Lets state it this way. You know the difference between screen coordinates, window coordinates, model coordniates, and world coordinates correct? Raster position is in window coordinates. So this means if you don’t do any modification to your modelview matrix (no rotates and no translates) you will get the following results on a window that is 256x256 pixels.
0,0 = lower left corner
128,128 = center
The only reason to use floats with raster position is to take advantage of sub-pixel precision.
The raster position is specified in world coordinates, not window coordinates, and is affected by both the modelview and projection matrix. It is treated just like any other vertex you pass to OpenGL; it get transformed by first the modelview, then the projection matrix, and after that, it’s clipped agains the view volume, and will be marked as an invalid raster position if outside the view volume.
To be 100% sure where the raster position will be located, replace glRasterPos2(x,y) with
glBegin(GL_POINTS);
glVertex2(x,y);
glEnd();
and see where the point appears on the window.
So, with identity matrices in both the modelview and projection stack, raster position (0,0) will be in the middle of the screen, (-1, -1) will be the lower left corner, and (1, 1) will be the upper right corner. And that is independent of the physical size of the window.
Most people that wants a 1-to-1 correspondence between the raster position and window pixel coodinated usually sets an orthograpic projection matrix that matches the dimensions of the viewport. This is done because the raster position is affected by the projection matrix (as I said above), which maps the position to window coordinates in a convenient way.
Pushing a matrix stack will produce a copy of the last matrix, if you want to start over (ie apply a new projection, new modelview), you still have to clear it to identity first.