59 #include <ACG/GL/acg_glew.hh>
62 #include <OpenMesh/Core/Utils/vector_cast.hh>
87 bool GLState::depthFuncLock_ =
false;
88 bool GLState::depthRangeLock_ =
false;
89 bool GLState::blendFuncSeparateLock_[2] = {
false };
90 bool GLState::blendEquationLock_ =
false;
91 bool GLState::blendColorLock_ =
false;
92 bool GLState::alphaFuncLock_ =
false;
93 bool GLState::shadeModelLock_ =
false;
94 bool GLState::cullFaceLock_ =
false;
95 bool GLState::vertexPointerLock_ =
false;
96 bool GLState::normalPointerLock_ =
false;
97 bool GLState::texcoordPointerLock_ =
false;
98 bool GLState::colorPointerLock_ =
false;
99 bool GLState::drawBufferLock_ =
false;
100 bool GLState::programLock_ =
false;
102 std::deque <GLStateContext> GLState::stateStack_;
103 std::bitset<0xFFFF+1> GLState::glStateLock_;
104 int GLState::glBufferTargetLock_[4] = {0};
105 int GLState::glTextureStageLock_[16] = {0};
106 bool GLState::framebufferLock_[2] = {
false};
107 int GLState::maxTextureCoords_ = 0;
108 int GLState::maxCombinedTextureImageUnits_ = 0;
109 int GLState::maxDrawBuffers_ = 0;
111 int GLState::num_texture_units_ = 0;
113 GLStateContext::GLStateContext() :
114 activeTexture_(GL_TEXTURE0),
115 drawBufferSingle_(GL_BACK),
116 activeDrawBuffer_(0),
119 framebuffers_[0] = framebuffers_[1] = 0;
120 memset(drawBufferState_, GL_BACK,
sizeof(drawBufferState_));
124 : compatibilityProfile_(_compatibilityProfile),
126 max_render_passes_(1),
137 multisampling_(false),
138 allow_multisampling_(true),
140 updateGL_(_updateGL),
142 msSinceLastRedraw_ (1),
146 if ( stateStack_.empty() )
150 memset(glBufferTargetLock_, 0,
sizeof(glBufferTargetLock_));
152 framebufferLock_[0] = framebufferLock_[1] =
false;
154 glStateLock_.reset();
166 while (!stack_projection_.empty())
167 stack_projection_.pop();
168 while (!stack_modelview_.empty())
169 stack_modelview_.pop();
170 while (!stack_inverse_projection_.empty())
171 stack_inverse_projection_.pop();
172 while (!stack_inverse_modelview_.empty())
173 stack_inverse_modelview_.pop();
200 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &value);
202 num_texture_units_ = value;
214 if (compatibilityProfile_ ) {
217 glMatrixMode(GL_PROJECTION);
219 glMatrixMode(GL_MODELVIEW);
227 glClearColor(clear_color_[0], clear_color_[1], clear_color_[2], clear_color_[3]);
229 if (compatibilityProfile_ ) {
231 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, base_color_.data());
234 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT , ambient_color_.data());
237 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE , diffuse_color_.data());
240 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular_color_.data());
243 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess_);
247 glPointSize(point_size_);
250 glLineWidth(line_width_);
252 if ( compatibilityProfile_ ) {
254 if (twosided_lighting_ )
255 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
257 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
261 glViewport(left_, bottom_, width_, height_);
270 if ( compatibilityProfile_ ) {
271 glPushAttrib (GL_ALL_ATTRIB_BITS);
276 glShadeModel( GL_FLAT );
278 if ( compatibilityProfile_ ) {
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;
327 bool GLState::compatibilityProfile()
const {
328 return compatibilityProfile_;
338 if (updateGL_ && compatibilityProfile_ )
341 glMatrixMode(GL_PROJECTION);
343 glMatrixMode(GL_MODELVIEW);
354 inverse_projection_ = _inv_m;
356 if (updateGL_ && compatibilityProfile_)
359 glMatrixMode(GL_PROJECTION);
361 glMatrixMode(GL_MODELVIEW);
374 if (updateGL_ && compatibilityProfile_ )
388 inverse_modelview_ = _inv_m;
390 if (updateGL_ && compatibilityProfile_)
402 double _bottom,
double _top,
403 double _n,
double _f )
408 projection_.
ortho(_left, _right, _bottom, _top, _n, _f);
409 inverse_projection_.
inverse_ortho(_left,_right,_bottom,_top,_n,_f);
411 if (updateGL_ && compatibilityProfile_ )
414 glMatrixMode(GL_PROJECTION);
415 glOrtho(_left, _right, _bottom, _top, _n, _f);
416 glMatrixMode(GL_MODELVIEW);
425 double _bottom,
double _top,
426 double _n,
double _f )
431 projection_.
frustum(_left, _right, _bottom, _top, _n, _f);
434 if (updateGL_ && compatibilityProfile_)
437 glMatrixMode(GL_PROJECTION);
438 glFrustum(_left, _right, _bottom, _top, _n, _f);
439 glMatrixMode(GL_MODELVIEW);
448 double _n,
double _f )
456 if (updateGL_ && compatibilityProfile_)
459 glMatrixMode(GL_PROJECTION);
460 glLoadMatrixd(projection_.data());
461 glMatrixMode(GL_MODELVIEW);
470 int _width,
int _height,
471 int _glwidth,
int _glheight)
478 if (_glwidth < _width || _glheight < _height)
484 glheight_ = _glheight;
488 window2viewport_(0,0) = 0.5f * width_;
489 window2viewport_(0,3) = 0.5f * width_ + left_;
490 window2viewport_(1,1) = 0.5f * height_;
491 window2viewport_(1,3) = 0.5f * height_ + bottom_;
492 window2viewport_(2,2) = 0.5f;
493 window2viewport_(2,3) = 0.5f;
495 inverse_window2viewport_.
identity();
496 inverse_window2viewport_(0,0) = 2.0f / width_;
497 inverse_window2viewport_(0,3) = -(2.0*left_ + width_) / width_;
498 inverse_window2viewport_(1,1) = 2.0f / height_;
499 inverse_window2viewport_(1,3) = -(2.0*bottom_ + height_) / height_;
500 inverse_window2viewport_(2,2) = 2.0f;
501 inverse_window2viewport_(2,3) = -1.0f;
506 glViewport(_left, _bottom, _width, _height);
515 const Vec3d& _center,
518 modelview_.
lookAt(_eye, _center, _up);
521 if (updateGL_ && compatibilityProfile_)
524 glLoadMatrixd(modelview_.data());
535 if (_mult_from == MULT_FROM_RIGHT)
538 inverse_modelview_.
translate(-_x, -_y, -_z, MULT_FROM_LEFT);
542 modelview_.
translate(_x, _y, _z, MULT_FROM_LEFT);
543 inverse_modelview_.
translate(-_x, -_y, -_z);
546 if (updateGL_ && compatibilityProfile_)
557 translate( _vector[0] , _vector[1] , _vector[2] ,_mult_from);
566 if (_mult_from == MULT_FROM_RIGHT)
568 modelview_.
rotate(_angle, _x, _y, _z);
569 inverse_modelview_.
rotate(-_angle, _x, _y, _z, MULT_FROM_LEFT);
573 modelview_.
rotate(_angle, _x, _y, _z, MULT_FROM_LEFT);
574 inverse_modelview_.
rotate(-_angle, _x, _y, _z);
577 if (updateGL_ && compatibilityProfile_)
591 if (_mult_from == MULT_FROM_RIGHT)
593 modelview_.
scale(_sx, _sy, _sz, MULT_FROM_RIGHT);
594 inverse_modelview_.
scale(1.0f/_sx, 1.0f/_sy, 1.0f/_sz, MULT_FROM_LEFT);
598 modelview_.
scale(_sx, _sy, _sz, MULT_FROM_LEFT);
599 inverse_modelview_.
scale(1.0f/_sx, 1.0f/_sy, 1.0f/_sz, MULT_FROM_RIGHT);
602 if (updateGL_ && compatibilityProfile_)
616 if (_mult_from == MULT_FROM_RIGHT)
619 inverse_modelview_.leftMult(_inv_m);
623 modelview_.leftMult(_m);
624 inverse_modelview_ *= _inv_m;
627 if (updateGL_ && compatibilityProfile_)
668 glClearColor(_col[0], _col[1], _col[2], _col[3]);
680 if (updateGL_ && compatibilityProfile_ )
683 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, _col.data());
708 ambient_color_ = _col;
710 if (updateGL_ && compatibilityProfile_)
713 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, _col.data());
723 diffuse_color_ = _col;
725 if (updateGL_ && compatibilityProfile_)
728 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, _col.data());
738 specular_color_ = _col;
740 if (updateGL_ && compatibilityProfile_)
743 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, _col.data());
753 overlay_color_ = _col;
762 shininess_ = _shininess;
764 if (updateGL_ && compatibilityProfile_)
767 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, _shininess);
782 glPointSize(point_size_);
797 glLineWidth(line_width_);
821 twosided_lighting_ = _b;
823 if (updateGL_ && compatibilityProfile_ )
826 if (twosided_lighting_)
827 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
829 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
844 if ( allow_multisampling_ ) {
853 multisampling_ =
false;
855 if ( glIsEnabled( GL_MULTISAMPLE ) )
867 assert(projection_(1,1) != 0.0);
869 return atan(1.0/projection_(1,1))*2.0;
876 assert(projection_(0,0) != 0.0);
878 return projection_(1,1) / projection_(0,0);
932 _direction.normalize();
940 return stateStack_.back().depthFunc_;
956 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
957 if (stateStack_.back().depthFunc_ != _depthFunc)
960 glDepthFunc(_depthFunc);
961 stateStack_.back().depthFunc_ = _depthFunc;
970 stack_projection_.push(projection_);
971 stack_inverse_projection_.push(inverse_projection_);
973 if (updateGL_ && compatibilityProfile_)
976 glMatrixMode(GL_PROJECTION);
978 glMatrixMode(GL_MODELVIEW);
988 projection_ = stack_projection_.top();
989 inverse_projection_ = stack_inverse_projection_.top();
991 stack_projection_.pop();
992 stack_inverse_projection_.pop();
994 if (updateGL_ && compatibilityProfile_)
997 glMatrixMode(GL_PROJECTION);
999 glMatrixMode(GL_MODELVIEW);
1009 stack_modelview_.push(modelview_);
1010 stack_inverse_modelview_.push(inverse_modelview_);
1012 if (updateGL_ && compatibilityProfile_)
1025 modelview_ = stack_modelview_.top();
1026 inverse_modelview_ = stack_inverse_modelview_.top();
1028 stack_modelview_.pop();
1029 stack_inverse_modelview_.pop();
1031 if (updateGL_ && compatibilityProfile_)
1042 colorPicking_ = _color;
1069 return Vec4uc (0, 0, 0, 0);
1076 Vec4f rv(0.0f, 0.0f, 0.0f, 0.0f);
1105 return std::vector<size_t> ();
1122 return colorStack_.
error ();
1140 return colorPicking_;
1145 GLenum GLState::glStateCaps[95] = {GL_ALPHA_TEST,
1182 GL_MAP1_TEXTURE_COORD_1,
1183 GL_MAP1_TEXTURE_COORD_2,
1184 GL_MAP1_TEXTURE_COORD_3,
1185 GL_MAP1_TEXTURE_COORD_4,
1191 GL_MAP2_TEXTURE_COORD_1,
1192 GL_MAP2_TEXTURE_COORD_2,
1193 GL_MAP2_TEXTURE_COORD_3,
1194 GL_MAP2_TEXTURE_COORD_4,
1203 GL_POLYGON_OFFSET_FILL,
1205 GL_POLYGON_OFFSET_LINE,
1207 GL_POLYGON_OFFSET_POINT,
1211 GL_POST_COLOR_MATRIX_COLOR_TABLE,
1212 GL_POST_CONVOLUTION_COLOR_TABLE,
1215 GL_SAMPLE_ALPHA_TO_COVERAGE,
1216 GL_SAMPLE_ALPHA_TO_ONE,
1218 GL_SAMPLE_COVERAGE_INVERT,
1225 GL_TEXTURE_CUBE_MAP,
1230 GL_VERTEX_PROGRAM_POINT_SIZE,
1231 GL_VERTEX_PROGRAM_TWO_SIDE,
1237 GL_SECONDARY_COLOR_ARRAY,
1238 GL_TEXTURE_COORD_ARRAY,
1244 GLenum caps[] = {GL_ALPHA_TEST,
1281 GL_MAP1_TEXTURE_COORD_1,
1282 GL_MAP1_TEXTURE_COORD_2,
1283 GL_MAP1_TEXTURE_COORD_3,
1284 GL_MAP1_TEXTURE_COORD_4,
1290 GL_MAP2_TEXTURE_COORD_1,
1291 GL_MAP2_TEXTURE_COORD_2,
1292 GL_MAP2_TEXTURE_COORD_3,
1293 GL_MAP2_TEXTURE_COORD_4,
1302 GL_POLYGON_OFFSET_FILL,
1303 GL_POLYGON_OFFSET_LINE,
1304 GL_POLYGON_OFFSET_POINT,
1307 GL_POST_COLOR_MATRIX_COLOR_TABLE,
1308 GL_POST_CONVOLUTION_COLOR_TABLE,
1311 GL_SAMPLE_ALPHA_TO_COVERAGE,
1312 GL_SAMPLE_ALPHA_TO_ONE,
1320 GL_TEXTURE_CUBE_MAP,
1325 GL_VERTEX_PROGRAM_POINT_SIZE,
1326 GL_VERTEX_PROGRAM_TWO_SIDE,
1332 GL_SECONDARY_COLOR_ARRAY,
1333 GL_TEXTURE_COORD_ARRAY,
1336 for (
unsigned int i = 0; i <
sizeof(caps) /
sizeof(GLenum); ++i)
1338 if (glIsEnabled(caps[i])) stateStack_.back().glStateEnabled_.set(caps[i]);
1339 else stateStack_.back().glStateEnabled_.reset(caps[i]);
1344 #ifdef GL_VERSION_1_4
1345 glGetIntegerv(GL_BLEND_SRC_RGB, &getparam);
1346 stateStack_.back().blendFuncState_[0] = getparam;
1348 glGetIntegerv(GL_BLEND_DST_ALPHA, &getparam);
1349 stateStack_.back().blendFuncState_[1] = getparam;
1351 glGetIntegerv(GL_BLEND_SRC_ALPHA, &getparam);
1352 stateStack_.back().blendFuncState_[2] = getparam;
1354 glGetIntegerv(GL_BLEND_DST_ALPHA, &getparam);
1355 stateStack_.back().blendFuncState_[3] = getparam;
1357 glGetIntegerv(GL_BLEND_SRC, &getparam);
1358 stateStack_.back().blendFuncState_[0] = getparam;
1360 glGetIntegerv(GL_BLEND_DST, &getparam);
1361 stateStack_.back().blendFuncState_[1] = getparam;
1365 glGetIntegerv(GL_BLEND_EQUATION_RGB, &getparam);
1366 stateStack_.back().blendEquationState_ = getparam;
1368 glGetFloatv(GL_BLEND_COLOR, stateStack_.back().blendColorState_);
1370 glGetIntegerv(GL_ALPHA_TEST_FUNC, &getparam);
1371 stateStack_.back().alphaFuncState_ = getparam;
1373 glGetFloatv(GL_ALPHA_TEST_REF, &stateStack_.back().alphaRefState_);
1375 glGetIntegerv(GL_DEPTH_FUNC, &getparam);
1376 stateStack_.back().depthFunc_ = getparam;
1378 glGetDoublev(GL_DEPTH_RANGE, stateStack_.back().depthRange_);
1382 GLenum bufGets[8] = {
1383 GL_ARRAY_BUFFER_BINDING, GL_ARRAY_BUFFER,
1384 GL_ELEMENT_ARRAY_BUFFER_BINDING, GL_ELEMENT_ARRAY_BUFFER,
1385 GL_PIXEL_PACK_BUFFER_BINDING, GL_PIXEL_PACK_BUFFER,
1386 GL_PIXEL_UNPACK_BUFFER_BINDING, GL_PIXEL_UNPACK_BUFFER};
1388 for (
int i = 0; i < 4; ++i)
1389 glGetIntegerv(bufGets[i*2], (GLint*)stateStack_.back().glBufferTargetState_ +
getBufferTargetIndex(bufGets[i*2+1]));
1393 glGetIntegerv(GL_ACTIVE_TEXTURE, &getparam);
1394 stateStack_.back().activeTexture_ = getparam;
1396 GLenum texBufGets[] = {
1397 GL_TEXTURE_BINDING_1D, GL_TEXTURE_1D,
1398 GL_TEXTURE_BINDING_2D, GL_TEXTURE_2D,
1399 GL_TEXTURE_BINDING_3D, GL_TEXTURE_3D,
1400 GL_TEXTURE_BINDING_CUBE_MAP, GL_TEXTURE_CUBE_MAP
1401 , GL_TEXTURE_BINDING_RECTANGLE_ARB, GL_TEXTURE_RECTANGLE_ARB
1404 glGetIntegerv(GL_MAX_TEXTURE_COORDS, &maxTextureCoords_);
1405 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxCombinedTextureImageUnits_);
1408 if (maxTextureCoords_ > 16) maxTextureCoords_ = 16;
1409 if (maxCombinedTextureImageUnits_ > 16) maxCombinedTextureImageUnits_ = 16;
1411 int numTexUnits = maxTextureCoords_;
1412 if (numTexUnits < maxCombinedTextureImageUnits_) numTexUnits = maxCombinedTextureImageUnits_;
1414 for (
int i = 0; i < numTexUnits; ++i)
1416 glActiveTexture(GL_TEXTURE0 + i);
1420 for (
int k = 0; k < 5 && !getparam; ++k)
1422 glGetIntegerv(texBufGets[k*2], &getparam);
1425 stateStack_.back().glTextureStage_[i].buf_ = getparam;
1426 stateStack_.back().glTextureStage_[i].target_ = texBufGets[k*2+1];
1432 if (numTexUnits > 0)
1433 glActiveTexture(stateStack_.back().activeTexture_);
1437 glGetIntegerv(GL_SHADE_MODEL, &getparam);
1438 stateStack_.back().shadeModel_ = getparam;
1441 glGetIntegerv(GL_CULL_FACE_MODE, &getparam);
1442 stateStack_.back().cullFace_ = getparam;
1447 GLenum ptrEnums[] = {
1448 GL_VERTEX_ARRAY_SIZE, GL_VERTEX_ARRAY_TYPE,
1449 GL_VERTEX_ARRAY_STRIDE, GL_VERTEX_ARRAY_POINTER,
1450 GL_COLOR_ARRAY_SIZE, GL_COLOR_ARRAY_TYPE,
1451 GL_COLOR_ARRAY_STRIDE, GL_COLOR_ARRAY_POINTER,
1452 GL_TEXTURE_COORD_ARRAY_SIZE, GL_TEXTURE_COORD_ARRAY_TYPE,
1453 GL_TEXTURE_COORD_ARRAY_STRIDE, GL_TEXTURE_COORD_ARRAY_POINTER};
1456 &stateStack_.back().colorPointer_, &stateStack_.back().texcoordPointer_};
1458 for (
int i = 0; i < 3 ; ++i)
1460 glGetIntegerv(ptrEnums[i*4], &getparam);
1461 ptrs[i]->size = getparam;
1462 glGetIntegerv(ptrEnums[i*4+1], &getparam);
1463 ptrs[i]->type = getparam;
1464 glGetIntegerv(ptrEnums[i*4+2], &getparam);
1465 ptrs[i]->stride = getparam;
1466 glGetPointerv(ptrEnums[i*4+3], (GLvoid**)&ptrs[i]->pointer);
1469 glGetIntegerv(GL_NORMAL_ARRAY_STRIDE, &getparam);
1470 stateStack_.back().normalPointer_.size = getparam;
1471 glGetIntegerv(GL_NORMAL_ARRAY_TYPE, &getparam);
1472 stateStack_.back().normalPointer_.type = getparam;
1473 glGetPointerv(GL_NORMAL_ARRAY_POINTER, (GLvoid**)&stateStack_.back().normalPointer_.pointer);
1478 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers_);
1479 if (maxDrawBuffers_ > 16) maxDrawBuffers_ = 16;
1481 for (
int i = 0; i < maxDrawBuffers_; ++i)
1483 glGetIntegerv(GL_DRAW_BUFFER0 + i, &getparam);
1484 stateStack_.back().drawBufferState_[i] = getparam;
1487 glGetIntegerv(GL_DRAW_BUFFER, &getparam);
1488 stateStack_.back().drawBufferSingle_ = getparam;
1491 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &getparam);
1492 stateStack_.back().framebuffers_[0] = getparam;
1493 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &getparam);
1494 stateStack_.back().framebuffers_[1] = getparam;
1497 glGetIntegerv(GL_CURRENT_PROGRAM, &getparam);
1498 stateStack_.back().program_ = getparam;
1506 if (!glStateLock_.test(_cap))
1508 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1509 if (!stateStack_.back().glStateEnabled_.test(_cap))
1513 stateStack_.back().glStateEnabled_.set(_cap);
1520 if (!glStateLock_.test(_cap))
1522 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1523 if (stateStack_.back().glStateEnabled_.test(_cap))
1527 stateStack_.back().glStateEnabled_.reset(_cap);
1534 glStateLock_.set(_cap);
1539 glStateLock_.reset(_cap);
1544 return glStateLock_.test(_cap);
1549 return stateStack_.back().glStateEnabled_.test(_cap);
1557 if (!glStateLock_.test(_cap))
1559 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1560 if (!stateStack_.back().glStateEnabled_.test(_cap))
1563 glEnableClientState(_cap);
1564 stateStack_.back().glStateEnabled_.set(_cap);
1571 if (!glStateLock_.test(_cap))
1573 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1574 if (stateStack_.back().glStateEnabled_.test(_cap))
1577 glDisableClientState(_cap);
1578 stateStack_.back().glStateEnabled_.reset(_cap);
1585 glStateLock_.set(_cap);
1590 glStateLock_.reset(_cap);
1595 return glStateLock_.test(_cap);
1600 return stateStack_.back().glStateEnabled_.test(_cap);
1609 if (blendFuncSeparateLock_[0])
1611 _srcRGB = stateStack_.back().blendFuncState_[0];
1612 _dstRGB = stateStack_.back().blendFuncState_[1];
1615 if (blendFuncSeparateLock_[1])
1617 _srcAlpha = stateStack_.back().blendFuncState_[2];
1618 _dstAlpha = stateStack_.back().blendFuncState_[3];
1621 if (!blendFuncSeparateLock_[0] || !blendFuncSeparateLock_[1])
1623 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1624 if (stateStack_.back().blendFuncState_[0] != _srcRGB || stateStack_.back().blendFuncState_[1] != _dstRGB ||
1625 stateStack_.back().blendFuncState_[2] != _srcAlpha || stateStack_.back().blendFuncState_[3] != _dstAlpha)
1628 #ifdef GL_VERSION_1_4
1630 if (glBlendFuncSeparate)
1631 glBlendFuncSeparate(_srcRGB, _dstRGB, _srcAlpha, _dstAlpha);
1633 glBlendFunc(_srcRGB, _dstRGB);
1634 stateStack_.back().blendFuncState_[0] = _srcRGB;
1635 stateStack_.back().blendFuncState_[1] = _dstRGB;
1636 stateStack_.back().blendFuncState_[2] = _srcAlpha;
1637 stateStack_.back().blendFuncState_[3] = _dstAlpha;
1639 glBlendFunc(_srcRGB, _dstRGB);
1640 stateStack_.back().blendFuncState_[0] = _srcRGB;
1641 stateStack_.back().blendFuncState_[1] = _dstRGB;
1642 stateStack_.back().blendFuncState_[2] = _srcRGB;
1643 stateStack_.back().blendFuncState_[3] = _dstRGB;
1651 if (_srcRGB) *_srcRGB = stateStack_.back().blendFuncState_[0];
1652 if (_dstRGB) *_dstRGB = stateStack_.back().blendFuncState_[1];
1653 if (_srcAlpha) *_srcAlpha = stateStack_.back().blendFuncState_[2];
1654 if (_dstAlpha) *_dstAlpha = stateStack_.back().blendFuncState_[3];
1659 if (!blendEquationLock_)
1661 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1662 if (stateStack_.back().blendEquationState_ != _mode)
1665 glBlendEquation(_mode);
1666 stateStack_.back().blendEquationState_ = _mode;
1673 if (!blendColorLock_)
1675 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1676 if (stateStack_.back().blendColorState_[0] != _red || stateStack_.back().blendColorState_[1] != _green ||
1677 stateStack_.back().blendColorState_[2] != _blue || stateStack_.back().blendColorState_[3] != _alpha)
1680 glBlendColor(_red, _green, _blue, _alpha);
1681 stateStack_.back().blendColorState_[0] = _red; stateStack_.back().blendColorState_[1] = _green;
1682 stateStack_.back().blendColorState_[2] = _blue; stateStack_.back().blendColorState_[3] = _alpha;
1689 for (
int i = 0; i < 4; ++i) _col[i] = stateStack_.back().blendColorState_[i];
1695 if (!alphaFuncLock_)
1697 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1698 if (stateStack_.back().alphaFuncState_ != _func || stateStack_.back().alphaRefState_ != _ref)
1701 glAlphaFunc(_func, _ref);
1702 stateStack_.back().alphaFuncState_ = _func;
1703 stateStack_.back().alphaRefState_ = _ref;
1710 if (_func) *_func = stateStack_.back().alphaFuncState_;
1711 if (_ref) *_ref = stateStack_.back().alphaRefState_;
1716 if (!shadeModelLock_)
1718 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1719 if (stateStack_.back().shadeModel_ != _mode)
1722 glShadeModel(_mode);
1723 stateStack_.back().shadeModel_ = _mode;
1732 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1733 if (stateStack_.back().cullFace_ != _mode)
1737 stateStack_.back().cullFace_ = _mode;
1744 if (!depthRangeLock_)
1746 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1747 if (abs(_zNear - stateStack_.back().depthRange_[0]) > 1e-6 ||
1748 abs(_zFar - stateStack_.back().depthRange_[1]) > 1e-6)
1751 glDepthRange(_zNear, _zFar);
1752 stateStack_.back().depthRange_[0] = _zNear;
1753 stateStack_.back().depthRange_[1] = _zFar;
1760 if (_zNearOut) *_zNearOut = stateStack_.back().depthRange_[0];
1761 if (_zFarOut) *_zFarOut = stateStack_.back().depthRange_[1];
1770 case GL_ARRAY_BUFFER:
return 0;
1771 case GL_ELEMENT_ARRAY_BUFFER:
return 1;
1772 case GL_PIXEL_PACK_BUFFER:
return 2;
1773 case GL_PIXEL_UNPACK_BUFFER:
return 3;
1774 #ifdef GL_ARB_uniform_buffer_object
1775 case GL_UNIFORM_BUFFER:
return 4;
1777 #ifdef GL_ARB_shader_storage_buffer_object
1778 case GL_SHADER_STORAGE_BUFFER:
return 5;
1780 #ifdef GL_ARB_shader_atomic_counters
1781 case GL_ATOMIC_COUNTER_BUFFER:
return 6;
1783 #ifdef GL_ARB_copy_buffer
1784 case GL_COPY_READ_BUFFER:
return 7;
1785 case GL_COPY_WRITE_BUFFER:
return 8;
1787 #ifdef GL_ARB_compute_shader
1788 case GL_DISPATCH_INDIRECT_BUFFER:
return 9;
1790 #ifdef GL_ARB_draw_indirect
1791 case GL_DRAW_INDIRECT_BUFFER:
return 10;
1793 #ifdef GL_ARB_query_buffer_object
1794 case GL_QUERY_BUFFER:
return 11;
1796 #ifdef GL_ARB_texture_buffer_object
1797 case GL_TEXTURE_BUFFER:
return 12;
1799 #ifdef GL_VERSION_3_0
1800 case GL_TRANSFORM_FEEDBACK_BUFFER:
return 13;
1803 std::cerr <<
"error : GLState::bindBuffer - unknown buffer target type" << _target << std::endl;
1810 if (idx >= 0 && !glBufferTargetLock_[idx])
1812 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1813 if (stateStack_.back().glBufferTargetState_[idx] != _buffer)
1816 glBindBufferARB(_target, _buffer);
1817 stateStack_.back().glBufferTargetState_[idx] = _buffer;
1846 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1847 if (stateStack_.back().activeTexture_ != _texunit)
1850 glActiveTexture(_texunit);
1851 stateStack_.back().activeTexture_ = _texunit;
1859 assert(activeTex >= 0);
1863 if (!glTextureStageLock_[activeTex])
1865 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1866 if (_buffer != stage->buf_ || _target != stage->target_)
1869 glBindTexture(_target, _buffer);
1871 stage->target_ = _target;
1872 stage->buf_ = _buffer;
1907 if (!vertexPointerLock_)
1909 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1910 if (!stateStack_.back().vertexPointer_.equals(_size, _type, _stride, _pointer))
1913 glVertexPointer(_size, _type, _stride, _pointer);
1914 stateStack_.back().vertexPointer_.set(_size, _type, _stride, _pointer);
1921 if (_size) *_size = stateStack_.back().vertexPointer_.size;
1922 if (_stride) *_stride = stateStack_.back().vertexPointer_.stride;
1923 if (_type) *_type = stateStack_.back().vertexPointer_.type;
1924 if (_pointer) *_pointer = stateStack_.back().vertexPointer_.pointer;
1929 if (!normalPointerLock_)
1931 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1932 if (!stateStack_.back().normalPointer_.equals(stateStack_.back().normalPointer_.size, _type, _stride, _pointer))
1935 glNormalPointer(_type, _stride, _pointer);
1936 stateStack_.back().normalPointer_.set(3, _type, _stride, _pointer);
1943 if (_type) *_type = stateStack_.back().normalPointer_.type;
1944 if (_stride) *_stride = stateStack_.back().normalPointer_.stride;
1945 if (_pointer) *_pointer = stateStack_.back().normalPointer_.pointer;
1951 if (!colorPointerLock_)
1953 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1954 if (!stateStack_.back().colorPointer_.equals(_size, _type, _stride, _pointer))
1957 glColorPointer(_size, _type, _stride, _pointer);
1958 stateStack_.back().colorPointer_.set(_size, _type, _stride, _pointer);
1965 if (_size) *_size = stateStack_.back().colorPointer_.size;
1966 if (_stride) *_stride = stateStack_.back().colorPointer_.stride;
1967 if (_type) *_type = stateStack_.back().colorPointer_.type;
1968 if (_pointer) *_pointer = stateStack_.back().colorPointer_.pointer;
1973 if (!texcoordPointerLock_)
1975 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1976 if (!stateStack_.back().texcoordPointer_.equals(_size, _type, _stride, _pointer))
1979 glTexCoordPointer(_size, _type, _stride, _pointer);
1980 stateStack_.back().texcoordPointer_.set(_size, _type, _stride, _pointer);
1987 if (_size) *_size = stateStack_.back().texcoordPointer_.size;
1988 if (_stride) *_stride = stateStack_.back().texcoordPointer_.stride;
1989 if (_type) *_type = stateStack_.back().texcoordPointer_.type;
1990 if (_pointer) *_pointer = stateStack_.back().texcoordPointer_.pointer;
1998 if (!drawBufferLock_)
2000 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
2001 if (stateStack_.back().drawBufferSingle_ != _mode || stateStack_.back().activeDrawBuffer_)
2004 glDrawBuffer(_mode);
2005 stateStack_.back().drawBufferSingle_ = _mode;
2006 stateStack_.back().activeDrawBuffer_ = 0;
2013 if (!drawBufferLock_)
2015 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
2016 int bChange = !stateStack_.back().activeDrawBuffer_;
2017 for (
int i = 0; i < _n && (!bChange); ++i)
2019 if (stateStack_.back().drawBufferState_[i] != _bufs[i])
2026 glDrawBuffers(_n, _bufs);
2028 for (
int i = 0; i < _n; ++i)
2029 stateStack_.back().drawBufferState_[i] = _bufs[i];
2031 stateStack_.back().activeDrawBuffer_ = _n;
2040 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&curfbo);
2048 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (GLint*)&curfbo);
2057 case GL_FRAMEBUFFER:
2063 case GL_DRAW_FRAMEBUFFER: i = 0;
break;
2064 case GL_READ_FRAMEBUFFER: i = 1;
break;
2067 if (i >= 0 && !framebufferLock_[i])
2069 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
2070 if (stateStack_.back().framebuffers_[i] != _framebuffer)
2073 glBindFramebufferEXT(_target, _framebuffer);
2074 stateStack_.back().framebuffers_[i] = _framebuffer;
2083 case GL_FRAMEBUFFER:
2084 framebufferLock_[0] = framebufferLock_[1] =
true;
break;
2086 case GL_DRAW_FRAMEBUFFER: framebufferLock_[0] =
true;
break;
2087 case GL_READ_FRAMEBUFFER: framebufferLock_[1] =
true;
break;
2095 case GL_FRAMEBUFFER:
2096 framebufferLock_[0] = framebufferLock_[1] =
false;
break;
2098 case GL_DRAW_FRAMEBUFFER: framebufferLock_[0] =
false;
break;
2099 case GL_READ_FRAMEBUFFER: framebufferLock_[1] =
false;
break;
2107 case GL_FRAMEBUFFER:
2108 return framebufferLock_[0] && framebufferLock_[1];
2110 case GL_DRAW_FRAMEBUFFER:
return framebufferLock_[0];
2111 case GL_READ_FRAMEBUFFER:
return framebufferLock_[1];
2120 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
2121 if (stateStack_.back().program_ != _program)
2124 glUseProgram(_program);
2125 stateStack_.back().program_ = _program;
2131 glGenBuffersARB(n, buffers);
2135 glGenBuffers(n, buffers);
2139 GLenum target, GLsizeiptrARB size,
const GLvoid *data, GLenum usage) {
2140 glBufferDataARB(target, size, data, usage);
2144 GLenum target, GLsizeiptr size,
const GLvoid* data, GLenum usage) {
2145 glBufferData(target, size, data, usage);
2149 glDeleteBuffers(n, buffers);
2153 return glMapBuffer(target, access);
2158 return glUnmapBuffer(target);
void set_shininess(float _shininess)
set specular shininess (must be in [0, 128])
void lookAt(const Vec3d &_eye, const Vec3d &_center, const Vec3d &_up)
set camera by lookAt
std::vector< size_t > colorToStack(Vec4uc _rgba) const
converts the given color to index values on the stack
static void blendFuncSeparate(GLenum _srcRGB, GLenum _dstRGB, GLenum _srcAlpha, GLenum _dstAlpha)
replaces glBlendFuncSeparate, supports locking
static void unlockClientState(GLenum _cap)
unlocks a client state
bool pick_set_maximum(size_t _idx)
Set the maximal number of primitives/components of your object.
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
static const Vec4f default_overlay_color
default value for overlay color
static int getBufferTargetIndex(GLenum _target)
bijective map from GLenum buffer_target to [0..3], -1 if unsupported
static void colorPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glColorPointer, 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
void set_base_color(const Vec4f &_col)
set base color (used when lighting is off)
static GLuint getFramebufferDraw()
get current draw framebuffer of a target
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
static void unlockState(GLenum _cap)
unlocks a specific cap state
Vec3d project(const Vec3d &_point) const
project point in world coordinates to window coordinates
void initialize()
initialize all state variables (called by constructor)
Vec3d right() const
get right-vector w.r.t. camera coordinates
static const Vec4f default_specular_color
default value for specular color
static void normalPointer(GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glNormalPointer, supports locking
Vec3d eye() const
get eye point
void set_diffuse_color(const Vec4f &_col)
set diffuse color
static void bufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage)
static void drawBuffers(GLsizei _n, const GLenum *_bufs)
replaces glDrawBuffers, supports locking
void pushIndex(size_t _idx)
creates a new node the stack (like glPushName)
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
static void blendColor(GLclampf _red, GLclampf _green, GLclampf _blue, GLclampf _alpha)
replaces glBlendColor, supports locking
void pop_modelview_matrix()
pop modelview matrix
double fovy() const
get field of view in y direction
static void disable(GLenum _cap)
replaces glDisable, but supports locking
static void getVertexPointer(GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get vertex pointer, null-ptr safe
void ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with orthographic projection matrix
static void genBuffersARB(GLsizei n, GLuint *buffers)
size_t pick_current_index() const
Returns the current color picking index (can be used for caching)
GLState(bool _updateGL=true, bool _compatibilityProfile=true)
Default constructor.
void push_modelview_matrix()
push modelview matrix
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
static void enable(GLenum _cap)
replaces glEnable, but supports locking
void set_modelview(const GLMatrixd &_m)
set modelview
bool error() const
Did an error occur during picking.
void makeCurrent()
does nothing
void translate(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
Namespace providing different geometric functions concerning angles.
void pick_push_name(size_t _idx)
creates a new name the stack (like glPushName())
void set_specular_color(const Vec4f &_col)
set specular color
void set_depthFunc(const GLenum &_depth_func)
Call glDepthFunc() to actually change the depth comparison function, and store the new value in this ...
void lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
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
static void lockFramebuffer(GLenum _target)
lock a framebuffer target
static void unlockTextureStage()
unlocks the current texture target
void rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
void set_ambient_color(const Vec4f &_col)
set ambient color
bool initialized() const
has it been initialized?
static void getNormalPointer(GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get normal pointer, null-ptr safe
static void getAlphaFunc(GLenum *_func, GLclampf *_ref)
get alpha function, null-ptr safe
static bool isStateLocked(GLenum _cap)
returns true, if a cap state is locked
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
static GLenum getBoundTextureTarget()
get bound texture target
static void bindTexture(GLenum _target, GLuint _buffer)
replaces glBindTexture, supports locking
bool color_picking() const
Is color picking active?
static void cullFace(GLenum _mode)
replaces glCullFace, supports locking
static void lockState(GLenum _cap)
locks a specific cap state, such that enable() or disable() has no effect
void pick_init(bool _color)
initialize name/color picking stack (like glInitNames())
static void bindFramebuffer(GLenum _target, GLuint _framebuffer)
replaces glBindFramebuffer, supports locking
static void activeTexture(GLenum _texunit)
replaces glActiveTexture, no locking support
std::vector< size_t > pick_color_to_stack(Vec4uc _rgba) const
void setIndex(size_t _idx)
sets the current color the given index (like glLoadName)
static const Vec4f default_diffuse_color
default value for diffuse color
static void blendEquation(GLenum _mode)
replaces glBlendEquation, supports locking
void initialize()
init (takes current GL context/ like glInitNames (); glPushName (0))
void reset_projection()
reset projection matrix (load identity)
Vec3d up() const
get up-vector w.r.t. camera coordinates
static GLboolean unmapBuffer(GLenum target)
static void deleteBuffers(GLsizei n, const GLuint *buffers)
static void getColorPointer(GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get color pointer, null-ptr safe
void inverse_lookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up)
multiply self from left with inverse lookAt matrix
void perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
static const float default_shininess
default value for shininess
static void vertexPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glVertexPointer, supports locking
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.
static GLvoid * mapBuffer(GLenum target, GLenum access)
static void syncFromGL()
synchronize this class with the OpenGL state machine
static void texcoordPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glTexcoordPointer, supports locking
const Scalar * get_raw_data() const
static bool isClientStateLocked(GLenum _cap)
returns true, if a client state is locked
static void genBuffers(GLsizei n, GLuint *buffers)
static void alphaFunc(GLenum _func, GLclampf _ref)
replaces glAlphaFunc, supports locking
Vec3d viewing_direction() const
get viewing ray
static void lockBufferTarget(GLenum _target)
lock buffer target
static GLuint getBoundTextureBuffer()
get bound texture
size_t freeIndicies() const
returns maximal available index count
void ortho(double _left, double _right, double _bottom, double _top, double _near_plane, double _far_plane)
orthographic projection
static bool isBufferTargetLocked(GLenum _target)
get buffer target locking state
bool setMaximumIndex(size_t _idx)
sets the maximum index number used in current node
void mult_matrix(const GLMatrixd &_m, const GLMatrixd &_inv_m, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply by a given transformation matrix
Vec4uc getIndexColor(size_t _idx)
gets the color instead of setting it directly
static const Vec4f default_ambient_color
default value for ambient color
const GLMatrixd & viewport() const
get viewport matrix
static void getDepthRange(GLclampd *_zNearOut, GLclampd *_zFarOut)
get current depth range
void translate(double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
translate by (_x, _y, _z)
static void useProgram(GLuint _program)
replaces glUseProgram, supports locking
void set_projection(const GLMatrixd &_m)
set projection
void reset_modelview()
reset modelview matrix (load identity)
void pop_projection_matrix()
pop projection matrix
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
static bool isClientStateEnabled(GLenum _cap)
returns true, if a client state is enabled
size_t pick_free_indicies() const
returns the number of still available colors during color picking
void set_point_size(float _f)
set point size
VectorT< float, 4 > Vec4f
void frustum(double _left, double _right, double _bottom, double _top, double _near_plane, double _far_plane)
perspective projection
void set_twosided_lighting(bool _b)
set whether transparent or solid objects should be drawn
void set_color(const Vec4f &_col)
set color
static void unlockFramebuffer(GLenum _target)
unlock a framebuffer target
static bool isStateEnabled(GLenum _cap)
returns true, if a cpa state is enabled
void pick_pop_name()
pops the current name from the stack (like glPopName())
void perspective(double _fovY, double _aspect, double _near_plane, double _far_plane)
perspective projection
void set_multisampling(bool _b)
Enable or disable multisampling.
void viewing_ray(int _x, int _y, Vec3d &_origin, Vec3d &_direction) const
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
void scale(double _s)
scale by (_s, _s, _s)
void push_projection_matrix()
push projection matrix
void set_bounding_box(ACG::Vec3d _min, ACG::Vec3d _max)
VectorT< unsigned char, 4 > Vec4uc
void clearBuffers()
clear buffers viewport rectangle
void frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
void set_overlay_color(const Vec4f &_col)
set overlay color
void set_clear_color(const Vec4f &_col)
set background color
static GLuint getBoundBuf(GLenum _target)
get currently bound buffer
void scale(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
void pick_set_name(size_t _idx)
sets the current name/color (like glLoadName(_idx))
static void lockClientState(GLenum _cap)
locks a client state
size_t currentIndex() const
returns the current color index
Vec4uc pick_get_name_color(size_t _idx)
static void drawBuffer(GLenum _mode)
replaces glDrawBuffer, supports locking
static void disableClientState(GLenum _cap)
replaces glDisableClientState, supports locking
static void bufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
VectorT< double, 3 > Vec3d
static GLuint getFramebufferRead()
get current read framebuffer of a target
static void getBlendFuncSeparate(GLenum *_srcRGB, GLenum *_dstRGB, GLenum *_srcAlpha, GLenum *_dstAlpha)
get blend function, null-ptr safe
void inverse_perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse of perspective projection matrix
static const Vec4f default_clear_color
default value for clear color
static void getBlendColor(GLclampf *_col)
get blend color, not null-ptr safe, 4 element color output: RGBA
static bool isTextureTargetLocked()
get texture target locking state
void setState()
set the whole stored gl state
VectorT< T, 3 > transform_point(const VectorT< T, 3 > &_v) const
transform point (x',y',z',1) = M * (x,y,z,1)
void set_line_width(float _f)
set line width
double aspect() const
get aspect ratio
static void bindBuffer(GLenum _target, GLuint _buffer)
replaces glBindBuffer, supports locking
void popIndex()
pops the current node from the stack (like glPopName)
static bool isFramebufferLocked(GLenum _target)
get framebuffer target lock state
static void getTexcoordPointer(GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get color pointer, null-ptr safe
void identity()
setup an identity matrix
Vec3d unproject(const Vec3d &_winPoint) const
unproject point in window coordinates _winPoint to world coordinates
static void lockTextureStage()
locks the current texture stage (set by setActiveTexture)
static const Vec4f default_base_color
default value for base color
void get_bounding_box(ACG::Vec3d &_min, ACG::Vec3d &_max)
static void unlockBufferTarget(GLenum _target)
unlock buffer target
static int getActiveTextureIndex()
get active texture as zero based index