I’m currently drawing inside a rectange that is 600x600 pixels. In openGL this area is referenced as a rectangle that has corners (1,1), (-1,1), (-1,-1), and (1,-1). Is there anywhere that this could be scaled to reflect the actual size of the rectange, such as, (300,300), (-300,300), (-300,-300), (300,-300)? From the documentation I’ve read it seems like glOrtho is the function that would do this. However, I haven’t been able to get it to work the way I would expect.
Thanks for the help!
And what did the documentation say about zNear == zFar. That throws an invalid_value error.
// If the Window's client area is 600x600:
glOrtho(0.0, 600.0, 0.0, 600.0, -1.0, 1.0);
glColor3f(1.0f, 0.0f, 0.0f); // Red
glBegin(GL_QUADS); // Counter-clockwise winding.
glVertex2f(0.0f, 0.0f); // Lower left corner of lower left pixel.
glVertex2f(600.0f, 600.0f); // Upper right corner of upper right pixel of the window.
That should fill the whole window with a red quad.
For point or line rendering you should adjust the vertices by (+0.5f, +0.5f).
Thanks for the help. The zNear==zFar was my issue. Now, however, (0,0) is at the bottom-left of the screen instead of the center like before. Is there any way to change this? It’s not that big of a deal, except all of the code that I’ve written up to this point used that assumption. I know I could fix it by just adding a +offset to each vertex.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.