Archived

This topic is now archived and is closed to further replies.

moogle33

Simple positioning question

Recommended Posts

Hello everybody, How do I put a point at a standard windows co-ordinate in a window i.e 0,0 at the top left and 1028*768 at the bottom right. Hope that makes sense. James

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Hope that makes sense.


Err, not really. Do you mean you want to make a window full size (size of the screen)? You want to plot a pixel on the screen? I assume you are developing on a Windows machine? What API are you using (GDI, DirectDraw, etc)?

Share this post


Link to post
Share on other sites
Assuming I''m understanding you correctly you need to set your projection matrix to an orthographic projection:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1024, 0, 768, -1, 1);
glMatrixMode(GL_MODELVIEW);


Enigma

Share this post


Link to post
Share on other sites
You forget to do the final offset as shown below. Otherwise the pixels will be slightly off.

glViewport(0, 0, g_rRect.right, g_rRect.bottom);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, g_rRect.right, 0, g_rRect.bottom);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

// Translate allows use of integer positions in Ortho Mode
glTranslatef(0.375, 0.375, 0.0);

Share this post


Link to post
Share on other sites