Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
mesh_filter::GLRenderer Class Reference

Abstracts the OpenGL frame buffer objects, and provides an interface to render meshes, and retrieve the color and depth ap from opengl. More...

#include <gl_renderer.h>

List of all members.

Public Member Functions

void begin () const
 initializes the frame buffers for rendering and or manipulating
void callList (GLuint list) const
 executes a OpenGL list
void end () const
 finalizes the frame buffers after rendering and/or manipulating
void getColorBuffer (unsigned char *buffer) const
 retrieves the color buffer from OpenGL
GLuint getColorTexture () const
 returns the handle of the color buffer as an OpenGL texture object
void getDepthBuffer (float *buffer) const
 retrieves the depth buffer from OpenGL
GLuint getDepthTexture () const
 returns the handle of the depth buffer as an OpenGL texture object
const float & getFarClippingDistance () const
 returns the distance of the far clipping plane in meters
const unsigned getHeight () const
 returns the height of the frame buffer objects in pixels
const float & getNearClippingDistance () const
 returns the distance of the near clipping plane in meters
const GLuint & getProgramID () const
const unsigned getWidth () const
 returns the width of the frame buffer objectsin pixels
 GLRenderer (unsigned width, unsigned height, float near=0.1, float far=10.0)
 constructs the frame buffer object in a new OpenGL context.
void setBufferSize (unsigned width, unsigned height)
 set the size of fram buffers
void setCameraParameters (float fx, float fy, float cx, float cy)
 set the camera parameters
void setClippingRange (float near, float far)
 sets the near and far clipping plane distances in meters
GLuint setShadersFromFile (const std::string &vertex_filename, const std::string &fragment_filename)
 loads, compiles, links and adds GLSL shaders from files to the current OpenGL context.
GLuint setShadersFromString (const std::string &vertex_shader, const std::string &fragment_shader)
 loads, compiles, links and adds GLSL shaders from string to the current OpenGL context.
 ~GLRenderer ()
 destructor, destroys frame buffer objects and OpenGL context

Private Member Functions

GLuint createShader (GLuint shaderID, const std::string &source) const
 create a OpenGL shader object from the shader source code
void deleteFrameBuffers ()
 deletes the frame buffer objects
void initFrameBuffers ()
 initializes the frame buffer objects
GLuint loadShaders (const std::string &vertex_source, const std::string &fragment_source) const
 Compiles, Links and adds the GLSL shaders from strings containing the source codes.
void readShaderCodeFromFile (const std::string &filename, std::string &source) const
 reads shader source code from file to a string
void setCameraParameters () const
 sets the OpenGL camera parameters

Static Private Member Functions

static void createGLContext ()
 create the OpenGL context if required. Only on context is created for each thread
static void deleteGLContext ()
 deletes OpenGL context for the current thread

Private Attributes

float cx_
 x-coordinate of principal point of camera in pixels
float cy_
 y-coordinate of principal point of camera in pixels
GLuint depth_id_
 handle to depth buffer
float far_
 distance of far clipping plane in meters
GLuint fbo_id_
 handle to frame buffer object
float fx_
 focal length in x-direction of camera in pixels
float fy_
 focal length in y-direction of camera in pixels
unsigned height_
 height of frame buffer objects in pixels
float near_
 distance of near clipping plane in meters
GLuint program_
 handle to program that is currently used
GLuint rbo_id_
 handle to render buffer object
GLuint rgb_id_
 handle to color buffer
unsigned width_
 width of frame buffer objects in pixels

Static Private Attributes

static std::map
< boost::thread::id, std::pair
< unsigned, GLuint > > 
context_
 map from thread id to OpenGL context
static boost::mutex context_lock_
static bool glutInitialized_ = false

Detailed Description

Abstracts the OpenGL frame buffer objects, and provides an interface to render meshes, and retrieve the color and depth ap from opengl.

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 54 of file gl_renderer.h.


Constructor & Destructor Documentation

mesh_filter::GLRenderer::GLRenderer ( unsigned  width,
unsigned  height,
float  near = 0.1,
float  far = 10.0 
)

