0025456: BOPAlgo_CheckerSI reports an error on the given shape
[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>
20
21#include <OpenGl_Element.hxx>
22#include <OpenGl_Light.hxx>
c827ea3a 23#include <OpenGl_Vec.hxx>
30f0ad28 24
6af4fe1c 25#include <NCollection_List.hxx>
ca102800 26
30f0ad28 27//! Defines interface for OpenGL state.
28class OpenGl_StateInterface
29{
30public:
31
32 //! Creates new OCCT state.
33 OpenGl_StateInterface();
34
35 //! Returns current state index.
36 Standard_Size Index() const;
37
38 //! Updates current state.
39 void Update();
40
41 //! Reverts current state.
42 void Revert();
43
44protected:
45
ca102800 46 Standard_Size myIndex; //!< Current state index
47 Standard_Size myNextIndex; //!< Next state index
6af4fe1c 48 NCollection_List<Standard_Size> myStateStack; //!< Stack of previous states.
30f0ad28 49
50};
51
52//! Defines state of OCCT projection transformation.
53class OpenGl_ProjectionState : public OpenGl_StateInterface
54{
55public:
56
57 //! Creates uninitialized projection state.
58 OpenGl_ProjectionState();
59
60 //! Sets new projection matrix.
c827ea3a 61 void Set (const OpenGl_Mat4& theProjectionMatrix);
30f0ad28 62
63 //! Returns current projection matrix.
c827ea3a 64 const OpenGl_Mat4& ProjectionMatrix() const;
30f0ad28 65
66 //! Returns inverse of current projection matrix.
c827ea3a 67 const OpenGl_Mat4& ProjectionMatrixInverse() const;
30f0ad28 68
69private:
70
c827ea3a 71 OpenGl_Mat4 myProjectionMatrix; //!< OCCT projection matrix
72 mutable OpenGl_Mat4 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
73 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
30f0ad28 74
75};
76
77//! Defines state of OCCT model-world transformation.
78class OpenGl_ModelWorldState : public OpenGl_StateInterface
79{
80public:
81
82 //! Creates uninitialized model-world state.
83 OpenGl_ModelWorldState();
84
85 //! Sets new model-world matrix.
c827ea3a 86 void Set (const OpenGl_Mat4& theModelWorldMatrix);
30f0ad28 87
88 //! Returns current model-world matrix.
c827ea3a 89 const OpenGl_Mat4& ModelWorldMatrix() const;
30f0ad28 90
91 //! Returns inverse of current model-world matrix.
c827ea3a 92 const OpenGl_Mat4& ModelWorldMatrixInverse() const;
30f0ad28 93
94private:
95
c827ea3a 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?
30f0ad28 99
100};
101
102//! Defines state of OCCT world-view transformation.
103class OpenGl_WorldViewState : public OpenGl_StateInterface
104{
105public:
106
107 //! Creates uninitialized world-view state.
108 OpenGl_WorldViewState();
109
110 //! Sets new world-view matrix.
c827ea3a 111 void Set (const OpenGl_Mat4& theWorldViewMatrix);
30f0ad28 112
113 //! Returns current world-view matrix.
c827ea3a 114 const OpenGl_Mat4& WorldViewMatrix() const;
30f0ad28 115
116 //! Returns inverse of current world-view matrix.
c827ea3a 117 const OpenGl_Mat4& WorldViewMatrixInverse() const;
30f0ad28 118
119private:
120
c827ea3a 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?
30f0ad28 124
125};
126
127//! Defines state of OCCT light sources.
128class OpenGl_LightSourceState : public OpenGl_StateInterface
129{
130public:
131
132 //! Creates uninitialized state of light sources.
133 OpenGl_LightSourceState();
134
135 //! Sets new light sources.
136 void Set (const OpenGl_ListOfLight* theLightSources);
137
138 //! Returns current list of light sources.
139 const OpenGl_ListOfLight* LightSources() const;
140
141private:
142
143 const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources
144
145};
146
147//! Defines generic state of OCCT material properties.
148class OpenGl_MaterialState : public OpenGl_StateInterface
149{
150public:
151
152 //! Creates new material state.
153 OpenGl_MaterialState (const OpenGl_Element* theAspect = NULL);
154
155 //! Sets new material aspect.
156 void Set (const OpenGl_Element* theAspect);
157
158 //! Returns material aspect.
159 const OpenGl_Element* Aspect() const;
160
161private:
162
163 const OpenGl_Element* myAspect; //!< OCCT material aspect
164
165};
166
167//! Defines generic state of OCCT clipping state.
168class OpenGl_ClippingState : public OpenGl_StateInterface
169{
170public:
171
172 //! Creates new clipping state.
173 OpenGl_ClippingState();
174
175};
176
177#endif // _OpenGl_State_HeaderFile