ae4bb1b8e401f9ec333b3580149d7dc2f1af9827
[occt.git] / src / OpenGl / OpenGl_ShaderStates.hxx
1 // Created on: 2013-10-02
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public 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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _OpenGl_State_HeaderFile
17 #define _OpenGl_State_HeaderFile
18
19 #include <InterfaceGraphic_tgl_all.hxx>
20
21 #include <OpenGl_Element.hxx>
22 #include <OpenGl_Light.hxx>
23
24 //! Defines interface for OpenGL state.
25 class OpenGl_StateInterface
26 {
27 public:
28
29   //! Creates new OCCT state.
30   OpenGl_StateInterface();
31
32   //! Returns current state index.
33   Standard_Size Index() const;
34
35   //! Updates current state.
36   void Update();
37
38   //! Reverts current state.
39   void Revert();
40
41 protected:
42
43   Standard_Size myIndex; //!< Current state index
44
45 };
46
47 //! Defines state of OCCT projection transformation.
48 class OpenGl_ProjectionState : public OpenGl_StateInterface
49 {
50 public:
51
52   //! Creates uninitialized projection state.
53   OpenGl_ProjectionState();
54
55   //! Sets new projection matrix.
56   void Set (const Tmatrix3& theProjectionMatrix);
57
58   //! Returns current projection matrix.
59   const Tmatrix3& ProjectionMatrix() const;
60
61   //! Returns inverse of current projection matrix.
62   const Tmatrix3& ProjectionMatrixInverse() const;
63
64 private:
65
66   Tmatrix3         myProjectionMatrix;        //!< OCCT projection matrix
67   mutable Tmatrix3 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
68   bool             myInverseNeedUpdate;       //!< Is inversed matrix outdated?
69
70 };
71
72 //! Defines state of OCCT model-world transformation.
73 class OpenGl_ModelWorldState : public OpenGl_StateInterface
74 {
75 public:
76
77   //! Creates uninitialized model-world state.
78   OpenGl_ModelWorldState();
79
80   //! Sets new model-world matrix.
81   void Set (const Tmatrix3& theModelWorldMatrix);
82
83   //! Returns current model-world matrix.
84   const Tmatrix3& ModelWorldMatrix() const;
85
86   //! Returns inverse of current model-world matrix.
87   const Tmatrix3& ModelWorldMatrixInverse() const;
88
89 private:
90
91   Tmatrix3         myModelWorldMatrix;        //!< OCCT model-world matrix
92   mutable Tmatrix3 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix
93   bool             myInverseNeedUpdate;       //!< Is inversed matrix outdated?
94   
95 };
96
97 //! Defines state of OCCT world-view transformation.
98 class OpenGl_WorldViewState : public OpenGl_StateInterface
99 {
100 public:
101
102   //! Creates uninitialized world-view state.
103   OpenGl_WorldViewState();
104   
105   //! Sets new world-view matrix.
106   void Set (const Tmatrix3& theWorldViewMatrix);
107
108   //! Returns current world-view matrix.
109   const Tmatrix3& WorldViewMatrix() const;
110
111   //! Returns inverse of current world-view matrix.
112   const Tmatrix3& WorldViewMatrixInverse() const;
113
114 private:
115
116   Tmatrix3         myWorldViewMatrix;        //!< OCCT world-view matrix
117   mutable Tmatrix3 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix
118   bool             myInverseNeedUpdate;      //!< Is inversed matrix outdated?
119
120 };
121
122 //! Defines state of OCCT light sources.
123 class OpenGl_LightSourceState : public OpenGl_StateInterface
124 {
125 public:
126
127   //! Creates uninitialized state of light sources.
128   OpenGl_LightSourceState();
129
130   //! Sets new light sources.
131   void Set (const OpenGl_ListOfLight* theLightSources);
132
133   //! Returns current list of light sources.
134   const OpenGl_ListOfLight* LightSources() const;
135
136 private:
137
138   const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources
139
140 };
141
142 //! Defines generic state of OCCT material properties.
143 class OpenGl_MaterialState : public OpenGl_StateInterface
144 {
145 public:
146
147   //! Creates new material state.
148   OpenGl_MaterialState (const OpenGl_Element* theAspect = NULL);
149   
150   //! Sets new material aspect.
151   void Set (const OpenGl_Element* theAspect);
152
153   //! Returns material aspect.
154   const OpenGl_Element* Aspect() const;
155
156 private:
157
158   const OpenGl_Element* myAspect; //!< OCCT material aspect
159
160 };
161
162 //! Defines generic state of OCCT clipping state.
163 class OpenGl_ClippingState : public OpenGl_StateInterface
164 {
165 public:
166
167   //! Creates new clipping state.
168   OpenGl_ClippingState();
169
170 };
171
172 #endif // _OpenGl_State_HeaderFile