Opentk/Source/Examples/OpenGL/1.x/Picking.rtf
thefiddler 8dcb8601a2 Normalized line endings
Hopefully this is the first and last time we have to do this.
2013-10-11 01:58:54 +02:00

20 lines
1.3 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{\rtf1\ansi\ansicpg1253\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}}
{\colortbl ;\red163\green21\blue21;}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\cf1\lang1033\b\fs28 Introduction\b0\fs22\par
\par
This sample demonstrates a way to select 3d objects from a scene using the mouse. In OpenGL nomenclature, this process is called "picking".\par
\par
\b\fs28 Controls\par
\b0\fs22\par
Press Esc or click the close button to exit.\par
The mouse pointer picks items automatically. Move the mouse to pick a different item.\par
\par
\b\fs28 Implementation\par
\b0\fs22\par
Every object in the scene is assigned a unique id by "coloring" all of its vertices with the same color. The color is generated by encoding the Int32 id into a 4-byte Rgba value.\par
\par
A first rendering pass clears the screen to Int32.MaxValue, disables all textures and shaders and renders the scene using the aforementioned coloring scheme. As soon as this rendering is complete, we use GL.ReadPixels() to retrieve the pixel below the mouse cursor. By reversing the encoding process, we convert the Rgba value of the pixel back into the unique Int32 id.\par
\par
A second rendering pass clears the screen once more and proceeds to render the scene normally (using all necessary textures and shaders). The user never sees the results of the first rendering pass!\par
}