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>
20 #include <NCollection_List.hxx>
21 #include <OpenGl_Element.hxx>
22 #include <OpenGl_Light.hxx>
23 #include <OpenGl_Vec.hxx>
25 //! Defines interface for OpenGL state.
26 class OpenGl_StateInterface
30 //! Creates new state.
31 OpenGl_StateInterface();
33 //! Returns current state index.
34 Standard_Size Index() const { return myIndex; }
36 //! Increment current state.
37 void Update() { ++myIndex; }
41 Standard_Size myIndex; //!< current state index
45 //! Defines state of OCCT projection transformation.
46 class OpenGl_ProjectionState : public OpenGl_StateInterface
50 //! Creates uninitialized projection state.
51 OpenGl_ProjectionState();
53 //! Sets new projection matrix.
54 void Set (const OpenGl_Mat4& theProjectionMatrix);
56 //! Returns current projection matrix.
57 const OpenGl_Mat4& ProjectionMatrix() const;
59 //! Returns inverse of current projection matrix.
60 const OpenGl_Mat4& ProjectionMatrixInverse() const;
64 OpenGl_Mat4 myProjectionMatrix; //!< OCCT projection matrix
65 mutable OpenGl_Mat4 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
66 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
70 //! Defines state of OCCT model-world transformation.
71 class OpenGl_ModelWorldState : public OpenGl_StateInterface
75 //! Creates uninitialized model-world state.
76 OpenGl_ModelWorldState();
78 //! Sets new model-world matrix.
79 void Set (const OpenGl_Mat4& theModelWorldMatrix);
81 //! Returns current model-world matrix.
82 const OpenGl_Mat4& ModelWorldMatrix() const;
84 //! Returns inverse of current model-world matrix.
85 const OpenGl_Mat4& ModelWorldMatrixInverse() const;
89 OpenGl_Mat4 myModelWorldMatrix; //!< OCCT model-world matrix
90 mutable OpenGl_Mat4 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix
91 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
95 //! Defines state of OCCT world-view transformation.
96 class OpenGl_WorldViewState : public OpenGl_StateInterface
100 //! Creates uninitialized world-view state.
101 OpenGl_WorldViewState();
103 //! Sets new world-view matrix.
104 void Set (const OpenGl_Mat4& theWorldViewMatrix);
106 //! Returns current world-view matrix.
107 const OpenGl_Mat4& WorldViewMatrix() const;
109 //! Returns inverse of current world-view matrix.
110 const OpenGl_Mat4& WorldViewMatrixInverse() const;
114 OpenGl_Mat4 myWorldViewMatrix; //!< OCCT world-view matrix
115 mutable OpenGl_Mat4 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix
116 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
120 //! Defines state of OCCT light sources.
121 class OpenGl_LightSourceState : public OpenGl_StateInterface
125 //! Creates uninitialized state of light sources.
126 OpenGl_LightSourceState();
128 //! Sets new light sources.
129 void Set (const OpenGl_ListOfLight* theLightSources);
131 //! Returns current list of light sources.
132 const OpenGl_ListOfLight* LightSources() const;
136 const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources
140 //! Defines generic state of OCCT material properties.
141 class OpenGl_MaterialState : public OpenGl_StateInterface
145 //! Creates new material state.
146 OpenGl_MaterialState (const OpenGl_Element* theAspect = NULL);
148 //! Sets new material aspect.
149 void Set (const OpenGl_Element* theAspect);
151 //! Returns material aspect.
152 const OpenGl_Element* Aspect() const;
156 const OpenGl_Element* myAspect; //!< OCCT material aspect
160 //! Defines generic state of OCCT clipping state.
161 class OpenGl_ClippingState
165 //! Creates new clipping state.
166 OpenGl_ClippingState();
168 //! Returns current state index.
169 Standard_Size Index() const { return myIndex; }
171 //! Updates current state.
174 //! Reverts current state.
179 Standard_Size myIndex; //!< Current state index
180 Standard_Size myNextIndex; //!< Next state index
181 NCollection_List<Standard_Size> myStateStack; //!< Stack of previous states
185 #endif // _OpenGl_State_HeaderFile