PDA

View Full Version : Reshape window



Vlasko
03-16-2003, 08:21 AM
i have a problem with reshape function if it is not registered with glut

glutReshapeFunc(reshape);

everything looks good but when it is registered the screen is showed only once and then black screen
the code:
void reshape ( int w, int h ) // Create The Reshape Function (the viewport)
{
float ratio;
if(h == 0)
h = 1;

ratio = 1.0f * w / h;
// Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// Set the viewport to be the entire window
glViewport(0, 0, w, h);

// Set the clipping volume
gluPerspective(80,ratio,1,200);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 0,
0,0,-1,
0.0f,1.0f,0.0f);
}

jebus
03-16-2003, 10:43 AM
try moving the glViewport() call above the glMatrixMode(GL_PROJECTION) call. i'm not sure if that is necessary, but that's how i've seen most all reshape funcs. also, make sure that there is an object to view in your scene. your view is at the origin looking down the neg. z axis, and if all your objects are behind the view, then you wont see anything. other than that, your code looks fine ...

jebus

nexusone
03-17-2003, 05:00 AM
What about your display code, sounds like it could be something in there causing it.
Post the code for us to look at.

Vlasko
03-17-2003, 08:24 AM
It's working now but can i have an explanation about clipping planes ? i don't actualy know what does it mean in gluPerspective and MSDN is bit short about it(english is not my native language)Thanks

nexusone
03-17-2003, 08:37 AM
Since your english is not good and even if it is, better that you see a example with graphics on how the perspective view works.

Nate Robins has a good tutor about projection on his site on how the perspective and ortho projections work.
The tutor graphicly shows you how each function works and let you change each setting used by perspecitve.
http://www.xmission.com/~nate/opengl.html



Originally posted by Vlasko:
It's working now but can i have an explanation about clipping planes ? i don't actualy know what does it mean in gluPerspective and MSDN is bit short about it(english is not my native language)Thanks