PDA

View Full Version : glOrtho problem



Digby
03-20-2001, 10:14 AM
I have a
void __fastcall TPVPLForm::GLP2DResize(TObject *Sender)
{
width=(GLsizei)GLP2D->Width;
height=(GLsizei)GLP2D->Height;
glViewport(0,0,width,height);
maxx=maxy*(width/height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(minx,maxx,miny,maxy,-1.0,1.0);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

But whenever I change minx,maxx,miny,maxy
nothing happens the drawing does not zoom
when I call Repaint but retains the values
that were first given when the program
started. Wht could be causing this?
Regards Digby Millikan.

davepermen
03-20-2001, 10:23 AM
hm, you have an TObject* Sender as parameter, you dont use it, is that ok?

second: width and height are integers? so maxx=maxy*(width/height);
has an integerdivision, as known as unprecisious.. use the floatones...

third, you dont reset maxy, so you set maxx perhaps always to the same value ( as long as width/heigth in integer results in the same value http://www.opengl.org/discussion_boards/ubb/smile.gif

Digby
03-20-2001, 11:40 AM
Dave,
None of these, but I set maxy externally to
the Resize.:confused:

davepermen
03-20-2001, 11:46 AM
ok, possible, too http://www.opengl.org/discussion_boards/ubb/smile.gif

Relic
03-20-2001, 10:50 PM
Is the OpenGL context current during the resize function?

Michail Bespalov
03-21-2001, 12:00 AM
Originally posted by Digby:
I have a
void __fastcall TPVPLForm::GLP2DResize(TObject *Sender)
{
...
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(minx,maxx,miny,maxy,-1.0,1.0);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
...
}
.
Hi
maybe glPushMatrix on each window resizing causes projection matrix stack overflow.



[This message has been edited by Michail Bespalov (edited 03-21-2001).]