Jump to content
  • Advertisement
Sign in to follow this  
one mind

gluPespective troubles

This topic is 5040 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 have setup a window that is split into 4 viewports. 3 of the views are ortho and work nicely no matter what size my window is. The perspective view is killing me. It works fine when the window is perfectly square. If the window is resized horizontaly the polyon square i am rendering is stretched into a rectangle. If the width becomes less than the height the polygon dissapears. Here is how the perspective view is setup gluPerspective(45.0f, width/height ,0, 100); If i use 1 for the aspect ratio, the same streching problem exists but it doesn't disappear when the windows width is less than height. What i want to happen is that the square should remain a square no matter what size the window is. I acheived this with ortho views with this code if (half_width <= half_height) Gl.glOrtho (-nRange, nRange, -nRange*half_height/half_width, nRange*half_height/half_width,-nRange,nRange); else Gl.glOrtho (-nRange*half_width/half_height, nRange*half_width/half_height, -nRange, nRange,-nRange,nRange); *********************************************************** with half_width and half_height being the windows dimensions halved because the are rendered in only 1/4 of the overall window and nRange being 100.0f So basicaly, i just have to find a way to turn my ortho code into perspective code. Has anyone solved this problem? Any help would be greatly appreciated :) Thanks

Share this post


Link to post
Share on other sites
Advertisement
Quote:

gluPerspective(45.0f, width/height ,0, 100);


I assume "width" and "height" are integers,so (width/height) is also an int.Just write "(float)width/height",and you're fine.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!