Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ACG::GLState Class Reference

#include <ACG/Scenegraph/GLState.hh>

Public Member Functions

 GLState (bool _updateGL=true)
 Default constructor.
 
 ~GLState ()
 destructor
 
void makeCurrent ()
 does nothing
 
void initialize ()
 initialize all state variables (called by constructor)
 
bool updateGL () const
 should GL matrices be updated after each matrix operation
 
void set_updateGL (bool _b)
 should GL matrices be updated after each matrix operation
 
unsigned int msSinceLastRedraw () const
 time passed since last redraw in milliseconds
 
void set_msSinceLastRedraw (unsigned int _ms)
 set time passed since last redraw in milliseconds
 
void setState ()
 set the whole stored gl state
 
void clearBuffers ()
 clear buffers viewport rectangle
 
const GLenum & depthFunc () const
 get glDepthFunc() that is supposed to be active
 
void set_depthFunc (const GLenum &_depth_func)
 Call glDepthFunc() to actually change the depth comparison function, and store the new value in this GLState.
 
Vec3d project (const Vec3d &_point) const
 project point in world coordinates to window coordinates
 
Vec3d unproject (const Vec3d &_winPoint) const
 unproject point in window coordinates _winPoint to world coordinates
 
void set_color (const Vec4f &_col)
 set color
 
const Vec4fcolor ()
 set color
 
void set_clear_color (const Vec4f &_col)
 set background color
 
const Vec4fclear_color () const
 get background color
 
void set_base_color (const Vec4f &_col)
 set base color (used when lighting is off)
 
const Vec4fbase_color () const
 get base color (used when lighting is off)
 
void set_ambient_color (const Vec4f &_col)
 set ambient color
 
const Vec4fambient_color () const
 get ambient color
 
void set_diffuse_color (const Vec4f &_col)
 set diffuse color
 
const Vec4fdiffuse_color () const
 get diffuse color
 
void set_specular_color (const Vec4f &_col)
 set specular color
 
const Vec4fspecular_color () const
 get specular color
 
void set_overlay_color (const Vec4f &_col)
 set overlay color More...
 
const Vec4foverlay_color () const
 Get overlay color. More...
 
void set_shininess (float _shininess)
 set specular shininess (must be in [0, 128])
 
float shininess () const
 get specular shininess (must be in [0, 128])
 
void set_point_size (float _f)
 set point size
 
float point_size () const
 get point size
 
void set_line_width (float _f)
 set line width
 
float line_width () const
 get line width
 
void set_blending (bool _b)
 set whether transparent or solid objects should be drawn
 
bool blending ()
 get whether transparenet or solid objects should be drawn
 
void set_twosided_lighting (bool _b)
 set whether transparent or solid objects should be drawn
 
bool twosided_lighting ()
 get whether transparenet or solid objects should be drawn
 
void set_multisampling (bool _b)
 Enable or disable multisampling.
 
bool multisampling ()
 Get current multisampling state.
 
void allow_multisampling (bool _b)
 Disable multisampling globally.
 
bool multisampling_allowed ()
 Check if Multisampling is globally disabled.
 
int max_texture_units () const
 Get max number of available texture units.
 
void allow_mipmapping (bool _b)
 Allow mipmapping globally. More...
 
bool mipmapping_allowed () const
 Get current global mipmapping state.
 
void pick_init (bool _color)
 initialize name/color picking stack (like glInitNames()) More...
 
bool pick_set_maximum (unsigned int _idx)
 Set the maximal number of primitives/components of your object. More...
 
void pick_set_name (unsigned int _idx)
 sets the current name/color (like glLoadName(_idx)) More...
 
Vec4uc pick_get_name_color (unsigned int _idx)
 
void pick_push_name (unsigned int _idx)
 creates a new name the stack (like glPushName())
 
void pick_pop_name ()
 pops the current name from the stack (like glPopName())
 
std::vector< unsigned int > pick_color_to_stack (Vec4uc _rgba) const
 
unsigned int pick_free_indicies () const
 returns the number of still available colors during color picking
 
bool pick_error () const
 
unsigned int pick_current_index () const
 Returns the current color picking index (can be used for caching) More...
 
bool color_picking () const
 Is color picking active?
 
set GL projection matrix
void reset_projection ()
 reset projection matrix (load identity)
 
