Jump to content
  • Advertisement
Sign in to follow this  
RDG

OpenGL Why won't th square start from the origin?

This topic is 4056 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm new to OpenGL, I wrote a simple square that is supposed to start at (0.0, 0.0) but it appears like this when I run: | |.......... _____________ |..........|....................| |..........|....................| |..........|....................| |..........|....................| |..........|____________.| | |__________________________ (It looked better in the editor) The point is that it starts like at (10, 10) -or (1, 1), I'm really new to this-. ...Here's the code: - (void) drawRect: (NSRect) bounds { glClearColor (1, 1, 1, 0); glClear (GL_COLOR_BUFFER_BIT); glBegin (GL_POLYGON); glColor3f (0.0, 0.0, 1.0); glVertex2f (0.0, 0.0); glColor3f (0.0, 1.0, 0.0); glVertex2f (0.0, 2.0); glColor3f (0.0, 1.0, 1.0); glVertex2f (2.0, 2.0); glColor3f (1.0, 0.0, 0.0); glVertex2f (2.0, 0.0); glEnd (); glFlush (); } By the way I'm using Xcode and Interface Builder.

Share this post


Link to post
Share on other sites
Advertisement
My memory may be failing me, but isn't (0,0) mapped to the center of the screen in OpenGL, as opposed to a corner?

Share this post


Link to post
Share on other sites
How did you setup your projection? If it's perspective, (0,0,0) is actually at the middle of the viewport (window). If it's orthographic, then it depends on the parameters passed.

Anyway, a screenshot could be useful.

Share this post


Link to post
Share on other sites
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1, 0, 1, -1, 1);
glMatrixMode(GL_MODELVIEW);


That would make (0,0) bottom-left and (1,1) top-right.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!