PDA

View Full Version : Splitting the screen



09-12-2001, 08:03 AM
I'm trying to write a molecular visulization program. I need to be able to show the molecule in stereo. So, I'm splitting the screen in half with glScissor, and then creating two veiwports, and drawing to each. My problem is that when I split the 600x600 window, I get 300x600 viewports and the molecule gets squished, which makes it futile. I tried using glScalef, to double the x co-ordinates, but it distorts the molecule completely.
I think I've messed up with the projection matrix and the matrix view matrix. I'm really quite confused! Help!!!! :-}

Satanic Dogus
09-12-2001, 10:36 AM
Any chance of me getting a reply?
The odds are 2 to the 23213224 power to 1 and rising
and that's the the hyperiprobability drive off!

zed
09-12-2001, 03:07 PM
4 each scissor region use a diffirent viewport

zed
09-13-2001, 12:45 PM
sorry i also remembered u need to change the aspect ratio of both your viewports
eg gluPerspective( FOV, viewportwidth/viewportheight, near, far )

Satanic Dogus
09-14-2001, 07:55 AM
I can't seem to get it to work!
Here's the code for that bit.
I can't get it to stop squishing the view.


const float StereoAngle = 2.5;

GLint vp[4];glGetIntegerv(GL_VIEWPORT,vp);
int GeomXsize = 600; //int(vp[3]);
int GeomYsize = 600; //int(vp[4]);
int hx = GeomXsize/2;int yx = GeomYsize;
int dx,mx;
if(SENSE)
{
dx = 1;
mx = hx+1;
}
else
{
mx = 1;
dx = hx+1;

}

glPushAttrib(GL_VIEWPORT_BIT);
glEnable(GL_SCISSOR_TEST);
glViewport(dx,0, hx,yx);
glScissor (dx,0, hx,yx);
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glRotatef(-2.0*StereoAngle, 0.0, 1.0, 0.0);
glMatrixMode(GL_MODELVIEW);
draw_scene(w,mouse_x,mouse_y);
glFlush();
glMatrixMode(GL_PROJECTION);
glRotatef(StereoAngle, 0.0, 1.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

glViewport(mx,0, hx,yx);
glScissor(mx,0, hx,yx);
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glRotatef(StereoAngle, 0.0, 1.0, 0.0);
glMatrixMode(GL_MODELVIEW);
draw_scene(w,mouse_x,mouse_y);
glFlush();

glPopMatrix();

glDisable(GL_SCISSOR_TEST);
glPopAttrib();
}

Michael Steinberg
09-14-2001, 08:17 AM
You need to use gluPerspective to setup a perspective projection.
And NEVER use glRotate in the GL_PROJECTION matrix! Just use glTranslate on the geometry, to simulate the two eyes.

Satanic Dogus
09-14-2001, 08:56 AM
What's wrong with glRotate?
How would I use glPerspective?
I haven't a clue.....not to fluent with opengl, as you can see.
I tried glPerspective(360,0.5,0,0)
didn't make any difference.

And how would I use translate to rotate?

Thanks!

Satanic Dogus
09-17-2001, 06:46 AM
Help?

Michael Steinberg
09-17-2001, 07:40 AM
Sorry, didn't see that post...
Well, glRotate and stuff are used in the GL_MODELVIEW Matrix.
The Projection matrix needs to be set up okay, in order to let opengl perform the lighting and other stuff like fog. gluPerspective now creates such a matrix that you can use in the GL_PROJECTION matrix.
You need to specify the ratio somewhere in the function. That is window_width/window_height. So, for your windows, the ratio should be as you used it 0.5. But the fov is not okay. You can specify values between 0 and 180 there, if I remember it correctly. Common values are 60 between 90. This value specifies the angle you can see between left border of the viewport and right border. So 360 degrees would show all the world around you squished to a little rectangle. http://www.opengl.org/discussion_boards/ubb/smile.gif