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