37 #ifndef MOVEIT_MESH_FILTER_GLRENDERER_ 38 #define MOVEIT_MESH_FILTER_GLRENDERER_ 43 #include <OpenGL/gl.h> 48 #include <boost/thread.hpp> 69 GLRenderer(
unsigned width,
unsigned height,
float near = 0.1,
float far = 10.0);
115 GLuint
setShadersFromFile(
const std::string& vertex_filename,
const std::string& fragment_filename);
124 GLuint
setShadersFromString(
const std::string& vertex_shader,
const std::string& fragment_shader);
223 GLuint
loadShaders(
const std::string& vertex_source,
const std::string& fragment_source)
const;
232 GLuint
createShader(GLuint shaderID,
const std::string& source)
const;
298 static std::map<boost::thread::id, std::pair<unsigned, GLuint> >
context_;
void getDepthBuffer(float *buffer) const
retrieves the depth buffer from OpenGL
const GLuint & getProgramID() const
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.
GLuint rgb_id_
handle to color buffer
float far_
distance of far clipping plane in meters
float fy_
focal length in y-direction of camera in pixels
static bool glutInitialized_
GLuint rbo_id_
handle to render buffer object
void callList(GLuint list) const
executes a OpenGL list
unsigned height_
height of frame buffer objects in pixels
const float & getFarClippingDistance() const
returns the distance of the far clipping plane in meters
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.
void deleteFrameBuffers()
deletes the frame buffer objects
const unsigned getWidth() const
returns the width of the frame buffer objectsin pixels
const float & getNearClippingDistance() const
returns the distance of the near clipping plane in meters
GLuint fbo_id_
handle to frame buffer object
void initFrameBuffers()
initializes the frame buffer objects
Abstracts the OpenGL frame buffer objects, and provides an interface to render meshes, and retrieve the color and depth ap from opengl.
float cx_
x-coordinate of principal point of camera in pixels
GLuint depth_id_
handle to depth buffer
static void deleteGLContext()
deletes OpenGL context for the current thread
float near_
distance of near clipping plane in meters
GLuint getColorTexture() const
returns the handle of the color buffer as an OpenGL texture object
void end() const
finalizes the frame buffers after rendering and/or manipulating
~GLRenderer()
destructor, destroys frame buffer objects and OpenGL context
GLuint createShader(GLuint shaderID, const std::string &source) const
create a OpenGL shader object from the shader source code
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.
static void createGLContext()
create the OpenGL context if required. Only on context is created for each thread ...
MOVEIT_CLASS_FORWARD(Job)
void setCameraParameters() const
sets the OpenGL camera parameters
void readShaderCodeFromFile(const std::string &filename, std::string &source) const
reads shader source code from file to a string
void begin() const
initializes the frame buffers for rendering and or manipulating
GLRenderer(unsigned width, unsigned height, float near=0.1, float far=10.0)
constructs the frame buffer object in a new OpenGL context.
static boost::mutex context_lock_
static std::map< boost::thread::id, std::pair< unsigned, GLuint > > context_
map from thread id to OpenGL context
const unsigned getHeight() const
returns the height of the frame buffer objects in pixels
float cy_
y-coordinate of principal point of camera in pixels
GLuint getDepthTexture() const
returns the handle of the depth buffer as an OpenGL texture object
GLuint program_
handle to program that is currently used
void setBufferSize(unsigned width, unsigned height)
set the size of fram buffers
float fx_
focal length in x-direction of camera in pixels
void setClippingRange(float near, float far)
sets the near and far clipping plane distances in meters
unsigned width_
width of frame buffer objects in pixels
void getColorBuffer(unsigned char *buffer) const
retrieves the color buffer from OpenGL