# opentl::modelprojection::GLScene Class Reference

Class OpenGL scene creates the OpenGL context, initializes display lists per objectModel and creates a FBO management and Shader management instance. More...

Inherits opentl::core::util::ParameterContainer.

List of all members.

## Public Types
## Public Member Functions
opentl::cvprocess::GlFbo * | getGlFbo (const std::string &str, int camIdx)
| Returns a pointer to a frame buffer object class instance. Uses singleton pattern per Camera and modality.
opentl::cvprocess::GlShaderMgr * | getGlShaderMgr (void)
| Returns pointer to a class for OpenGL shader management.
void | getOpenGlModelViewMatrix (const opentl::core::cvdata::Pose &objPose, double *modelViewMatrix, int cameraIdx, int linkIdx) const
| Get target specific OpenGL model view matrix.
| GLScene (ObjModelPtrVector &objModels, opentl::cvprocess::GpuStdShaders *gpuShaders=NULL)
| Constructor.
void | init ()
| Initialize class.
void | prepareDisplayLists (const ObjModelPtrVector &objModels)
void | renderScene (const TargetPtrVector &targets, std::size_t partitionIdx, RENDER_MODE renderMode, int camIdx, std::vector< int > &linkIds, std::vector< math::Vector4 > &shadowColors, GLuint *drawnPixQueryArray=NULL)
| Render scene consisting of all targets in given render mode for a certain camera/sensor. Hint: - Requires call of setOpenGlProjection() first! glFogCoord encodes index position within target vector.
void | renderScene (const std::vector< boost::shared_ptr< opentl::core::State > > &states, const ObjModelPtrVector &objModels, RENDER_MODE renderMode, int camIdx, std::vector< int > &linkIds, std::vector< math::Vector4 > &shadowColors, GLuint *drawnPixQueryArray=NULL)
| Render scene consisting of all states in given render mode for a certain camera/sensor. Hint: - Requires call of setOpenGlProjection() first! glFogCoord encodes index position within state vector.
void | renderSingleObject (const opentl::core::State *state, const opentl::models::ObjModel *objModel, RENDER_MODE renderMode, int targetIdx=0, int camIdx=0, int partIdx=0)
| Render a single object (state hypothesis) in given render mode for a certain camera/sensor. Hint: - Requires call of setOpenGlProjection() first! NOTE: The target ID is encoded in glFogCoord.
void | setOpenGlProjection (const TargetPtrVector &targets, std::size_t partitionIdx, input::ImageSensor &sensor, int cameraIdx, std::vector< int > &linkIds) const
| Set OpenGL projection paramenters and culling planes based on last warpUpdate().
void | setOpenGlProjection (const std::vector< boost::shared_ptr< opentl::core::State > > &states, const ObjModelPtrVector &objModels, input::ImageSensor &sensor, int cameraIdx, std::vector< int > &linkIds) const
| Set OpenGL projection paramenters and culling planes based on last warpUpdate().
virtual | ~GLScene ()
| Destructor.
## Public Attributes
ObjModelPtrVector & | mObjModels
| Vector of object model pointers.

## Detailed Description

Class OpenGL scene creates the OpenGL context, initializes display lists per objectModel and creates a FBO management and Shader management instance.

HINT: A GLScene instance is created per GL hardware accelerated graphics card (SLI connected cards are perceived as a single card). Each graphic card should handle at least one sensor view and all corresponding modalities/features processing Explanation: Independet graphic cards should have their own GL contexts (=non shared FBOs) to avoid unwanted driver internal texture copy/syncronization tasks.

Author:
  Giorgio Panin <panin@in.tum.de>, Erwin Roth <eroth@mytum.de>

## Member Enumeration Documentation

enum opentl::modelprojection::GLScene::OfflineParameters