void set_projection (const GLMatrixd &_m)
 set projection
 
void set_projection (const GLMatrixd &_m, const GLMatrixd &_inv_m)
 set projection and provide inverse projection matrix
 
void ortho (double _left, double _right, double _bottom, double _top, double _near_plane, double _far_plane)
 orthographic projection
 
void frustum (double _left, double _right, double _bottom, double _top, double _near_plane, double _far_plane)
 perspective projection
 
void perspective (double _fovY, double _aspect, double _near_plane, double _far_plane)
 perspective projection
 
void viewport (int _left, int _bottom, int _width, int _height, int _glwidth=0, int _glheight=0)
 set viewport (lower left corner, width, height, glcontext width, height)
 
set GL modelview matrix
void reset_modelview ()
 reset modelview matrix (load identity)
 
void set_modelview (const GLMatrixd &_m)
 set modelview
 
void set_modelview (const GLMatrixd &_m, const GLMatrixd &_inv_m)
 set modelview and provide inverse modelview matrix
 
void lookAt (const Vec3d &_eye, const Vec3d &_center, const Vec3d &_up)
 set camera by lookAt
 
void translate (double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
 translate by (_x, _y, _z)
 
void translate (Vec3d _vector, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
 translate by _vector
 
void rotate (double _angle, double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
 rotate around axis (_x, _y, _z) by _angle
 
void scale (double _s)
 scale by (_s, _s, _s)
 
void scale (double _s, MultiplyFrom)
 scale by (_s, _s, _s)
 
void scale (double _sx, double _sy, double _sz, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
 scale by (_sx, _sy, _sz)
 
void mult_matrix (const GLMatrixd &_m, const GLMatrixd &_inv_m, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
 multiply by a given transformation matrix
 
void push_projection_matrix ()
 push projection matrix
 
void pop_projection_matrix ()
 pop projection matrix
 
void push_modelview_matrix ()
 push modelview matrix
 
void pop_modelview_matrix ()
 pop modelview matrix
 
get GL states, matrices and projection details
const GLMatrixdprojection () const
 get projection matrix
 
const GLMatrixdmodelview () const
 get modelview matrix
 
const GLMatrixdviewport () const
 get viewport matrix
 
const GLMatrixdforward_projection () const
 get forward projection matrix
 
const GLMatrixdinverse_projection () const
 get inverse projection matrix
 
const GLMatrixdinverse_modelview () const
 get inverse modelview matrix
 
void get_viewport (int &_left, int &_bottom, int &_width, int &_height) const
 get viewport
 
int viewport_width () const
 get viewport width
 
int viewport_height () const
 get viewport height
 
int context_width () const
 get gl context width
 
int context_height () const
 get gl context height
 
double near_plane () const
 get near clipping distance
 
double far_plane () const
 get far clipping distance
 
double fovy () const
 get field of view in y direction
 
double aspect () const
 get aspect ratio
 
Vec3d eye () const
 get eye point
 
Vec3d viewing_direction () const
 get viewing ray
 
Vec3d viewing_direction (int _x, int _y) const
 get viewing ray through pixel (_x,_y)
 
Vec3d up () const
 get up-vector w.r.t. camera coordinates
 
Vec3d right () const
 get right-vector w.r.t. camera coordinates
 
void viewing_ray (int _x, int _y, Vec3d &_origin, Vec3d &_direction) const
 

Static Public Member Functions

static void syncFromGL ()
 synchronize this class with the OpenGL state machine
 
static void depthFunc (GLenum _depthFunc)
 replaces glDepthFunc, supports locking (called in set_depthFunc too)
 
static void lockDepthFunc ()
 
static void unlockDepthFunc ()
 
static bool isDepthFuncLocked ()
 
glEnable / glDisable functionality
static void enable (GLenum _cap)
 replaces glEnable, but supports locking
 
static void disable (GLenum _cap)
 replaces glDisable, but supports locking
 
static void lockState (GLenum _cap)
 locks a specific cap state, such that enable() or disable() has no effect
 
static void unlockState (GLenum _cap)
 unlocks a specific cap state
 
static bool isStateLocked (GLenum _cap)
 returns true, if a cap state is locked
 
static bool isStateEnabled (GLenum _cap)
 returns true, if a cpa state is enabled
 
static void enableClientState (GLenum _cap)
 replaces glEnableClientState, supports locking
 
static void disableClientState (GLenum _cap)
 replaces glDisableClientState, supports locking
 
static void lockClientState (GLenum _cap)
 locks a client state
 
static void unlockClientState (GLenum _cap)
 unlocks a client state
 
static bool isClientStateEnabled (GLenum _cap)
 returns true, if a client state is enabled
 
static bool isClientStateLocked (GLenum _cap)
 returns true, if a client state is locked
 
static void blendFunc (GLenum _sfactor, GLenum _dfactor)
 replaces glBlendFunc, supports locking
 
static void getBlendFunc (GLenum *_sfactor, GLenum *_dfactor)
 get blend function, null-ptr safe
 
static void lockBlendFunc ()
 lock blend func
 
static void unlockBlendFunc ()
 unlock blend func
 
static bool isBlendFuncLocked ()
 get blend func locking state
 
static void blendEquation (GLenum _mode)
 replaces glBlendEquation, supports locking
 
static GLenum getBlendEquation ()
 get blend equation
 
static void lockBlendEquation ()
 lock blend equation
 
static void unlockBlendEquation ()
 unlock blend equation
 
static bool isBlendEquationLocked ()
 get blend equation locking state
 
static void blendColor (GLclampf _red, GLclampf _green, GLclampf _blue, GLclampf _alpha)
 replaces glBlendColor, supports locking
 
static void getBlendColor (GLclampf *_col)
 get blend color, not null-ptr safe, 4 element color output: RGBA
 
static void lockBlendColor ()
 lock blend color
 
static void unlockBlendColor ()
 unlock blend color
 
static bool isBlendColorLocked ()
 get blend color locking state
 
static void alphaFunc (GLenum _func, GLclampf _ref)
 replaces glAlphaFunc, supports locking
 
static void getAlphaFunc (GLenum *_func, GLclampf *_ref)
 get alpha function, null-ptr safe
 
static void lockAlphaFunc ()
 lock alpha func
 
static void unlockAlphaFunc ()
 unlock alpha func
 
static bool isAlphaFuncLocked ()
 get alpha func locking state
 
static void shadeModel (GLenum _mode)
 replaces glShadeModel, supports locking
 
static GLenum getShadeModel ()
 get current shade model
 
static void lockShadeModel ()
 lock shade model
 
static void unlockShadeModel ()
 unlock shade model
 
static bool isShadeModelLocked ()
 get shade model locking state
 
static void cullFace (GLenum _mode)
 replaces glCullFace, supports locking
 
static GLenum getCullFace ()
 get current cull face
 
static void lockCullFace ()
 lock cull face
 
static void unlockCullFace ()
 unlock cull face
 
static bool isCullFaceLocked ()
 get cull face locking state
 
static void depthRange (GLclampd _zNear, GLclampd _zFar)
 replaces glDepthRange, supports locking
 
static void getDepthRange (GLclampd *_zNearOut, GLclampd *_zFarOut)
 get current depth range
 
static void lockDepthRange ()
 lock depth range
 
static void unlockDepthRange ()
 unlock depth range
 
static bool isDepthRangeLocked ()
 get depth range locking state
 
GL vertex pointers
static void vertexPointer (GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
 replaces glVertexPointer, supports locking
 
static void getVertexPointer (GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
 get vertex pointer, null-ptr safe
 
static void vertexPointer (const Vec2f *_p)
 Wrapper: glVertexPointer for Vec2f.
 
static void vertexPointer (const Vec2d *_p)
 Wrapper: glVertexPointer for Vec2d.
 
static void vertexPointer (const Vec3f *_p)
 Wrapper: glVertexPointer for Vec3f.
 
static void vertexPointer (const Vec3d *_p)
 Wrapper: glVertexPointer for Vec3d.
 
static void vertexPointer (const Vec4f *_p)
 Wrapper: glVertexPointer for Vec4f.
 
static void vertexPointer (const Vec4d *_p)
 Wrapper: glVertexPointer for Vec4d.
 
static void lockVertexPointer ()
 lock vertex pointer
 
static void unlockVertexPointer ()
 unlock vertex pointer
 
static bool isVertexPointerLocked ()
 get vertex pointer lock state
 
static void normalPointer (GLenum _type, GLsizei _stride, const GLvoid *_pointer)
 replaces glNormalPointer, supports locking
 
static void getNormalPointer (GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
 get normal pointer, null-ptr safe
 
static void normalPointer (const Vec3f *_p)
 Wrapper: glNormalPointer for Vec3f.
 
static void normalPointer (const Vec3d *_p)
 Wrapper: glNormalPointer for Vec3d.
 
static void lockNormalPointer ()
 lock normal pointer
 
static void unlockNormalPointer ()
 unlock normal pointer
 
static bool isNormalPointerLocked ()
 get normal pointer lock state
 
static void colorPointer (GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
 replaces glColorPointer, supports locking
 
static void getColorPointer (GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
 get color pointer, null-ptr safe
 
static void colorPointer (const Vec3uc *_p)
 Wrapper: glColorPointer for Vec3uc.
 
static void colorPointer (const Vec3f *_p)
 Wrapper: glColorPointer for Vec3f.
 
static void colorPointer (const Vec4uc *_p)
 Wrapper: glColorPointer for Vec4uc.
 
static void colorPointer (const Vec4f *_p)
 Wrapper: glColorPointer for Vec4f.
 
static void lockColorPointer ()
 lock color pointer
 
static void unlockColorPointer ()
 unlock vertex pointer
 
static bool isColorPointerLocked ()
 get vertex pointer lock state
 
static void texcoordPointer (GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
 replaces glTexcoordPointer, supports locking
 
static void getTexcoordPointer (GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
 get color pointer, null-ptr safe
 
static void texcoordPointer (const float *_p)
 Wrapper: glTexcoordPointer for float.
 
static void texcoordPointer (const double *_p)
 Wrapper: glTexcoordPointer for double.
 
static void texcoordPointer (const Vec2f *_p)
 Wrapper: glTexcoordPointer for Vec2f.
 
static void texcoordPointer (const Vec2d *_p)
 Wrapper: glTexcoordPointer for Vec2d.
 
static void texcoordPointer (const Vec3f *_p)
 Wrapper: glTexcoordPointer for Vec3f.
 
static void texcoordPointer (const Vec3d *_p)
 Wrapper: glTexcoordPointer for Vec3d.
 
static void texcoordPointer (const Vec4f *_p)
 Wrapper: glTexcoordPointer for Vec4f.
 
static void texcoordPointer (const Vec4d *_p)
 Wrapper: glTexcoordPointer for Vec4d.
 
static void lockTexcoordPointer ()
 lock color pointer
 
static void unlockTexcoordPointer ()
 unlock vertex pointer
 
static bool isTexcoordPointerLocked ()
 get vertex pointer lock state
 
GL buffer binding
static void genBuffersARB (GLsizei n, GLuint *buffers)
 
static void genBuffers (GLsizei n, GLuint *buffers)
 
static void bufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage)
 
static void bufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
 
static GLvoid * mapBuffer (GLenum target, GLenum access)
 
static GLboolean unmapBuffer (GLenum target)
 
static void deleteBuffers (GLsizei n, const GLuint *buffers)
 
static void bindBuffer (GLenum _target, GLuint _buffer)
 replaces glBindBuffer, supports locking
 
static void bindBufferARB (GLenum _target, GLuint _buffer)
 same function as bindBuffer
 
static void lockBufferTarget (GLenum _target)
 lock buffer target
 
static void unlockBufferTarget (GLenum _target)
 unlock buffer target
 
static bool isBufferTargetLocked (GLenum _target)
 get buffer target locking state
 
static GLuint getBoundBuf (GLenum _target)
 get currently bound buffer
 
static void drawBuffer (GLenum _mode)
 replaces glDrawBuffer, supports locking
 
static void drawBuffers (GLsizei _n, const GLenum *_bufs)
 replaces glDrawBuffers, supports locking
 
static void lockDrawBuffer ()
 lock draw buffer state, applies to drawBuffer and drawBuffers
 
static void unlockDrawBuffer ()
 unlock draw buffer state
 
static bool isDrawBufferLocked ()
 get draw buffer lock state
 
static void bindFramebuffer (GLenum _target, GLuint _framebuffer)
 replaces glBindFramebuffer, supports locking
 
static GLuint getFramebufferDraw ()
 get current draw framebuffer of a target More...
 
static GLuint getFramebufferRead ()
 get current read framebuffer of a target More...
 
static void lockFramebuffer (GLenum _target)
 lock a framebuffer target
 
static void unlockFramebuffer (GLenum _target)
 unlock a framebuffer target
 
static bool isFramebufferLocked (GLenum _target)
 get framebuffer target lock state
 
GL shader program binding
static void useProgram (GLuint _program)
 replaces glUseProgram, supports locking
 
static GLuint getProgram ()
 get bound program
 
static void lockProgram ()
 lock the program
 
static void unlockProgram ()
 unlock the program
 
static bool isProgramLocked ()
 get program locking state
 
GL texture binding
static void activeTexture (GLenum _texunit)
 replaces glActiveTexture, no locking support
 
static void activeTextureARB (GLenum _texunit)
 same functiona as activeTexture
 
static GLenum getActiveTexture ()
 get active GL texture
 
static int getActiveTextureIndex ()
 get active texture as zero based index
 
static void bindTexture (GLenum _target, GLuint _buffer)
 replaces glBindTexture, supports locking
 
static void lockTextureStage ()
 locks the current texture stage (set by setActiveTexture)
 
static void unlockTextureStage ()
 unlocks the current texture target
 
static bool isTextureTargetLocked ()
 get texture target locking state
 
static GLuint getBoundTextureBuffer ()
 get bound texture
 
static GLenum getBoundTextureTarget ()
 get bound texture target
 

Static Public Attributes

static const Vec4f default_clear_color
 default value for clear color
 
static const Vec4f default_base_color
 default value for base color
 
static const Vec4f default_ambient_color
 default value for ambient color
 
static const Vec4f default_diffuse_color
 default value for diffuse color
 
static const Vec4f default_specular_color
 default value for specular color
 
static const Vec4f default_overlay_color
 default value for overlay color
 
static const float default_shininess
 default value for shininess
 

Private Member Functions

void update_matrices ()
 

Static Private Member Functions

static int getBufferTargetIndex (GLenum _target)
 bijective map from GLenum buffer_target to [0..3], -1 if unsupported
 

Private Attributes

std::stack< GLMatrixdstack_projection_
 
std::stack< GLMatrixdstack_modelview_
 
std::stack< GLMatrixdstack_inverse_projection_
 
std::stack< GLMatrixdstack_inverse_modelview_
 
GLMatrixd projection_
 
GLMatrixd inverse_projection_
 
GLMatrixd modelview_
 
GLMatrixd inverse_modelview_
 
GLMatrixd window2viewport_
 
GLMatrixd inverse_window2viewport_
 
GLMatrixd forward_projection_
 
GLMatrixd backward_projection_
 
int left_
 
int bottom_
 
int width_
 
int height_
 
int glwidth_
 
int glheight_
 
double near_plane_
 
double far_plane_
 
Vec4f clear_color_
 
Vec4f color_
 
Vec4f base_color_
 
Vec4f ambient_color_
 
Vec4f diffuse_color_
 
Vec4f specular_color_
 
Vec4f overlay_color_
 
float shininess_
 
float point_size_
 
float line_width_
 
bool twosided_lighting_
 
bool multisampling_
 
bool allow_multisampling_
 
bool mipmapping_
 
bool updateGL_
 
bool blending_
 
unsigned int msSinceLastRedraw_
 
ColorStack colorStack_
 
bool colorPicking_
 

Static Private Attributes

static int num_texture_units_ = 0
 
static bool depthFuncLock_ = false
 
static std::deque< GLStateContextstateStack_
 
static GLenum glStateCaps [95]
 
static std::bitset< 0xFFFF+1 > glStateLock_
 
static bool blendFuncLock_ = false
 
static bool blendEquationLock_ = false
 
static bool blendColorLock_ = false
 
static bool alphaFuncLock_ = false
 
static bool depthRangeLock_ = false
 
static int glBufferTargetLock_ [4] = {0}
 
static int glTextureStageLock_ [16] = {0}
 
static bool shadeModelLock_ = false
 
static bool cullFaceLock_ = false
 
static bool vertexPointerLock_ = false
 
static bool normalPointerLock_ = false
 
static bool texcoordPointerLock_ = false
 
static bool colorPointerLock_ = false
 
static bool drawBufferLock_ = false
 
static bool framebufferLock_ [2] = {false}
 
static bool programLock_ = false
 
static int maxTextureCoords_ = 0
 
static int maxCombinedTextureImageUnits_ = 0
 
static int maxDrawBuffers_ = 0
 

Render pass controls

unsigned int render_pass_
 
unsigned int max_render_passes_
 
unsigned int render_pass () const
 get current render pass counter
 
void reset_render_pass ()
 reset render pass counter
 
void next_render_pass ()
 increment render pass counter
 
unsigned int max_render_passes () const
 get maximum number of render passes
 
void set_max_render_passes (const unsigned int _max)
 set maximum number of render passes
 

Scene Infos

ACG::Vec3d bb_min_
 
ACG::Vec3d bb_max_
 
void set_bounding_box (ACG::Vec3d _min, ACG::Vec3d _max)
 
void get_bounding_box (ACG::Vec3d &_min, ACG::Vec3d &_max)
 

Detailed Description

This class stores all relevant OpenGL states and can therefore provide some nice and efficient functions like projecting, unprojecting, eye point or viewing direction.

Note
This class needs an OpenGL context. This is currently given in a QGLContext.

The projection matrix

The GLState class stores its own projection matrix which is of type GLMatrixT. Creating a viewing frustum of a perspective projection will result in the following projection matrix:

pmatrix.png

Where n is the orthogonal distance from the viewing plane (near plane) to the eye position, f is the orthogonal distance from the back clipping plane (far plane) to the eye position, l, r, t, b are scalars indicating the left, right, top and bottom coordinates of the viewing plane (so in fact we have a rectangle between the points (b,l) and (t,r)) and phi is the opening angle (field of view), also see figure 1.

projection.png
Figure 1. A schematic illustration of a viewing frustum

Some useful values that can directly be computed out of the projection matrix:

pfovy.png
Computing the fovy out of the projection matrix
paspect.png
Computing the aspect out of the projection matrix

Definition at line 213 of file GLState.hh.

Member Function Documentation

void ACG::GLState::allow_mipmapping ( bool  _b)
inline

Allow mipmapping globally.

Note: This actually does not change the opengl state since mipmapping is turned on/off via texture parameters To change the behaviour see in TextureNode

Definition at line 1029 of file GLState.hh.

void ACG::GLState::bufferData ( GLenum  target,
GLsizeiptr  size,
const GLvoid *  data,
GLenum  usage 
)
static

Simple wrapper around glBufferData. Useful where glew cannot be included.

Definition at line 2070 of file GLState.cc.

void ACG::GLState::bufferDataARB ( GLenum  target,
GLsizeiptrARB  size,
const GLvoid *  data,
GLenum  usage 
)
static

Simple wrapper around glBufferDataARB. Useful where glew cannot be included.

Definition at line 2065 of file GLState.cc.

void ACG::GLState::deleteBuffers ( GLsizei  n,
const GLuint *  buffers 
)
static

Simple wrapper around glDeleteBuffers. Useful where glew cannot be included.

Definition at line 2075 of file GLState.cc.

void ACG::GLState::genBuffers ( GLsizei  n,
GLuint *  buffers 
)
static

Simple wrapper around glGenBuffers. Useful where glew cannot be included.

Definition at line 2061 of file GLState.cc.

void ACG::GLState::genBuffersARB ( GLsizei  n,
GLuint *  buffers 
)
static

Simple wrapper around glGenBuffersARB. Useful where glew cannot be included.

Definition at line 2057 of file GLState.cc.

void ACG::GLState::get_bounding_box ( ACG::Vec3d _min,
ACG::Vec3d _max 
)

Get the current bounding box of the scene. This has to be set before traversal happens in the viewer by using set_bounding_box

Definition at line 818 of file GLState.cc.

GLuint ACG::GLState::getFramebufferDraw ( )
static

get current draw framebuffer of a target

get current framebuffer of a target

Definition at line 1964 of file GLState.cc.

GLuint ACG::GLState::getFramebufferRead ( )
static

get current read framebuffer of a target

get current framebuffer of a target

Definition at line 1972 of file GLState.cc.

GLvoid * ACG::GLState::mapBuffer ( GLenum  target,
GLenum  access 
)
static

Simple wrapper around glMapBuffer. Useful where glew cannot be included.

Definition at line 2079 of file GLState.cc.

const Vec4f& ACG::GLState::overlay_color ( ) const
inline

Get overlay color.

This color does not set an opengl state but can be used to store an additional color for a wireframe.

Definition at line 916 of file GLState.hh.

std::vector< unsigned int > ACG::GLState::pick_color_to_stack ( Vec4uc  _rgba) const

converts the given color to index values on the stack (only used in color picking) This can be compared to the results of the selection buffer results

Definition at line 1102 of file GLState.cc.

unsigned int ACG::GLState::pick_current_index ( ) const

Returns the current color picking index (can be used for caching)

Is this value equal to a value used in a previous picking run, then the same colors will be used. In this case a previously calculated color array/display list can be reused.

This is basically the name of the whole object ( which would be the same as the name of the first component of the object), not the name of the primitives/components in the object!

Definition at line 1129 of file GLState.cc.

bool ACG::GLState::pick_error ( ) const

Did an error occur during picking (only used in color picking) Mostly to small color depth or wrong handling of pick_set_maximum

Definition at line 1120 of file GLState.cc.

Vec4uc ACG::GLState::pick_get_name_color ( unsigned int  _idx)

returns the color that will be used for index _idx during color picking if this index will be set with pick_set_name. This can be used to generate color arrays instead of using direct gl calls for each primitive

Definition at line 1079 of file GLState.cc.

void ACG::GLState::pick_init ( bool  _color)

initialize name/color picking stack (like glInitNames())

Follows the OpenGL selection buffer implementation (OpenGL Red Book Chapter 13) http://www.glprogramming.com/red/chapter13.html

Color picking is another method to realize picking. This functions replace the original OpenGL functions, to allow the handling of selection buffer picking and color based picking with the same code.

Definition at line 1054 of file GLState.cc.

bool ACG::GLState::pick_set_maximum ( unsigned int  _idx)

Set the maximal number of primitives/components of your object.

Sets the maximum used name index at current stack position (only used in color picking) A restriction inside the color picking implementation forces to set the maximum used number for the following pick_set_name calls between the two pick_push_name/pick_pop_name calls.

If you create picking for your nodes, the values set with pick_set_name have to be between zero and this value.

Definition at line 1062 of file GLState.cc.

void ACG::GLState::pick_set_name ( unsigned int  _idx)

sets the current name/color (like glLoadName(_idx))

This will be the index of the primitive/component in the object. If you create picking for your nodes, the values set here will be returned as the target index. So if your object has three parts, you call pick_set_name(0), than render the first component and then pick_set_name(1), ...

If you perform the picking and click on the second component, the returned index will be 1 as set in the node.

Definition at line 1072 of file GLState.cc.

void ACG::GLState::set_bounding_box ( ACG::Vec3d  _min,
ACG::Vec3d  _max 
)

Provide scene Information about the boundingbox via this function It is not computed by the state itself!!

Definition at line 811 of file GLState.cc.

void ACG::GLState::set_overlay_color ( const Vec4f _col)

set overlay color

This color does not set an opengl state but can be used to store an additional color for a wireframe

Definition at line 759 of file GLState.cc.

GLboolean ACG::GLState::unmapBuffer ( GLenum  target)
static

Simple wrapper around glUnmapBuffer. Useful where glew cannot be included.

Definition at line 2084 of file GLState.cc.

void ACG::GLState::viewing_ray ( int  _x,
int  _y,
Vec3d _origin,
Vec3d _direction 
) const

get viewing ray (_orgin & _direction) through pixel (_x,_y). _direction will be nornalized.

Definition at line 935 of file GLState.cc.

Member Data Documentation

ACG::Vec3d ACG::GLState::bb_max_
private

Provide scene Information about the boundingbox via this function It is not computed by the state itself!!

Definition at line 986 of file GLState.hh.

ACG::Vec3d ACG::GLState::bb_min_
private

Provide scene Information about the boundingbox via this function It is not computed by the state itself!!

Definition at line 986 of file GLState.hh.

unsigned int ACG::GLState::max_render_passes_
private

holds the maximum render pass number this has to be set externally

Definition at line 966 of file GLState.hh.

unsigned int ACG::GLState::render_pass_
private

holds the current render pass number (1-indexed) this has to be set externally

Definition at line 962 of file GLState.hh.


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