#include <ACG/Scenegraph/GLState.hh>

Public Member Functions | |
| GLState (bool _updateGL=true) | |
| Default constructor. | |
| ~GLState () | |
| destructor | |
| void | makeCurrent () |
| 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 | |
| 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) | |
| 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 | 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 | |
| const GLMatrixd & | projection () const |
| get projection matrix | |
| const GLMatrixd & | modelview () const |
| get modelview matrix | |
| const GLMatrixd & | viewport () const |
| get viewport matrix | |
| const GLMatrixd & | forward_projection () const |
| get forward projection matrix | |
| const GLMatrixd & | inverse_projection () const |
| get inverse projection matrix | |
| const GLMatrixd & | inverse_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 |
| 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_clear_color (const Vec4f &_col) |
| set background color | |
| const Vec4f & | clear_color () const |
| get background color | |
| void | set_base_color (const Vec4f &_col) |
| set base color (used when lighting is off) | |
| const Vec4f & | base_color () const |
| get base color (used when lighting is off) | |
| void | set_ambient_color (const Vec4f &_col) |
| set ambient color | |
| const Vec4f & | ambient_color () const |
| get ambient color | |
| void | set_diffuse_color (const Vec4f &_col) |
| set diffuse color | |
| const Vec4f & | diffuse_color () const |
| get diffuse color | |
| void | set_specular_color (const Vec4f &_col) |
| set specular color | |
| const Vec4f & | specular_color () const |
| get specular color | |
| 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_alloowed () |
| Check if Multisampling is globally disabled. | |
| void | pick_init (bool _color) |
| initialize name/color picking stack (like glInitNames()) | |
| bool | pick_set_maximum (unsigned int _idx) |
| void | pick_set_name (unsigned int _idx) |
| sets the current name/color (like glLoadName(_idx)) | |
| 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 |
| bool | color_picking () const |
| Is color picking active? | |
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 speculat color | |
| static const float | default_shininess |
| default value for shininess | |
Private Member Functions | |
| void | update_matrices () |
Private Attributes | |
| std::stack< GLMatrixd > | stack_projection_ |
| std::stack< GLMatrixd > | stack_modelview_ |
| std::stack< GLMatrixd > | stack_inverse_projection_ |
| std::stack< GLMatrixd > | stack_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 | base_color_ |
| Vec4f | ambient_color_ |
| Vec4f | diffuse_color_ |
| Vec4f | specular_color_ |
| float | shininess_ |
| float | point_size_ |
| float | line_width_ |
| bool | twosided_lighting_ |
| bool | multisampling_ |
| bool | allow_multisampling_ |
| bool | updateGL_ |
| bool | blending_ |
| unsigned int | msSinceLastRedraw_ |
| ColorStack | colorStack_ |
| bool | colorPicking_ |
This class stores all relevant OpenGL states and can therefore provide some nice and efficient functions like projecting, unprojecting, eye point or viewing direction.
Definition at line 90 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 950 of file GLState.cc.
References ACG::ColorStack::colorToStack(), and ACG::ColorStack::initialized().
Referenced by glViewer::pick_region(), glViewer::pickColor(), and glViewer::pickFromCache().
| 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, then the same colors will be used. In this case a previously calculated color array/display list can be reused.
Definition at line 977 of file GLState.cc.
References ACG::ColorStack::currentIndex().
| 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 968 of file GLState.cc.
References ACG::ColorStack::error().
Referenced by glViewer::pick_region(), and glViewer::pickColor().
| 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 924 of file GLState.cc.
References ACG::ColorStack::getIndexColor().
| 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 896 of file GLState.cc.
References ACG::ColorStack::initialize().
Referenced by ACG::QtWidgets::QtBaseViewer::pick(), glViewer::pick_region(), glViewer::pickColor(), and glViewer::pickGL().
| bool ACG::GLState::pick_set_maximum | ( | unsigned int | _idx | ) |
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.
Definition at line 906 of file GLState.cc.
References ACG::ColorStack::setMaximumIndex().
Referenced by ACG::SceneGraph::TriangleNode::pick(), ACG::SceneGraph::TranslationManipulatorNode::pick(), ACG::SceneGraph::SliceNode::pick(), ACG::SceneGraph::QuadNode::pick(), ACG::SceneGraph::PolyLineNodeT< PolyLine >::pick(), ACG::SceneGraph::OBJNode::pick(), ACG::SceneGraph::ManipulatorNode::pick(), ACG::SceneGraph::GlutPrimitiveNode::pick(), and ACG::SceneGraph::CoordsysNode::pick().
| 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 806 of file GLState.cc.
References unproject().
Referenced by ACG::SceneGraph::TranslationManipulatorNode::hitOuterSphere(), ACG::SceneGraph::TranslationManipulatorNode::hitSphere(), ACG::SceneGraph::TranslationManipulatorNode::mapToCylinder(), ACG::SceneGraph::TranslationManipulatorNode::mapToCylinderTop(), ACG::SceneGraph::TranslationManipulatorNode::mapToSphere(), and ACG::SceneGraph::TrackballNode::mapToSphere().