0
\$\begingroup\$

I haven't used OpenGL for a long time and have trouble setting up a 2D screen where the upper left window coordinates are (0,0) and the width and height of the window are the max x and max y OpenGL coordinates, such that:

glBegin(GL_LINES);
glVertex2i(0,0);
glVertex2i(800, 0);
glVertex2i(0,0);
glVertex2i(0, 600);
glEnd();

does draw one line at the top of the window and one that goes down from the top. I found many examples for glOrtho(left, right, bottom, top, near, far), but none explains what I need here. I hope the question is not too trivial and you can help me.

\$\endgroup\$
2
  • \$\begingroup\$ i've set glOrtho(0, w, h, 0, 0.0f, -1.0f) but that gives the 0,0 to the middle of the screen, no matter what other variations i try i am not able to get 0,0 to the upper left corner \$\endgroup\$ Commented Sep 4, 2022 at 9:23
  • \$\begingroup\$ The glOrtho call looks correct. Perhaps the state is wrong? I suggest to check glViewport, the matrix mode and whether or not the projection matrix is set to identity before glOrtho is called. \$\endgroup\$ Commented Sep 4, 2022 at 21:07

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.