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 58 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 56 of file gl_renderer.cpp.

destructor, destroys frame buffer objects and OpenGL context

Definition at line 75 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 185 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 195 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 367 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 259 of file gl_renderer.cpp.

deletes the frame buffer objects

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 171 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 415 of file gl_renderer.cpp.

finalizes the frame buffers after rendering and/or manipulating

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 202 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 209 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 434 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 217 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 439 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 254 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 449 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 249 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 244 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 444 of file gl_renderer.cpp.

initializes the frame buffer objects

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 129 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 312 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 289 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 84 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 105 of file gl_renderer.cpp.

sets the OpenGL camera parameters

Author:
Suat Gedikli (gedikli@willowgarage.com)

Definition at line 113 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 95 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 225 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 238 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 298 of file gl_renderer.h.

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

Definition at line 301 of file gl_renderer.h.

x-coordinate of principal point of camera in pixels

Definition at line 292 of file gl_renderer.h.

y-coordinate of principal point of camera in pixels

Definition at line 295 of file gl_renderer.h.

handle to depth buffer

Definition at line 274 of file gl_renderer.h.

distance of far clipping plane in meters

Definition at line 283 of file gl_renderer.h.

handle to frame buffer object

Definition at line 265 of file gl_renderer.h.

focal length in x-direction of camera in pixels

Definition at line 286 of file gl_renderer.h.

focal length in y-direction of camera in pixels

Definition at line 289 of file gl_renderer.h.

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

Definition at line 303 of file gl_renderer.h.

height of frame buffer objects in pixels

Definition at line 262 of file gl_renderer.h.

distance of near clipping plane in meters

Definition at line 280 of file gl_renderer.h.

handle to program that is currently used

Definition at line 277 of file gl_renderer.h.

handle to render buffer object

Definition at line 268 of file gl_renderer.h.

handle to color buffer

Definition at line 271 of file gl_renderer.h.

unsigned mesh_filter::GLRenderer::width_ [private]

width of frame buffer objects in pixels

Definition at line 259 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 Mon Apr 23 2018 10:25:10