Simple positioning question

Started by
2 comments, last by moogle33 20 years, 3 months ago
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
Advertisement
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)?
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
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);
*News tagenigma.com is my new domain.

This topic is closed to new replies.

Advertisement