Sign in to follow this  
Kynes

OpenGL Shadow mapping and viewport size

Recommended Posts

Hello everyone, I am trying to implement shadow mapping, using OpenGL and GLUT. To sum up, I proceed as follows: 1) glViewport (size of the shadow map) 2) draw geometry from the light point of view 3) copy depth component to texture 4) glViewport (size of the window) 5) render the scene, and do depth comparisons To make a copy of the depth buffer, I use the glCopyTexImage2D function. Everything works fine, as long as the shadow map is smaller than the window. But if I use a 1024x1024 shadow map and a 800x600 glut window, the only data copied to the texture is in the lower-left 800x600 rectangle (that could have actually been displayed on screen...) I wonder if this is this a behaviour that one should expect (meaning I can't render "outside" the glut window, and that I should render to a pbuffer for instance), or if there is a bug somewhere in my code... any idea ?

Share this post


Link to post
Share on other sites
You should use a Frame Buffer Object instead copying the backbuffer to a texture. With a FBO you can render directly into the depth texture and the view port isn't limited to the windows size anymore.

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