May 2017
Intermediate to advanced
982 pages
22h 42m
English
Another method which is used for picking objects in a 3D world is color-based picking. In this recipe, we will use the same scene as in the last recipe.
The code for this recipe is in the Chapter2/Picking_ColorBuffer folder. Relevant source files are in the Chapter2/src folder.
To enable picking with the color buffer, the following steps are needed:
glDisable(GL_DITHER);
glReadPixels function:GLubyte pixel[4]; glReadPixels(x, HEIGHT-y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
Read now
Unlock full access