Hi
im trying to do some simple basic rendering in 2D. I started with first Nehe tutorial (setting openGL window) and changed it to render in 2D instead of 3D. Many people on internet do it this way so i hope that this code is correct. I didnt touch rest of the code.
Changes in ReSizeGLScene().
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, height, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
Rendering code:
glBegin(GL_LINES);
glColor4ub(255, 0, 0, 255);
glVertex2i(10, 1);
glVertex2i(10, 100);
glColor4ub(0, 255, 0, 255);
glVertex2i(20, 1);
glVertex2i(25, 1);
glEnd();
glBegin(GL_POINTS);
glVertex2i(30, 1);
glEnd();
glBegin(GL_QUADS);
glColor4ub(0, 0, 255, 255);
glVertex2i(35, 1);
glVertex2i(35 + 10, 1);
glVertex2i(35 + 10, 1 + 10);
glVertex2i(35, 1 + 10);
glEnd();
My code: pastebin.com
Pic of my app: imageshack.us
As you can see red line and blue quad are rendered correctly, but green line and dot should be rendered one pixel lower. Now id like to know why this happens and how can i fix it.
When point [0,0] is at default position (bottom left - means glOrtho(0, width, 0, height, 0, 1) everything works fine, but i would really appreciate having [0,0] at top left of my window.
thank you very much for any help or explanation
Peto