szgezu has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
Have anybody implemented a code to choose an object in a 3d enviroment? Like the one at the bottom of this page:
http://gpwiki.org/index.php/OpenGL:Tutorials:Picking
I use opengl.pm but the documentation is so poor that I can get on with the conversion of the C code doing this task into perl extremely slowly. If someone else have delat with the problem and would be able to send it to me, it would be great help!

Thanks a lot!

Regards,
Geza Szabo

Replies are listed 'Best First'.
Re: Perl and OpenGL object selection
by Corion (Patriarch) on Feb 11, 2006 at 18:09 UTC

    I've used OpenGL::Simple to great effect. The documentation is likely as poor as the documentation of OpenGL.pm, but that's because OpenGL itself is documented in the Red Book. I recommend buying the 1.4 version, but the 1.1 version online might be enough for you.

Re: Perl and OpenGL object selection
by chromatic (Archbishop) on Feb 11, 2006 at 20:21 UTC

    The OpenGL bindings in the SDL_perl version 1 branch work; I've had success here.

    If you try them, make sure that you're converting between SDL and OpenGL coordinate systems appropriately. The origin for SDL is in the upper left while the origin for OpenGL is in the lower left. (That may be backwards, but the point is that they don't agree.)

      I could not use the SDL openGL libary as it has no gluProject function somehow... Or am I wrong? What do you mean by success with the module? Did you do this object selection somehow? If yes let me know how?

        I didn't use gluProject(), I just rendered the selectable objects in select and projection modes and set a pick matrix of four by four pixels around the cursor, setting a new unique ID for each object. After that, if you call glRenderMode() with GL_RENDER, you get back an array of selected ids.

        It's pretty straightforward in the red book.