Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Perferati

Window resizing problems..please help!

This topic is 5953 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!