Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GLState.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $Author$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50
51 //=============================================================================
52 //
53 // CLASS GLState - IMPLEMENTATION
54 //
55 //=============================================================================
56
57 //== INCLUDES =================================================================
58
59 #include <ACG/GL/acg_glew.hh>
60 #include "GLState.hh"
61
62 #include <cstring>
63
64
65 //== NAMESPACES ===============================================================
66
67
68 namespace ACG {
69
70
71 //== IMPLEMENTATION ==========================================================
72
73 //#define GLSTATE_AVOID_REDUNDANT_GLCALLS
74
75 const Vec4f GLState::default_clear_color(0.f, 0.f, 0.f, 1.f);
76 const Vec4f GLState::default_base_color(0.f, 0.f, 0.f, 1.f);
77 const Vec4f GLState::default_ambient_color(0.2f, 0.2f, 0.2f, 1.f);
78 const Vec4f GLState::default_diffuse_color(0.5f, 0.53f, 0.6f, 1.f);
79 const Vec4f GLState::default_specular_color(0.75f, 0.8f, 0.85f, 1.f);
80 const Vec4f GLState::default_overlay_color(0.f, 0.f, 0.f, 1.f);
81 const float GLState::default_shininess(100.f);
82
83
84 //-----------------------------------------------------------------------------
85
86 bool GLState::depthFuncLock_ = false;
87 bool GLState::depthRangeLock_ = false;
88 bool GLState::blendFuncSeparateLock_[2] = { false };
89 bool GLState::blendEquationLock_ = false;
90 bool GLState::blendColorLock_ = false;
91 bool GLState::alphaFuncLock_ = false;
92 bool GLState::shadeModelLock_ = false;
93 bool GLState::cullFaceLock_ = false;
94 bool GLState::vertexPointerLock_ = false;
95 bool GLState::normalPointerLock_ = false;
96 bool GLState::texcoordPointerLock_ = false;
97 bool GLState::colorPointerLock_ = false;
98 bool GLState::drawBufferLock_ = false;
99 bool GLState::programLock_ = false;
100
101 std::deque <GLStateContext> GLState::stateStack_;
102 std::bitset<0xFFFF+1> GLState::glStateLock_;
103 int GLState::glBufferTargetLock_[4] = {0};
104 int GLState::glTextureStageLock_[16] = {0};
105 bool GLState::framebufferLock_[2] = {false};
106 int GLState::maxTextureCoords_ = 0;
107 int GLState::maxCombinedTextureImageUnits_ = 0;
108 int GLState::maxDrawBuffers_ = 0;
109
110 int GLState::num_texture_units_ = 0;
111
112 GLStateContext::GLStateContext() :
113 activeTexture_(GL_TEXTURE0),
114 drawBufferSingle_(GL_BACK),
115 activeDrawBuffer_(0),
116 program_(0)
117 {
118 framebuffers_[0] = framebuffers_[1] = 0;
119 memset(drawBufferState_, GL_BACK, sizeof(drawBufferState_));
120 }
121
122 GLState::GLState(bool _updateGL, bool _compatibilityProfile)
123 : compatibilityProfile_(_compatibilityProfile),
124 render_pass_(1),
125 max_render_passes_(1),
126 bb_min_(ACG::Vec3d(0.0,0.0,0.0)),
127 bb_max_(ACG::Vec3d(0.0,0.0,0.0)),
128 left_(-1),
129 bottom_(1),
130 width_(2),
131 height_(2),
132 glwidth_(2),
133 glheight_(2),
134 near_plane_(1.0),
135 far_plane_(100.0),
136 multisampling_(false),
137 allow_multisampling_(true),
138 mipmapping_(true),
139 updateGL_(_updateGL),
140 blending_(false),
141 msSinceLastRedraw_ (1),
142 colorPicking_(true)
143 {
144
145 if ( stateStack_.empty() )
146 {
147 stateStack_.push_back(GLStateContext());
148
149 memset(glBufferTargetLock_, 0, sizeof(glBufferTargetLock_));
150
151 framebufferLock_[0] = framebufferLock_[1] = false;
152
153 glStateLock_.reset();
154 }
155
156 initialize();
157 }
158
159 //-----------------------------------------------------------------------------
160
161
162 void GLState::initialize()
163 {
164 // clear matrix stacks
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();
173
174
175 // load identity matrix
176 reset_projection();
177 reset_modelview();
178
179
180 // colors
181 set_clear_color(default_clear_color);
182 set_base_color(default_base_color);
183 set_ambient_color(default_ambient_color);
184 set_diffuse_color(default_diffuse_color);
185 set_specular_color(default_specular_color);
186 set_overlay_color(default_overlay_color);
187 set_shininess(default_shininess);
188
189
190 // thickness
191 set_point_size(1.0f);
192 set_line_width(1.0f);
193
194 // multisampling
195 set_multisampling(true);
196
197 // Get max number of texture units
198 GLint value;
199 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &value);
200
201 num_texture_units_ = value;
202
203 // lighting
204 set_twosided_lighting(true);
205 }
206
207 //-----------------------------------------------------------------------------
208
209 void GLState::setState ()
210 {
211 makeCurrent();
212
213 if (compatibilityProfile_ ) {
214
215 // projection matrix
216 glMatrixMode(GL_PROJECTION);
217 glLoadMatrixd(projection_.get_raw_data());
218 glMatrixMode(GL_MODELVIEW);
219
220 // modelview matrix
221 glLoadMatrixd(modelview_.get_raw_data());
222
223 }
224
225 // clear color
226 glClearColor(clear_color_[0], clear_color_[1], clear_color_[2], clear_color_[3]);
227
228 if (compatibilityProfile_ ) {
229 // base color
230 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, base_color_.data());
231
232 // ambient color
233 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT , ambient_color_.data());
234
235 // diffuse color
236 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE , diffuse_color_.data());
237
238 // specular color
239 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular_color_.data());
240
241 // shininess
242 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess_);
243 }
244
245 // point size
246 glPointSize(point_size_);
247
248 // line width
249 glLineWidth(line_width_);
250
251 if ( compatibilityProfile_ ) {
252 // two sided lighting
253 if (twosided_lighting_ )
254 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
255 else
256 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
257 }
258
259 // viewport
260 glViewport(left_, bottom_, width_, height_);
261 }
262
263
264 //-----------------------------------------------------------------------------
265
266 void GLState::clearBuffers ()
267 {
268
269 if ( compatibilityProfile_ ) {
270 glPushAttrib (GL_ALL_ATTRIB_BITS);
271 }
272
273 GLState::disable(GL_DEPTH_TEST);
274 GLState::disable(GL_DITHER);
275 glShadeModel( GL_FLAT );
276
277 if ( compatibilityProfile_ ) {
278 GLState::disable(GL_LIGHTING);
279 glMatrixMode(GL_PROJECTION);
280 glPushMatrix();
281 glLoadIdentity ();
282
283 glMatrixMode(GL_MODELVIEW);
284 glPushMatrix();
285 glLoadIdentity ();
286 }
287
288
289 // GetoriginalScissor settings
290 GLboolean scissor = glIsEnabled(GL_SCISSOR_TEST);
291
292 GLint origBox[4];
293 glGetIntegerv(GL_SCISSOR_BOX,&origBox[0]);
294
295 //Enable scissor
296 if (!scissor)
297 GLState::enable(GL_SCISSOR_TEST);
298
299 // Restrict to our current viewport
300 glScissor( left_,bottom_,width_,height_ );
301
302 // Clear restricted region
303 glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
304
305 // Reset to originalsettings
306 glScissor( origBox[0], origBox[1], origBox[2], origBox[3] );
307
308 if (!scissor)
309 GLState::disable(GL_SCISSOR_TEST);
310
311 if ( compatibilityProfile_ ) {
312 glPopMatrix ();
313 glMatrixMode(GL_PROJECTION);
314 glPopMatrix();
315 glMatrixMode(GL_MODELVIEW);
316 glPopAttrib ();
317 }
318 }
319
320 //-----------------------------------------------------------------------------
321
322 void GLState::setCompatibilityProfile( bool _compatibility ) {
323 compatibilityProfile_ = _compatibility;
324 }
325
326 bool GLState::compatibilityProfile() const {
327 return compatibilityProfile_;
328 }
329
330 //-----------------------------------------------------------------------------
331
332 void GLState::reset_projection()
333 {
334 projection_.identity();
335 inverse_projection_.identity();
336
337 if (updateGL_ && compatibilityProfile_ )
338 {
339 makeCurrent();
340 glMatrixMode(GL_PROJECTION);
341 glLoadIdentity();
342 glMatrixMode(GL_MODELVIEW);
343 }
344 }
345
346
347 //-----------------------------------------------------------------------------
348
349
350 void GLState::set_projection(const GLMatrixd& _m, const GLMatrixd& _inv_m)
351 {
352 projection_ = _m;
353 inverse_projection_ = _inv_m;
354
355 if (updateGL_ && compatibilityProfile_)
356 {
357 makeCurrent();
358 glMatrixMode(GL_PROJECTION);
359 glLoadMatrixd(projection_.get_raw_data());
360 glMatrixMode(GL_MODELVIEW);
361 }
362 }
363
364
365 //-----------------------------------------------------------------------------
366
367
368 void GLState::reset_modelview()
369 {
370 modelview_.identity();
371 inverse_modelview_.identity();
372
373 if (updateGL_ && compatibilityProfile_ )
374 {
375 makeCurrent();
376 glLoadIdentity();
377 }
378 }
379
380
381 //-----------------------------------------------------------------------------
382
383
384 void GLState::set_modelview(const GLMatrixd& _m, const GLMatrixd& _inv_m)
385 {
386 modelview_ = _m;
387 inverse_modelview_ = _inv_m;
388
389 if (updateGL_ && compatibilityProfile_)
390 {
391 makeCurrent();
392 glLoadMatrixd(modelview_.get_raw_data());
393 }
394 }
395
396
397 //-----------------------------------------------------------------------------
398
399
400 void GLState::ortho( double _left, double _right,
401 double _bottom, double _top,
402 double _n, double _f )
403 {
404 near_plane_ = _n;
405 far_plane_ = _f;
406
407 projection_.ortho(_left, _right, _bottom, _top, _n, _f);
408 inverse_projection_.inverse_ortho(_left,_right,_bottom,_top,_n,_f);
409
410 if (updateGL_ && compatibilityProfile_ )
411 {
412 makeCurrent();
413 glMatrixMode(GL_PROJECTION);
414 glOrtho(_left, _right, _bottom, _top, _n, _f);
415 glMatrixMode(GL_MODELVIEW);
416 }
417 }
418
419
420 //-----------------------------------------------------------------------------
421
422
423 void GLState::frustum( double _left, double _right,
424 double _bottom, double _top,
425 double _n, double _f )
426 {
427 near_plane_ = _n;
428 far_plane_ = _f;
429
430 projection_.frustum(_left, _right, _bottom, _top, _n, _f);
431 inverse_projection_.inverse_frustum(_left,_right,_bottom,_top,_n,_f);
432
433 if (updateGL_ && compatibilityProfile_)
434 {
435 makeCurrent();
436 glMatrixMode(GL_PROJECTION);
437 glFrustum(_left, _right, _bottom, _top, _n, _f);
438 glMatrixMode(GL_MODELVIEW);
439 }
440 }
441
442
443 //-----------------------------------------------------------------------------
444
445
446 void GLState::perspective( double _fovY, double _aspect,
447 double _n, double _f )
448 {
449 near_plane_ = _n;
450 far_plane_ = _f;
451
452 projection_.perspective(_fovY, _aspect, _n, _f);
453 inverse_projection_.inverse_perspective(_fovY, _aspect, _n, _f);
454
455 if (updateGL_ && compatibilityProfile_)
456 {
457 makeCurrent();
458 glMatrixMode(GL_PROJECTION);
459 glLoadMatrixd(projection_.data());
460 glMatrixMode(GL_MODELVIEW);
461 }
462 }
463
464
465 //-----------------------------------------------------------------------------
466
467
468 void GLState::viewport( int _left, int _bottom,
469 int _width, int _height,
470 int _glwidth, int _glheight)
471 {
472 left_ = _left;
473 bottom_ = _bottom;
474 width_ = _width;
475 height_ = _height;
476
477 if (_glwidth < _width || _glheight < _height)
478 {
479 glwidth_ = _width;
480 glheight_ = _height;
481 } else {
482 glwidth_ = _glwidth;
483 glheight_ = _glheight;
484 }
485
486 window2viewport_.identity();
487 window2viewport_(0,0) = 0.5f * width_;
488 window2viewport_(0,3) = 0.5f * width_ + left_;
489 window2viewport_(1,1) = 0.5f * height_;
490 window2viewport_(1,3) = 0.5f * height_ + bottom_;
491 window2viewport_(2,2) = 0.5f;
492 window2viewport_(2,3) = 0.5f;
493
494 inverse_window2viewport_.identity();
495 inverse_window2viewport_(0,0) = 2.0f / width_;
496 inverse_window2viewport_(0,3) = -(2.0*left_ + width_) / width_;
497 inverse_window2viewport_(1,1) = 2.0f / height_;
498 inverse_window2viewport_(1,3) = -(2.0*bottom_ + height_) / height_;
499 inverse_window2viewport_(2,2) = 2.0f;
500 inverse_window2viewport_(2,3) = -1.0f;
501
502 if (updateGL_)
503 {
504 makeCurrent();
505 glViewport(_left, _bottom, _width, _height);
506 }
507 }
508
509
510 //-----------------------------------------------------------------------------
511
512
513 void GLState::lookAt( const Vec3d& _eye,
514 const Vec3d& _center,
515 const Vec3d& _up )
516 {
517 modelview_.lookAt(_eye, _center, _up);
518 inverse_modelview_.inverse_lookAt(_eye, _center, _up);
519
520 if (updateGL_ && compatibilityProfile_)
521 {
522 makeCurrent();
523 glLoadMatrixd(modelview_.data());
524 }
525 }
526
527
528 //-----------------------------------------------------------------------------
529
530
531 void GLState::translate( double _x, double _y, double _z,
532 MultiplyFrom _mult_from )
533 {
534 if (_mult_from == MULT_FROM_RIGHT)
535 {
536 modelview_.translate(_x, _y, _z);
537 inverse_modelview_.translate(-_x, -_y, -_z, MULT_FROM_LEFT);
538 }
539 else
540 {
541 modelview_.translate(_x, _y, _z, MULT_FROM_LEFT);
542 inverse_modelview_.translate(-_x, -_y, -_z);
543 }
544
545 if (updateGL_ && compatibilityProfile_)
546 {
547 makeCurrent();
548 glLoadMatrixd(modelview_.get_raw_data());
549 }
550 }
551
552 //-----------------------------------------------------------------------------
553
554 void GLState::translate( Vec3d _vector,
555 MultiplyFrom _mult_from ) {
556 translate( _vector[0] , _vector[1] , _vector[2] ,_mult_from);
557 }
558
559 //-----------------------------------------------------------------------------
560
561
562 void GLState::rotate( double _angle, double _x, double _y, double _z,
563 MultiplyFrom _mult_from )
564 {
565 if (_mult_from == MULT_FROM_RIGHT)
566 {
567 modelview_.rotate(_angle, _x, _y, _z);
568 inverse_modelview_.rotate(-_angle, _x, _y, _z, MULT_FROM_LEFT);
569 }
570 else
571 {
572 modelview_.rotate(_angle, _x, _y, _z, MULT_FROM_LEFT);
573 inverse_modelview_.rotate(-_angle, _x, _y, _z);
574 }
575
576 if (updateGL_ && compatibilityProfile_)
577 {
578 makeCurrent();
579 glLoadMatrixd(modelview_.get_raw_data());
580 }
581 }
582
583
584 //-----------------------------------------------------------------------------
585
586
587 void GLState::scale( double _sx, double _sy, double _sz,
588 MultiplyFrom _mult_from )
589 {
590 if (_mult_from == MULT_FROM_RIGHT)
591 {
592 modelview_.scale(_sx, _sy, _sz, MULT_FROM_RIGHT);
593 inverse_modelview_.scale(1.0f/_sx, 1.0f/_sy, 1.0f/_sz, MULT_FROM_LEFT);
594 }
595 else
596 {
597 modelview_.scale(_sx, _sy, _sz, MULT_FROM_LEFT);
598 inverse_modelview_.scale(1.0f/_sx, 1.0f/_sy, 1.0f/_sz, MULT_FROM_RIGHT);
599 }
600
601 if (updateGL_ && compatibilityProfile_)
602 {
603 makeCurrent();
604 glLoadMatrixd(modelview_.get_raw_data());
605 }
606 }
607
608
609 //-----------------------------------------------------------------------------
610
611
612 void GLState::mult_matrix( const GLMatrixd& _m, const GLMatrixd& _inv_m,
613 MultiplyFrom _mult_from )
614 {
615 if (_mult_from == MULT_FROM_RIGHT)
616 {
617 modelview_ *= _m;
618 inverse_modelview_.leftMult(_inv_m);
619 }
620 else
621 {
622 modelview_.leftMult(_m);
623 inverse_modelview_ *= _inv_m;
624 }
625
626 if (updateGL_ && compatibilityProfile_)
627 {
628 makeCurrent();
629 glLoadMatrixd(modelview_.get_raw_data());
630 }
631 }
632
633
634
635 //-----------------------------------------------------------------------------
636
637
638 Vec3d GLState::project(const Vec3d& _point) const
639 {
640 Vec3d t = modelview_.transform_point(_point);
641 t = projection_.transform_point(t);
642 return window2viewport_.transform_point(t);
643 }
644
645
646 //-----------------------------------------------------------------------------
647
648
649 Vec3d GLState::unproject(const Vec3d& _winPoint) const
650 {
651 Vec3d t = inverse_window2viewport_.transform_point(_winPoint);
652 t = inverse_projection_.transform_point(t);
653 return inverse_modelview_.transform_point(t);
654 }
655
656
657 //-----------------------------------------------------------------------------
658
659
660 void GLState::set_clear_color(const Vec4f& _col)
661 {
662 clear_color_ = _col;
663
664 if (updateGL_)
665 {
666 makeCurrent();
667 glClearColor(_col[0], _col[1], _col[2], _col[3]);
668 }
669 }
670
671
672 //-----------------------------------------------------------------------------
673
674
675 void GLState::set_base_color(const Vec4f& _col)
676 {
677 base_color_ = _col;
678
679 if (updateGL_ && compatibilityProfile_ )
680 {
681 makeCurrent();
682 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, _col.data());
683 }
684 }
685
686 //-----------------------------------------------------------------------------
687
688
689 void GLState::set_color(const Vec4f& _col)
690 {
691 color_ = _col;
692
693 if (updateGL_)
694 {
695 makeCurrent();
696 glColor(color_);
697 }
698 }
699
700
701
702 //-----------------------------------------------------------------------------
703
704
705 void GLState::set_ambient_color(const Vec4f& _col)
706 {
707 ambient_color_ = _col;
708
709 if (updateGL_ && compatibilityProfile_)
710 {
711 makeCurrent();
712 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, _col.data());
713 }
714 }
715
716
717 //-----------------------------------------------------------------------------
718
719
720 void GLState::set_diffuse_color(const Vec4f& _col)
721 {
722 diffuse_color_ = _col;
723
724 if (updateGL_ && compatibilityProfile_)
725 {
726 makeCurrent();
727 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, _col.data());
728 }
729 }
730
731
732 //-----------------------------------------------------------------------------
733
734
735 void GLState::set_specular_color(const Vec4f& _col)
736 {
737 specular_color_ = _col;
738
739 if (updateGL_ && compatibilityProfile_)
740 {
741 makeCurrent();
742 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, _col.data());
743 }
744
745 }
746
747 //-----------------------------------------------------------------------------
748
749
750 void GLState::set_overlay_color(const Vec4f& _col)
751 {
752 overlay_color_ = _col;
753 }
754
755
756 //-----------------------------------------------------------------------------
757
758
759 void GLState::set_shininess(float _shininess)
760 {
761 shininess_ = _shininess;
762
763 if (updateGL_ && compatibilityProfile_)
764 {
765 makeCurrent();
766 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, _shininess);
767 }
768 }
769
770
771 //-----------------------------------------------------------------------------
772
773
774 void GLState::set_point_size(float _f)
775 {
776 point_size_ = _f;
777
778 if (updateGL_)
779 {
780 makeCurrent();
781 glPointSize(point_size_);
782 }
783 }
784
785
786 //-----------------------------------------------------------------------------
787
788
789 void GLState::set_line_width(float _f)
790 {
791 line_width_ = _f;
792
793 if (updateGL_)
794 {
795 makeCurrent();
796 glLineWidth(line_width_);
797 }
798 }
799
800 //-----------------------------------------------------------------------------
801
802 void GLState::set_bounding_box(ACG::Vec3d _min, ACG::Vec3d _max ) {
803 bb_min_ = _min;
804 bb_max_ = _max;
805 }
806
807 //-----------------------------------------------------------------------------
808
809 void GLState::get_bounding_box(ACG::Vec3d& _min, ACG::Vec3d& _max ) {
810 _min = bb_min_;
811 _max = bb_max_;
812 }
813
814
815 //-----------------------------------------------------------------------------
816
817
818 void GLState::set_twosided_lighting(bool _b)
819 {
820 twosided_lighting_ = _b;
821
822 if (updateGL_ && compatibilityProfile_ )
823 {
824 makeCurrent();
825 if (twosided_lighting_)
826 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
827 else
828 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
829 }
830 }
831
832
833 //-----------------------------------------------------------------------------
834
835 void GLState::set_multisampling(bool _b)
836 {
837
838 multisampling_ = _b;
839
840 if (updateGL_)
841 {
842 makeCurrent();
843 if ( allow_multisampling_ ) {
844
845 if ( _b )
846 GLState::enable( GL_MULTISAMPLE );
847 else
848 GLState::disable( GL_MULTISAMPLE );
849
850 } else {
851
852 multisampling_ = false;
853
854 if ( glIsEnabled( GL_MULTISAMPLE ) )
855 GLState::disable( GL_MULTISAMPLE );
856
857 }
858 }
859
860 }
861
862 //-----------------------------------------------------------------------------
863
864 double GLState::fovy() const
865 {
866 assert(projection_(1,1) != 0.0);
867
868 return atan(1.0/projection_(1,1))*2.0;
869 }
870
871 //-----------------------------------------------------------------------------
872
873 double GLState::aspect() const
874 {
875 assert(projection_(0,0) != 0.0);
876
877 return projection_(1,1) / projection_(0,0);
878 }
879
880 //-----------------------------------------------------------------------------
881
882 Vec3d GLState::eye() const
883 {
884 return inverse_modelview_.transform_point(Vec3d(0.0, 0.0, 0.0));
885 }
886
887 //-----------------------------------------------------------------------------
888
889
890 Vec3d GLState::viewing_direction(int _x, int _y) const
891 {
892 Vec3d dir = ( unproject(Vec3d(_x, _y, 1.0)) -
893 unproject(Vec3d(_x, _y, 0.0)) );
894 dir.normalize();
895 return dir;
896 }
897
898
899 //-----------------------------------------------------------------------------
900
901
902 Vec3d GLState::up() const
903 {
904 Vec3d dir( unproject(Vec3d(0.5*width_, height_-1, 0.0)) -
905 unproject(Vec3d(0.5*width_, 0.5*height_, 0.0)) );
906 dir.normalize();
907 return dir;
908 }
909
910
911 //-----------------------------------------------------------------------------
912
913
914 Vec3d GLState::right() const
915 {
916 Vec3d dir( unproject(Vec3d(width_-1, 0.5*height_, 0.0)) -
917 unproject(Vec3d(0.5*width_, 0.5*height_, 0.0)) );
918 dir.normalize();
919 return dir;
920 }
921
922
923 //-----------------------------------------------------------------------------
924
925
926 void GLState::viewing_ray( int _x, int _y,
927 Vec3d& _origin, Vec3d& _direction) const
928 {
929 _origin = unproject(Vec3d(_x, _y, 0.0));
930 _direction = unproject(Vec3d(_x, _y, 1.0)) - _origin;
931 _direction.normalize();
932 }
933
934
935 //-----------------------------------------------------------------------------
936
937 const GLenum& GLState::depthFunc() const
938 {
939 return stateStack_.back().depthFunc_;
940 }
941
942 //-----------------------------------------------------------------------------
943
944 void GLState:: set_depthFunc(const GLenum& _depth_func)
945 {
946 depthFunc(_depth_func);
947 }
948
949 //-----------------------------------------------------------------------------
950
951 void GLState::depthFunc(GLenum _depthFunc)
952 {
953 if (!depthFuncLock_)
954 {
955 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
956 if (stateStack_.back().depthFunc_ != _depthFunc)
957 #endif
958 {
959 glDepthFunc(_depthFunc);
960 stateStack_.back().depthFunc_ = _depthFunc;
961 }
962 }
963 }
964
965 //-----------------------------------------------------------------------------
966
967 void GLState::push_projection_matrix()
968 {
969 stack_projection_.push(projection_);
970 stack_inverse_projection_.push(inverse_projection_);
971
972 if (updateGL_ && compatibilityProfile_)
973 {
974 makeCurrent();
975 glMatrixMode(GL_PROJECTION);
976 glPushMatrix();
977 glMatrixMode(GL_MODELVIEW);
978 }
979 }
980
981
982 //-----------------------------------------------------------------------------
983
984
985 void GLState::pop_projection_matrix()
986 {
987 projection_ = stack_projection_.top();
988 inverse_projection_ = stack_inverse_projection_.top();
989
990 stack_projection_.pop();
991 stack_inverse_projection_.pop();
992
993 if (updateGL_ && compatibilityProfile_)
994 {
995 makeCurrent();
996 glMatrixMode(GL_PROJECTION);
997 glPopMatrix();
998 glMatrixMode(GL_MODELVIEW);
999 }
1000 }
1001
1002
1003 //-----------------------------------------------------------------------------
1004
1005
1006 void GLState::push_modelview_matrix()
1007 {
1008 stack_modelview_.push(modelview_);
1009 stack_inverse_modelview_.push(inverse_modelview_);
1010
1011 if (updateGL_ && compatibilityProfile_)
1012 {
1013 makeCurrent();
1014 glPushMatrix();
1015 }
1016 }
1017
1018
1019 //-----------------------------------------------------------------------------
1020
1021
1022 void GLState::pop_modelview_matrix()
1023 {
1024 modelview_ = stack_modelview_.top();
1025 inverse_modelview_ = stack_inverse_modelview_.top();
1026
1027 stack_modelview_.pop();
1028 stack_inverse_modelview_.pop();
1029
1030 if (updateGL_ && compatibilityProfile_)
1031 {
1032 makeCurrent();
1033 glPopMatrix();
1034 }
1035 }
1036
1037 //-----------------------------------------------------------------------------
1038
1039 void GLState::pick_init (bool _color)
1040 {
1041 colorPicking_ = _color;
1042 colorStack_.initialize ();
1043 }
1044
1045 //-----------------------------------------------------------------------------
1046
1047 bool GLState::pick_set_maximum (unsigned int _idx)
1048 {
1049 bool rv = colorStack_.setMaximumIndex (_idx);
1050 if (colorPicking_)
1051 return rv;
1052 return true;
1053 }
1054
1055 //-----------------------------------------------------------------------------
1056
1057 void GLState::pick_set_name (unsigned int _idx)
1058 {
1059 colorStack_.setIndex (_idx);
1060 }
1061
1062 //-----------------------------------------------------------------------------
1063
1064 Vec4uc GLState::pick_get_name_color (unsigned int _idx)
1065 {
1066 if (colorPicking_)
1067 return colorStack_.getIndexColor (_idx);
1068 return Vec4uc (0, 0, 0, 0);
1069 }
1070
1071 //-----------------------------------------------------------------------------
1072
1073 void GLState::pick_push_name (unsigned int _idx)
1074 {
1075 colorStack_.pushIndex (_idx);
1076 }
1077
1078 //-----------------------------------------------------------------------------
1079
1080 void GLState::pick_pop_name ()
1081 {
1082 colorStack_.popIndex ();
1083 }
1084
1085 //-----------------------------------------------------------------------------
1086
1087 std::vector<unsigned int> GLState::pick_color_to_stack (Vec4uc _rgba) const
1088 {
1089 if (colorPicking_ && colorStack_.initialized ())
1090 return colorStack_.colorToStack (_rgba);
1091 return std::vector<unsigned int> ();
1092 }
1093
1094 //-----------------------------------------------------------------------------
1095
1096 unsigned int GLState::pick_free_indicies () const
1097 {
1098 if (colorPicking_ && colorStack_.initialized ())
1099 return colorStack_.freeIndicies ();
1100 return -1;
1101 }
1102
1103 //-----------------------------------------------------------------------------
1104
1105 bool GLState::pick_error () const
1106 {
1107 if (colorPicking_)
1108 return colorStack_.error ();
1109 return false;
1110 }
1111
1112 //-----------------------------------------------------------------------------
1113
1114 unsigned int GLState::pick_current_index () const
1115 {
1116 if (colorPicking_)
1117 return colorStack_.currentIndex ();
1118 else
1119 return 0;
1120 }
1121
1122 //-----------------------------------------------------------------------------
1123
1124 bool GLState::color_picking () const
1125 {
1126 return colorPicking_;
1127 }
1128
1129 //-----------------------------------------------------------------------------
1130
1131 GLenum GLState::glStateCaps[95] = {GL_ALPHA_TEST,
1132 GL_AUTO_NORMAL,
1133 GL_MAP2_VERTEX_3,
1134 GL_MAP2_VERTEX_4,
1135 GL_BLEND,
1136 GL_CLIP_PLANE0,
1137 GL_CLIP_PLANE1,
1138 GL_CLIP_PLANE2,
1139 GL_CLIP_PLANE3,
1140 GL_CLIP_PLANE4,
1141 GL_CLIP_PLANE5,
1142 GL_COLOR_LOGIC_OP,
1143 GL_COLOR_MATERIAL,
1144 GL_COLOR_SUM,
1145 GL_COLOR_TABLE,
1146 GL_CONVOLUTION_1D,
1147 GL_CONVOLUTION_2D,
1148 GL_CULL_FACE,
1149 GL_DEPTH_TEST,
1150 GL_DITHER,
1151 GL_FOG,
1152 GL_HISTOGRAM,
1153 GL_INDEX_LOGIC_OP,
1154 GL_LIGHT0,
1155 GL_LIGHT1,
1156 GL_LIGHT2,
1157 GL_LIGHT3,
1158 GL_LIGHT4,
1159 GL_LIGHT5,
1160 GL_LIGHT6,
1161 GL_LIGHT7,
1162 GL_LIGHTING,
1163 GL_LINE_SMOOTH,
1164 GL_LINE_STIPPLE,
1165 GL_MAP1_COLOR_4,
1166 GL_MAP1_INDEX,
1167 GL_MAP1_NORMAL,
1168 GL_MAP1_TEXTURE_COORD_1,
1169 GL_MAP1_TEXTURE_COORD_2,
1170 GL_MAP1_TEXTURE_COORD_3,
1171 GL_MAP1_TEXTURE_COORD_4,
1172 GL_MAP1_VERTEX_3,
1173 GL_MAP1_VERTEX_4,
1174 GL_MAP2_COLOR_4,
1175 GL_MAP2_INDEX,
1176 GL_MAP2_NORMAL,
1177 GL_MAP2_TEXTURE_COORD_1,
1178 GL_MAP2_TEXTURE_COORD_2,
1179 GL_MAP2_TEXTURE_COORD_3,
1180 GL_MAP2_TEXTURE_COORD_4,
1181 GL_MAP2_VERTEX_3,
1182 GL_MAP2_VERTEX_4,
1183 GL_MINMAX,
1184 GL_MULTISAMPLE,
1185 GL_NORMALIZE,
1186 GL_RESCALE_NORMAL,
1187 GL_POINT_SMOOTH,
1188 GL_POINT_SPRITE,
1189 GL_POLYGON_OFFSET_FILL,
1190 GL_FILL,
1191 GL_POLYGON_OFFSET_LINE,
1192 GL_LINE,
1193 GL_POLYGON_OFFSET_POINT,
1194 GL_POINT,
1195 GL_POLYGON_SMOOTH,
1196 GL_POLYGON_STIPPLE,
1197 GL_POST_COLOR_MATRIX_COLOR_TABLE,
1198 GL_POST_CONVOLUTION_COLOR_TABLE,
1199 GL_RESCALE_NORMAL,
1200 GL_NORMALIZE,
1201 GL_SAMPLE_ALPHA_TO_COVERAGE,
1202 GL_SAMPLE_ALPHA_TO_ONE,
1203 GL_SAMPLE_COVERAGE,
1204 GL_SAMPLE_COVERAGE_INVERT,
1205 GL_SEPARABLE_2D,
1206 GL_SCISSOR_TEST,
1207 GL_STENCIL_TEST,
1208 GL_TEXTURE_1D,
1209 GL_TEXTURE_2D,
1210 GL_TEXTURE_3D,
1211 GL_TEXTURE_CUBE_MAP,
1212 GL_TEXTURE_GEN_Q,
1213 GL_TEXTURE_GEN_R,
1214 GL_TEXTURE_GEN_S,
1215 GL_TEXTURE_GEN_T,
1216 GL_VERTEX_PROGRAM_POINT_SIZE,
1217 GL_VERTEX_PROGRAM_TWO_SIDE,
1218 GL_COLOR_ARRAY,
1219 GL_EDGE_FLAG_ARRAY,
1220 GL_FOG_COORD_ARRAY,
1221 GL_INDEX_ARRAY,
1222 GL_NORMAL_ARRAY,
1223 GL_SECONDARY_COLOR_ARRAY,
1224 GL_TEXTURE_COORD_ARRAY,
1225 GL_VERTEX_ARRAY};
1226
1227 void GLState::syncFromGL()
1228 {
1229 // get enabled states
1230 GLenum caps[] = {GL_ALPHA_TEST,
1231 GL_AUTO_NORMAL,
1232 GL_MAP2_VERTEX_3,
1233 GL_MAP2_VERTEX_4,
1234 GL_BLEND,
1235 GL_CLIP_PLANE0,
1236 GL_CLIP_PLANE1,
1237 GL_CLIP_PLANE2,
1238 GL_CLIP_PLANE3,
1239 GL_CLIP_PLANE4,
1240 GL_CLIP_PLANE5,
1241 GL_COLOR_LOGIC_OP,
1242 GL_COLOR_MATERIAL,
1243 GL_COLOR_SUM,
1244 GL_COLOR_TABLE,
1245 GL_CONVOLUTION_1D,
1246 GL_CONVOLUTION_2D,
1247 GL_CULL_FACE,
1248 GL_DEPTH_TEST,
1249 GL_DITHER,
1250 GL_FOG,
1251 GL_HISTOGRAM,
1252 GL_INDEX_LOGIC_OP,
1253 GL_LIGHT0,
1254 GL_LIGHT1,
1255 GL_LIGHT2,
1256 GL_LIGHT3,
1257 GL_LIGHT4,
1258 GL_LIGHT5,
1259 GL_LIGHT6,
1260 GL_LIGHT7,
1261 GL_LIGHTING,
1262 GL_LINE_SMOOTH,
1263 GL_LINE_STIPPLE,
1264 GL_MAP1_COLOR_4,
1265 GL_MAP1_INDEX,
1266 GL_MAP1_NORMAL,
1267 GL_MAP1_TEXTURE_COORD_1,
1268 GL_MAP1_TEXTURE_COORD_2,
1269 GL_MAP1_TEXTURE_COORD_3,
1270 GL_MAP1_TEXTURE_COORD_4,
1271 GL_MAP1_VERTEX_3,
1272 GL_MAP1_VERTEX_4,
1273 GL_MAP2_COLOR_4,
1274 GL_MAP2_INDEX,
1275 GL_MAP2_NORMAL,
1276 GL_MAP2_TEXTURE_COORD_1,
1277 GL_MAP2_TEXTURE_COORD_2,
1278 GL_MAP2_TEXTURE_COORD_3,
1279 GL_MAP2_TEXTURE_COORD_4,
1280 GL_MAP2_VERTEX_3,
1281 GL_MAP2_VERTEX_4,
1282 GL_MINMAX,
1283 GL_MULTISAMPLE,
1284 GL_NORMALIZE,
1285 GL_RESCALE_NORMAL,
1286 GL_POINT_SMOOTH,
1287 GL_POINT_SPRITE,
1288 GL_POLYGON_OFFSET_FILL,
1289 GL_POLYGON_OFFSET_LINE,
1290 GL_POLYGON_OFFSET_POINT,
1291 GL_POLYGON_SMOOTH,
1292 GL_POLYGON_STIPPLE,
1293 GL_POST_COLOR_MATRIX_COLOR_TABLE,
1294 GL_POST_CONVOLUTION_COLOR_TABLE,
1295 GL_RESCALE_NORMAL,
1296 GL_NORMALIZE,
1297 GL_SAMPLE_ALPHA_TO_COVERAGE,
1298 GL_SAMPLE_ALPHA_TO_ONE,
1299 GL_SAMPLE_COVERAGE,
1300 GL_SEPARABLE_2D,
1301 GL_SCISSOR_TEST,
1302 GL_STENCIL_TEST,
1303 GL_TEXTURE_1D,
1304 GL_TEXTURE_2D,
1305 GL_TEXTURE_3D,
1306 GL_TEXTURE_CUBE_MAP,
1307 GL_TEXTURE_GEN_Q,
1308 GL_TEXTURE_GEN_R,
1309 GL_TEXTURE_GEN_S,
1310 GL_TEXTURE_GEN_T,
1311 GL_VERTEX_PROGRAM_POINT_SIZE,
1312 GL_VERTEX_PROGRAM_TWO_SIDE,
1313 GL_COLOR_ARRAY,
1314 GL_EDGE_FLAG_ARRAY,
1315 GL_FOG_COORD_ARRAY,
1316 GL_INDEX_ARRAY,
1317 GL_NORMAL_ARRAY,
1318 GL_SECONDARY_COLOR_ARRAY,
1319 GL_TEXTURE_COORD_ARRAY,
1320 GL_VERTEX_ARRAY};
1321
1322 for (unsigned int i = 0; i < sizeof(caps) / sizeof(GLenum); ++i)
1323 {
1324 if (glIsEnabled(caps[i])) stateStack_.back().glStateEnabled_.set(caps[i]);
1325 else stateStack_.back().glStateEnabled_.reset(caps[i]);
1326 }
1327
1328 GLint getparam;
1329
1330 #ifdef GL_VERSION_1_4
1331 glGetIntegerv(GL_BLEND_SRC_RGB, &getparam);
1332 stateStack_.back().blendFuncState_[0] = getparam;
1333
1334 glGetIntegerv(GL_BLEND_DST_ALPHA, &getparam);
1335 stateStack_.back().blendFuncState_[1] = getparam;
1336
1337 glGetIntegerv(GL_BLEND_SRC_ALPHA, &getparam);
1338 stateStack_.back().blendFuncState_[2] = getparam;
1339
1340 glGetIntegerv(GL_BLEND_DST_ALPHA, &getparam);
1341 stateStack_.back().blendFuncState_[3] = getparam;
1342 #else
1343 glGetIntegerv(GL_BLEND_SRC, &getparam);
1344 stateStack_.back().blendFuncState_[0] = getparam;
1345
1346 glGetIntegerv(GL_BLEND_DST, &getparam);
1347 stateStack_.back().blendFuncState_[1] = getparam;
1348 #endif
1349
1350
1351 glGetIntegerv(GL_BLEND_EQUATION_RGB, &getparam);
1352 stateStack_.back().blendEquationState_ = getparam;
1353
1354 glGetFloatv(GL_BLEND_COLOR, stateStack_.back().blendColorState_);
1355
1356 glGetIntegerv(GL_ALPHA_TEST_FUNC, &getparam);
1357 stateStack_.back().alphaFuncState_ = getparam;
1358
1359 glGetFloatv(GL_ALPHA_TEST_REF, &stateStack_.back().alphaRefState_);
1360
1361 glGetIntegerv(GL_DEPTH_FUNC, &getparam);
1362 stateStack_.back().depthFunc_ = getparam;
1363
1364 glGetDoublev(GL_DEPTH_RANGE, stateStack_.back().depthRange_);
1365
1366 // bound buffers
1367
1368 GLenum bufGets[8] = {
1369 GL_ARRAY_BUFFER_BINDING, GL_ARRAY_BUFFER,
1370 GL_ELEMENT_ARRAY_BUFFER_BINDING, GL_ELEMENT_ARRAY_BUFFER,
1371 GL_PIXEL_PACK_BUFFER_BINDING, GL_PIXEL_PACK_BUFFER,
1372 GL_PIXEL_UNPACK_BUFFER_BINDING, GL_PIXEL_UNPACK_BUFFER};
1373
1374 for (int i = 0; i < 4; ++i)
1375 glGetIntegerv(bufGets[i*2], (GLint*)stateStack_.back().glBufferTargetState_ + getBufferTargetIndex(bufGets[i*2+1]));
1376
1377
1378 // bound textures
1379 glGetIntegerv(GL_ACTIVE_TEXTURE, &getparam);
1380 stateStack_.back().activeTexture_ = getparam;
1381
1382 GLenum texBufGets[] = {
1383 GL_TEXTURE_BINDING_1D, GL_TEXTURE_1D,
1384 GL_TEXTURE_BINDING_2D, GL_TEXTURE_2D,
1385 GL_TEXTURE_BINDING_3D, GL_TEXTURE_3D,
1386 GL_TEXTURE_BINDING_CUBE_MAP, GL_TEXTURE_CUBE_MAP
1387 , GL_TEXTURE_BINDING_RECTANGLE_ARB, GL_TEXTURE_RECTANGLE_ARB
1388 };
1389
1390 glGetIntegerv(GL_MAX_TEXTURE_COORDS, &maxTextureCoords_);
1391 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxCombinedTextureImageUnits_);
1392
1393 // safe clamp
1394 if (maxTextureCoords_ > 16) maxTextureCoords_ = 16;
1395 if (maxCombinedTextureImageUnits_ > 16) maxCombinedTextureImageUnits_ = 16;
1396
1397 int numTexUnits = maxTextureCoords_;
1398 if (numTexUnits < maxCombinedTextureImageUnits_) numTexUnits = maxCombinedTextureImageUnits_;
1399
1400 for (int i = 0; i < numTexUnits; ++i)
1401 {
1402 glActiveTexture(GL_TEXTURE0 + i);
1403
1404 getparam = 0;
1405 // for each texture stage query 5 texture types: 1D, 2D, 3D, Cube, Rect
1406 for (int k = 0; k < 5 && !getparam; ++k)
1407 {
1408 glGetIntegerv(texBufGets[k*2], &getparam);
1409 if (getparam)
1410 {
1411 stateStack_.back().glTextureStage_[i].buf_ = getparam;
1412 stateStack_.back().glTextureStage_[i].target_ = texBufGets[k*2+1];
1413 }
1414 }
1415 }
1416
1417 // restore active texture unit
1418 if (numTexUnits > 0)
1419 glActiveTexture(stateStack_.back().activeTexture_);
1420
1421
1422 // shade model
1423 glGetIntegerv(GL_SHADE_MODEL, &getparam);
1424 stateStack_.back().shadeModel_ = getparam;
1425
1426 // cull face
1427 glGetIntegerv(GL_CULL_FACE_MODE, &getparam);
1428 stateStack_.back().cullFace_ = getparam;
1429
1430
1431 // vertex pointers
1432 {
1433 GLenum ptrEnums[] = {
1434 GL_VERTEX_ARRAY_SIZE, GL_VERTEX_ARRAY_TYPE,
1435 GL_VERTEX_ARRAY_STRIDE, GL_VERTEX_ARRAY_POINTER,
1436 GL_COLOR_ARRAY_SIZE, GL_COLOR_ARRAY_TYPE,
1437 GL_COLOR_ARRAY_STRIDE, GL_COLOR_ARRAY_POINTER,
1438 GL_TEXTURE_COORD_ARRAY_SIZE, GL_TEXTURE_COORD_ARRAY_TYPE,
1439 GL_TEXTURE_COORD_ARRAY_STRIDE, GL_TEXTURE_COORD_ARRAY_POINTER};
1440
1441 GLStateContext::GLVertexPointer* ptrs[] = {&stateStack_.back().vertexPointer_,
1442 &stateStack_.back().colorPointer_, &stateStack_.back().texcoordPointer_};
1443
1444 for (int i = 0; i < 3 ; ++i)
1445 {
1446 glGetIntegerv(ptrEnums[i*4], &getparam);
1447 ptrs[i]->size = getparam;
1448 glGetIntegerv(ptrEnums[i*4+1], &getparam);
1449 ptrs[i]->type = getparam;
1450 glGetIntegerv(ptrEnums[i*4+2], &getparam);
1451 ptrs[i]->stride = getparam;
1452 glGetPointerv(ptrEnums[i*4+3], (GLvoid**)&ptrs[i]->pointer);
1453 }
1454
1455 glGetIntegerv(GL_NORMAL_ARRAY_STRIDE, &getparam);
1456 stateStack_.back().normalPointer_.size = getparam;
1457 glGetIntegerv(GL_NORMAL_ARRAY_TYPE, &getparam);
1458 stateStack_.back().normalPointer_.type = getparam;
1459 glGetPointerv(GL_NORMAL_ARRAY_POINTER, (GLvoid**)&stateStack_.back().normalPointer_.pointer);
1460 }
1461
1462
1463 // draw buffer state
1464 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers_);
1465 if (maxDrawBuffers_ > 16) maxDrawBuffers_ = 16;
1466
1467 for (int i = 0; i < maxDrawBuffers_; ++i)
1468 {
1469 glGetIntegerv(GL_DRAW_BUFFER0 + i, &getparam);
1470 stateStack_.back().drawBufferState_[i] = getparam;
1471 }
1472
1473 glGetIntegerv(GL_DRAW_BUFFER, &getparam);
1474 stateStack_.back().drawBufferSingle_ = getparam;
1475
1476 // framebuffer
1477 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &getparam);
1478 stateStack_.back().framebuffers_[0] = getparam;
1479 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &getparam);
1480 stateStack_.back().framebuffers_[1] = getparam;
1481
1482 // shader program
1483 glGetIntegerv(GL_CURRENT_PROGRAM, &getparam);
1484 stateStack_.back().program_ = getparam;
1485 }
1486
1487 //-----------------------------------------------------------------------------
1488
1489
1490 void GLState::enable(GLenum _cap)
1491 {
1492 if (!glStateLock_.test(_cap))
1493 {
1494 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1495 if (!stateStack_.back().glStateEnabled_.test(_cap))
1496 #endif
1497 {
1498 glEnable(_cap);
1499 stateStack_.back().glStateEnabled_.set(_cap);
1500 }
1501 }
1502 }
1503
1504 void GLState::disable(GLenum _cap)
1505 {
1506 if (!glStateLock_.test(_cap))
1507 {
1508 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1509 if (stateStack_.back().glStateEnabled_.test(_cap))
1510 #endif
1511 {
1512 glDisable(_cap);
1513 stateStack_.back().glStateEnabled_.reset(_cap);
1514 }
1515 }
1516 }
1517
1518 void GLState::lockState(GLenum _cap)
1519 {
1520 glStateLock_.set(_cap);
1521 }
1522
1523 void GLState::unlockState(GLenum _cap)
1524 {
1525 glStateLock_.reset(_cap);
1526 }
1527
1528 bool GLState::isStateLocked(GLenum _cap)
1529 {
1530 return glStateLock_.test(_cap);
1531 }
1532
1533 bool GLState::isStateEnabled(GLenum _cap)
1534 {
1535 return stateStack_.back().glStateEnabled_.test(_cap);
1536 }
1537
1538 //-----------------------------------------------------------------------------
1539 // client state functions
1540
1541 void GLState::enableClientState(GLenum _cap)
1542 {
1543 if (!glStateLock_.test(_cap))
1544 {
1545 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1546 if (!stateStack_.back().glStateEnabled_.test(_cap))
1547 #endif
1548 {
1549 glEnableClientState(_cap);
1550 stateStack_.back().glStateEnabled_.set(_cap);
1551 }
1552 }
1553 }
1554
1555 void GLState::disableClientState(GLenum _cap)
1556 {
1557 if (!glStateLock_.test(_cap))
1558 {
1559 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1560 if (stateStack_.back().glStateEnabled_.test(_cap))
1561 #endif
1562 {
1563 glDisableClientState(_cap);
1564 stateStack_.back().glStateEnabled_.reset(_cap);
1565 }
1566 }
1567 }
1568
1569 void GLState::lockClientState(GLenum _cap)
1570 {
1571 glStateLock_.set(_cap);
1572 }
1573
1574 void GLState::unlockClientState(GLenum _cap)
1575 {
1576 glStateLock_.reset(_cap);
1577 }
1578
1579 bool GLState::isClientStateLocked(GLenum _cap)
1580 {
1581 return glStateLock_.test(_cap);
1582 }
1583
1584 bool GLState::isClientStateEnabled(GLenum _cap)
1585 {
1586 return stateStack_.back().glStateEnabled_.test(_cap);
1587 }
1588
1589 //-----------------------------------------------------------------------------
1590 // blending functions
1591
1592 void GLState::blendFuncSeparate(GLenum _srcRGB, GLenum _dstRGB, GLenum _srcAlpha, GLenum _dstAlpha)
1593 {
1594 // fix parameters according to lock status
1595 if (blendFuncSeparateLock_[0])
1596 {
1597 _srcRGB = stateStack_.back().blendFuncState_[0];
1598 _dstRGB = stateStack_.back().blendFuncState_[1];
1599 }
1600
1601 if (blendFuncSeparateLock_[1])
1602 {
1603 _srcAlpha = stateStack_.back().blendFuncState_[2];
1604 _dstAlpha = stateStack_.back().blendFuncState_[3];
1605 }
1606
1607 if (!blendFuncSeparateLock_[0] || !blendFuncSeparateLock_[1])
1608 {
1609 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1610 if (stateStack_.back().blendFuncState_[0] != _srcRGB || stateStack_.back().blendFuncState_[1] != _dstRGB ||
1611 stateStack_.back().blendFuncState_[2] != _srcAlpha || stateStack_.back().blendFuncState_[3] != _dstAlpha)
1612 #endif
1613 {
1614 #ifdef GL_VERSION_1_4
1615 // check if glew has loaded glBlendFuncSeparate already
1616 if (glBlendFuncSeparate)
1617 glBlendFuncSeparate(_srcRGB, _dstRGB, _srcAlpha, _dstAlpha);
1618 else
1619 glBlendFunc(_srcRGB, _dstRGB);
1620 stateStack_.back().blendFuncState_[0] = _srcRGB;
1621 stateStack_.back().blendFuncState_[1] = _dstRGB;
1622 stateStack_.back().blendFuncState_[2] = _srcAlpha;
1623 stateStack_.back().blendFuncState_[3] = _dstAlpha;
1624 #else
1625 glBlendFunc(_srcRGB, _dstRGB);
1626 stateStack_.back().blendFuncState_[0] = _srcRGB;
1627 stateStack_.back().blendFuncState_[1] = _dstRGB;
1628 stateStack_.back().blendFuncState_[2] = _srcRGB;
1629 stateStack_.back().blendFuncState_[3] = _dstRGB;
1630 #endif
1631 }
1632 }
1633 }
1634
1635 void GLState::getBlendFuncSeparate(GLenum* _srcRGB, GLenum* _dstRGB, GLenum* _srcAlpha, GLenum* _dstAlpha)
1636 {
1637 if (_srcRGB) *_srcRGB = stateStack_.back().blendFuncState_[0];
1638 if (_dstRGB) *_dstRGB = stateStack_.back().blendFuncState_[1];
1639 if (_srcAlpha) *_srcAlpha = stateStack_.back().blendFuncState_[2];
1640 if (_dstAlpha) *_dstAlpha = stateStack_.back().blendFuncState_[3];
1641 }
1642
1643 void GLState::blendEquation(GLenum _mode)
1644 {
1645 if (!blendEquationLock_)
1646 {
1647 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1648 if (stateStack_.back().blendEquationState_ != _mode)
1649 #endif
1650 {
1651 glBlendEquation(_mode);
1652 stateStack_.back().blendEquationState_ = _mode;
1653 }
1654 }
1655 }
1656
1657 void GLState::blendColor(GLclampf _red, GLclampf _green, GLclampf _blue, GLclampf _alpha)
1658 {
1659 if (!blendColorLock_)
1660 {
1661 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1662 if (stateStack_.back().blendColorState_[0] != _red || stateStack_.back().blendColorState_[1] != _green ||
1663 stateStack_.back().blendColorState_[2] != _blue || stateStack_.back().blendColorState_[3] != _alpha)
1664 #endif
1665 {
1666 glBlendColor(_red, _green, _blue, _alpha);
1667 stateStack_.back().blendColorState_[0] = _red; stateStack_.back().blendColorState_[1] = _green;
1668 stateStack_.back().blendColorState_[2] = _blue; stateStack_.back().blendColorState_[3] = _alpha;
1669 }
1670 }
1671 }
1672
1673 void GLState::getBlendColor(GLclampf* _col)
1674 {
1675 for (int i = 0; i < 4; ++i) _col[i] = stateStack_.back().blendColorState_[i];
1676 }
1677
1678
1679 void GLState::alphaFunc(GLenum _func, GLclampf _ref)
1680 {
1681 if (!alphaFuncLock_)
1682 {
1683 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1684 if (stateStack_.back().alphaFuncState_ != _func || stateStack_.back().alphaRefState_ != _ref)
1685 #endif
1686 {
1687 glAlphaFunc(_func, _ref);
1688 stateStack_.back().alphaFuncState_ = _func;
1689 stateStack_.back().alphaRefState_ = _ref;
1690 }
1691 }
1692 }
1693
1694 void GLState::getAlphaFunc(GLenum* _func, GLclampf* _ref)
1695 {
1696 if (_func) *_func = stateStack_.back().alphaFuncState_;
1697 if (_ref) *_ref = stateStack_.back().alphaRefState_;
1698 }
1699
1700 void GLState::shadeModel(GLenum _mode)
1701 {
1702 if (!shadeModelLock_)
1703 {
1704 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1705 if (stateStack_.back().shadeModel_ != _mode)
1706 #endif
1707 {
1708 glShadeModel(_mode);
1709 stateStack_.back().shadeModel_ = _mode;
1710 }
1711 }
1712 }
1713
1714 void GLState::cullFace(GLenum _mode)
1715 {
1716 if (!cullFaceLock_)
1717 {
1718 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1719 if (stateStack_.back().cullFace_ != _mode)
1720 #endif
1721 {
1722 glCullFace(_mode);
1723 stateStack_.back().cullFace_ = _mode;
1724 }
1725 }
1726 }
1727
1728 void GLState::depthRange(GLclampd _zNear, GLclampd _zFar)
1729 {
1730 if (!depthRangeLock_)
1731 {
1732 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1733 if (abs(_zNear - stateStack_.back().depthRange_[0]) > 1e-6 ||
1734 abs(_zFar - stateStack_.back().depthRange_[1]) > 1e-6)
1735 #endif
1736 {
1737 glDepthRange(_zNear, _zFar);
1738 stateStack_.back().depthRange_[0] = _zNear;
1739 stateStack_.back().depthRange_[1] = _zFar;
1740 }
1741 }
1742 }
1743
1744 void GLState::getDepthRange(GLclampd* _zNearOut, GLclampd* _zFarOut)
1745 {
1746 if (_zNearOut) *_zNearOut = stateStack_.back().depthRange_[0];
1747 if (_zFarOut) *_zFarOut = stateStack_.back().depthRange_[1];
1748 }
1749
1750 //-----------------------------------------------------------------------------
1751
1752 int GLState::getBufferTargetIndex(GLenum _target)
1753 {
1754 switch (_target)
1755 {
1756 case GL_ARRAY_BUFFER: return 0;
1757 case GL_ELEMENT_ARRAY_BUFFER: return 1;
1758 case GL_PIXEL_PACK_BUFFER: return 2;
1759 case GL_PIXEL_UNPACK_BUFFER: return 3;
1760 }
1761 return -1;
1762 }
1763
1764 void GLState::bindBuffer(GLenum _target, GLuint _buffer)
1765 {
1766 int idx = getBufferTargetIndex(_target);
1767 if (idx >= 0 && !glBufferTargetLock_[idx])
1768 {
1769 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1770 if (stateStack_.back().glBufferTargetState_[idx] != _buffer)
1771 #endif
1772 {
1773 glBindBufferARB(_target, _buffer);
1774 stateStack_.back().glBufferTargetState_[idx] = _buffer;
1775 }
1776 }
1777 }
1778
1779 void GLState::lockBufferTarget(GLenum _target)
1780 {
1781 glBufferTargetLock_[getBufferTargetIndex(_target)] = 1;
1782 }
1783
1784 void GLState::unlockBufferTarget(GLenum _target)
1785 {
1786 glBufferTargetLock_[getBufferTargetIndex(_target)] = 0;
1787 }
1788
1789 bool GLState::isBufferTargetLocked(GLenum _target)
1790 {
1791 return glBufferTargetLock_[getBufferTargetIndex(_target)] != 0;
1792 }
1793
1794 GLuint GLState::getBoundBuf(GLenum _target)
1795 {
1796 return stateStack_.back().glBufferTargetState_[getBufferTargetIndex(_target)];
1797 }
1798
1799 //-----------------------------------------------------------------------------
1800
1801 void GLState::activeTexture(GLenum _texunit)
1802 {
1803 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1804 if (stateStack_.back().activeTexture_ != _texunit)
1805 #endif
1806 {
1807 glActiveTexture(_texunit);
1808 stateStack_.back().activeTexture_ = _texunit;
1809 }
1810 }
1811
1812 void GLState::bindTexture(GLenum _target, GLuint _buffer)
1813 {
1814 int activeTex = getActiveTextureIndex();
1815
1816 assert(activeTex >= 0);
1817
1818 GLStateContext::TextureStage* stage = stateStack_.back().glTextureStage_ + activeTex;
1819
1820 if (!glTextureStageLock_[activeTex])
1821 {
1822 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1823 if (_buffer != stage->buf_ || _target != stage->target_)
1824 #endif
1825 {
1826 glBindTexture(_target, _buffer);
1827
1828 stage->target_ = _target;
1829 stage->buf_ = _buffer;
1830 }
1831 }
1832 }
1833
1834 void GLState::lockTextureStage()
1835 {
1836 glTextureStageLock_[getActiveTextureIndex()] = 1;
1837 }
1838
1839 void GLState::unlockTextureStage()
1840 {
1841 glTextureStageLock_[getActiveTextureIndex()] = 0;
1842 }
1843
1844 bool GLState::isTextureTargetLocked()
1845 {
1846 return glTextureStageLock_[getActiveTextureIndex()] != 0;
1847 }
1848
1849 GLuint GLState::getBoundTextureBuffer()
1850 {
1851 return stateStack_.back().glTextureStage_[getActiveTextureIndex()].buf_;
1852 }
1853
1854 GLenum GLState::getBoundTextureTarget()
1855 {
1856 return stateStack_.back().glTextureStage_[getActiveTextureIndex()].target_;
1857 }
1858
1859 //----------------------------------------------------------
1860 // vertex pointers
1861
1862 void GLState::vertexPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid* _pointer)
1863 {
1864 if (!vertexPointerLock_)
1865 {
1866 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1867 if (!stateStack_.back().vertexPointer_.equals(_size, _type, _stride, _pointer))
1868 #endif
1869 {
1870 glVertexPointer(_size, _type, _stride, _pointer);
1871 stateStack_.back().vertexPointer_.set(_size, _type, _stride, _pointer);
1872 }
1873 }
1874 }
1875
1876 void GLState::getVertexPointer(GLint* _size, GLenum* _type, GLsizei* _stride, const GLvoid** _pointer)
1877 {
1878 if (_size) *_size = stateStack_.back().vertexPointer_.size;
1879 if (_stride) *_stride = stateStack_.back().vertexPointer_.stride;
1880 if (_type) *_type = stateStack_.back().vertexPointer_.type;
1881 if (_pointer) *_pointer = stateStack_.back().vertexPointer_.pointer;
1882 }
1883
1884 void GLState::normalPointer(GLenum _type, GLsizei _stride, const GLvoid* _pointer)
1885 {
1886 if (!normalPointerLock_)
1887 {
1888 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1889 if (!stateStack_.back().normalPointer_.equals(stateStack_.back().normalPointer_.size, _type, _stride, _pointer))
1890 #endif
1891 {
1892 glNormalPointer(_type, _stride, _pointer);
1893 stateStack_.back().normalPointer_.set(3, _type, _stride, _pointer);
1894 }
1895 }
1896 }
1897
1898 void GLState::getNormalPointer(GLenum* _type, GLsizei* _stride, const GLvoid** _pointer)
1899 {
1900 if (_type) *_type = stateStack_.back().normalPointer_.type;
1901 if (_stride) *_stride = stateStack_.back().normalPointer_.stride;
1902 if (_pointer) *_pointer = stateStack_.back().normalPointer_.pointer;
1903 }
1904
1905
1906 void GLState::colorPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid* _pointer)
1907 {
1908 if (!colorPointerLock_)
1909 {
1910 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1911 if (!stateStack_.back().colorPointer_.equals(_size, _type, _stride, _pointer))
1912 #endif
1913 {
1914 glColorPointer(_size, _type, _stride, _pointer);
1915 stateStack_.back().colorPointer_.set(_size, _type, _stride, _pointer);
1916 }
1917 }
1918 }
1919
1920 void GLState::getColorPointer(GLint* _size, GLenum* _type, GLsizei* _stride, const GLvoid** _pointer)
1921 {
1922 if (_size) *_size = stateStack_.back().colorPointer_.size;
1923 if (_stride) *_stride = stateStack_.back().colorPointer_.stride;
1924 if (_type) *_type = stateStack_.back().colorPointer_.type;
1925 if (_pointer) *_pointer = stateStack_.back().colorPointer_.pointer;
1926 }
1927
1928 void GLState::texcoordPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid* _pointer)
1929 {
1930 if (!texcoordPointerLock_)
1931 {
1932 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1933 if (!stateStack_.back().texcoordPointer_.equals(_size, _type, _stride, _pointer))
1934 #endif
1935 {
1936 glTexCoordPointer(_size, _type, _stride, _pointer);
1937 stateStack_.back().texcoordPointer_.set(_size, _type, _stride, _pointer);
1938 }
1939 }
1940 }
1941
1942 void GLState::getTexcoordPointer(GLint* _size, GLenum* _type, GLsizei* _stride, const GLvoid** _pointer)
1943 {
1944 if (_size) *_size = stateStack_.back().texcoordPointer_.size;
1945 if (_stride) *_stride = stateStack_.back().texcoordPointer_.stride;
1946 if (_type) *_type = stateStack_.back().texcoordPointer_.type;
1947 if (_pointer) *_pointer = stateStack_.back().texcoordPointer_.pointer;
1948 }
1949
1950 //---------------------------------------------------------------------
1951 // draw buffer functions
1952
1953 void GLState::drawBuffer(GLenum _mode)
1954 {
1955 if (!drawBufferLock_)
1956 {
1957 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1958 if (stateStack_.back().drawBufferSingle_ != _mode || stateStack_.back().activeDrawBuffer_)
1959 #endif
1960 {
1961 glDrawBuffer(_mode);
1962 stateStack_.back().drawBufferSingle_ = _mode;
1963 stateStack_.back().activeDrawBuffer_ = 0;
1964 }
1965 }
1966 }
1967
1968 void GLState::drawBuffers(GLsizei _n, const GLenum* _bufs)
1969 {
1970 if (!drawBufferLock_)
1971 {
1972 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
1973 int bChange = !stateStack_.back().activeDrawBuffer_;
1974 for (int i = 0; i < _n && (!bChange); ++i)
1975 {
1976 if (stateStack_.back().drawBufferState_[i] != _bufs[i])
1977 bChange = 1;
1978 }
1979
1980 if (bChange)
1981 #endif
1982 {
1983 glDrawBuffers(_n, _bufs);
1984
1985 for (int i = 0; i < _n; ++i)
1986 stateStack_.back().drawBufferState_[i] = _bufs[i];
1987
1988 stateStack_.back().activeDrawBuffer_ = _n;
1989 }
1990 }
1991 }
1992
1994 GLuint GLState::getFramebufferDraw()
1995 {
1996 GLint curfbo;
1997 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&curfbo);
1998 return curfbo;
1999 }
2000
2002 GLuint GLState::getFramebufferRead()
2003 {
2004 GLint curfbo;
2005 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (GLint*)&curfbo);
2006 return curfbo;
2007 }
2008
2009 void GLState::bindFramebuffer(GLenum _target, GLuint _framebuffer)
2010 {
2011 int i = -1;
2012 switch (_target)
2013 {
2014 case GL_FRAMEBUFFER:
2015 {
2016 bindFramebuffer(GL_READ_FRAMEBUFFER, _framebuffer);
2017 bindFramebuffer(GL_DRAW_FRAMEBUFFER, _framebuffer);
2018 return;
2019 }
2020 case GL_DRAW_FRAMEBUFFER: i = 0; break;
2021 case GL_READ_FRAMEBUFFER: i = 1; break;
2022 }
2023
2024 if (i >= 0 && !framebufferLock_[i])
2025 {
2026 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
2027 if (stateStack_.back().framebuffers_[i] != _framebuffer)
2028 #endif
2029 {
2030 glBindFramebufferEXT(_target, _framebuffer);
2031 stateStack_.back().framebuffers_[i] = _framebuffer;
2032 }
2033 }
2034 }
2035
2036 void GLState::lockFramebuffer(GLenum _target)
2037 {
2038 switch (_target)
2039 {
2040 case GL_FRAMEBUFFER:
2041 framebufferLock_[0] = framebufferLock_[1] = true; break;
2042
2043 case GL_DRAW_FRAMEBUFFER: framebufferLock_[0] = true; break;
2044 case GL_READ_FRAMEBUFFER: framebufferLock_[1] = true; break;
2045 }
2046 }
2047
2048 void GLState::unlockFramebuffer(GLenum _target)
2049 {
2050 switch (_target)
2051 {
2052 case GL_FRAMEBUFFER:
2053 framebufferLock_[0] = framebufferLock_[1] = false; break;
2054
2055 case GL_DRAW_FRAMEBUFFER: framebufferLock_[0] = false; break;
2056 case GL_READ_FRAMEBUFFER: framebufferLock_[1] = false; break;
2057 }
2058 }
2059
2060 bool GLState::isFramebufferLocked(GLenum _target)
2061 {
2062 switch (_target)
2063 {
2064 case GL_FRAMEBUFFER:
2065 return framebufferLock_[0] && framebufferLock_[1];
2066
2067 case GL_DRAW_FRAMEBUFFER: return framebufferLock_[0];
2068 case GL_READ_FRAMEBUFFER: return framebufferLock_[1];
2069 }
2070 return false;
2071 }
2072
2073 void GLState::useProgram(GLuint _program)
2074 {
2075 if (!programLock_)
2076 {
2077 #ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
2078 if (stateStack_.back().program_ != _program)
2079 #endif
2080 {
2081 glUseProgram(_program);
2082 stateStack_.back().program_ = _program;
2083 }
2084 }
2085 }
2086
2087 void GLState::genBuffersARB(GLsizei n, GLuint* buffers) {
2088 glGenBuffersARB(n, buffers);
2089 }
2090
2091 void GLState::genBuffers(GLsizei n, GLuint* buffers) {
2092 glGenBuffers(n, buffers);
2093 }
2094
2095 void GLState::bufferDataARB(
2096 GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage) {
2097 glBufferDataARB(target, size, data, usage);
2098 }
2099
2100 void GLState::bufferData(
2101 GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) {
2102 glBufferData(target, size, data, usage);
2103 }
2104
2105 void GLState::deleteBuffers(GLsizei n, const GLuint* buffers) {
2106 glDeleteBuffers(n, buffers);
2107 }
2108
2109 GLvoid* GLState::mapBuffer (GLenum target, GLenum access) {
2110 return glMapBuffer(target, access);
2111 }
2112
2113
2114 GLboolean GLState::unmapBuffer (GLenum target) {
2115 return glUnmapBuffer(target);
2116 }
2117
2118
2119 //---------------------------------------------------------------------
2120
2121
2122
2123
2124 //=============================================================================
2125 } // namespace ACG
2126 //=============================================================================
ACG::GLState::alphaFunc
static void alphaFunc(GLenum _func, GLclampf _ref)
replaces glAlphaFunc, supports locking
Definition: GLState.cc:1679
ACG::GLState::scale
void scale(double _s)
scale by (_s, _s, _s)
Definition: GLState.hh:753
ACG::GLState::bindFramebuffer
static void bindFramebuffer(GLenum _target, GLuint _framebuffer)
replaces glBindFramebuffer, supports locking
Definition: GLState.cc:2009
ACG::GLState::right
Vec3d right() const
get right-vector w.r.t. camera coordinates
Definition: GLState.cc:914
ACG::GLState::getActiveTextureIndex
static int getActiveTextureIndex()
get active texture as zero based index
Definition: GLState.hh:662
ACG::GLStateContext::TextureStage
Definition: GLState.hh:158
ACG::GLState::lookAt
void lookAt(const Vec3d &_eye, const Vec3d &_center, const Vec3d &_up)
set camera by lookAt
Definition: GLState.cc:513
ACG::ColorStack::popIndex
void popIndex()
pops the current node from the stack (like glPopName)
Definition: ColorStack.cc:155
ACG::GLState::getBlendFuncSeparate
static void getBlendFuncSeparate(GLenum *_srcRGB, GLenum *_dstRGB, GLenum *_srcAlpha, GLenum *_dstAlpha)
get blend function, null-ptr safe
Definition: GLState.cc:1635
ACG::ColorStack::pushIndex
void pushIndex(unsigned int _idx)
creates a new node the stack (like glPushName)
Definition: ColorStack.cc:147
ACG::GLState::enable
static void enable(GLenum _cap)
replaces glEnable, but supports locking
Definition: GLState.cc:1490
ACG::GLState::default_clear_color
static const Vec4f default_clear_color
default value for clear color
Definition: GLState.hh:900
ACG::GLState::default_ambient_color
static const Vec4f default_ambient_color
default value for ambient color
Definition: GLState.hh:904
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
ACG::GLState::drawBuffers
static void drawBuffers(GLsizei _n, const GLenum *_bufs)
replaces glDrawBuffers, supports locking
Definition: GLState.cc:1968
ACG::GLState::getColorPointer
static void getColorPointer(GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get color pointer, null-ptr safe
Definition: GLState.cc:1920
ACG::GLState::pick_set_name
void pick_set_name(unsigned int _idx)
sets the current name/color (like glLoadName(_idx))
Definition: GLState.cc:1057
ACG::GLState::bindBuffer
static void bindBuffer(GLenum _target, GLuint _buffer)
replaces glBindBuffer, supports locking
Definition: GLState.cc:1764
ACG::MultiplyFrom
MultiplyFrom
Definition: GLMatrixT.hh:79
ACG::GLState::unlockState
static void unlockState(GLenum _cap)
unlocks a specific cap state
Definition: GLState.cc:1523
ACG::GLState::getBlendColor
static void getBlendColor(GLclampf *_col)
get blend color, not null-ptr safe, 4 element color output: RGBA
Definition: GLState.cc:1673
ACG::GLState::initialize
void initialize()
initialize all state variables (called by constructor)
Definition: GLState.cc:162
ACG::GLState::unlockTextureStage
static void unlockTextureStage()
unlocks the current texture target
Definition: GLState.cc:1839
ACG::GLState::getVertexPointer
static void getVertexPointer(GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get vertex pointer, null-ptr safe
Definition: GLState.cc:1876
ACG::GLState::isTextureTargetLocked
static bool isTextureTargetLocked()
get texture target locking state
Definition: GLState.cc:1844
ACG::GLState::pick_set_maximum
bool pick_set_maximum(unsigned int _idx)
Set the maximal number of primitives/components of your object.
Definition: GLState.cc:1047
ACG::GLMatrixT::inverse_lookAt
void inverse_lookAt(const Vec3 &eye, const Vec3 &center, const Vec3 &up)
multiply self from left with inverse lookAt matrix
Definition: GLMatrixT.cc:253
ACG::GLState::aspect
double aspect() const
get aspect ratio
Definition: GLState.cc:873
ACG::GLState::bufferDataARB
static void bufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage)
Definition: GLState.cc:2095
ACG::GLMatrixT::inverse_perspective
void inverse_perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self from left with inverse of perspective projection matrix
Definition: GLMatrixT.cc:300
ACG::GLState::pick_get_name_color
Vec4uc pick_get_name_color(unsigned int _idx)
Definition: GLState.cc:1064
ACG::GLState::blendFuncSeparate
static void blendFuncSeparate(GLenum _srcRGB, GLenum _dstRGB, GLenum _srcAlpha, GLenum _dstAlpha)
replaces glBlendFuncSeparate, supports locking
Definition: GLState.cc:1592
ACG::GLState::translate
void translate(double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
translate by (_x, _y, _z)
Definition: GLState.cc:531
ACG::GLState::unproject
Vec3d unproject(const Vec3d &_winPoint) const
unproject point in window coordinates _winPoint to world coordinates
Definition: GLState.cc:649
ACG::GLState::bindTexture
static void bindTexture(GLenum _target, GLuint _buffer)
replaces glBindTexture, supports locking
Definition: GLState.cc:1812
ACG::ColorStack::colorToStack
std::vector< unsigned int > colorToStack(Vec4uc _rgba) const
converts the given color to index values on the stack
Definition: ColorStack.cc:163
ACG::GLState::set_depthFunc
void set_depthFunc(const GLenum &_depth_func)
Call glDepthFunc() to actually change the depth comparison function, and store the new value in this ...
Definition: GLState.cc:944
ACG::GLState::colorPointer
static void colorPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glColorPointer, supports locking
Definition: GLState.cc:1906
ACG::GLState::rotate
void rotate(double _angle, double _x, double _y, double _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
rotate around axis (_x, _y, _z) by _angle
Definition: GLState.cc:562
ACG::GLState::set_bounding_box
void set_bounding_box(ACG::Vec3d _min, ACG::Vec3d _max)
Definition: GLState.cc:802
ACG::GLState::getBoundBuf
static GLuint getBoundBuf(GLenum _target)
get currently bound buffer
Definition: GLState.cc:1794
ACG::GLState::set_ambient_color
void set_ambient_color(const Vec4f &_col)
set ambient color
Definition: GLState.cc:705
ACG::GLState::lockState
static void lockState(GLenum _cap)
locks a specific cap state, such that enable() or disable() has no effect
Definition: GLState.cc:1518
ACG::GLState::frustum
void frustum(double _left, double _right, double _bottom, double _top, double _near_plane, double _far_plane)
perspective projection
Definition: GLState.cc:423
ACG::GLState::unmapBuffer
static GLboolean unmapBuffer(GLenum target)
Definition: GLState.cc:2114
ACG::ColorStack::initialized
bool initialized() const
has it been initialized?
Definition: ColorStack.hh:95
ACG::GLState::depthRange
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
Definition: GLState.cc:1728
ACG::Vec3d
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:127
ACG::GLState::pick_free_indicies
unsigned int pick_free_indicies() const
returns the number of still available colors during color picking
Definition: GLState.cc:1096
ACG::GLState::mapBuffer
static GLvoid * mapBuffer(GLenum target, GLenum access)
Definition: GLState.cc:2109
ACG::GLState::syncFromGL
static void syncFromGL()
synchronize this class with the OpenGL state machine
Definition: GLState.cc:1227
ACG::GLState::lockFramebuffer
static void lockFramebuffer(GLenum _target)
lock a framebuffer target
Definition: GLState.cc:2036
ACG::GLState::set_diffuse_color
void set_diffuse_color(const Vec4f &_col)
set diffuse color
Definition: GLState.cc:720
ACG::glColor
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
Definition: gl.hh:146
ACG::GLState::clearBuffers
void clearBuffers()
clear buffers viewport rectangle
Definition: GLState.cc:266
ACG::ColorStack::getIndexColor
Vec4uc getIndexColor(unsigned int _idx)
gets the color instead of setting it directly
Definition: ColorStack.cc:131
ACG::GLState::getAlphaFunc
static void getAlphaFunc(GLenum *_func, GLclampf *_ref)
get alpha function, null-ptr safe
Definition: GLState.cc:1694
ACG::GLState::push_modelview_matrix
void push_modelview_matrix()
push modelview matrix
Definition: GLState.cc:1006
ACG::GLState::enableClientState
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
Definition: GLState.cc:1541
ACG::GLState::lockClientState
static void lockClientState(GLenum _cap)
locks a client state
Definition: GLState.cc:1569
ACG::GLState::activeTexture
static void activeTexture(GLenum _texunit)
replaces glActiveTexture, no locking support
Definition: GLState.cc:1801
ACG::GLState::makeCurrent
void makeCurrent()
does nothing
Definition: GLState.hh:231
ACG::GLState::genBuffersARB
static void genBuffersARB(GLsizei n, GLuint *buffers)
Definition: GLState.cc:2087
ACG::GLState::drawBuffer
static void drawBuffer(GLenum _mode)
replaces glDrawBuffer, supports locking
Definition: GLState.cc:1953
ACG::GLMatrixT::inverse_ortho
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
Definition: GLMatrixT.cc:414
ACG::GLState::default_diffuse_color
static const Vec4f default_diffuse_color
default value for diffuse color
Definition: GLState.hh:906
ACG::GLMatrixT::translate
void translate(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with translation matrix (x,y,z)
Definition: GLMatrixT.cc:102
ACG::GLMatrixT< double >
ACG::GLState::reset_modelview
void reset_modelview()
reset modelview matrix (load identity)
Definition: GLState.cc:368
ACG::GLState::pop_projection_matrix
void pop_projection_matrix()
pop projection matrix
Definition: GLState.cc:985
ACG::GLMatrixT::scale
void scale(Scalar _x, Scalar _y, Scalar _z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply self with scaling matrix (x,y,z)
Definition: GLMatrixT.cc:81
ACG::GLState::reset_projection
void reset_projection()
reset projection matrix (load identity)
Definition: GLState.cc:332
ACG::GLState::mult_matrix
void mult_matrix(const GLMatrixd &_m, const GLMatrixd &_inv_m, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
multiply by a given transformation matrix
Definition: GLState.cc:612
ACG::GLState::shadeModel
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
Definition: GLState.cc:1700
ACG::ColorStack::freeIndicies
unsigned int freeIndicies() const
returns maximal available index count
Definition: ColorStack.cc:177
ACG::GLState::bb_max_
ACG::Vec3d bb_max_
Definition: GLState.hh:1028
ACG::GLState::pick_current_index
unsigned int pick_current_index() const
Returns the current color picking index (can be used for caching)
Definition: GLState.cc:1114
ACG::GLState::set_twosided_lighting
void set_twosided_lighting(bool _b)
set whether transparent or solid objects should be drawn
Definition: GLState.cc:818
ACG::GLState::set_color
void set_color(const Vec4f &_col)
set color
Definition: GLState.cc:689
ACG::GLState::lockTextureStage
static void lockTextureStage()
locks the current texture stage (set by setActiveTexture)
Definition: GLState.cc:1834
ACG::GLState::default_base_color
static const Vec4f default_base_color
default value for base color
Definition: GLState.hh:902
ACG::GLState::blendEquation
static void blendEquation(GLenum _mode)
replaces glBlendEquation, supports locking
Definition: GLState.cc:1643
ACG::GLState::isClientStateEnabled
static bool isClientStateEnabled(GLenum _cap)
returns true, if a client state is enabled
Definition: GLState.cc:1584
ACG::GLState::normalPointer
static void normalPointer(GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glNormalPointer, supports locking
Definition: GLState.cc:1884
ACG::GLState::getNormalPointer
static void getNormalPointer(GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get normal pointer, null-ptr safe
Definition: GLState.cc:1898
ACG::GLState::up
Vec3d up() const
get up-vector w.r.t. camera coordinates
Definition: GLState.cc:902
ACG::Vec4uc
VectorT< unsigned char, 4 > Vec4uc
Definition: VectorT.hh:134
OpenMesh::VectorT< float, 4 >
ACG::GLState::isStateLocked
static bool isStateLocked(GLenum _cap)
returns true, if a cap state is locked
Definition: GLState.cc:1528
ACG::GLMatrixT::inverse_frustum
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
Definition: GLMatrixT.cc:348
ACG::GLState::ortho
void ortho(double _left, double _right, double _bottom, double _top, double _near_plane, double _far_plane)
orthographic projection
Definition: GLState.cc:400
ACG::GLMatrixT::rotate
void rotate(Scalar angle, Scalar x, Scalar y, Scalar z, MultiplyFrom _mult_from=MULT_FROM_RIGHT)
Definition: GLMatrixT.cc:161
ACG::GLState::set_overlay_color
void set_overlay_color(const Vec4f &_col)
set overlay color
Definition: GLState.cc:750
ACG::GLState::isStateEnabled
static bool isStateEnabled(GLenum _cap)
returns true, if a cpa state is enabled
Definition: GLState.cc:1533
ACG::GLState::getBoundTextureTarget
static GLenum getBoundTextureTarget()
get bound texture target
Definition: GLState.cc:1854
ACG::GLState::default_overlay_color
static const Vec4f default_overlay_color
default value for overlay color
Definition: GLState.hh:910
ACG::GLState::texcoordPointer
static void texcoordPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glTexcoordPointer, supports locking
Definition: GLState.cc:1928
ACG::GLMatrixT::frustum
void frustum(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
Definition: GLMatrixT.cc:317
ACG::GLState::pop_modelview_matrix
void pop_modelview_matrix()
pop modelview matrix
Definition: GLState.cc:1022
ACG::GLState::pick_init
void pick_init(bool _color)
initialize name/color picking stack (like glInitNames())
Definition: GLState.cc:1039
ACG::GLState::fovy
double fovy() const
get field of view in y direction
Definition: GLState.cc:864
ACG::GLState::pick_push_name
void pick_push_name(unsigned int _idx)
creates a new name the stack (like glPushName())
Definition: GLState.cc:1073
ACG::GLMatrixT::perspective
void perspective(Scalar fovY, Scalar aspect, Scalar near_plane, Scalar far_plane)
multiply self with a perspective projection matrix
Definition: GLMatrixT.cc:283
ACG::GLState::set_base_color
void set_base_color(const Vec4f &_col)
set base color (used when lighting is off)
Definition: GLState.cc:675
ACG::GLState::viewing_direction
Vec3d viewing_direction() const
get viewing ray
Definition: GLState.hh:851
ACG::GLState::color_picking
bool color_picking() const
Is color picking active?
Definition: GLState.cc:1124
ACG::ColorStack::setMaximumIndex
bool setMaximumIndex(unsigned int _idx)
sets the maximum index number used in current node
Definition: ColorStack.cc:106
ACG::GLState::viewport
const GLMatrixd & viewport() const
get viewport matrix
Definition: GLState.hh:799
ACG::GLState::unlockFramebuffer
static void unlockFramebuffer(GLenum _target)
unlock a framebuffer target
Definition: GLState.cc:2048
ACG::GLState::deleteBuffers
static void deleteBuffers(GLsizei n, const GLuint *buffers)
Definition: GLState.cc:2105
ACG::GLState::useProgram
static void useProgram(GLuint _program)
replaces glUseProgram, supports locking
Definition: GLState.cc:2073
ACG::GLState::setState
void setState()
set the whole stored gl state
Definition: GLState.cc:209
ACG::GLState::disableClientState
static void disableClientState(GLenum _cap)
replaces glDisableClientState, supports locking
Definition: GLState.cc:1555
ACG::ColorStack::error
bool error() const
Did an error occur during picking.
Definition: ColorStack.hh:119
ACG::GLState::set_line_width
void set_line_width(float _f)
set line width
Definition: GLState.cc:789
ACG::GLState::set_specular_color
void set_specular_color(const Vec4f &_col)
set specular color
Definition: GLState.cc:735
ACG::GLState::bufferData
static void bufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
Definition: GLState.cc:2100
ACG::Matrix4x4T::identity
void identity()
setup an identity matrix
Definition: Matrix4x4T.cc:256
ACG::GLState::default_shininess
static const float default_shininess
default value for shininess
Definition: GLState.hh:912
ACG::GLState::vertexPointer
static void vertexPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glVertexPointer, supports locking
Definition: GLState.cc:1862
ACG::GLState::set_multisampling
void set_multisampling(bool _b)
Enable or disable multisampling.
Definition: GLState.cc:835
ACG::Matrix4x4T::transform_point
VectorT< T, 3 > transform_point(const VectorT< T, 3 > &_v) const
transform point (x',y',z',1) = M * (x,y,z,1)
Definition: Matrix4x4T.cc:202
ACG::GLState::isClientStateLocked
static bool isClientStateLocked(GLenum _cap)
returns true, if a client state is locked
Definition: GLState.cc:1579
ACG::GLState::isFramebufferLocked
static bool isFramebufferLocked(GLenum _target)
get framebuffer target lock state
Definition: GLState.cc:2060
ACG::GLMatrixT::lookAt
void lookAt(const Vec3 &eye, const Vec3 &center, const Vec3 &up)
Definition: GLMatrixT.cc:222
ACG::GLState::disable
static void disable(GLenum _cap)
replaces glDisable, but supports locking
Definition: GLState.cc:1504
ACG::GLState::pick_color_to_stack
std::vector< unsigned int > pick_color_to_stack(Vec4uc _rgba) const
Definition: GLState.cc:1087
ACG::GLState::get_bounding_box
void get_bounding_box(ACG::Vec3d &_min, ACG::Vec3d &_max)
Definition: GLState.cc:809
ACG::GLState::getBoundTextureBuffer
static GLuint getBoundTextureBuffer()
get bound texture
Definition: GLState.cc:1849
ACG::GLStateContext
Definition: GLState.hh:122
ACG::GLState::set_shininess
void set_shininess(float _shininess)
set specular shininess (must be in [0, 128])
Definition: GLState.cc:759
ACG::GLState::genBuffers
static void genBuffers(GLsizei n, GLuint *buffers)
Definition: GLState.cc:2091
ACG::GLState::pick_error
bool pick_error() const
Definition: GLState.cc:1105
ACG::GLState::set_modelview
void set_modelview(const GLMatrixd &_m)
set modelview
Definition: GLState.hh:731
ACG::GLState::unlockClientState
static void unlockClientState(GLenum _cap)
unlocks a client state
Definition: GLState.cc:1574
ACG::GLState::perspective
void perspective(double _fovY, double _aspect, double _near_plane, double _far_plane)
perspective projection
Definition: GLState.cc:446
ACG::GLState::depthFunc
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
Definition: GLState.cc:937
ACG::GLState::lockBufferTarget
static void lockBufferTarget(GLenum _target)
lock buffer target
Definition: GLState.cc:1779
ACG::GLState::bb_min_
ACG::Vec3d bb_min_
Definition: GLState.hh:1028
ACG::GLState::isBufferTargetLocked
static bool isBufferTargetLocked(GLenum _target)
get buffer target locking state
Definition: GLState.cc:1789
ACG::GLState::getDepthRange
static void getDepthRange(GLclampd *_zNearOut, GLclampd *_zFarOut)
get current depth range
Definition: GLState.cc:1744
ACG::GLState::getBufferTargetIndex
static int getBufferTargetIndex(GLenum _target)
bijective map from GLenum buffer_target to [0..3], -1 if unsupported
Definition: GLState.cc:1752
ACG::GLState::set_projection
void set_projection(const GLMatrixd &_m)
set projection
Definition: GLState.hh:694
ACG::GLState::set_point_size
void set_point_size(float _f)
set point size
Definition: GLState.cc:774
ACG::GLState::eye
Vec3d eye() const
get eye point
Definition: GLState.cc:882
ACG::GLState::getTexcoordPointer
static void getTexcoordPointer(GLint *_size, GLenum *_type, GLsizei *_stride, const GLvoid **_pointer)
get color pointer, null-ptr safe
Definition: GLState.cc:1942
ACG::GLStateContext::GLVertexPointer
Definition: GLState.hh:180
ACG::GLState::getFramebufferDraw
static GLuint getFramebufferDraw()
get current draw framebuffer of a target
Definition: GLState.cc:1994
ACG::GLState::project
Vec3d project(const Vec3d &_point) const
project point in world coordinates to window coordinates
Definition: GLState.cc:638
ACG::GLMatrixT::ortho
void ortho(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near_plane, Scalar far_plane)
multiply self with orthographic projection matrix
Definition: GLMatrixT.cc:379
ACG::ColorStack::initialize
void initialize()
init (takes current GL context/ like glInitNames (); glPushName (0))
Definition: ColorStack.cc:92
ACG::GLState::default_specular_color
static const Vec4f default_specular_color
default value for specular color
Definition: GLState.hh:908
ACG::GLState::getFramebufferRead
static GLuint getFramebufferRead()
get current read framebuffer of a target
Definition: GLState.cc:2002
ACG::GLState::viewing_ray
void viewing_ray(int _x, int _y, Vec3d &_origin, Vec3d &_direction) const
Definition: GLState.cc:926
ACG::ColorStack::setIndex
void setIndex(unsigned int _idx)
sets the current color the given index (like glLoadName)
Definition: ColorStack.cc:120
ACG::GLState::blendColor
static void blendColor(GLclampf _red, GLclampf _green, GLclampf _blue, GLclampf _alpha)
replaces glBlendColor, supports locking
Definition: GLState.cc:1657
ACG::GLState::unlockBufferTarget
static void unlockBufferTarget(GLenum _target)
unlock buffer target
Definition: GLState.cc:1784
ACG::Matrix4x4T::get_raw_data
const Scalar * get_raw_data() const
Definition: Matrix4x4T.hh:262
ACG::GLState::push_projection_matrix
void push_projection_matrix()
push projection matrix
Definition: GLState.cc:967
ACG::GLState::set_clear_color
void set_clear_color(const Vec4f &_col)
set background color
Definition: GLState.cc:660
ACG::ColorStack::currentIndex
unsigned int currentIndex() const
returns the current color index
Definition: ColorStack.cc:189
ACG::GLState::GLState
GLState(bool _updateGL=true, bool _compatibilityProfile=true)
Default constructor.
Definition: GLState.cc:122
ACG::GLState::pick_pop_name
void pick_pop_name()
pops the current name from the stack (like glPopName())
Definition: GLState.cc:1080
ACG::GLState::cullFace
static void cullFace(GLenum _mode)
replaces glCullFace, supports locking
Definition: GLState.cc:1714