Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StatekeeperGL.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef _StatekeeperGL__hh__
26 #define _StatekeeperGL__hh__
27 
28 #include <bias_config.h>
29 
30 #ifndef BIAS_HAVE_OPENGL
31 # error Please recompile BIAS with USE_OPENGL
32 #endif // BIAS_HAVE_OPENGL
33 
34 
35 # include <Gui/biasgl.h>
36 
37 namespace BIAS {
38 
39  /** push and pop GL states on constructor/destructor
40  Helper class pop(save) OpenGL states on construction
41  and push them on destruction automatically.
42  Using matching push/pop pairs is easy with this class.
43  Sample usage:
44  \verbatim
45  // begin var. scop
46  {
47  // save state by push
48  StatekeeperGL myTmp;
49  // change the state, fire GL calls
50  ...
51  // reload state by destructors pop call automatically
52  }
53  // end var. scope
54  \endverbatim
55  There should not be a performance impact if you use display lists.
56  @author Jan Woetzel */
57  class BIASUtils_EXPORT StatekeeperGL {
58  public:
59  /// constructor, pushes major OpenGL states
61  glPushAttrib( 0
62  //|GL_ALL_ATTRIB_BITS
63  |GL_ENABLE_BIT
64  |GL_COLOR_BUFFER_BIT
65  |GL_CURRENT_BIT
66  //|GL_DEPTH_BUFFER_BIT
67  //|GL_LIGHTING_BIT
68  //|GL_SCISSOR_BIT
69  //|GL_STENCIL_BUFFER_BIT
70  );
71  };
72 
73  /** constructor, pushes OpenGL state as given by mask
74  GLbitfield mask */
75  StatekeeperGL(const GLbitfield & mask){
76  glPushAttrib(mask);
77  }
78 
79  /// destructor, pops OpenGL state
81  glPopAttrib();
82  }
83 
84  }; // end of class
85 } // end namespace
86 
87 
88 #endif
89 
~StatekeeperGL()
destructor, pops OpenGL state
StatekeeperGL(const GLbitfield &mask)
constructor, pushes OpenGL state as given by mask GLbitfield mask
push and pop GL states on constructor/destructor Helper class pop(save) OpenGL states on constructi...
StatekeeperGL()
constructor, pushes major OpenGL states