viewing from perspective

BlitzMax Forums/OpenGL Module/viewing from perspective

Gavin Beard(Posted 2007) [#1]
hi all, when i setup my ogl scene i call :

	glViewport(0.0,0.0,width,height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0.0,width,height,0.0,-1.0,1.0);
	glMatrixMode(GL_MODELVIEW);				
	glLoadIdentity();

which is fine for a std. top down or side scroll view, but whats best way to create a perspective type view of the scene?

cheers


Ryan Burnside(Posted 2007) [#2]
Instead of glOrtho you want glFrustum.
It uses slightly different parameters however. You might need to adapt your game.


ImaginaryHuman(Posted 2007) [#3]
Also you can't have negative or zero for your Z coordinate range so yu have to know to position your objects at at least >0 coordinate in Z.


Gavin Beard(Posted 2007) [#4]
is it easier to just create a camera and position that at the right viewing angel or is this not poss with ogl?


ImaginaryHuman(Posted 2007) [#5]
The projection matrix is the camera so you can move/rotate it to where you want. But it will only be 3d if you use a perspective projection with glFrustum or gluPerspective


Gavin Beard(Posted 2007) [#6]
Thanking you very much :)