0024947: Redesign OCCT legacy type system -- automatic
[occt.git] / src / OpenGl / OpenGl_ShaderStates.hxx
CommitLineData
30f0ad28 1// Created on: 2013-10-02
2// Created by: Denis BOGOLEPOV
d5f74e42 3// Copyright (c) 2013-2014 OPEN CASCADE SAS
30f0ad28 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
30f0ad28 6//
d5f74e42 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
973c2be1 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.
30f0ad28 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
30f0ad28 15
16#ifndef _OpenGl_State_HeaderFile
17#define _OpenGl_State_HeaderFile
18
30f0ad28 19#include <InterfaceGraphic_tgl_all.hxx>
e135a155 20#include <NCollection_List.hxx>
30f0ad28 21#include <OpenGl_Element.hxx>
22#include <OpenGl_Light.hxx>
c827ea3a 23#include <OpenGl_Vec.hxx>
e135a155 24#include <Visual3d_TypeOfSurfaceDetail.hxx>
ca102800 25
30f0ad28 26//! Defines interface for OpenGL state.
27class OpenGl_StateInterface
28{
29public:
30
8cf06aa2 31 //! Creates new state.
30f0ad28 32 OpenGl_StateInterface();
33
34 //! Returns current state index.
8cf06aa2 35 Standard_Size Index() const { return myIndex; }
30f0ad28 36
8cf06aa2 37 //! Increment current state.
38 void Update() { ++myIndex; }
30f0ad28 39
40protected:
41
8cf06aa2 42 Standard_Size myIndex; //!< current state index
30f0ad28 43
44};
45
46//! Defines state of OCCT projection transformation.
47class OpenGl_ProjectionState : public OpenGl_StateInterface
48{
49public:
50
51 //! Creates uninitialized projection state.
52 OpenGl_ProjectionState();
53
54 //! Sets new projection matrix.
c827ea3a 55 void Set (const OpenGl_Mat4& theProjectionMatrix);
30f0ad28 56
57 //! Returns current projection matrix.
c827ea3a 58 const OpenGl_Mat4& ProjectionMatrix() const;
30f0ad28 59
60 //! Returns inverse of current projection matrix.
c827ea3a 61 const OpenGl_Mat4& ProjectionMatrixInverse() const;
30f0ad28 62
63private:
64
c827ea3a 65 OpenGl_Mat4 myProjectionMatrix; //!< OCCT projection matrix
66 mutable OpenGl_Mat4 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
67 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
30f0ad28 68
69};
70
71//! Defines state of OCCT model-world transformation.
72class OpenGl_ModelWorldState : public OpenGl_StateInterface
73{
74public:
75
76 //! Creates uninitialized model-world state.
77 OpenGl_ModelWorldState();
78
79 //! Sets new model-world matrix.
c827ea3a 80 void Set (const OpenGl_Mat4& theModelWorldMatrix);
30f0ad28 81
82 //! Returns current model-world matrix.
c827ea3a 83 const OpenGl_Mat4& ModelWorldMatrix() const;
30f0ad28 84
85 //! Returns inverse of current model-world matrix.
c827ea3a 86 const OpenGl_Mat4& ModelWorldMatrixInverse() const;
30f0ad28 87
88private:
89
c827ea3a 90 OpenGl_Mat4 myModelWorldMatrix; //!< OCCT model-world matrix
91 mutable OpenGl_Mat4 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix
92 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
30f0ad28 93
94};
95
96//! Defines state of OCCT world-view transformation.
97class OpenGl_WorldViewState : public OpenGl_StateInterface
98{
99public:
100
101 //! Creates uninitialized world-view state.
102 OpenGl_WorldViewState();
e135a155 103
30f0ad28 104 //! Sets new world-view matrix.
c827ea3a 105 void Set (const OpenGl_Mat4& theWorldViewMatrix);
30f0ad28 106
107 //! Returns current world-view matrix.
c827ea3a 108 const OpenGl_Mat4& WorldViewMatrix() const;
30f0ad28 109
110 //! Returns inverse of current world-view matrix.
c827ea3a 111 const OpenGl_Mat4& WorldViewMatrixInverse() const;
30f0ad28 112
113private:
114
c827ea3a 115 OpenGl_Mat4 myWorldViewMatrix; //!< OCCT world-view matrix
116 mutable OpenGl_Mat4 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix
117 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
30f0ad28 118
119};
120
121//! Defines state of OCCT light sources.
122class OpenGl_LightSourceState : public OpenGl_StateInterface
123{
124public:
125
126 //! Creates uninitialized state of light sources.
127 OpenGl_LightSourceState();
128
129 //! Sets new light sources.
130 void Set (const OpenGl_ListOfLight* theLightSources);
131
132 //! Returns current list of light sources.
133 const OpenGl_ListOfLight* LightSources() const;
134
135private:
136
137 const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources
138
139};
140
141//! Defines generic state of OCCT material properties.
142class OpenGl_MaterialState : public OpenGl_StateInterface
143{
144public:
145
146 //! Creates new material state.
147 OpenGl_MaterialState (const OpenGl_Element* theAspect = NULL);
e135a155 148
30f0ad28 149 //! Sets new material aspect.
150 void Set (const OpenGl_Element* theAspect);
151
152 //! Returns material aspect.
153 const OpenGl_Element* Aspect() const;
154
155private:
156
157 const OpenGl_Element* myAspect; //!< OCCT material aspect
158
159};
160
161//! Defines generic state of OCCT clipping state.
8cf06aa2 162class OpenGl_ClippingState
30f0ad28 163{
164public:
165
166 //! Creates new clipping state.
167 OpenGl_ClippingState();
168
8cf06aa2 169 //! Returns current state index.
170 Standard_Size Index() const { return myIndex; }
171
172 //! Updates current state.
173 void Update();
174
175 //! Reverts current state.
176 void Revert();
177
178protected:
179
180 Standard_Size myIndex; //!< Current state index
181 Standard_Size myNextIndex; //!< Next state index
182 NCollection_List<Standard_Size> myStateStack; //!< Stack of previous states
183
30f0ad28 184};
185
e135a155 186//! Defines generic state of OCCT surface detail.
187class OpenGl_SurfaceDetailState : public OpenGl_StateInterface
188{
189public:
190
191 //! Creates new surface detail state.
192 OpenGl_SurfaceDetailState (const Visual3d_TypeOfSurfaceDetail theDetail = Visual3d_TOD_NONE)
193 : myDetail (theDetail)
194 {
195 //
196 }
197
198 //! Sets new surface detail.
199 void Set (const Visual3d_TypeOfSurfaceDetail theDetail) { myDetail = theDetail; }
200
201 //! Returns surface detail.
202 const Visual3d_TypeOfSurfaceDetail Detail() const { return myDetail; }
203
204private:
205
206 Visual3d_TypeOfSurfaceDetail myDetail; //!< OCCT surface detail
207
208};
209
30f0ad28 210#endif // _OpenGl_State_HeaderFile