Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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>

Public Member Functions

void begin () const
 initializes the frame buffers for rendering and or manipulating More...
 
void callList (GLuint list) const
 executes a OpenGL list More...
 
void end () const
 finalizes the frame buffers after rendering and/or manipulating More...
 
void getColorBuffer (unsigned char *buffer) const
 retrieves the color buffer from OpenGL More...
 
GLuint getColorTexture () const
 returns the handle of the color buffer as an OpenGL texture object More...
 
void getDepthBuffer (float *buffer) const
 retrieves the depth buffer from OpenGL More...
 
GLuint getDepthTexture () const
 returns the handle of the depth buffer as an OpenGL texture object More...
 
const float & getFarClippingDistance () const
 returns the distance of the far clipping plane in meters More...
 
const unsigned getHeight () const
 returns the height of the frame buffer objects in pixels More...
 
const float & getNearClippingDistance () const
 returns the distance of the near clipping plane in meters More...
 
const GLuint & getProgramID () const
 
const unsigned getWidth () const
 returns the width of the frame buffer objectsin pixels More...
 
 GLRenderer (unsigned width, unsigned height, float near=0.1, float far=10.0)
 constructs the frame buffer object in a new OpenGL context. More...
 
void setBufferSize (unsigned width, unsigned height)
 set the size of fram buffers More...
 
void setCameraParameters (float fx, float fy, float cx, float cy)
 set the camera parameters More...
 
void setClippingRange (float near, float far)
 sets the near and far clipping plane distances in meters More...
 
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. More...
 
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. More...
 
 ~GLRenderer ()
 destructor, destroys frame buffer objects and OpenGL context More...
 

Private Member Functions

GLuint createShader (GLuint shaderID, const std::string &source) const
 create a OpenGL shader object from the shader source code More...
 
void deleteFrameBuffers ()
 deletes the frame buffer objects More...
 
void initFrameBuffers ()
 initializes the frame buffer objects More...
 
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. More...
 
void readShaderCodeFromFile (const std::string &filename, std::string &source) const
 reads shader source code from file to a string More...
 
void setCameraParameters () const
 sets the OpenGL camera parameters More...
 

Static Private Member Functions

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

Private Attributes

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

Static Private Attributes

static std::map< boost::thread::id, std::pair< unsigned, GLuint > > context_
 map from thread id to OpenGL context More...
 
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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)

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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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.

mesh_filter::GLRenderer::~GLRenderer ( )

destructor, destroys frame buffer objects and OpenGL context

Definition at line 75 of file gl_renderer.cpp.

Member Function Documentation

void mesh_filter::GLRenderer::begin ( ) const

initializes the frame buffers for rendering and or manipulating

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)

Definition at line 185 of file gl_renderer.cpp.

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

executes a OpenGL list

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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 ( )
staticprivate

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

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)

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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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.

void mesh_filter::GLRenderer::deleteFrameBuffers ( )
private

deletes the frame buffer objects

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)

Definition at line 171 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::deleteGLContext ( )
staticprivate

deletes OpenGL context for the current thread

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)

Definition at line 414 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::end ( ) const

finalizes the frame buffers after rendering and/or manipulating

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)

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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
Parameters
[out]bufferpointer to memory where the color values need to be stored

Definition at line 209 of file gl_renderer.cpp.

GLuint mesh_filter::GLRenderer::getColorTexture ( ) const

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

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
Returns
handle of the OpenGL texture object for the color buffer

Definition at line 433 of file gl_renderer.cpp.

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

retrieves the depth buffer from OpenGL

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
Parameters
[out]bufferpointer to memory where the depth values need to be stored

Definition at line 217 of file gl_renderer.cpp.

GLuint mesh_filter::GLRenderer::getDepthTexture ( ) const

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

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
Returns
handle of the OpenGL texture object for the depth buffer

Definition at line 438 of file gl_renderer.cpp.

const float & mesh_filter::GLRenderer::getFarClippingDistance ( ) const

returns the distance of the far clipping plane in meters

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
Returns
height of frame buffer in pixels

Definition at line 448 of file gl_renderer.cpp.

const float & mesh_filter::GLRenderer::getNearClippingDistance ( ) const

returns the distance of the near clipping plane in meters

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
Returns
width of frame buffer in pixels

Definition at line 443 of file gl_renderer.cpp.

void mesh_filter::GLRenderer::initFrameBuffers ( )
private

initializes the frame buffer objects

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)

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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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.

void mesh_filter::GLRenderer::setCameraParameters ( ) const
private

sets the OpenGL camera parameters

Author
Suat Gedikli (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)

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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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 (gedik.nosp@m.li@w.nosp@m.illow.nosp@m.gara.nosp@m.ge.co.nosp@m.m)
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_
staticprivate

map from thread id to OpenGL context

Definition at line 298 of file gl_renderer.h.

boost::mutex mesh_filter::GLRenderer::context_lock_
staticprivate

Definition at line 301 of file gl_renderer.h.

float mesh_filter::GLRenderer::cx_
private

x-coordinate of principal point of camera in pixels

Definition at line 292 of file gl_renderer.h.

float mesh_filter::GLRenderer::cy_
private

y-coordinate of principal point of camera in pixels

Definition at line 295 of file gl_renderer.h.

GLuint mesh_filter::GLRenderer::depth_id_
private

handle to depth buffer

Definition at line 274 of file gl_renderer.h.

float mesh_filter::GLRenderer::far_
private

distance of far clipping plane in meters

Definition at line 283 of file gl_renderer.h.

GLuint mesh_filter::GLRenderer::fbo_id_
private

handle to frame buffer object

Definition at line 265 of file gl_renderer.h.

float mesh_filter::GLRenderer::fx_
private

focal length in x-direction of camera in pixels

Definition at line 286 of file gl_renderer.h.

float mesh_filter::GLRenderer::fy_
private

focal length in y-direction of camera in pixels

Definition at line 289 of file gl_renderer.h.

bool mesh_filter::GLRenderer::glutInitialized_ = false
staticprivate

Definition at line 303 of file gl_renderer.h.

unsigned mesh_filter::GLRenderer::height_
private

height of frame buffer objects in pixels

Definition at line 262 of file gl_renderer.h.

float mesh_filter::GLRenderer::near_
private

distance of near clipping plane in meters

Definition at line 280 of file gl_renderer.h.

GLuint mesh_filter::GLRenderer::program_
private

handle to program that is currently used

Definition at line 277 of file gl_renderer.h.

GLuint mesh_filter::GLRenderer::rbo_id_
private

handle to render buffer object

Definition at line 268 of file gl_renderer.h.

GLuint mesh_filter::GLRenderer::rgb_id_
private

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 Tue Nov 6 2018 04:00:51