Mouse selection

Hi i’m french so i’m sorry for my poor english.

is there a way to select an object with the mouse ?

i’m using gl.h, glu.h and glaux.h but not glut.dll.

Thierry

Yeah, there is.

If you’ve got the Red book, then look up picking. If you don’t have the Red book, then here’s a quick intro:

  1. Call glSelectBuffer
  2. Call glRenderMode(GL_SELECT)
  3. Select the projection matrix
  4. Load identity
  5. Call gluPickMatrix
  6. Call gluPerspective (if you’re using perspective)
  7. Select the modelview matrix
  8. Load identity
  9. Clear depth and colour buffers
  10. Draw scene pusing and popping names where appropriate
  11. Call glRenderMode(GL_RENDER)
  12. Read through your selection buffer, to find the lowest z-value.

Try doing some searches on the internet for these functions, and you should be able to work it out from there (it’s a fairly tricky technique, so don’t worry if it takes a while to get it working.)

Good luck with it.

thank you for your help but is there any sample ?

Probably.

An internet search should find something easily enough (ther’s a fair bit of online information about OpenGL).

Good luck!

You can also try feedback function. Make your render mode to GL_FEEDBACK. It will tell you the screen coordinate of the object you draw with OpenGL. Note, the vertical coordinate of screen is up to down while what feedback tell is is down to up. Good Luck!

i have a sample on my site (url in profile)

for the link in your profile doesn’t work