Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So in my SDL application, which I setup for OpenGL, if I were to do the following code:

glBegin(GL_QUADS);
glVertex2i(0, 0);
glVertex2i(50, 0);
glVertex2i(50, 50);
glVertex2i(0, 50);
glEnd();

The quad shows up on my right hand side of my screen. I tried to use glOrtho but that didn't work for some reason. What happend?

share|improve this question
1  
I would guess it's because the OpenGL co-ordinate system is far from intuitive. –  Polar Jun 2 '13 at 7:52
    
You should accept answers, if they're correct :L –  CoffeeandCode Jul 31 '13 at 10:44
add comment

1 Answer

The problem seems to be because you are treating (0, 0) as the bottom left; in OpenGL (0, 0) is the center of the screen.

To say this is counter-intuitive is silly, it is fully your opinion to say so.

I presume you have a 50x50 window you are trying to fill?

To get your desired behaviour you would need the following:

glBegin(GL_QUADS);
glVertex2i(-1, -1); // bottom left
glVertex2i( 1, -1); // bottom right
glVertex2i( 1,  1); // top right
glVertex2i(-1,  1); // top left
glEnd();

and a diagram

(-1, 1)--------------------------(1, 1)

----------------------------------------

-----------------(0,0)-----------------

----------------------------------------

(-1,-1)------------------------(1, -1)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.