0025973: Visualization, TKOpenGl - support EAGLContext as alternative to NSOpenGLContext
[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
8cf06aa2 32 //! Creates new state.
30f0ad28 33 OpenGl_StateInterface();
34
35 //! Returns current state index.
8cf06aa2 36 Standard_Size Index() const { return myIndex; }
30f0ad28 37
8cf06aa2 38 //! Increment current state.
39 void Update() { ++myIndex; }
30f0ad28 40
41protected:
42
8cf06aa2 43 Standard_Size myIndex; //!< current state index
30f0ad28 44
45};
46
47//! Defines state of OCCT projection transformation.
48class OpenGl_ProjectionState : public OpenGl_StateInterface
49{
50public:
51
52 //! Creates uninitialized projection state.
53 OpenGl_ProjectionState();
54
55 //! Sets new projection matrix.
c827ea3a 56 void Set (const OpenGl_Mat4& theProjectionMatrix);
30f0ad28 57
58 //! Returns current projection matrix.
c827ea3a 59 const OpenGl_Mat4& ProjectionMatrix() const;
30f0ad28 60
61 //! Returns inverse of current projection matrix.
c827ea3a 62 const OpenGl_Mat4& ProjectionMatrixInverse() const;
30f0ad28 63
64private:
65
c827ea3a 66 OpenGl_Mat4 myProjectionMatrix; //!< OCCT projection matrix
67 mutable OpenGl_Mat4 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
68 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
30f0ad28 69
70};
71
72//! Defines state of OCCT model-world transformation.
73class OpenGl_ModelWorldState : public OpenGl_StateInterface
74{
75public:
76
77 //! Creates uninitialized model-world state.
78 OpenGl_ModelWorldState();
79
80 //! Sets new model-world matrix.
c827ea3a 81 void Set (const OpenGl_Mat4& theModelWorldMatrix);
30f0ad28 82
83 //! Returns current model-world matrix.
c827ea3a 84 const OpenGl_Mat4& ModelWorldMatrix() const;
30f0ad28 85
86 //! Returns inverse of current model-world matrix.
c827ea3a 87 const OpenGl_Mat4& ModelWorldMatrixInverse() const;
30f0ad28 88
89private:
90
c827ea3a 91 OpenGl_Mat4 myModelWorldMatrix; //!< OCCT model-world matrix
92 mutable OpenGl_Mat4 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix
93 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
30f0ad28 94
95};
96
97//! Defines state of OCCT world-view transformation.
98class OpenGl_WorldViewState : public OpenGl_StateInterface
99{
100public:
101
102 //! Creates uninitialized world-view state.
103 OpenGl_WorldViewState();
104
105 //! Sets new world-view matrix.
c827ea3a 106 void Set (const OpenGl_Mat4& theWorldViewMatrix);
30f0ad28 107
108 //! Returns current world-view matrix.
c827ea3a 109 const OpenGl_Mat4& WorldViewMatrix() const;
30f0ad28 110
111 //! Returns inverse of current world-view matrix.
c827ea3a 112 const OpenGl_Mat4& WorldViewMatrixInverse() const;
30f0ad28 113
114private:
115
c827ea3a 116 OpenGl_Mat4 myWorldViewMatrix; //!< OCCT world-view matrix
117 mutable OpenGl_Mat4 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix
118 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
30f0ad28 119
120};
121
122//! Defines state of OCCT light sources.
123class OpenGl_LightSourceState : public OpenGl_StateInterface
124{
125public:
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
136private:
137
138 const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources
139
140};
141
142//! Defines generic state of OCCT material properties.
143class OpenGl_MaterialState : public OpenGl_StateInterface
144{
145public:
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
156private:
157
158 const OpenGl_Element* myAspect; //!< OCCT material aspect
159
160};
161
162//! Defines generic state of OCCT clipping state.
8cf06aa2 163class OpenGl_ClippingState
30f0ad28 164{
165public:
166
167 //! Creates new clipping state.
168 OpenGl_ClippingState();
169
8cf06aa2 170 //! Returns current state index.
171 Standard_Size Index() const { return myIndex; }
172
173 //! Updates current state.
174 void Update();
175
176 //! Reverts current state.
177 void Revert();
178
179protected:
180
181 Standard_Size myIndex; //!< Current state index
182 Standard_Size myNextIndex; //!< Next state index
183 NCollection_List<Standard_Size> myStateStack; //!< Stack of previous states
184
30f0ad28 185};
186
187#endif // _OpenGl_State_HeaderFile