Enumerator:

  construct_autoCreateGLContext | (bool) Automatically create OpenGL context at class instantiation
  construct_showGpuCapabilityInfo | (bool) Show GPU hardware capability info
  construct_initWindowPosX | (int) Initial window X position
  construct_initWindowPosY | (int) Initial window Y position
  construct_initWindowSizeX | (int) Initial window X resolution
  construct_initWindowSizeY | (int) Initial window Y resolution
  construct_initglutWindowName | �(std::string) Window name
  OFFLINE_COUNT |

enum opentl::modelprojection::GLScene::OnlineParameters

Enumerator:

  ONLINE_COUNT |

enum opentl::modelprojection::GLScene::RENDER_MODE

Rendering modes (one OpenGL call list per link and unique object shape).

Enumerator:

  POINTS | Render unique vertices list (GL_POINT mode), without color.
  LINES | Render unique edges list (GL_LINE mode), without color.
  FACES | Render polygon list (GL_POLYGON mode), with: ambient and diffuse color, normal and vertices.
  FACES_NO_MATERIAL | Render polygon list (GL_POLYGON mode), with: normal and vertices (no material color).
  FACES_CODED_COLORS | Render polygon list (GL_POLYGON mode), with normal and vertices, and face ID encoded in the red and green color channels (lo and hi byte; max = 65535).
  TEXTURES |
  EDGE_FEATURES |

## Constructor & Destructor Documentation

opentl::modelprojection::GLScene::GLScene | ( | ObjModelPtrVector & | objModels,
|  | opentl::cvprocess::GpuStdShaders * | gpuShaders = `NULL` |
| ) |  |  |

Constructor.

Parameters:

  | objModels | Vector of object model pointers.
  | gpuShaders | pointer to gpu-shader (optional)

virtual opentl::modelprojection::GLScene::~GLScene | ( |  | ) | `[virtual]`

Destructor.

## Member Function Documentation

opentl::cvprocess::GlFbo* opentl::modelprojection::GLScene::getGlFbo | ( | const std::string & | str,
|  | int | camIdx |
| ) |  |  | `[inline]`

Returns a pointer to a frame buffer object class instance. Uses singleton pattern per Camera and modality.

Parameters:

  | str | Arbitrary string to uniquely identify this fbo instance. If str = "_ENFORCE_NEW_", the creation of a new fbo instance is enforced!
  | camIdx | Camera index.

Returns:
  Pointer to fbo class instance.

opentl::cvprocess::GlShaderMgr* opentl::modelprojection::GLScene::getGlShaderMgr | ( | void |  | ) | `[inline]`

Returns pointer to a class for OpenGL shader management.

Returns:
  Pointer to shader management class instance.

void opentl::modelprojection::GLScene::getOpenGlModelViewMatrix | ( | const opentl::core::cvdata::Pose & | objPose,
|  | double * | modelViewMatrix,
|  | int | cameraIdx,
|  | int | linkIdx |
| ) |  |  | const`[inline]`

Get target specific OpenGL model view matrix.

Parameters:

  | objPose | Object pose.
  | modelViewMatrix | Resulting OpenGL model view matrix.
  | cameraIdx | Camera index.
  | linkIdx | Link index of articulated object.

void opentl::modelprojection::GLScene::init | ( |  | ) | `[virtual]`

Initialize class.

Implements opentl::core::util::ParameterContainer.

void opentl::modelprojection::GLScene::prepareDisplayLists | ( | const ObjModelPtrVector & | objModels | ) |

void opentl::modelprojection::GLScene::renderScene | ( | const TargetPtrVector & | targets,
|  | std::size_t | partitionIdx,
|  | RENDER_MODE | renderMode,
|  | int | camIdx,
|  | std::vector< int > & | linkIds,
|  | std::vector< math::Vector4 > & | shadowColors,
|  | GLuint * | drawnPixQueryArray = `NULL` |
| ) |  |  |

Render scene consisting of all targets in given render mode for a certain camera/sensor. Hint: - Requires call of setOpenGlProjection() first!

- glFogCoord encodes index position within target vector.

