Urgent : gluPickMatrix with VC++

I need some help because I have an urgent project to do and I have a problem with the picking. In fact, these 3 lines heve been given to me by experienced users but they used glut and not VC++ :
GLint viewport [4];
glGetIntegerv (GL_VIEWPORT, viewport);
gluPickMatrix (xmouse, viewport [3] - ymouse, 1., 1., viewport);
i think it’s a window coordinate problem.

I hope you can help me.

Kurt

PS: sorry for my bad english but i’m french

Your code is correct, I think that it’s more likely that your problem lies in the code before or after this statement.

Just double check that you’ve carried out operations in this order:

  1. Call glSelectBuffer
  2. Call glRenderMode(GL_SELECT)
  3. Select the projection matrix
  4. Load identity
  5. Call gluPickMatrix (as in your question)
  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.

(this last part can be slightly awquard, unless you’ve made sure that there’s only one name on the stack at the time)

I might have missed out a step or two…

Hope this helps.