Jump to content
  • Advertisement
Sign in to follow this  
VerMan

Mapping coordinates (gluUnproject - gluProject)

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

Hello fellows, I'm doing some shadow mapping and i'm rendering from the light's point of view, get the depth buffer and save it to some array using glReadpixels. Later i render from the camera's point of view, do another glReadpixels and for every pixel i need to find its position in the previously saved array (where the depth map is stored). So i thought, ok 1) for every pixel in my array (x,y) i do a glUnproject(x,y,depth[x,y], camView, camProj, viewport, &wx, &wy, &wz) 2) glProject(wx, wy, wz, lightView, lightProj, viewport, &lx, &ly, &lz) but i'm getting some garbage, i.e. negative coordinates or off-limits like -1322, 673, etc assuming the viewport is 0,0,512,512 this should not happen... does it? or maybe i'm totally wrong in my approach... comments? thank you

Share this post


Link to post
Share on other sites
Advertisement
well, i figured it out.
For some reason i don't know after a glReadPixels(0,0,width,height,pixels) where pixels has been declared as:
GLubyte pixels[width][height][3]

I was reading this using a nested for loop like:
for(x=0; ...)
for(y=0; ...)
gluUnproject(x,y,...)

but x and y were inverted so now I use:
gluUnproject(y,x,...) and i'm done (wtf?)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!