Advertisement Jump to content
Sign in to follow this  

pbuffer aspect ratio

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

I am using a pbuffer as a means to generate water reflections. Everything works great except for that my aspect ratio on the pbuffer is 1:1 since it is a power of 2 which results in a black stripe on the top of the texture. What can i do to correct this? I have searched the forums and the closest case I can find to mine is this guys. He solves the same issue I am having, but does not specify how.

Share this post

Link to post
Share on other sites
ah, that'll be me then [grin]

Basicaly, after creating my pbuffer and then when I set up the state of the OpenGL context to match that of my main context I tell it that its size is whatever size the pbuffer is (say 1024*1024) and then, in my gluPerspective() call instead of setting the aspect ratio to the pbuffer width/pbuffer height I set it to the windows width/windows hight

ie, assuming a pbuffer of 1024*1024 and a screen rez of 1024*768

// Create pbuffer
// switch its context to being the active one
// then do all your various state setup and include this
gluPerspective(45.0f,(1024.0f/768.0f),0.1f,100.0f); // Calculate The Aspect Ratio Of The Window

tada, aspect ratio of pbuffer now matches that of the window.
Personaly, for my test program, I wrapped all my state setup in a function and just fed it height, width and aspect as varibles and used them in the code above where I need them.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!