Skip to main content
gamedev.net
🔒 Locked

Window resizing problems..please help!

Started by Perferati Jun 1, 2002 at 1:14 AM 0 replies 500+ views
Original Post
Perferati
Perferati
Hey everyone, I am working on a windows/opengl application under MFC. The problem Im having is when the user resizes the openGL window the image doesn''t seem to scale properly. For example, I am drawing a Sphere at the center of the screen...a sphere is always a sphere..but when i resize the window I can get an ellipse. I have overrided the "OnSize" message that windows sends to properly set the viewport and perspective, yet this is unaffective. Anyhelp on this issue would be greatly appreciated. BTW : Anyone know how to fix the "flicker" effect when one is resizing a window? Perferati
v71
v71

void CEditor::OnSize(UINT nType, int cx, int cy)
{

//********************************************
// OnSize
//********************************************

// Set OpenGL perspective, viewport and mode

CSize size(cx,cy);

Aspect = (cy == 0) ? (double)size.cx :
(double)size.cx/(double)size.cy;

Height=(float)size.cy;
Width=(float)size.cx;

glViewport(0,0,size.cx,size.cy);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// if you want to use frustum , use this piece
// of code

double PI=3.14159265f;
right = Znear * tan( FovX/2.0f * PI/180.0f );
top = right / Aspect;
bottom = -top;
left = -right;
glFrustum(left, right, bottom, top, Znear, Zfar);

// if you don''t want to use frustum viewport
// uncomment here and let opengl do the rest

//gluPerspective(45,Aspect,Znear,Zfar);


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDrawBuffer(GL_BACK);
glEnable(GL_DEPTH_TEST);


// note that this code comes from an mdi
// application , you have to change the
// base class onsize member

CMDIChildWnd::OnSize(nType, cx, cy);



}


let me know if this worked out , byez
by the way i have the flicker problem too and
i''m working to solve it...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.