Jump to content
  • Advertisement
Sign in to follow this  

OpenGL resizing windows and object

This topic is 4254 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! I am using nehe 42 lesson to learn about Viewports. And I have found a problem with resizing. When I am changing the size of the ports, the object drawn on it also resize (eg. after stretching a window, sphere becames ellipsoid). Could anybody help me and tell how to make Viewports resizing without resizing the objects drawn in it?

Share this post

Link to post
Share on other sites
You'll want glViewport to size things correctly. You'll also want gluPerspective to keep things sized correctly. Whenever you process an OnSize message, call gluPerspective in something along the following lines:

void CChildView::OnSize(UINT nType, int cx, int cy)
CWnd::OnSize(nType, cx, cy);


glViewport(0, 0, cx, cy);

float height = (float)cy; // important! integers round
float width = (float)cx; // and will cause errors below

// Calculate The Aspect Ratio Of The Window
width/height ,

Best of luck!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!