Converting over from Ortho to Frustum

closed account (2NywAqkS)
I have always used Ortho projection for my OpenGL programs. But half-way through my current project I have realised that I should instead be using Perspective(Frustrum) projection.

My current reshape function is as follows:
1
2
3
4
5
6
7
8
9
void Reshape(void)
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glViewport(0, 0, WIN_WIDTH, WIN_HEIGHT);
	glOrtho(0, WIN_WIDTH, WIN_HEIGHT, 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}


I tried swapping the word Ortho to Frustum and a few other ways but none work.

What do I need to do to change it to Perspective projection. Is it just a matter of chopping and changing a few lines or do I have to change the way I draw object?

Thanks,
Rowan.
In your case, switching the words glOrtho and glFrustum isn't good enough because of your second last parameter:

glOrtho(0, WIN_WIDTH, WIN_HEIGHT, 0, -1, 1);

glOrthoSpec wrote:
nearVal, farVal

Specify the distances to the nearer and farther depth clipping planes. These values are negative if the plane is to be behind the viewer.


glFrustumSpec wrote:
nearVal, farVal

Specify the distances to the near and far depth clipping planes. Both distances must be positive.
Last edited on
Topic archived. No new replies allowed.