Advertisement

Functions to switch between 3D and Ortho Mode

Started by September 13, 2003 12:09 AM
3 comments, last by Jumpman 21 years, 5 months ago
I know Nehe did some functions (2 of them) to call which whould put GL into either 3d projection mode or Ortho Mode.. I''ve been though all of my sample code and can''t find them.. Does anybody know where I Can find them.. I''m having some problems with the 3D side of things where my lines are not being correctly drawn (upto now I have only used ortho mode in jumpman) but I want to do a 3d type front end for it.. Cheers Jumpman - Under Construction
Not nehe's but:

void ViewOrtho(int & SCREEN_HEIGHT, int & SCREEN_WIDTH)							// Set Up An Ortho View{	glMatrixMode(GL_PROJECTION);					// Select Projection	glPushMatrix();							// Push The Matrix	glLoadIdentity();						// Reset The Matrix	glOrtho( 0, SCREEN_WIDTH , SCREEN_HEIGHT , 0, -1, 1 );				// Select Ortho Mode (640x480)	glMatrixMode(GL_MODELVIEW);					// Select Modelview Matrix	glPushMatrix();							// Push The Matrix	glLoadIdentity();						// Reset The Matrix}void ViewPerspective()							// Set Up A Perspective View{	glMatrixMode( GL_PROJECTION );					// Select Projection	glPopMatrix();							// Pop The Matrix	glMatrixMode( GL_MODELVIEW );					// Select Modelview	glPopMatrix();							// Pop The Matrix} 


[edited by - skow on September 13, 2003 1:31:07 AM]
Advertisement
does that assume that the inital GL viewport has been set up in 3D mode then ??

Is it slow to call gluPerspective every frame ?? (as I switch into 3d mode) as I am only using a bit of 3d on the main title screen (for the spinning grid on the following mockup.. the rest of the game is pure ortho..



Cheers



[edited by - Jumpman on September 13, 2003 1:51:15 AM]
Yes, those functions assume that you have already estalished the viewport you wish to use. They''re just two functions that allow you to create and remove an orthogonal view, such as you might wish to do to draw a pointer on the screen at a specific location, or draw a GUI.


It wouldn''t be slow to call those functions each frame, or even multiple times each frame. The projection matrix is a matrix exactly like the modelview matrix. All you''re doing when you rebuild the projection matrix is generating a single matrix and placing it on the projection matrix stack. There''s actually very little to those gl functions that setup those views. I actually don''t use glOrtho or gluPerspective at all. It''s one of the simplest things to do once you have a set of 3D math commands to work with.

Just for the record, Jumpman was one of my favorite games.

Love means nothing to a tennis player

My nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)

This topic is closed to new replies.

Advertisement