Advertisement

split screen question

Started by September 14, 2003 11:23 PM
3 comments, last by nitzan 21 years, 5 months ago
I am trying to modify lesson 42 to handle two viewports. What I have is: // top window glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,((GLfloat)window_width/(GLfloat window_height), 0.2f, 2001.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0, window_height/2, window_width, window_height); drawGame(); // bottom window glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,((GLfloat)window_width/(GLfloat)window_height)*2, 0.2f, 2001.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0, 0, window_width, window_height/2); drawGame(); The bottom window is ok, but the top window is screwed up. I cant seem to get the gluPerspective settings correct for the top window. Any ideas ? Thanks, Nitzan
When calling gluPerspective, you might want to calculate the ratio using the dimensions of the viewport, not the dimensions of the window.

There's a missing "*2" in your first gluPerspective call.


SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.
The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)

[edited by - rodzilla on September 15, 2003 1:03:47 AM]
SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)
Advertisement
Yeah, I thought a *2 would fix the first call, but it doesnt.

Any other ideas ?

Nitzan
I can''t tell if this will work but add the *2 and change the top glViewport to this
glViewport(0, window_height/2, window_width, window_height/2);

As it where before the viewport was the size of the whole window instead of half the size of the window.
Dude, you rock. That totally worked.

The last two values in glViewPort are the size of the window, not where the window ends.

Thanks.

Nitzan

This topic is closed to new replies.

Advertisement