Parameters:

  | targets | Vector of wanted targets.
  | partitionIdx | Index to the current active state in the targets.
  | renderMode | Mode in which to render into OpenGL buffer.
  | camIdx | Camera index.
  | linkIds | Link indices: for each object, a single link, or the full shape (id = -1) can be rendered.
  | shadowColors | Custom colors (per target), in case of shadow drawing (must have the same size of linkIds, or empty = all white)
  | drawnPixQueryArray | Optional: creates query for drawn pixel per target (including all articulated object parts). Query array elements must already exist.

void opentl::modelprojection::GLScene::renderScene | ( | const std::vector< boost::shared_ptr< opentl::core::State > > & | states,
|  | const ObjModelPtrVector & | objModels,
|  | RENDER_MODE | renderMode,
|  | int | camIdx,
|  | std::vector< int > & | linkIds,
|  | std::vector< math::Vector4 > & | shadowColors,
|  | GLuint * | drawnPixQueryArray = `NULL` |
| ) |  |  |

Render scene consisting of all states in given render mode for a certain camera/sensor. Hint: - Requires call of setOpenGlProjection() first!

- glFogCoord encodes index position within state vector.

Parameters:

  | states | Vector of states.
  | objModels | reference to the object models used
  | renderMode | Mode in which to render into OpenGL buffer.
  | camIdx | Camera index.
  | linkIds | Link indices: for each object, a single link, or the full shape (id = -1) can be rendered.
  | shadowColors | Custom colors (per target), in case of shadow drawing (must have the same size of linkIds, or empty = all white)
  | drawnPixQueryArray | Optional: creates query for drawn pixel per target (including all articulated object parts). Query array elements must already exist.

void opentl::modelprojection::GLScene::renderSingleObject | ( | const opentl::core::State * | state,
|  | const opentl::models::ObjModel * | objModel,
|  | RENDER_MODE | renderMode,
|  | int | targetIdx = `0`,
|  | int | camIdx = `0`,
|  | int | partIdx = `0` |
| ) |  |  |

Render a single object (state hypothesis) in given render mode for a certain camera/sensor. Hint: - Requires call of setOpenGlProjection() first! NOTE: The target ID is encoded in glFogCoord.

Parameters:

  | state | State to be drawn.
  | objModel | pointer to Object model
  | renderMode | Mode in which to render into OpenGL buffer.
  | targetIdx | This is the vector position within the target vector to be rendered. ATTENTION: This is not the targetId !!!
  | camIdx | Camera index.
  | partIdx | Optional: part index of articulated object.

void opentl::modelprojection::GLScene::setOpenGlProjection | ( | const TargetPtrVector & | targets,
|  | std::size_t | partitionIdx,
|  | input::ImageSensor & | sensor,
|  | int | cameraIdx,
|  | std::vector< int > & | linkIds |
| ) |  |  | const

Set OpenGL projection paramenters and culling planes based on last warpUpdate().

Parameters:

  | targets | Vector of targets.
  | partitionIdx | Index to the current active state in the targets.
  | sensor | pointer to the used sensor models
  | cameraIdx | Camera index.
  | linkIdx | Link index of articulated object.

void opentl::modelprojection::GLScene::setOpenGlProjection | ( | const std::vector< boost::shared_ptr< opentl::core::State > > & | states,
|  | const ObjModelPtrVector & | objModels,
|  | input::ImageSensor & | sensor,
|  | int | cameraIdx,
|  | std::vector< int > & | linkIds |
| ) |  |  | const

Set OpenGL projection paramenters and culling planes based on last warpUpdate().

Parameters:

  | states | Vector of states.
  | objModels | reference to the object models used
  | sensor | pointer to the used sensor models
  | cameraIdx | Camera index.
  | linkIdx | Link index of articulated object.

## Member Data Documentation

ObjModelPtrVector& opentl::modelprojection::GLScene::mObjModels

Vector of object model pointers.