Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualOlof Hedman

Posted 17 May 2013 - 05:24 AM

By replacing my gluOrtho2D with gluPerspective, what changes shoud I make and where?


You also need to set up the modelview matrix.

After glMatrixMode(GL_MODELVIEW); you need some calls to glScale and glTranslate, to make sure your coordinates are scaled into the -1,1 range.

something like:
glLoadIdentity();
glTranslate(w/2,h/2,0);
glScalef(w,h,1);

Anything positioned on z-depth 0 can have the same coordinates as if they were set up in a ortho view.

You need to use different coordinates for your vertices since the coordinate systems are completely different. For a given vertical FOV and aspect ratio, you can calculate the range in X and Y direction at a certain depth Z.


They are only completely different if you choose to make them completely different.
(By for example not setting up the modelview-matrix.)

I'm assuming he want 2d planes in a 3d space, and feels it is convenient to use screen points to position those panes.

#1Olof Hedman

Posted 17 May 2013 - 05:23 AM

By replacing my gluOrtho2D with gluPerspective, what changes shoud I make and where?

 

You also need to set up the modelview matrix.

 

After glMatrixMode(GL_MODELVIEW); you need some calls to glScale and glTranslate, to make sure your coordinates are scaled into the -1,1 range.

 

something like:

glLoadIdentity();

glTranslate(w/2,h/2,0);

glScalef(w,h,1);
 

Anything positioned on z-depth 0 can have the same coordinates as if they were set up in a ortho view.

 

You need to use different coordinates for your vertices since the coordinate systems are completely different. For a given vertical FOV and aspect ratio, you can calculate the range in X and Y direction at a certain depth Z.

 

They are only completely different if you choose to make them completely different.

By for example not setting up the modelview-matrix.

 

I'm assuming he want 2d planes in a 3d space, and feels it is convenient to use screen points to position those panes.


PARTNERS