constructs the frame buffer object in a new OpenGL context.

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]widththe width of the frame buffers
[in]heightheight of the framebuffers
[in]neardistance of the near clipping plane in meters
[in]fardistance of the far clipping plane in meters

Definition at line 57 of file gl_renderer.cpp.

destructor, destroys frame buffer objects and OpenGL context

Definition at line 76 of file gl_renderer.cpp.


Member Function Documentation

initializes the frame buffers for rendering and or manipulating

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 186 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::callList ( GLuint  list) const

executes a OpenGL list

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]listthe handle of the OpenGL list to be executed

Definition at line 196 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::createGLContext ( ) [static, private]

create the OpenGL context if required. Only on context is created for each thread

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 363 of file gl_renderer.cpp.

GLuint mesh_filter::GLRenderer::createShader ( GLuint  shaderID,
const std::string &  source 
) const [private]

create a OpenGL shader object from the shader source code

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]shaderIDtype of shader to be created (e.g. GL_VERTEX_SHADER or GL_FRAGMENT_SHADER)
[in]sourcethe source code of the shader to be created
Returns:
handle to the shader object

Definition at line 260 of file gl_renderer.cpp.

deletes the frame buffer objects

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 172 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::deleteGLContext ( ) [static, private]

deletes OpenGL context for the current thread

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 410 of file gl_renderer.cpp.

finalizes the frame buffers after rendering and/or manipulating

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 203 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::getColorBuffer ( unsigned char *  buffer) const

retrieves the color buffer from OpenGL

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[out]bufferpointer to memory where the color values need to be stored

Definition at line 210 of file gl_renderer.cpp.

returns the handle of the color buffer as an OpenGL texture object

Author:
Suat Gedikli (gedikli@willowgarage.com)
Returns:
handle of the OpenGL texture object for the color buffer

Definition at line 429 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::getDepthBuffer ( float *  buffer) const

retrieves the depth buffer from OpenGL

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[out]bufferpointer to memory where the depth values need to be stored

Definition at line 218 of file gl_renderer.cpp.

returns the handle of the depth buffer as an OpenGL texture object

Author:
Suat Gedikli (gedikli@willowgarage.com)
Returns:
handle of the OpenGL texture object for the depth buffer

Definition at line 434 of file gl_renderer.cpp.

returns the distance of the far clipping plane in meters

Author:
Suat Gedikli (gedikli@willowgarage.com)
Returns:
distance of the far clipping plane in meters

Definition at line 255 of file gl_renderer.cpp.

const unsigned mesh_filter::GLRenderer::getHeight ( ) const

returns the height of the frame buffer objects in pixels

Author:
Suat Gedikli (gedikli@willowgarage.com)
Returns:
height of frame buffer in pixels

Definition at line 444 of file gl_renderer.cpp.

returns the distance of the near clipping plane in meters

Author:
Suat Gedikli (gedikli@willowgarage.com)
Returns:
distance of near clipping plane in meters

Definition at line 250 of file gl_renderer.cpp.

const GLuint & mesh_filter::GLRenderer::getProgramID ( ) const
Returns:
the current programID
Author:
Suat Gedikli (gedikli@willowgarage.com)
Returns:
current porgamID. 0 if no shaders are used.

Definition at line 245 of file gl_renderer.cpp.

const unsigned mesh_filter::GLRenderer::getWidth ( ) const

returns the width of the frame buffer objectsin pixels

Author:
Suat Gedikli (gedikli@willowgarage.com)
Returns:
width of frame buffer in pixels

Definition at line 439 of file gl_renderer.cpp.

initializes the frame buffer objects

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 130 of file gl_renderer.cpp.

GLuint mesh_filter::GLRenderer::loadShaders ( const std::string &  vertex_source,
const std::string &  fragment_source 
) const [private]

Compiles, Links and adds the GLSL shaders from strings containing the source codes.

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]vertex_sourcestring containing the vertex shader source code
[in]fragment_sourcestring containing the fragment shader source code
Returns:
programID

