#include <Selector.h>
Inherits noncopyable.
The Selector class simplifies the process of selecting objects rendered with OpenGL.
The Mode defines the method used to perform selection. Each mode has pros and cons.
Enumerator |
---|
GLSelect |
Uses glRenderMode( GL_SELECT ). This can select multiple overlapping objects at once and provides accurate depth information for each. However it is officially deprecated in modern OpenGL and has terrible performance on many modern drivers due to using a software fallback path.
|
OcclusionQuery |
Uses OpenGL occlusion queries. This can also select multiple overlapping objects at once but does not provide depth information at all.
|
IDRender |
Renders each object to an offscreen framebuffer using a unique colour per object. Can therefore only select the frontmost objects, but does provide accurate depth information. Note that this mode is currently only supported for GLSL versions 330 and up - lesser versions will fall back to using the GLSelect mode.
|
IECoreGL::Selector::Selector |
( |
const Imath::Box2f & |
region, |
|
|
Mode |
mode, |
|
|
std::vector< HitRecord > & |
hits |
|
) |
| |
Starts an operation to select objects in the specified region of NDC space (0,0-1,1 top left to bottom right). Set up the GL camera, construct a Selector, then render the objects with appropriate loadName() calls with names generated using NameStateComponent. It is the caller's responsibility to keep the hits vector alive for the lifetime of the Selector.
virtual IECoreGL::Selector::~Selector |
( |
| ) |
|
|
virtual |
Completes the selection operation, filling in the vector of hits that was passed to the constructor.
State* IECoreGL::Selector::baseState |
( |
| ) |
|
A State that should be used as the base state for selection drawing.
static Selector* IECoreGL::Selector::currentSelector |
( |
| ) |
|
|
static |
Returns the currently active Selector - this may be used in drawing code to retrieve a selector to call loadName() on. The NameStateComponent is an example of a class which does this.
void IECoreGL::Selector::loadName |
( |
GLuint |
name | ) |
|
Call this to set the name attached to subsequently rendered objects. If rendering a Scene, this will be called automatically by the NameStateComponents within the Scene.
GLuint IECoreGL::Selector::loadName |
( |
| ) |
|
Generates a new name (by incrementing an internal counter) and loads and returns it. No guarantee is made that generated names will not clash with names loaded explicitly with the method above.
const Imath::M44d& IECoreGL::Selector::postProjectionMatrix |
( |
| ) |
|
The post-projection matrix being used to perform the selection. This is applied automatically by the constructor, but if the projection matrix is changed after construction, then this matrix must be multiplied with it.
The IDRender mode requires a shader which takes a name via a "uniform uint ieCoreGLName" parameter and outputs it via an "out uint ieCoreGLNameOut" fragment output. The defaultIDShader() meets these criteria and will be bound automatically when the selector constructs in IDRender mode. Note however, that if any other shaders are subsequently bound while the selector is active, they too must meet the same critera.
The documentation for this class was generated from the following file: