Problem setting up viewport and orthographic projection

Started by
-1 comments, last by rek 15 years, 2 months ago
I've got the following code to setup my viewport and coordinate system.

  glViewport(0, 0, width, height);


  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();

  gluOrtho2D(0, width, height, 0);
I'm just testing drawing a pixel at position (0,0), which I want to be the top left corner of the window. The problem is that the top row, where y = 0 does not appear. Only when I give a y coord greater than zero can I see the pixel. I tried using the bottom left corner for the origin with

  gluOrtho2D(0, width, 0, height);
and the pixels are drawn as expected. Am I missing something obvious here or what? I also changed the top argument to gluOrtho2D to -1 and it seems to work also

gluOrtho2D(0, width, height, -1);
but I don't like this as a solution, smells bad ;) Any help or suggestions would be greatly appreciated.

This topic is closed to new replies.

Advertisement