Examples » Object picking

Usage of multiple framebuffer attachments to implement object picking.

Image

One attachment is used for color output, the other contains object IDs. The color buffer is blit to window framebuffer, a pixel from the other is read after mouse click to retrieve object ID.

Key controls

Use mouse drag to rotate the scene, mouse click to highlight particular object.

Source

Full source code is linked below and also available in the magnum-examples GitHub repository.

The ports branch contains additional patches for Emscripten support that aren't present in master in order to keep the example code as simple as possible.