0024192: Adding support for shaders to OCCT visualization toolkit
[occt.git] / src / OpenGl / OpenGl_ShaderStates.hxx
CommitLineData
30f0ad28 1// Created on: 2013-10-02
2// Created by: Denis BOGOLEPOV
3// Copyright (c) 2013 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
20#ifndef _OpenGl_State_HeaderFile
21#define _OpenGl_State_HeaderFile
22
23#include <Graphic3d_SetOfHClipPlane.hxx>
24
25#include <InterfaceGraphic_tgl_all.hxx>
26
27#include <OpenGl_Element.hxx>
28#include <OpenGl_Light.hxx>
29
30//! Defines interface for OpenGL state.
31class OpenGl_StateInterface
32{
33public:
34
35 //! Creates new OCCT state.
36 OpenGl_StateInterface();
37
38 //! Returns current state index.
39 Standard_Size Index() const;
40
41 //! Updates current state.
42 void Update();
43
44 //! Reverts current state.
45 void Revert();
46
47protected:
48
49 Standard_Size myIndex; //!< Current state index
50
51};
52
53//! Defines state of OCCT projection transformation.
54class OpenGl_ProjectionState : public OpenGl_StateInterface
55{
56public:
57
58 //! Creates uninitialized projection state.
59 OpenGl_ProjectionState();
60
61 //! Sets new projection matrix.
62 void Set (const Tmatrix3& theProjectionMatrix);
63
64 //! Returns current projection matrix.
65 const Tmatrix3& ProjectionMatrix() const;
66
67 //! Returns inverse of current projection matrix.
68 const Tmatrix3& ProjectionMatrixInverse() const;
69
70private:
71
72 Tmatrix3 myProjectionMatrix; //!< OCCT projection matrix
73 mutable Tmatrix3 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
74 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
75
76};
77
78//! Defines state of OCCT model-world transformation.
79class OpenGl_ModelWorldState : public OpenGl_StateInterface
80{
81public:
82
83 //! Creates uninitialized model-world state.
84 OpenGl_ModelWorldState();
85
86 //! Sets new model-world matrix.
87 void Set (const Tmatrix3& theModelWorldMatrix);
88
89 //! Returns current model-world matrix.
90 const Tmatrix3& ModelWorldMatrix() const;
91
92 //! Returns inverse of current model-world matrix.
93 const Tmatrix3& ModelWorldMatrixInverse() const;
94
95private:
96
97 Tmatrix3 myModelWorldMatrix; //!< OCCT model-world matrix
98 mutable Tmatrix3 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix
99 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
100
101};
102
103//! Defines state of OCCT world-view transformation.
104class OpenGl_WorldViewState : public OpenGl_StateInterface
105{
106public:
107
108 //! Creates uninitialized world-view state.
109 OpenGl_WorldViewState();
110
111 //! Sets new world-view matrix.
112 void Set (const Tmatrix3& theWorldViewMatrix);
113
114 //! Returns current world-view matrix.
115 const Tmatrix3& WorldViewMatrix() const;
116
117 //! Returns inverse of current world-view matrix.
118 const Tmatrix3& WorldViewMatrixInverse() const;
119
120private:
121
122 Tmatrix3 myWorldViewMatrix; //!< OCCT world-view matrix
123 mutable Tmatrix3 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix
124 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
125
126};
127
128//! Defines state of OCCT light sources.
129class OpenGl_LightSourceState : public OpenGl_StateInterface
130{
131public:
132
133 //! Creates uninitialized state of light sources.
134 OpenGl_LightSourceState();
135
136 //! Sets new light sources.
137 void Set (const OpenGl_ListOfLight* theLightSources);
138
139 //! Returns current list of light sources.
140 const OpenGl_ListOfLight* LightSources() const;
141
142private:
143
144 const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources
145
146};
147
148//! Defines generic state of OCCT material properties.
149class OpenGl_MaterialState : public OpenGl_StateInterface
150{
151public:
152
153 //! Creates new material state.
154 OpenGl_MaterialState (const OpenGl_Element* theAspect = NULL);
155
156 //! Sets new material aspect.
157 void Set (const OpenGl_Element* theAspect);
158
159 //! Returns material aspect.
160 const OpenGl_Element* Aspect() const;
161
162private:
163
164 const OpenGl_Element* myAspect; //!< OCCT material aspect
165
166};
167
168//! Defines generic state of OCCT clipping state.
169class OpenGl_ClippingState : public OpenGl_StateInterface
170{
171public:
172
173 //! Creates new clipping state.
174 OpenGl_ClippingState();
175
176};
177
178#endif // _OpenGl_State_HeaderFile