Http://bbs.ogdev.net/TopicContent.aspx? Boardid = 2 & topicid = 7659
Developers who have used OpenGL selection and feedback mechanisms may find it unsatisfactory. It is shown in the following aspects:
I. WritingProgramComplex.
To use the selection feedback mechanism, you need to switch the rendering mode, operate the naming stack, calculate the picking matrix, and check the selected records. These tedious steps are prone to errors and are very difficult for debugging, it only reduces work efficiency and enthusiasm.
2. You can only select elements.
For users, the picking mechanism provided by OpenGL is indeed limited.
3. Reduced rendering efficiency.
Selection and feedback in OpenGL are different from normal rendering methods. During usage, the normal scenario is first rendered in the frame cache and then re-painted in the selected mode. At this time, the content of the frame cache remains unchanged. That is to say, in order to select some objects, we need to use different rendering methods in one frame to render them twice. We know that rendering objects is time-consuming. When there are many and complex objects to be selected in the scene, using this mechanism will greatly affect the speed.
In the OpenGL redbooks, we introduced a simple method: Re-paint all objects with different colors in the backbuffer, and each object uses a single color to indicate its color, in this way, we can read the color of the point where the mouse is located to determine the selected object. This method is flawed. When the number of objects to be selected in the scene exceeds a certain limit, the number of identifiers may overflow. For this problem, the solution provided by hongbao is to scan multiple times. Practice has proved that this method is indeed simple and easy, but it still has many limitations, and it is not much easier to do than the first mechanism. I will not repeat it for further details.