PDA

View Full Version : keeping scale using glOrtho call



11-15-2000, 03:44 AM
I have tried doing this too many times can someone look at my code and tell me if you see any thing that is screwy

int h = ClientHeight;
int w = ClientWidth;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w<h){
h=250.0*h/w;
w=250;
}
else{
w =250.0*h/w;
h =250.0;
}
glOrtho(0,w,0,h,1.0,-1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
FormPaint(Sender);

11-15-2000, 03:49 AM
When I run the program I can see the edge of the image that is draw in the lower left hand corner.

zed
11-15-2000, 11:09 AM
try this

glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,w,0,h,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

sorry reread your message again
u might wanna try
glScalef(w/800,h/600,w/600); (or someit) after the orthod call


[This message has been edited by zed (edited 11-15-2000).]