Archived

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

OpenGL newbie question

This topic is 5501 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

Hi, I am following NeHe''s tutorial, and just on lesson 2!! Ok, I get the triangle and the square. When I resize the window (by mouse) vertically, the triangle and square get scaled. When I do the same horizontally, they get clipped. Why is so? The code for "ReSizeGLScene" function seems symmetric wrt width and height!¨ Thanks a lot Uday

Share this post


Link to post
Share on other sites
This only occurs when you use gluPerspective, if you use an ortho projection the image is not clipped no matter how far you shrink the window horizontally.

Its probably something to do with the field of view variable, in order to prevent clipping this will need to be modified to adjust the program to the new window dimension.

Share this post


Link to post
Share on other sites
Because of this line
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
witch changes the aspect ratio of the screen, replace it with this
gluPerspective(45.0f,1.33,0.1f,100.0f);
to have it scale both ways.



[edited by - lc_overlord on November 21, 2002 12:04:26 PM]

Share this post


Link to post
Share on other sites
Thanks for your replies.

But using a fixed value like 1.33 for gluPerspective causes the distortion in the triangle shape, which was not happening before. If I resized vertically, the triangle and square were getting scle proportionately without any distortion.

In case of orthographic projection, how do I set the left right top bottom parameters with respect to current viewport size?

Thanks again

Share this post


Link to post
Share on other sites