Hi WILL
I use the routines below to switch between 3d and 2d (ortho) views.
[pascal]
Procedure TRenderEngineGL.Set3dView(FOV,NearPlane,FarPlane: Single);
Begin
// 3d view.
glMatrixMode(GL_PROJECTION); // Select the projection matrix.
glLoadIdentity; // Reset the projection matrix.
// Set up the perspective projection matrix
gluPerspective(FOV,FWidth/FHeight,NearPlane,FarPlane);
glMatrixMode(GL_MODELVIEW); // Select the modelview matrix.
glLoadIdentity; // Reset the modelview matrix.
End;
{................................................. ......}
{................................................. ......}
Procedure TRenderEngineGL.Set2dView;
Begin
glMatrixMode(GL_PROJECTION); // Select the projection matrix.
glLoadIdentity; // Reset the projection matrix.
// Set up the perspective projection matrix.
gluOrtho2d(0,FWidth,FHeight,0);
glMatrixMode(GL_MODELVIEW); // Select the modelview matrix.
glLoadIdentity; // Reset the modelview matrix.
End;
[/pascal]
Use like so:
Code:
Set3dView(...);
//draw 3d scene
Set2dView;
Where :
FWidth and FHeight are the size of my window where the opengl graphics are being drawn.
FOV is the vertical field of view...eg. 45 degrees
NearPlane (near clipping plane) = a value > 0...eg. 0.1
FarPlane (far clipping plane) = a value > NearPlane...eg. 1000
I hope this helps you
cheers,
Paul
Bookmarks