Archived

This topic is now archived and is closed to further replies.

Lestat3D

OpenGL I need help from an opengl guru

Recommended Posts

Hi, lets get into the situation... I''m building an application that draws a square with opengl using a triangle list of two triangles. Well, that works fine, but I have to know what textures coordinates the mouse is over. I''ve serching the web for any tutorial or refference explainning some of ray picking, but nobody could explain me how to get the textuer coordinates under the cursor nor triangle barycentric coords. Please help meeeeeeeeeeee!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Use glReadPixels with the mouse x and y coordinates, this will give you a depth value (from the depth buffer)

Use this depth value in gluUnproject to give you the 3D x, y and z coordinates

The next bit will be specific to your app, you will need to use the x,y and z values to determine which triangle the pixel is part of and where on the triangle it lies

Then map this position to your texture coordinates

Why do you need the texture coords?

Share this post


Link to post
Share on other sites