Sign in to follow this  
Eps

pbuffer aspect ratio

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
glViewport(0,0,1024,1024);
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this