51 #include <ACG/GL/acg_glew.hh> 53 #include <ACG/GL/removedEnums.hh> 55 #include <OpenMesh/Core/Utils/vector_cast.hh> 80 bool GLState::depthFuncLock_ =
false;
81 bool GLState::depthRangeLock_ =
false;
82 bool GLState::blendFuncSeparateLock_[] = {
false };
83 bool GLState::blendEquationLock_ =
false;
84 bool GLState::blendColorLock_ =
false;
85 bool GLState::alphaFuncLock_ =
false;
86 bool GLState::shadeModelLock_ =
false;
87 bool GLState::cullFaceLock_ =
false;
88 bool GLState::vertexPointerLock_ =
false;
89 bool GLState::normalPointerLock_ =
false;
90 bool GLState::texcoordPointerLock_ =
false;
91 bool GLState::colorPointerLock_ =
false;
92 bool GLState::drawBufferLock_ =
false;
93 bool GLState::programLock_ =
false;
95 std::deque <GLStateContext> GLState::stateStack_;
96 std::bitset<0xFFFF+1> GLState::glStateLock_;
97 int GLState::glBufferTargetLock_[] = {0};
98 int GLState::glTextureStageLock_[] = {0};
99 bool GLState::framebufferLock_[] = {
false};
100 int GLState::maxTextureCoords_ = 0;
101 int GLState::maxCombinedTextureImageUnits_ = 0;
102 int GLState::maxDrawBuffers_ = 0;
104 int GLState::num_texture_units_ = 0;
106 GLStateContext::GLStateContext() :
107 activeTexture_(GL_TEXTURE0),
108 drawBufferSingle_(GL_BACK),
109 activeDrawBuffer_(0),
112 framebuffers_[0] = framebuffers_[1] = 0;
113 memset(drawBufferState_, GL_BACK,
sizeof(drawBufferState_));
114 blendFuncState_[0] = GL_SRC_ALPHA;
115 blendFuncState_[1] = GL_ONE_MINUS_SRC_ALPHA;
116 blendFuncState_[2] = GL_SRC_ALPHA;
117 blendFuncState_[3] = GL_ONE_MINUS_SRC_ALPHA;
118 texGenMode_ = GL_EYE_LINEAR;
122 : compatibilityProfile_(_compatibilityProfile),
124 max_render_passes_(1),
135 multisampling_(false),
136 allow_multisampling_(true),
138 updateGL_(_updateGL),
140 msSinceLastRedraw_ (1),
144 if ( stateStack_.empty() )
148 memset(glBufferTargetLock_, 0,
sizeof(glBufferTargetLock_));
150 framebufferLock_[0] = framebufferLock_[1] =
false;
152 glStateLock_.reset();
165 while (!stack_projection_.empty())
166 stack_projection_.pop();
167 while (!stack_modelview_.empty())
168 stack_modelview_.pop();
169 while (!stack_inverse_projection_.empty())
170 stack_inverse_projection_.pop();
171 while (!stack_inverse_modelview_.empty())
172 stack_inverse_modelview_.pop();
199 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &value);
201 num_texture_units_ = value;
213 if (compatibilityProfile_ ) {
216 glMatrixMode(GL_PROJECTION);
218 glMatrixMode(GL_MODELVIEW);
226 glClearColor(clear_color_[0], clear_color_[1], clear_color_[2], clear_color_[3]);
228 if (compatibilityProfile_ ) {
230 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, base_color_.
data());
233 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT , ambient_color_.
data());
236 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE , diffuse_color_.
data());
239 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular_color_.
data());
242 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess_);
246 glPointSize(point_size_);
249 glLineWidth(line_width_);
251 if ( compatibilityProfile_ ) {
253 if (twosided_lighting_ )
254 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
256 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
260 glViewport(left_, bottom_, width_, height_);
269 if ( compatibilityProfile_ ) {
270 glPushAttrib (GL_ALL_ATTRIB_BITS);
276 if ( compatibilityProfile_ ) {
277 glShadeModel(GL_FLAT);
280 glMatrixMode(GL_PROJECTION);
284 glMatrixMode(GL_MODELVIEW);
291 GLboolean scissor = glIsEnabled(GL_SCISSOR_TEST);
294 glGetIntegerv(GL_SCISSOR_BOX,&origBox[0]);
301 glScissor( left_,bottom_,width_,height_ );
304 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
307 glScissor( origBox[0], origBox[1], origBox[2], origBox[3] );
312 if ( compatibilityProfile_ ) {
314 glMatrixMode(GL_PROJECTION);
316 glMatrixMode(GL_MODELVIEW);
323 void GLState::setCompatibilityProfile(
bool _compatibility ) {
324 compatibilityProfile_ = _compatibility;
328 bool GLState::compatibilityProfile()
const {
329 return compatibilityProfile_;
339 if (updateGL_ && compatibilityProfile_ )
342 glMatrixMode(GL_PROJECTION);
344 glMatrixMode(GL_MODELVIEW);
355 inverse_projection_ = _inv_m;
357 if (updateGL_ && compatibilityProfile_)
360 glMatrixMode(GL_PROJECTION);
362 glMatrixMode(GL_MODELVIEW);
375 if (updateGL_ && compatibilityProfile_ )
389 inverse_modelview_ = _inv_m;
391 if (updateGL_ && compatibilityProfile_)
403 double _bottom,
double _top,
404 double _n,
double _f )
409 projection_.
ortho(_left, _right, _bottom, _top, _n, _f);
410 inverse_projection_.
inverse_ortho(_left,_right,_bottom,_top,_n,_f);
412 if (updateGL_ && compatibilityProfile_ )
415 glMatrixMode(GL_PROJECTION);
416 glOrtho(_left, _right, _bottom, _top, _n, _f);
417 glMatrixMode(GL_MODELVIEW);
426 double _bottom,
double _top,
427 double _n,
double _f )
432 projection_.
frustum(_left, _right, _bottom, _top, _n, _f);
435 if (updateGL_ && compatibilityProfile_)
438 glMatrixMode(GL_PROJECTION);
439 glFrustum(_left, _right, _bottom, _top, _n, _f);
440 glMatrixMode(GL_MODELVIEW);
449 double _n,
double _f )
457 if (updateGL_ && compatibilityProfile_)
460 glMatrixMode(GL_PROJECTION);
461 glLoadMatrixd(projection_.data());
462 glMatrixMode(GL_MODELVIEW);
471 int _width,
int _height,
472 int _glwidth,
int _glheight)
479 if (_glwidth < _width || _glheight < _height)
485 glheight_ = _glheight;
489 window2viewport_(0,0) = 0.5f * width_;
490 window2viewport_(0,3) = 0.5f * width_ + left_;
491 window2viewport_(1,1) = 0.5f * height_;
492 window2viewport_(1,3) = 0.5f * height_ + bottom_;
493 window2viewport_(2,2) = 0.5f;
494 window2viewport_(2,3) = 0.5f;
496 inverse_window2viewport_.
identity();
497 inverse_window2viewport_(0,0) = 2.0f / width_;
498 inverse_window2viewport_(0,3) = -(2.0*left_ + width_) / width_;
499 inverse_window2viewport_(1,1) = 2.0f / height_;
500 inverse_window2viewport_(1,3) = -(2.0*bottom_ + height_) / height_;
501 inverse_window2viewport_(2,2) = 2.0f;
502 inverse_window2viewport_(2,3) = -1.0f;
507 glViewport(_left, _bottom, _width, _height);
516 const Vec3d& _center,
519 modelview_.
lookAt(_eye, _center, _up);
522 if (updateGL_ && compatibilityProfile_)
525 glLoadMatrixd(modelview_.data());
536 if (_mult_from == MULT_FROM_RIGHT)
539 inverse_modelview_.
translate(-_x, -_y, -_z, MULT_FROM_LEFT);
543 modelview_.
translate(_x, _y, _z, MULT_FROM_LEFT);
544 inverse_modelview_.
translate(-_x, -_y, -_z);
547 if (updateGL_ && compatibilityProfile_)
558 translate( _vector[0] , _vector[1] , _vector[2] ,_mult_from);
567 if (_mult_from == MULT_FROM_RIGHT)
569 modelview_.
rotate(_angle, _x, _y, _z);
570 inverse_modelview_.
rotate(-_angle, _x, _y, _z, MULT_FROM_LEFT);
574 modelview_.
rotate(_angle, _x, _y, _z, MULT_FROM_LEFT);
575 inverse_modelview_.
rotate(-_angle, _x, _y, _z);
578 if (updateGL_ && compatibilityProfile_)
592 if (_mult_from == MULT_FROM_RIGHT)
594 modelview_.
scale(_sx, _sy, _sz, MULT_FROM_RIGHT);
595 inverse_modelview_.
scale(1.0f/_sx, 1.0f/_sy, 1.0f/_sz, MULT_FROM_LEFT);
599 modelview_.
scale(_sx, _sy, _sz, MULT_FROM_LEFT);
600 inverse_modelview_.
scale(1.0f/_sx, 1.0f/_sy, 1.0f/_sz, MULT_FROM_RIGHT);
603 if (updateGL_ && compatibilityProfile_)
617 if (_mult_from == MULT_FROM_RIGHT)
620 inverse_modelview_.leftMult(_inv_m);
624 modelview_.leftMult(_m);
625 inverse_modelview_ *= _inv_m;
628 if (updateGL_ && compatibilityProfile_)
669 glClearColor(_col[0], _col[1], _col[2], _col[3]);
681 if (updateGL_ && compatibilityProfile_ )
684 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, _col.
data());
709 ambient_color_ = _col;
711 if (updateGL_ && compatibilityProfile_)
714 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, _col.
data());
724 diffuse_color_ = _col;
726 if (updateGL_ && compatibilityProfile_)
729 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, _col.
data());
739 specular_color_ = _col;
741 if (updateGL_ && compatibilityProfile_)
744 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, _col.
data());
754 overlay_color_ = _col;
763 shininess_ = _shininess;
765 if (updateGL_ && compatibilityProfile_)
768 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, std::min(128.f, _shininess));
783 glPointSize(point_size_);
794 if(compatibilityProfile())
799 glLineWidth(line_width_);
824 twosided_lighting_ = _b;
826 if (updateGL_ && compatibilityProfile_ )
829 if (twosided_lighting_)
830 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
832 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
847 if ( allow_multisampling_ ) {
856 multisampling_ =
false;
858 if ( glIsEnabled( GL_MULTISAMPLE ) )
870 assert(projection_(1,1) != 0.0);
872 return atan(1.0/projection_(1,1))*2.0;
879 assert(projection_(0,0) != 0.0);
881 return projection_(1,1) / projection_(0,0);
943 return stateStack_.back().depthFunc_;
959 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 960 if (stateStack_.back().depthFunc_ != _depthFunc)
963 glDepthFunc(_depthFunc);
964 stateStack_.back().depthFunc_ = _depthFunc;
973 stack_projection_.push(projection_);
974 stack_inverse_projection_.push(inverse_projection_);
976 if (updateGL_ && compatibilityProfile_)
979 glMatrixMode(GL_PROJECTION);
981 glMatrixMode(GL_MODELVIEW);
991 projection_ = stack_projection_.top();
992 inverse_projection_ = stack_inverse_projection_.top();
994 stack_projection_.pop();
995 stack_inverse_projection_.pop();
997 if (updateGL_ && compatibilityProfile_)
1000 glMatrixMode(GL_PROJECTION);
1002 glMatrixMode(GL_MODELVIEW);
1012 stack_modelview_.push(modelview_);
1013 stack_inverse_modelview_.push(inverse_modelview_);
1015 if (updateGL_ && compatibilityProfile_)
1028 modelview_ = stack_modelview_.top();
1029 inverse_modelview_ = stack_inverse_modelview_.top();
1031 stack_modelview_.pop();
1032 stack_inverse_modelview_.pop();
1034 if (updateGL_ && compatibilityProfile_)
1045 colorPicking_ = _color;
1072 return Vec4uc (0, 0, 0, 0);
1079 Vec4f rv(0.0f, 0.0f, 0.0f, 0.0f);
1108 return std::vector<size_t> ();
1125 return colorStack_.
error ();
1143 return colorPicking_;
1148 GLenum GLState::glStateCaps[] = {GL_ALPHA_TEST,
1185 GL_MAP1_TEXTURE_COORD_1,
1186 GL_MAP1_TEXTURE_COORD_2,
1187 GL_MAP1_TEXTURE_COORD_3,
1188 GL_MAP1_TEXTURE_COORD_4,
1194 GL_MAP2_TEXTURE_COORD_1,
1195 GL_MAP2_TEXTURE_COORD_2,
1196 GL_MAP2_TEXTURE_COORD_3,
1197 GL_MAP2_TEXTURE_COORD_4,
1206 GL_POLYGON_OFFSET_FILL,
1208 GL_POLYGON_OFFSET_LINE,
1210 GL_POLYGON_OFFSET_POINT,
1214 GL_POST_COLOR_MATRIX_COLOR_TABLE,
1215 GL_POST_CONVOLUTION_COLOR_TABLE,
1218 GL_SAMPLE_ALPHA_TO_COVERAGE,
1219 GL_SAMPLE_ALPHA_TO_ONE,
1221 GL_SAMPLE_COVERAGE_INVERT,
1228 GL_TEXTURE_CUBE_MAP,
1233 GL_VERTEX_PROGRAM_POINT_SIZE,
1234 GL_VERTEX_PROGRAM_TWO_SIDE,
1240 GL_SECONDARY_COLOR_ARRAY,
1241 GL_TEXTURE_COORD_ARRAY,
1247 GLenum caps[] = {GL_ALPHA_TEST,
1284 GL_MAP1_TEXTURE_COORD_1,
1285 GL_MAP1_TEXTURE_COORD_2,
1286 GL_MAP1_TEXTURE_COORD_3,
1287 GL_MAP1_TEXTURE_COORD_4,
1293 GL_MAP2_TEXTURE_COORD_1,
1294 GL_MAP2_TEXTURE_COORD_2,
1295 GL_MAP2_TEXTURE_COORD_3,
1296 GL_MAP2_TEXTURE_COORD_4,
1305 GL_POLYGON_OFFSET_FILL,
1306 GL_POLYGON_OFFSET_LINE,
1307 GL_POLYGON_OFFSET_POINT,
1310 GL_POST_COLOR_MATRIX_COLOR_TABLE,
1311 GL_POST_CONVOLUTION_COLOR_TABLE,
1314 GL_SAMPLE_ALPHA_TO_COVERAGE,
1315 GL_SAMPLE_ALPHA_TO_ONE,
1323 GL_TEXTURE_CUBE_MAP,
1328 GL_VERTEX_PROGRAM_POINT_SIZE,
1329 GL_VERTEX_PROGRAM_TWO_SIDE,
1335 GL_SECONDARY_COLOR_ARRAY,
1336 GL_TEXTURE_COORD_ARRAY,
1339 for (
unsigned int i = 0; i <
sizeof(caps) /
sizeof(GLenum); ++i)
1341 if (glIsEnabled(caps[i])) stateStack_.back().glStateEnabled_.set(caps[i]);
1342 else stateStack_.back().glStateEnabled_.reset(caps[i]);
1347 #ifdef GL_VERSION_1_4 1348 glGetIntegerv(GL_BLEND_SRC_RGB, &getparam);
1349 stateStack_.back().blendFuncState_[0] = getparam;
1351 glGetIntegerv(GL_BLEND_DST_ALPHA, &getparam);
1352 stateStack_.back().blendFuncState_[1] = getparam;
1354 glGetIntegerv(GL_BLEND_SRC_ALPHA, &getparam);
1355 stateStack_.back().blendFuncState_[2] = getparam;
1357 glGetIntegerv(GL_BLEND_DST_ALPHA, &getparam);
1358 stateStack_.back().blendFuncState_[3] = getparam;
1360 glGetIntegerv(GL_BLEND_SRC, &getparam);
1361 stateStack_.back().blendFuncState_[0] = getparam;
1363 glGetIntegerv(GL_BLEND_DST, &getparam);
1364 stateStack_.back().blendFuncState_[1] = getparam;
1368 glGetIntegerv(GL_BLEND_EQUATION_RGB, &getparam);
1369 stateStack_.back().blendEquationState_ = getparam;
1371 glGetFloatv(GL_BLEND_COLOR, stateStack_.back().blendColorState_);
1373 glGetIntegerv(GL_ALPHA_TEST_FUNC, &getparam);
1374 stateStack_.back().alphaFuncState_ = getparam;
1376 glGetFloatv(GL_ALPHA_TEST_REF, &stateStack_.back().alphaRefState_);
1378 glGetIntegerv(GL_DEPTH_FUNC, &getparam);
1379 stateStack_.back().depthFunc_ = getparam;
1381 glGetDoublev(GL_DEPTH_RANGE, stateStack_.back().depthRange_);
1385 GLenum bufGets[8] = {
1386 GL_ARRAY_BUFFER_BINDING, GL_ARRAY_BUFFER,
1387 GL_ELEMENT_ARRAY_BUFFER_BINDING, GL_ELEMENT_ARRAY_BUFFER,
1388 GL_PIXEL_PACK_BUFFER_BINDING, GL_PIXEL_PACK_BUFFER,
1389 GL_PIXEL_UNPACK_BUFFER_BINDING, GL_PIXEL_UNPACK_BUFFER};
1391 for (
int i = 0; i < 4; ++i)
1392 glGetIntegerv(bufGets[i*2], (GLint*)stateStack_.back().glBufferTargetState_ +
getBufferTargetIndex(bufGets[i*2+1]));
1396 glGetIntegerv(GL_ACTIVE_TEXTURE, &getparam);
1397 stateStack_.back().activeTexture_ = getparam;
1399 GLenum texBufGets[] = {
1400 GL_TEXTURE_BINDING_1D, GL_TEXTURE_1D,
1401 GL_TEXTURE_BINDING_2D, GL_TEXTURE_2D,
1402 GL_TEXTURE_BINDING_3D, GL_TEXTURE_3D,
1403 GL_TEXTURE_BINDING_CUBE_MAP, GL_TEXTURE_CUBE_MAP
1404 , GL_TEXTURE_BINDING_RECTANGLE_ARB, GL_TEXTURE_RECTANGLE_ARB
1407 glGetIntegerv(GL_MAX_TEXTURE_COORDS, &maxTextureCoords_);
1408 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxCombinedTextureImageUnits_);
1411 if (maxTextureCoords_ > 16) maxTextureCoords_ = 16;
1412 if (maxCombinedTextureImageUnits_ > 16) maxCombinedTextureImageUnits_ = 16;
1414 int numTexUnits = maxTextureCoords_;
1415 if (numTexUnits < maxCombinedTextureImageUnits_) numTexUnits = maxCombinedTextureImageUnits_;
1417 for (
int i = 0; i < numTexUnits; ++i)
1419 glActiveTexture(GL_TEXTURE0 + i);
1423 for (
int k = 0; k < 5 && !getparam; ++k)
1425 glGetIntegerv(texBufGets[k*2], &getparam);
1428 stateStack_.back().glTextureStage_[i].buf_ = getparam;
1429 stateStack_.back().glTextureStage_[i].target_ = texBufGets[k*2+1];
1435 if (numTexUnits > 0)
1436 glActiveTexture(stateStack_.back().activeTexture_);
1440 glGetIntegerv(GL_SHADE_MODEL, &getparam);
1441 stateStack_.back().shadeModel_ = getparam;
1444 glGetIntegerv(GL_CULL_FACE_MODE, &getparam);
1445 stateStack_.back().cullFace_ = getparam;
1450 GLenum ptrEnums[] = {
1451 GL_VERTEX_ARRAY_SIZE, GL_VERTEX_ARRAY_TYPE,
1452 GL_VERTEX_ARRAY_STRIDE, GL_VERTEX_ARRAY_POINTER,
1453 GL_COLOR_ARRAY_SIZE, GL_COLOR_ARRAY_TYPE,
1454 GL_COLOR_ARRAY_STRIDE, GL_COLOR_ARRAY_POINTER,
1455 GL_TEXTURE_COORD_ARRAY_SIZE, GL_TEXTURE_COORD_ARRAY_TYPE,
1456 GL_TEXTURE_COORD_ARRAY_STRIDE, GL_TEXTURE_COORD_ARRAY_POINTER};
1459 &stateStack_.back().colorPointer_, &stateStack_.back().texcoordPointer_};
1461 for (
int i = 0; i < 3 ; ++i)
1463 glGetIntegerv(ptrEnums[i*4], &getparam);
1464 ptrs[i]->size = getparam;
1465 glGetIntegerv(ptrEnums[i*4+1], &getparam);
1466 ptrs[i]->type = getparam;
1467 glGetIntegerv(ptrEnums[i*4+2], &getparam);
1468 ptrs[i]->stride = getparam;
1469 glGetPointerv(ptrEnums[i*4+3], (GLvoid**)&ptrs[i]->pointer);
1472 glGetIntegerv(GL_NORMAL_ARRAY_STRIDE, &getparam);
1473 stateStack_.back().normalPointer_.size = getparam;
1474 glGetIntegerv(GL_NORMAL_ARRAY_TYPE, &getparam);
1475 stateStack_.back().normalPointer_.type = getparam;
1476 glGetPointerv(GL_NORMAL_ARRAY_POINTER, (GLvoid**)&stateStack_.back().normalPointer_.pointer);
1481 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers_);
1482 if (maxDrawBuffers_ > 16) maxDrawBuffers_ = 16;
1484 for (
int i = 0; i < maxDrawBuffers_; ++i)
1486 glGetIntegerv(GL_DRAW_BUFFER0 + i, &getparam);
1487 stateStack_.back().drawBufferState_[i] = getparam;
1490 glGetIntegerv(GL_DRAW_BUFFER, &getparam);
1491 stateStack_.back().drawBufferSingle_ = getparam;
1494 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &getparam);
1495 stateStack_.back().framebuffers_[0] = getparam;
1496 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &getparam);
1497 stateStack_.back().framebuffers_[1] = getparam;
1500 glGetIntegerv(GL_CURRENT_PROGRAM, &getparam);
1501 stateStack_.back().program_ = getparam;
1509 if (!glStateLock_.test(_cap))
1511 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1512 if (!stateStack_.back().glStateEnabled_.test(_cap))
1520 std::cerr <<
"OpenGL Warning:You are trying to use a GLenum that has been removed for OpenGL core profiles." << std::endl;
1522 stateStack_.back().glStateEnabled_.set(_cap);
1529 if (!glStateLock_.test(_cap))
1531 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1532 if (stateStack_.back().glStateEnabled_.test(_cap))
1540 std::cerr <<
"OpenGL Warning:You are trying to use a GLenum that has been removed for OpenGL core profiles." << std::endl;
1542 stateStack_.back().glStateEnabled_.reset(_cap);
1549 glStateLock_.set(_cap);
1554 glStateLock_.reset(_cap);
1559 return glStateLock_.test(_cap);
1564 return stateStack_.back().glStateEnabled_.test(_cap);
1572 if (!glStateLock_.test(_cap))
1574 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1575 if (!stateStack_.back().glStateEnabled_.test(_cap))
1578 glEnableClientState(_cap);
1579 stateStack_.back().glStateEnabled_.set(_cap);
1586 if (!glStateLock_.test(_cap))
1588 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1589 if (stateStack_.back().glStateEnabled_.test(_cap))
1592 glDisableClientState(_cap);
1593 stateStack_.back().glStateEnabled_.reset(_cap);
1600 glStateLock_.set(_cap);
1605 glStateLock_.reset(_cap);
1610 return glStateLock_.test(_cap);
1615 return stateStack_.back().glStateEnabled_.test(_cap);
1624 if (blendFuncSeparateLock_[0])
1626 _srcRGB = stateStack_.back().blendFuncState_[0];
1627 _dstRGB = stateStack_.back().blendFuncState_[1];
1630 if (blendFuncSeparateLock_[1])
1632 _srcAlpha = stateStack_.back().blendFuncState_[2];
1633 _dstAlpha = stateStack_.back().blendFuncState_[3];
1636 if (!blendFuncSeparateLock_[0] || !blendFuncSeparateLock_[1])
1638 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1639 if (stateStack_.back().blendFuncState_[0] != _srcRGB || stateStack_.back().blendFuncState_[1] != _dstRGB ||
1640 stateStack_.back().blendFuncState_[2] != _srcAlpha || stateStack_.back().blendFuncState_[3] != _dstAlpha)
1643 #ifdef GL_VERSION_1_4 1645 if (glBlendFuncSeparate)
1646 glBlendFuncSeparate(_srcRGB, _dstRGB, _srcAlpha, _dstAlpha);
1648 glBlendFunc(_srcRGB, _dstRGB);
1649 stateStack_.back().blendFuncState_[0] = _srcRGB;
1650 stateStack_.back().blendFuncState_[1] = _dstRGB;
1651 stateStack_.back().blendFuncState_[2] = _srcAlpha;
1652 stateStack_.back().blendFuncState_[3] = _dstAlpha;
1654 glBlendFunc(_srcRGB, _dstRGB);
1655 stateStack_.back().blendFuncState_[0] = _srcRGB;
1656 stateStack_.back().blendFuncState_[1] = _dstRGB;
1657 stateStack_.back().blendFuncState_[2] = _srcRGB;
1658 stateStack_.back().blendFuncState_[3] = _dstRGB;
1666 if (_srcRGB) *_srcRGB = stateStack_.back().blendFuncState_[0];
1667 if (_dstRGB) *_dstRGB = stateStack_.back().blendFuncState_[1];
1668 if (_srcAlpha) *_srcAlpha = stateStack_.back().blendFuncState_[2];
1669 if (_dstAlpha) *_dstAlpha = stateStack_.back().blendFuncState_[3];
1674 if (!blendEquationLock_)
1676 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1677 if (stateStack_.back().blendEquationState_ != _mode)
1680 glBlendEquation(_mode);
1681 stateStack_.back().blendEquationState_ = _mode;
1688 if (!blendColorLock_)
1690 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1691 if (stateStack_.back().blendColorState_[0] != _red || stateStack_.back().blendColorState_[1] != _green ||
1692 stateStack_.back().blendColorState_[2] != _blue || stateStack_.back().blendColorState_[3] != _alpha)
1695 glBlendColor(_red, _green, _blue, _alpha);
1696 stateStack_.back().blendColorState_[0] = _red; stateStack_.back().blendColorState_[1] = _green;
1697 stateStack_.back().blendColorState_[2] = _blue; stateStack_.back().blendColorState_[3] = _alpha;
1704 for (
int i = 0; i < 4; ++i) _col[i] = stateStack_.back().blendColorState_[i];
1710 if (!alphaFuncLock_)
1712 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1713 if (stateStack_.back().alphaFuncState_ != _func || stateStack_.back().alphaRefState_ != _ref)
1716 glAlphaFunc(_func, _ref);
1717 stateStack_.back().alphaFuncState_ = _func;
1718 stateStack_.back().alphaRefState_ = _ref;
1725 if (_func) *_func = stateStack_.back().alphaFuncState_;
1726 if (_ref) *_ref = stateStack_.back().alphaRefState_;
1731 if (!shadeModelLock_)
1733 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1734 if (stateStack_.back().shadeModel_ != _mode)
1737 glShadeModel(_mode);
1738 stateStack_.back().shadeModel_ = _mode;
1747 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1748 if (stateStack_.back().cullFace_ != _mode)
1752 stateStack_.back().cullFace_ = _mode;
1759 if (!depthRangeLock_)
1761 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1762 if (abs(_zNear - stateStack_.back().depthRange_[0]) > 1e-6 ||
1763 abs(_zFar - stateStack_.back().depthRange_[1]) > 1e-6)
1766 glDepthRange(_zNear, _zFar);
1767 stateStack_.back().depthRange_[0] = _zNear;
1768 stateStack_.back().depthRange_[1] = _zFar;
1775 if (_zNearOut) *_zNearOut = stateStack_.back().depthRange_[0];
1776 if (_zFarOut) *_zFarOut = stateStack_.back().depthRange_[1];
1785 case GL_ARRAY_BUFFER:
return 0;
1786 case GL_ELEMENT_ARRAY_BUFFER:
return 1;
1787 case GL_PIXEL_PACK_BUFFER:
return 2;
1788 case GL_PIXEL_UNPACK_BUFFER:
return 3;
1789 #ifdef GL_ARB_uniform_buffer_object 1790 case GL_UNIFORM_BUFFER:
return 4;
1792 #ifdef GL_ARB_shader_storage_buffer_object 1793 case GL_SHADER_STORAGE_BUFFER:
return 5;
1795 #ifdef GL_ARB_shader_atomic_counters 1796 case GL_ATOMIC_COUNTER_BUFFER:
return 6;
1798 #ifdef GL_ARB_copy_buffer 1799 case GL_COPY_READ_BUFFER:
return 7;
1800 case GL_COPY_WRITE_BUFFER:
return 8;
1802 #ifdef GL_ARB_compute_shader 1803 case GL_DISPATCH_INDIRECT_BUFFER:
return 9;
1805 #ifdef GL_ARB_draw_indirect 1806 case GL_DRAW_INDIRECT_BUFFER:
return 10;
1808 #ifdef GL_ARB_query_buffer_object 1809 case GL_QUERY_BUFFER:
return 11;
1811 case GL_TEXTURE_BUFFER:
return 12;
1812 #ifdef GL_VERSION_3_0 1813 case GL_TRANSFORM_FEEDBACK_BUFFER:
return 13;
1816 std::cerr <<
"error : GLState::bindBuffer - unknown buffer target type" << _target << std::endl;
1823 if (idx >= 0 && !glBufferTargetLock_[idx])
1825 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1826 if (stateStack_.back().glBufferTargetState_[idx] != _buffer)
1829 glBindBuffer(_target, _buffer);
1830 stateStack_.back().glBufferTargetState_[idx] = _buffer;
1859 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1860 if (stateStack_.back().activeTexture_ != _texunit)
1863 glActiveTexture(_texunit);
1864 stateStack_.back().activeTexture_ = _texunit;
1872 assert(activeTex >= 0);
1876 if (!glTextureStageLock_[activeTex])
1878 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1879 if (_buffer != stage->buf_ || _target != stage->target_)
1882 glBindTexture(_target, _buffer);
1884 stage->target_ = _target;
1885 stage->buf_ = _buffer;
1920 if (!vertexPointerLock_)
1922 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1923 if (!stateStack_.back().vertexPointer_.equals(_size, _type, _stride, _pointer))
1926 glVertexPointer(_size, _type, _stride, _pointer);
1927 stateStack_.back().vertexPointer_.set(_size, _type, _stride, _pointer);
1934 if (_size) *_size = stateStack_.back().vertexPointer_.size;
1935 if (_stride) *_stride = stateStack_.back().vertexPointer_.stride;
1936 if (_type) *_type = stateStack_.back().vertexPointer_.type;
1937 if (_pointer) *_pointer = stateStack_.back().vertexPointer_.pointer;
1942 if (!normalPointerLock_)
1944 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1945 if (!stateStack_.back().normalPointer_.equals(stateStack_.back().normalPointer_.size, _type, _stride, _pointer))
1948 glNormalPointer(_type, _stride, _pointer);
1949 stateStack_.back().normalPointer_.set(3, _type, _stride, _pointer);
1956 if (_type) *_type = stateStack_.back().normalPointer_.type;
1957 if (_stride) *_stride = stateStack_.back().normalPointer_.stride;
1958 if (_pointer) *_pointer = stateStack_.back().normalPointer_.pointer;
1964 if (!colorPointerLock_)
1966 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1967 if (!stateStack_.back().colorPointer_.equals(_size, _type, _stride, _pointer))
1970 glColorPointer(_size, _type, _stride, _pointer);
1971 stateStack_.back().colorPointer_.set(_size, _type, _stride, _pointer);
1978 if (_size) *_size = stateStack_.back().colorPointer_.size;
1979 if (_stride) *_stride = stateStack_.back().colorPointer_.stride;
1980 if (_type) *_type = stateStack_.back().colorPointer_.type;
1981 if (_pointer) *_pointer = stateStack_.back().colorPointer_.pointer;
1986 if (!texcoordPointerLock_)
1988 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 1989 if (!stateStack_.back().texcoordPointer_.equals(_size, _type, _stride, _pointer))
1992 glTexCoordPointer(_size, _type, _stride, _pointer);
1993 stateStack_.back().texcoordPointer_.set(_size, _type, _stride, _pointer);
2000 if (_size) *_size = stateStack_.back().texcoordPointer_.size;
2001 if (_stride) *_stride = stateStack_.back().texcoordPointer_.stride;
2002 if (_type) *_type = stateStack_.back().texcoordPointer_.type;
2003 if (_pointer) *_pointer = stateStack_.back().texcoordPointer_.pointer;
2010 glTexGeni(_coord, _name, _param);
2014 stateStack_.back().texGenMode_ = _param;
2022 glGetTexGeniv(_coord, _name, _param);
2026 *_param = stateStack_.back().texGenMode_;
2035 if (!drawBufferLock_)
2037 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 2038 if (stateStack_.back().drawBufferSingle_ != _mode || stateStack_.back().activeDrawBuffer_)
2041 glDrawBuffer(_mode);
2042 stateStack_.back().drawBufferSingle_ = _mode;
2043 stateStack_.back().activeDrawBuffer_ = 0;
2050 if (!drawBufferLock_)
2052 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 2053 int bChange = !stateStack_.back().activeDrawBuffer_;
2054 for (
int i = 0; i < _n && (!bChange); ++i)
2056 if (stateStack_.back().drawBufferState_[i] != _bufs[i])
2063 glDrawBuffers(_n, _bufs);
2065 for (
int i = 0; i < _n; ++i)
2066 stateStack_.back().drawBufferState_[i] = _bufs[i];
2068 stateStack_.back().activeDrawBuffer_ = _n;
2077 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&curfbo);
2085 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (GLint*)&curfbo);
2094 case GL_FRAMEBUFFER:
2100 case GL_DRAW_FRAMEBUFFER: i = 0;
break;
2101 case GL_READ_FRAMEBUFFER: i = 1;
break;
2104 if (i >= 0 && !framebufferLock_[i])
2106 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 2107 if (stateStack_.back().framebuffers_[i] != _framebuffer)
2111 if (glBindFramebuffer ==
nullptr)
2114 glBindFramebuffer(_target, _framebuffer);
2115 stateStack_.back().framebuffers_[i] = _framebuffer;
2124 case GL_FRAMEBUFFER:
2125 framebufferLock_[0] = framebufferLock_[1] =
true;
break;
2127 case GL_DRAW_FRAMEBUFFER: framebufferLock_[0] =
true;
break;
2128 case GL_READ_FRAMEBUFFER: framebufferLock_[1] =
true;
break;
2136 case GL_FRAMEBUFFER:
2137 framebufferLock_[0] = framebufferLock_[1] =
false;
break;
2139 case GL_DRAW_FRAMEBUFFER: framebufferLock_[0] =
false;
break;
2140 case GL_READ_FRAMEBUFFER: framebufferLock_[1] =
false;
break;
2148 case GL_FRAMEBUFFER:
2149 return framebufferLock_[0] && framebufferLock_[1];
2151 case GL_DRAW_FRAMEBUFFER:
return framebufferLock_[0];
2152 case GL_READ_FRAMEBUFFER:
return framebufferLock_[1];
2161 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS 2162 if (stateStack_.back().program_ != _program)
2165 glUseProgram(_program);
2166 stateStack_.back().program_ = _program;
2172 glGenBuffers(n, buffers);
2176 glGenBuffers(n, buffers);
2180 GLenum target, GLsizeiptrARB size,
const GLvoid *data, GLenum usage) {
2181 glBufferData(target, size, data, usage);
2185 GLenum target, GLsizeiptr size,
const GLvoid* data, GLenum usage) {
2186 glBufferData(target, size, data, usage);
2190 glDeleteBuffers(n, buffers);
2194 return glMapBuffer(target, access);
2199 return glUnmapBuffer(target);
void set_bounding_box(ACG::Vec3d _min, ACG::Vec3d _max)
void vector_cast(const src_t &_src, dst_t &_dst, GenProg::Int2Type< n >)
Cast vector type to another vector type by copying the vector elements.
void frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
Namespace providing different geometric functions concerning angles.
std::vector< size_t > colorToStack(Vec4uc _rgba) const
converts the given color to index values on the stack
void inverse_perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse of perspective projection matrix
static int getBufferTargetIndex(GLenum _target)
bijective map from GLenum buffer_target to [0..3], -1 if unsupported
static void texcoordPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glTexcoordPointer, supports locking
void makeCurrent()
does nothing
static const Vec4f default_specular_color
default value for specular color
Vec3d right() const
get right-vector w.r.t. camera coordinates
void set_shininess(float _shininess)
set specular shininess (must be in [0, 128])
void set_specular_color(const Vec4f &_col)
set specular color
bool initialized() const
has it been initialized?
Vec4f pick_get_name_color_norm(unsigned int _idx)
same as pick_get_name_color, but the resulting color channels are normalized in [0.0, 1.0] range
const GLMatrixd & viewport() const
get viewport matrix
bool color_picking() const
Is color picking active?
std::vector< size_t > pick_color_to_stack(Vec4uc _rgba) const
static void alphaFunc(GLenum _func, GLclampf _ref)
replaces glAlphaFunc, supports locking
Vec4uc pick_get_name_color(size_t _idx)
static void blendColor(GLclampf _red, GLclampf _green, GLclampf _blue, GLclampf _alpha)
replaces glBlendColor, supports locking
void set_ambient_color(const Vec4f &_col)
set ambient color
static bool isClientStateLocked(GLenum _cap)
returns true, if a client state is locked
static void deleteBuffers(GLsizei n, const GLuint *buffers)
VectorT< unsigned char, 4 > Vec4uc
static void blendEquation(GLenum _mode)
replaces glBlendEquation, supports locking
void set_diffuse_color(const Vec4f &_col)
set diffuse color
static GLuint getFramebufferRead()
get current read framebuffer of a target
void push_modelview_matrix()
push modelview matrix
static void colorPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glColorPointer, supports locking
static bool isStateLocked(GLenum _cap)
returns true, if a cap state is locked
void pick_pop_name()
pops the current name from the stack (like glPopName())
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
void set_twosided_lighting(bool _b)
set whether transparent or solid objects should be drawn
static bool isTextureTargetLocked()
get texture target locking state
void lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
void reset_modelview()
reset modelview matrix (load identity)
size_t currentIndex() const
returns the current color index
static void lockClientState(GLenum _cap)
locks a client state
VectorT< float, 4 > Vec4f
size_t freeIndicies() const
returns maximal available index count
void inverse_lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
multiply self from left with inverse lookAt matrix
void set_color(const Vec4f &_col)
set color
void translate(double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
translate by (_x, _y, _z)
size_t pick_free_indicies() const
returns the number of still available colors during color picking
static GLuint getFramebufferDraw()
get current draw framebuffer of a target
static void unlockClientState(GLenum _cap)
unlocks a client state
size_t pick_current_index() const
Returns the current color picking index (can be used for caching)
static void getBlendFuncSeparate(GLenum *_srcRGB, GLenum *_dstRGB, GLenum *_srcAlpha, GLenum *_dstAlpha)
get blend function, null-ptr safe
void set_overlay_color(const Vec4f &_col)
set overlay color
auto normalize() -> decltype(*this/=std::declval< VectorT< S, DIM >>().norm())
void set_depthFunc(const GLenum &_depth_func)
Call glDepthFunc() to actually change the depth comparison function, and store the new value in this ...
VectorT< T, 3 > transform_point(const VectorT< T, 3 > &_v) const
transform point (x',y',z',1) = M * (x,y,z,1)
void clearBuffers()
clear buffers viewport rectangle
static void blendFuncSeparate(GLenum _srcRGB, GLenum _dstRGB, GLenum _srcAlpha, GLenum _dstAlpha)
replaces glBlendFuncSeparate, supports locking
Scalar * data()
access to Scalar array
void popIndex()
pops the current node from the stack (like glPopName)
static void lockState(GLenum _cap)
locks a specific cap state, such that enable() or disable() has no effect
void push_projection_matrix()
push projection matrix
void pushIndex(size_t _idx)
creates a new node the stack (like glPushName)
static void drawBuffers(GLsizei _n, const GLenum *_bufs)
replaces glDrawBuffers, supports locking
static void getDepthRange(GLclampd *_zNearOut, GLclampd *_zFarOut)
get current depth range
static void bindFramebuffer(GLenum _target, GLuint _framebuffer)
replaces glBindFramebuffer, supports locking
void compatibilityProfile(bool _enableCoreProfile)
Store opengl core profile setting.
static void lockTextureStage()
locks the current texture stage (set by setActiveTexture)
static void bufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
void pick_push_name(size_t _idx)
creates a new name the stack (like glPushName())
void perspective(double _fovY, double _aspect, double _near_plane, double _far_plane)
perspective projection
static void bufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage)
static GLvoid * mapBuffer(GLenum target, GLenum access)
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
static void unlockTextureStage()
unlocks the current texture target
static void getNormalPointer(GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get normal pointer, null-ptr safe
void ortho(double _left, double _right, double _bottom, double _top, double _near_plane, double _far_plane)
orthographic projection
static GLuint getBoundBuf(GLenum _target)
get currently bound buffer
static GLenum getBoundTextureTarget()
get bound texture target
Vec3d up() const
get up-vector w.r.t. camera coordinates
static const Vec4f default_clear_color
default value for clear color
void setIndex(size_t _idx)
sets the current color the given index (like glLoadName)
void pick_init(bool _color)
initialize name/color picking stack (like glInitNames())
static void drawBuffer(GLenum _mode)
replaces glDrawBuffer, supports locking
void set_multisampling(bool _b)
Enable or disable multisampling.
static void disableClientState(GLenum _cap)
replaces glDisableClientState, supports locking
static void getVertexPointer(GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get vertex pointer, null-ptr safe
static const Vec4f default_base_color
default value for base color
static void genBuffers(GLsizei n, GLuint *buffers)
static void unlockFramebuffer(GLenum _target)
unlock a framebuffer target
void inverse_ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse orthographic projection matrix
Vec3d unproject(const Vec3d &_winPoint) const
unproject point in window coordinates _winPoint to world coordinates
GLState(bool _updateGL=true, bool _compatibilityProfile=true)
Default constructor.
Vec3d project(const Vec3d &_point) const
project point in world coordinates to window coordinates
void mult_matrix(const GLMatrixd &_m, const GLMatrixd &_inv_m, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply by a given transformation matrix
void set_point_size(float _f)
set point size
static void useProgram(GLuint _program)
replaces glUseProgram, supports locking
static bool isFramebufferLocked(GLenum _target)
get framebuffer target lock state
void frustum(double _left, double _right, double _bottom, double _top, double _near_plane, double _far_plane)
perspective projection
VectorT< double, 3 > Vec3d
void scale(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
static const Vec4f default_diffuse_color
default value for diffuse color
static void syncFromGL()
synchronize this class with the OpenGL state machine
void set_line_width(float _f)
set line width
void set_clear_color(const Vec4f &_col)
set background color
double fovy() const
get field of view in y direction
static int getActiveTextureIndex()
get active texture as zero based index
static void getTexcoordPointer(GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get color pointer, null-ptr safe
double aspect() const
get aspect ratio
const Scalar * get_raw_data() const
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
static void normalPointer(GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glNormalPointer, supports locking
static const Vec4f default_overlay_color
default value for overlay color
void viewing_ray(int _x, int _y, Vec3d &_origin, Vec3d &_direction) const
void inverse_frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse of perspective projection matrix
Vec3d viewing_direction() const
get viewing ray
static void getAlphaFunc(GLenum *_func, GLclampf *_ref)
get alpha function, null-ptr safe
Vec3d eye() const
get eye point
static void unlockBufferTarget(GLenum _target)
unlock buffer target
void reset_projection()
reset projection matrix (load identity)
static bool isBufferTargetLocked(GLenum _target)
get buffer target locking state
static void vertexPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glVertexPointer, supports locking
void ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with orthographic projection matrix
static void getBlendColor(GLclampf *_col)
get blend color, not null-ptr safe, 4 element color output: RGBA
void perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
static void setTexGenMode(GLenum _coord, GLenum _name, GLint _param)
replaces glVertexPointer, supports locking
void rotate(double _angle, double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
rotate around axis (_x, _y, _z) by _angle
static bool isStateEnabled(GLenum _cap)
returns true, if a cpa state is enabled
static void activeTexture(GLenum _texunit)
replaces glActiveTexture, no locking support
void pop_modelview_matrix()
pop modelview matrix
void identity()
setup an identity matrix
static void getTexGenMode(GLenum _coord, GLenum _name, GLint *_param)
replaces glVertexPointer, supports locking
void pop_projection_matrix()
pop projection matrix
static void cullFace(GLenum _mode)
replaces glCullFace, supports locking
void scale(double _s)
scale by (_s, _s, _s)
bool setMaximumIndex(size_t _idx)
sets the maximum index number used in current node
static GLuint getBoundTextureBuffer()
get bound texture
static const Vec4f default_ambient_color
default value for ambient color
bool error() const
Did an error occur during picking.
static void bindBuffer(GLenum _target, GLuint _buffer)
replaces glBindBuffer, supports locking
Vec4uc getIndexColor(size_t _idx)
gets the color instead of setting it directly
static void getColorPointer(GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get color pointer, null-ptr safe
static void genBuffersARB(GLsizei n, GLuint *buffers)
static GLboolean unmapBuffer(GLenum target)
void initialize()
initialize all state variables (called by constructor)
void set_modelview(const GLMatrixd &_m)
set modelview
static bool isClientStateEnabled(GLenum _cap)
returns true, if a client state is enabled
static void lockFramebuffer(GLenum _target)
lock a framebuffer target
static void lockBufferTarget(GLenum _target)
lock buffer target
void rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
void set_base_color(const Vec4f &_col)
set base color (used when lighting is off)
void setState()
set the whole stored gl state
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
void get_bounding_box(ACG::Vec3d &_min, ACG::Vec3d &_max)
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
static void unlockState(GLenum _cap)
unlocks a specific cap state
void initialize(ACG::GLState *)
init (takes current GL context/ like glInitNames (); glPushName (0))
void lookAt(const Vec3d &_eye, const Vec3d &_center, const Vec3d &_up)
set camera by lookAt
void translate(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
void set_projection(const GLMatrixd &_m)
set projection
static const float default_shininess
default value for shininess
bool pick_set_maximum(size_t _idx)
Set the maximal number of primitives/components of your object.
void pick_set_name(size_t _idx)
sets the current name/color (like glLoadName(_idx))
static void bindTexture(GLenum _target, GLuint _buffer)
replaces glBindTexture, supports locking