Jump to content
  • Advertisement


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


OpenGL I need help from an opengl guru

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

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!