1 // Created on: 2013-10-02
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _OpenGl_State_HeaderFile
17 #define _OpenGl_State_HeaderFile
19 #include <InterfaceGraphic_tgl_all.hxx>
21 #include <OpenGl_Element.hxx>
22 #include <OpenGl_Light.hxx>
23 #include <OpenGl_Vec.hxx>
25 #include <NCollection_List.hxx>
27 //! Defines interface for OpenGL state.
28 class OpenGl_StateInterface
32 //! Creates new OCCT state.
33 OpenGl_StateInterface();
35 //! Returns current state index.
36 Standard_Size Index() const;
38 //! Updates current state.
41 //! Reverts current state.
46 Standard_Size myIndex; //!< Current state index
47 Standard_Size myNextIndex; //!< Next state index
48 NCollection_List<Standard_Size> myStateStack; //!< Stack of previous states.
52 //! Defines state of OCCT projection transformation.
53 class OpenGl_ProjectionState : public OpenGl_StateInterface
57 //! Creates uninitialized projection state.
58 OpenGl_ProjectionState();
60 //! Sets new projection matrix.
61 void Set (const OpenGl_Mat4& theProjectionMatrix);
63 //! Returns current projection matrix.
64 const OpenGl_Mat4& ProjectionMatrix() const;
66 //! Returns inverse of current projection matrix.
67 const OpenGl_Mat4& ProjectionMatrixInverse() const;
71 OpenGl_Mat4 myProjectionMatrix; //!< OCCT projection matrix
72 mutable OpenGl_Mat4 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
73 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
77 //! Defines state of OCCT model-world transformation.
78 class OpenGl_ModelWorldState : public OpenGl_StateInterface
82 //! Creates uninitialized model-world state.
83 OpenGl_ModelWorldState();
85 //! Sets new model-world matrix.
86 void Set (const OpenGl_Mat4& theModelWorldMatrix);
88 //! Returns current model-world matrix.
89 const OpenGl_Mat4& ModelWorldMatrix() const;
91 //! Returns inverse of current model-world matrix.
92 const OpenGl_Mat4& ModelWorldMatrixInverse() const;
96 OpenGl_Mat4 myModelWorldMatrix; //!< OCCT model-world matrix
97 mutable OpenGl_Mat4 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix
98 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
102 //! Defines state of OCCT world-view transformation.
103 class OpenGl_WorldViewState : public OpenGl_StateInterface
107 //! Creates uninitialized world-view state.
108 OpenGl_WorldViewState();
110 //! Sets new world-view matrix.
111 void Set (const OpenGl_Mat4& theWorldViewMatrix);
113 //! Returns current world-view matrix.
114 const OpenGl_Mat4& WorldViewMatrix() const;
116 //! Returns inverse of current world-view matrix.
117 const OpenGl_Mat4& WorldViewMatrixInverse() const;
121 OpenGl_Mat4 myWorldViewMatrix; //!< OCCT world-view matrix
122 mutable OpenGl_Mat4 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix
123 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
127 //! Defines state of OCCT light sources.
128 class OpenGl_LightSourceState : public OpenGl_StateInterface
132 //! Creates uninitialized state of light sources.
133 OpenGl_LightSourceState();
135 //! Sets new light sources.
136 void Set (const OpenGl_ListOfLight* theLightSources);
138 //! Returns current list of light sources.
139 const OpenGl_ListOfLight* LightSources() const;
143 const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources
147 //! Defines generic state of OCCT material properties.
148 class OpenGl_MaterialState : public OpenGl_StateInterface
152 //! Creates new material state.
153 OpenGl_MaterialState (const OpenGl_Element* theAspect = NULL);
155 //! Sets new material aspect.
156 void Set (const OpenGl_Element* theAspect);
158 //! Returns material aspect.
159 const OpenGl_Element* Aspect() const;
163 const OpenGl_Element* myAspect; //!< OCCT material aspect
167 //! Defines generic state of OCCT clipping state.
168 class OpenGl_ClippingState : public OpenGl_StateInterface
172 //! Creates new clipping state.
173 OpenGl_ClippingState();
177 #endif // _OpenGl_State_HeaderFile