split screen question
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]
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)
Yeah, I thought a *2 would fix the first call, but it doesnt.
Any other ideas ?
Nitzan
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.
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.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement