How to associate a function to a drawable object?

There are many drawable objects on my display. I would like my program to call a function when one of the polygons is selected.

How to make a polygon selectable and associate a function to it? Obviously I am new here.


For selection, have a look at OpenGL’s selection mode.

For calling a function based on selection, it depends on language. Since you didn’t mention any language I’m going to assume C++. You can map OpenGL’s selection names to a function pointer using map or vector.

Here’s a link for selection (among other things).