Definition at line 313 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::readShaderCodeFromFile ( const std::string &  filename,
std::string &  source 
) const [private]

reads shader source code from file to a string

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]filenamepath to file containing the shader source code
[out]sourcestring to be filled with the shader source code

Definition at line 290 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::setBufferSize ( unsigned  width,
unsigned  height 
)

set the size of fram buffers

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]widthwidth of frame buffer in pixels
[in]heightheight of frame buffer in pixels

Definition at line 85 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::setCameraParameters ( float  fx,
float  fy,
float  cx,
float  cy 
)

set the camera parameters

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]fxfocal length in x-direction
[in]fyfocal length in y-direction
[in]cxx component of principal point
[in]cyy component of principal point

Definition at line 106 of file gl_renderer.cpp.

sets the OpenGL camera parameters

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 114 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::setClippingRange ( float  near,
float  far 
)

sets the near and far clipping plane distances in meters

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]neardistance of the near clipping plane in meters
[in]fardistance of the far clipping plane in meters

Definition at line 96 of file gl_renderer.cpp.

GLuint mesh_filter::GLRenderer::setShadersFromFile ( const std::string &  vertex_filename,
const std::string &  fragment_filename 
)

loads, compiles, links and adds GLSL shaders from files to the current OpenGL context.

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]vertex_filenamepath to vertex shader source code. Can set to "" (empty string) if no vertex shader is used.
[in]fragment_filenamepath to fragemnt shader source code. Can be set to "" if no fragment shader is used.
Returns:
the programID

Definition at line 226 of file gl_renderer.cpp.

GLuint mesh_filter::GLRenderer::setShadersFromString ( const std::string &  vertex_shader,
const std::string &  fragment_shader 
)

loads, compiles, links and adds GLSL shaders from string to the current OpenGL context.

Author:
Suat Gedikli (gedikli@willowgarage.com)
Parameters:
[in]vertex_shadersource code of the vertex shader. Can be "" if no vertex shader is used.
[in]fragment_shadersource code of the fragment shader. Can be "" if no fragment shader is used.
Returns:
programID

Definition at line 239 of file gl_renderer.cpp.


Member Data Documentation

map< boost::thread::id, pair< unsigned, GLuint > > mesh_filter::GLRenderer::context_ [static, private]

map from thread id to OpenGL context

Definition at line 293 of file gl_renderer.h.

boost::mutex mesh_filter::GLRenderer::context_lock_ [static, private]

Definition at line 296 of file gl_renderer.h.

x-coordinate of principal point of camera in pixels

Definition at line 287 of file gl_renderer.h.

y-coordinate of principal point of camera in pixels

Definition at line 290 of file gl_renderer.h.

handle to depth buffer

Definition at line 269 of file gl_renderer.h.

distance of far clipping plane in meters

Definition at line 278 of file gl_renderer.h.

handle to frame buffer object

Definition at line 260 of file gl_renderer.h.

focal length in x-direction of camera in pixels

Definition at line 281 of file gl_renderer.h.

focal length in y-direction of camera in pixels

Definition at line 284 of file gl_renderer.h.

bool mesh_filter::GLRenderer::glutInitialized_ = false [static, private]

Definition at line 298 of file gl_renderer.h.

height of frame buffer objects in pixels

Definition at line 257 of file gl_renderer.h.

distance of near clipping plane in meters

Definition at line 275 of file gl_renderer.h.

handle to program that is currently used

Definition at line 272 of file gl_renderer.h.

handle to render buffer object

Definition at line 263 of file gl_renderer.h.

handle to color buffer

Definition at line 266 of file gl_renderer.h.

unsigned mesh_filter::GLRenderer::width_ [private]

width of frame buffer objects in pixels

Definition at line 254 of file gl_renderer.h.


The documentation for this class was generated from the following files:


perception
Author(s): Ioan Sucan , Jon Binney , Suat Gedikli
autogenerated on Wed Aug 26 2015 12:43:21