30f0ad28 |
1 | // Created on: 2013-09-26 |
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_ShaderManager_HeaderFile |
17 | #define _OpenGl_ShaderManager_HeaderFile |
18 | |
494782f6 |
19 | #include <Graphic3d_ShaderProgram.hxx> |
f978241f |
20 | #include <Graphic3d_StereoMode.hxx> |
c357e426 |
21 | #include <Graphic3d_TypeOfShadingModel.hxx> |
30f0ad28 |
22 | |
23 | #include <NCollection_DataMap.hxx> |
24 | #include <NCollection_Sequence.hxx> |
25 | |
256f9ac0 |
26 | #include <OpenGl_SetOfShaderPrograms.hxx> |
30f0ad28 |
27 | #include <OpenGl_ShaderStates.hxx> |
8625ef7e |
28 | #include <OpenGl_AspectFace.hxx> |
29 | #include <OpenGl_AspectLine.hxx> |
30 | #include <OpenGl_AspectText.hxx> |
31 | #include <OpenGl_AspectMarker.hxx> |
8613985b |
32 | #include <OpenGl_MaterialState.hxx> |
8625ef7e |
33 | #include <OpenGl_Texture.hxx> |
c357e426 |
34 | |
e6804ff7 |
35 | class OpenGl_View; |
36 | |
30f0ad28 |
37 | //! List of shader programs. |
38 | typedef NCollection_Sequence<Handle(OpenGl_ShaderProgram)> OpenGl_ShaderProgramList; |
39 | |
30f0ad28 |
40 | //! This class is responsible for managing shader programs. |
41 | class OpenGl_ShaderManager : public Standard_Transient |
42 | { |
8613985b |
43 | DEFINE_STANDARD_RTTIEXT(OpenGl_ShaderManager, Standard_Transient) |
30f0ad28 |
44 | friend class OpenGl_ShaderProgram; |
30f0ad28 |
45 | public: |
46 | |
47 | //! Creates new empty shader manager. |
48 | Standard_EXPORT OpenGl_ShaderManager (OpenGl_Context* theContext); |
49 | |
50 | //! Releases resources of shader manager. |
51 | Standard_EXPORT virtual ~OpenGl_ShaderManager(); |
52 | |
05e2200b |
53 | //! Release all resources. |
54 | Standard_EXPORT void clear(); |
55 | |
7c3ef2f7 |
56 | //! Return local camera transformation. |
57 | const gp_XYZ& LocalOrigin() const { return myLocalOrigin; } |
58 | |
59 | //! Setup local camera transformation for compensating float precision issues. |
60 | void SetLocalOrigin (const gp_XYZ& theOrigin) |
61 | { |
62 | myLocalOrigin = theOrigin; |
63 | myHasLocalOrigin = !theOrigin.IsEqual (gp_XYZ(0.0, 0.0, 0.0), gp::Resolution()); |
64 | } |
65 | |
392ac980 |
66 | //! Creates new shader program or re-use shared instance. |
67 | //! @param theProxy [IN] program definition |
68 | //! @param theShareKey [OUT] sharing key |
69 | //! @param theProgram [OUT] OpenGL program |
8625ef7e |
70 | //! @return true on success |
71 | Standard_EXPORT Standard_Boolean Create (const Handle(Graphic3d_ShaderProgram)& theProxy, |
72 | TCollection_AsciiString& theShareKey, |
73 | Handle(OpenGl_ShaderProgram)& theProgram); |
30f0ad28 |
74 | |
75 | //! Unregisters specified shader program. |
392ac980 |
76 | Standard_EXPORT void Unregister (TCollection_AsciiString& theShareKey, |
77 | Handle(OpenGl_ShaderProgram)& theProgram); |
30f0ad28 |
78 | |
79 | //! Returns list of registered shader programs. |
80 | Standard_EXPORT const OpenGl_ShaderProgramList& ShaderPrograms() const; |
81 | |
82 | //! Returns true if no program objects are registered in the manager. |
83 | Standard_EXPORT Standard_Boolean IsEmpty() const; |
84 | |
8625ef7e |
85 | //! Bind program for filled primitives rendering |
299e0ab9 |
86 | Standard_Boolean BindFaceProgram (const Handle(OpenGl_Texture)& theTexture, |
87 | const Standard_Boolean theToLightOn, |
88 | const Standard_Boolean theHasVertColor, |
89 | const Standard_Boolean theEnableEnvMap, |
90 | const Handle(OpenGl_ShaderProgram)& theCustomProgram) |
8625ef7e |
91 | { |
92 | if (!theCustomProgram.IsNull() |
93 | || myContext->caps->ffpEnable) |
94 | { |
299e0ab9 |
95 | return bindProgramWithState (theCustomProgram); |
8625ef7e |
96 | } |
97 | |
83da37b1 |
98 | const Standard_Integer aBits = getProgramBits (theTexture, theHasVertColor, theEnableEnvMap); |
8625ef7e |
99 | Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theToLightOn, aBits); |
299e0ab9 |
100 | return bindProgramWithState (aProgram); |
8625ef7e |
101 | } |
30f0ad28 |
102 | |
8625ef7e |
103 | //! Bind program for line rendering |
299e0ab9 |
104 | Standard_Boolean BindLineProgram (const Handle(OpenGl_Texture)& theTexture, |
105 | const Standard_Boolean theStipple, |
106 | const Standard_Boolean theToLightOn, |
107 | const Standard_Boolean theHasVertColor, |
108 | const Handle(OpenGl_ShaderProgram)& theCustomProgram) |
8625ef7e |
109 | { |
110 | if (!theCustomProgram.IsNull() |
111 | || myContext->caps->ffpEnable) |
112 | { |
299e0ab9 |
113 | return bindProgramWithState (theCustomProgram); |
8625ef7e |
114 | } |
115 | |
ac116c22 |
116 | Standard_Integer aBits = getProgramBits (theTexture, theHasVertColor); |
299e0ab9 |
117 | if (theStipple) |
ac116c22 |
118 | { |
119 | aBits |= OpenGl_PO_StippleLine; |
120 | } |
121 | |
8625ef7e |
122 | Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theToLightOn, aBits); |
299e0ab9 |
123 | return bindProgramWithState (aProgram); |
8625ef7e |
124 | } |
30f0ad28 |
125 | |
8625ef7e |
126 | //! Bind program for point rendering |
299e0ab9 |
127 | Standard_Boolean BindMarkerProgram (const Handle(OpenGl_Texture)& theTexture, |
128 | const Standard_Boolean theToLightOn, |
129 | const Standard_Boolean theHasVertColor, |
130 | const Handle(OpenGl_ShaderProgram)& theCustomProgram) |
8625ef7e |
131 | { |
132 | if (!theCustomProgram.IsNull() |
133 | || myContext->caps->ffpEnable) |
134 | { |
299e0ab9 |
135 | return bindProgramWithState (theCustomProgram); |
8625ef7e |
136 | } |
137 | |
138 | const Standard_Integer aBits = getProgramBits (theTexture, theHasVertColor) | OpenGl_PO_Point; |
139 | Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theToLightOn, aBits); |
299e0ab9 |
140 | return bindProgramWithState (aProgram); |
8625ef7e |
141 | } |
142 | |
143 | //! Bind program for rendering alpha-textured font. |
299e0ab9 |
144 | Standard_Boolean BindFontProgram (const Handle(OpenGl_ShaderProgram)& theCustomProgram) |
8625ef7e |
145 | { |
146 | if (!theCustomProgram.IsNull() |
147 | || myContext->caps->ffpEnable) |
148 | { |
299e0ab9 |
149 | return bindProgramWithState (theCustomProgram); |
8625ef7e |
150 | } |
151 | |
152 | if (myFontProgram.IsNull()) |
153 | { |
154 | prepareStdProgramFont(); |
155 | } |
299e0ab9 |
156 | |
157 | return bindProgramWithState (myFontProgram); |
8625ef7e |
158 | } |
30f0ad28 |
159 | |
b86bb3df |
160 | //! Bind program for FBO blit operation. |
161 | Standard_Boolean BindFboBlitProgram() |
162 | { |
163 | if (myBlitProgram.IsNull()) |
164 | { |
165 | prepareStdProgramFboBlit(); |
166 | } |
167 | return !myBlitProgram.IsNull() |
168 | && myContext->BindProgram (myBlitProgram); |
169 | } |
170 | |
a1073ae2 |
171 | //! Bind program for blended order-independent transparency buffers compositing. |
172 | Standard_Boolean BindOitCompositingProgram (const Standard_Boolean theIsMSAAEnabled) |
173 | { |
174 | const Standard_Integer aProgramIdx = theIsMSAAEnabled ? 1 : 0; |
175 | if (myOitCompositingProgram[aProgramIdx].IsNull()) |
176 | { |
177 | prepareStdProgramOitCompositing (theIsMSAAEnabled); |
178 | } |
179 | |
180 | const Handle(OpenGl_ShaderProgram)& aProgram = myOitCompositingProgram [aProgramIdx]; |
181 | return !aProgram.IsNull() && myContext->BindProgram (aProgram); |
182 | } |
183 | |
f978241f |
184 | //! Bind program for rendering stereoscopic image. |
185 | Standard_Boolean BindStereoProgram (const Graphic3d_StereoMode theStereoMode) |
38a0206f |
186 | { |
f978241f |
187 | if (theStereoMode < 0 || theStereoMode >= Graphic3d_StereoMode_NB) |
38a0206f |
188 | { |
f978241f |
189 | return Standard_False; |
38a0206f |
190 | } |
f978241f |
191 | |
192 | if (myStereoPrograms[theStereoMode].IsNull()) |
193 | { |
194 | prepareStdProgramStereo (myStereoPrograms[theStereoMode], theStereoMode); |
195 | } |
196 | const Handle(OpenGl_ShaderProgram)& aProgram = myStereoPrograms[theStereoMode]; |
197 | return !aProgram.IsNull() |
198 | && myContext->BindProgram (aProgram); |
38a0206f |
199 | } |
200 | |
30f0ad28 |
201 | public: |
202 | |
203 | //! Returns current state of OCCT light sources. |
8613985b |
204 | const OpenGl_LightSourceState& LightSourceState() const { return myLightSourceState; } |
30f0ad28 |
205 | |
206 | //! Updates state of OCCT light sources. |
207 | Standard_EXPORT void UpdateLightSourceStateTo (const OpenGl_ListOfLight* theLights); |
208 | |
7c3ef2f7 |
209 | //! Invalidate state of OCCT light sources. |
210 | Standard_EXPORT void UpdateLightSourceState(); |
211 | |
30f0ad28 |
212 | //! Pushes current state of OCCT light sources to specified program. |
213 | Standard_EXPORT void PushLightSourceState (const Handle(OpenGl_ShaderProgram)& theProgram) const; |
214 | |
215 | public: |
216 | |
217 | //! Returns current state of OCCT projection transform. |
8613985b |
218 | const OpenGl_ProjectionState& ProjectionState() const { return myProjectionState; } |
30f0ad28 |
219 | |
220 | //! Updates state of OCCT projection transform. |
c827ea3a |
221 | Standard_EXPORT void UpdateProjectionStateTo (const OpenGl_Mat4& theProjectionMatrix); |
30f0ad28 |
222 | |
30f0ad28 |
223 | //! Pushes current state of OCCT projection transform to specified program. |
224 | Standard_EXPORT void PushProjectionState (const Handle(OpenGl_ShaderProgram)& theProgram) const; |
225 | |
226 | public: |
227 | |
228 | //! Returns current state of OCCT model-world transform. |
8613985b |
229 | const OpenGl_ModelWorldState& ModelWorldState() const { return myModelWorldState; } |
30f0ad28 |
230 | |
231 | //! Updates state of OCCT model-world transform. |
c827ea3a |
232 | Standard_EXPORT void UpdateModelWorldStateTo (const OpenGl_Mat4& theModelWorldMatrix); |
30f0ad28 |
233 | |
30f0ad28 |
234 | //! Pushes current state of OCCT model-world transform to specified program. |
235 | Standard_EXPORT void PushModelWorldState (const Handle(OpenGl_ShaderProgram)& theProgram) const; |
236 | |
237 | public: |
238 | |
239 | //! Returns current state of OCCT world-view transform. |
8613985b |
240 | const OpenGl_WorldViewState& WorldViewState() const { return myWorldViewState; } |
30f0ad28 |
241 | |
242 | //! Updates state of OCCT world-view transform. |
c827ea3a |
243 | Standard_EXPORT void UpdateWorldViewStateTo (const OpenGl_Mat4& theWorldViewMatrix); |
30f0ad28 |
244 | |
30f0ad28 |
245 | //! Pushes current state of OCCT world-view transform to specified program. |
246 | Standard_EXPORT void PushWorldViewState (const Handle(OpenGl_ShaderProgram)& theProgram) const; |
247 | |
248 | public: |
249 | |
250 | //! Updates state of OCCT clipping planes. |
251 | Standard_EXPORT void UpdateClippingState(); |
252 | |
253 | //! Reverts state of OCCT clipping planes. |
254 | Standard_EXPORT void RevertClippingState(); |
255 | |
256 | //! Pushes current state of OCCT clipping planes to specified program. |
257 | Standard_EXPORT void PushClippingState (const Handle(OpenGl_ShaderProgram)& theProgram) const; |
258 | |
259 | public: |
260 | |
8613985b |
261 | //! Returns current state of material. |
262 | const OpenGl_MaterialState& MaterialState() const { return myMaterialState; } |
263 | |
264 | //! Updates state of material. |
265 | void UpdateMaterialStateTo (const OpenGl_Material& theFrontMat, |
266 | const OpenGl_Material& theBackMat, |
267 | const bool theToDistinguish, |
268 | const bool theToMapTexture) |
269 | { |
270 | myMaterialState.Set (theFrontMat, theBackMat, theToDistinguish, theToMapTexture); |
271 | myMaterialState.Update(); |
272 | } |
273 | |
274 | //! Updates state of material. |
275 | void UpdateMaterialState() |
276 | { |
277 | myMaterialState.Update(); |
278 | } |
279 | |
280 | //! Pushes current state of material to specified program. |
281 | void PushMaterialState (const Handle(OpenGl_ShaderProgram)& theProgram) const; |
282 | |
283 | public: |
284 | |
a1073ae2 |
285 | //! Set the state of OIT rendering pass. |
286 | //! @param theToEnableOitWrite [in] flag indicating whether the special output should be written for OIT algorithm. |
287 | //! @param theDepthFactor [in] the scalar factor of depth influence to the fragment's coverage. |
288 | void SetOitState (const bool theToEnableOitWrite, const float theDepthFactor) |
289 | { |
290 | myOitState.Set (theToEnableOitWrite, theDepthFactor); |
291 | myOitState.Update(); |
292 | } |
293 | |
294 | //! Pushes state of OIT uniforms to the specified program. |
295 | Standard_EXPORT void PushOitState (const Handle(OpenGl_ShaderProgram)& theProgram) const; |
296 | |
297 | public: |
298 | |
30f0ad28 |
299 | //! Pushes current state of OCCT graphics parameters to specified program. |
300 | Standard_EXPORT void PushState (const Handle(OpenGl_ShaderProgram)& theProgram) const; |
301 | |
392ac980 |
302 | public: |
303 | |
304 | //! Overwrites context |
305 | void SetContext (OpenGl_Context* theCtx) |
306 | { |
307 | myContext = theCtx; |
308 | } |
309 | |
c357e426 |
310 | //! Returns true when provided context is the same as used one by shader manager. |
311 | bool IsSameContext (OpenGl_Context* theCtx) const |
312 | { |
313 | return myContext == theCtx; |
314 | } |
315 | |
8625ef7e |
316 | //! Sets shading model. |
c357e426 |
317 | Standard_EXPORT void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel); |
8625ef7e |
318 | |
e6804ff7 |
319 | //! Sets last view manger used with. |
320 | //! Helps to handle matrix states in multi-view configurations. |
321 | void SetLastView (const OpenGl_View* theLastView) |
322 | { |
323 | myLastView = theLastView; |
324 | } |
325 | |
326 | //! Returns true when provided view is the same as cached one. |
327 | bool IsSameView (const OpenGl_View* theView) const |
328 | { |
329 | return myLastView == theView; |
330 | } |
331 | |
30f0ad28 |
332 | protected: |
333 | |
8625ef7e |
334 | //! Define program bits. |
335 | Standard_Integer getProgramBits (const Handle(OpenGl_Texture)& theTexture, |
e135a155 |
336 | const Standard_Boolean theHasVertColor, |
337 | const Standard_Boolean theEnableEnvMap = Standard_False) |
338 | |
8625ef7e |
339 | { |
340 | Standard_Integer aBits = 0; |
1a7ece8f |
341 | |
342 | const Standard_Integer aNbPlanes = myContext->Clipping().NbClippingOrCappingOn(); |
343 | if (aNbPlanes > 0) |
8625ef7e |
344 | { |
1a7ece8f |
345 | aBits |= OpenGl_PO_ClipPlanesN; |
346 | if (aNbPlanes == 1) |
347 | { |
348 | aBits |= OpenGl_PO_ClipPlanes1; |
349 | } |
350 | else if (aNbPlanes == 2) |
351 | { |
352 | aBits |= OpenGl_PO_ClipPlanes2; |
353 | } |
8625ef7e |
354 | } |
1a7ece8f |
355 | |
83da37b1 |
356 | if (theEnableEnvMap) |
e135a155 |
357 | { |
358 | // Environment map overwrites material texture |
359 | aBits |= OpenGl_PO_TextureEnv; |
360 | } |
361 | else if (!theTexture.IsNull()) |
8625ef7e |
362 | { |
4e1523ef |
363 | aBits |= theTexture->IsAlpha() ? OpenGl_PO_TextureA : OpenGl_PO_TextureRGB; |
8625ef7e |
364 | } |
365 | if (theHasVertColor) |
366 | { |
367 | aBits |= OpenGl_PO_VertColor; |
368 | } |
a1073ae2 |
369 | |
370 | if (myOitState.ToEnableWrite()) |
371 | { |
372 | aBits |= OpenGl_PO_WriteOit; |
373 | } |
8625ef7e |
374 | return aBits; |
375 | } |
376 | |
377 | //! Prepare standard GLSL program. |
378 | Handle(OpenGl_ShaderProgram)& getStdProgram (const Standard_Boolean theToLightOn, |
379 | const Standard_Integer theBits) |
380 | { |
e135a155 |
381 | // If environment map is enabled lighting calculations are |
382 | // not needed (in accordance with default OCCT behaviour) |
383 | if (theToLightOn && (theBits & OpenGl_PO_TextureEnv) == 0) |
8625ef7e |
384 | { |
256f9ac0 |
385 | Handle(OpenGl_ShaderProgram)& aProgram = myLightPrograms->ChangeValue (theBits); |
8625ef7e |
386 | if (aProgram.IsNull()) |
387 | { |
388 | prepareStdProgramLight (aProgram, theBits); |
389 | } |
390 | return aProgram; |
391 | } |
392 | |
256f9ac0 |
393 | Handle(OpenGl_ShaderProgram)& aProgram = myFlatPrograms.ChangeValue (theBits); |
8625ef7e |
394 | if (aProgram.IsNull()) |
395 | { |
396 | prepareStdProgramFlat (aProgram, theBits); |
397 | } |
398 | return aProgram; |
399 | } |
400 | |
299e0ab9 |
401 | //! Prepare standard GLSL program for accessing point sprite alpha. |
fd59283a |
402 | Standard_EXPORT TCollection_AsciiString pointSpriteAlphaSrc (const Standard_Integer theBits); |
299e0ab9 |
403 | |
404 | //! Prepare standard GLSL program for computing point sprite shading. |
405 | Standard_EXPORT TCollection_AsciiString pointSpriteShadingSrc (const TCollection_AsciiString theBaseColorSrc, const Standard_Integer theBits); |
406 | |
8625ef7e |
407 | //! Prepare standard GLSL program for textured font. |
408 | Standard_EXPORT Standard_Boolean prepareStdProgramFont(); |
409 | |
b86bb3df |
410 | //! Prepare standard GLSL program for FBO blit operation. |
411 | Standard_EXPORT Standard_Boolean prepareStdProgramFboBlit(); |
412 | |
a1073ae2 |
413 | //! Prepare standard GLSL programs for OIT compositing operation. |
414 | Standard_EXPORT Standard_Boolean prepareStdProgramOitCompositing (const Standard_Boolean theMsaa); |
415 | |
8625ef7e |
416 | //! Prepare standard GLSL program without lighting. |
417 | Standard_EXPORT Standard_Boolean prepareStdProgramFlat (Handle(OpenGl_ShaderProgram)& theProgram, |
418 | const Standard_Integer theBits); |
419 | |
420 | //! Prepare standard GLSL program with lighting. |
421 | Standard_Boolean prepareStdProgramLight (Handle(OpenGl_ShaderProgram)& theProgram, |
422 | const Standard_Integer theBits) |
423 | { |
c357e426 |
424 | return myShadingModel == Graphic3d_TOSM_FRAGMENT |
8625ef7e |
425 | ? prepareStdProgramPhong (theProgram, theBits) |
426 | : prepareStdProgramGouraud (theProgram, theBits); |
427 | } |
428 | |
429 | //! Prepare standard GLSL program with per-vertex lighting. |
430 | Standard_EXPORT Standard_Boolean prepareStdProgramGouraud (Handle(OpenGl_ShaderProgram)& theProgram, |
431 | const Standard_Integer theBits); |
432 | |
433 | //! Prepare standard GLSL program with per-pixel lighting. |
434 | Standard_EXPORT Standard_Boolean prepareStdProgramPhong (Handle(OpenGl_ShaderProgram)& theProgram, |
435 | const Standard_Integer theBits); |
436 | |
256f9ac0 |
437 | //! Define computeLighting GLSL function depending on current lights configuration |
abdf0b10 |
438 | //! @param theHasVertColor flag to use getVertColor() instead of Ambient and Diffuse components of active material |
439 | Standard_EXPORT TCollection_AsciiString stdComputeLighting (const Standard_Boolean theHasVertColor); |
256f9ac0 |
440 | |
8625ef7e |
441 | //! Bind specified program to current context and apply state. |
299e0ab9 |
442 | Standard_EXPORT Standard_Boolean bindProgramWithState (const Handle(OpenGl_ShaderProgram)& theProgram); |
8625ef7e |
443 | |
256f9ac0 |
444 | //! Set pointer myLightPrograms to active lighting programs set from myMapOfLightPrograms |
445 | Standard_EXPORT void switchLightPrograms(); |
446 | |
f978241f |
447 | //! Prepare standard GLSL program for stereoscopic image. |
448 | Standard_EXPORT Standard_Boolean prepareStdProgramStereo (Handle(OpenGl_ShaderProgram)& theProgram, |
449 | const Graphic3d_StereoMode theStereoMode); |
38a0206f |
450 | |
8625ef7e |
451 | protected: |
452 | |
7c3ef2f7 |
453 | //! Packed properties of light source |
454 | struct OpenGl_ShaderLightParameters |
455 | { |
456 | OpenGl_Vec4 Color; |
457 | OpenGl_Vec4 Position; |
458 | OpenGl_Vec4 Direction; |
459 | OpenGl_Vec4 Parameters; |
460 | |
461 | //! Returns packed (serialized) representation of light source properties |
462 | const OpenGl_Vec4* Packed() const { return reinterpret_cast<const OpenGl_Vec4*> (this); } |
463 | static Standard_Integer NbOfVec4() { return 4; } |
464 | }; |
465 | |
466 | //! Packed light source type information |
467 | struct OpenGl_ShaderLightType |
468 | { |
469 | Standard_Integer Type; |
470 | Standard_Integer IsHeadlight; |
471 | |
472 | //! Returns packed (serialized) representation of light source type |
473 | const OpenGl_Vec2i* Packed() const { return reinterpret_cast<const OpenGl_Vec2i*> (this); } |
474 | static Standard_Integer NbOfVec2i() { return 1; } |
475 | }; |
476 | |
8613985b |
477 | //! Fake OpenGL program for tracking FFP state in the way consistent to programmable pipeline. |
478 | class OpenGl_ShaderProgramFFP : public OpenGl_ShaderProgram |
479 | { |
480 | DEFINE_STANDARD_RTTI_INLINE(OpenGl_ShaderProgramFFP, OpenGl_ShaderProgram) |
481 | friend class OpenGl_ShaderManager; |
482 | protected: |
483 | OpenGl_ShaderProgramFFP() {} |
484 | }; |
485 | |
7c3ef2f7 |
486 | protected: |
487 | |
8613985b |
488 | Handle(OpenGl_ShaderProgramFFP) myFfpProgram; |
489 | |
c357e426 |
490 | Graphic3d_TypeOfShadingModel myShadingModel; //!< lighting shading model |
256f9ac0 |
491 | OpenGl_ShaderProgramList myProgramList; //!< The list of shader programs |
492 | Handle(OpenGl_SetOfShaderPrograms) myLightPrograms; //!< pointer to active lighting programs matrix |
493 | OpenGl_SetOfShaderPrograms myFlatPrograms; //!< programs matrix without lighting |
494 | Handle(OpenGl_ShaderProgram) myFontProgram; //!< standard program for textured text |
b86bb3df |
495 | Handle(OpenGl_ShaderProgram) myBlitProgram; //!< standard program for FBO blit emulation |
a1073ae2 |
496 | Handle(OpenGl_ShaderProgram) myOitCompositingProgram[2]; //!< standard program for OIT compositing (default and MSAA). |
256f9ac0 |
497 | OpenGl_MapOfShaderPrograms myMapOfLightPrograms; //!< map of lighting programs depending on shading model and lights configuration |
8625ef7e |
498 | |
f978241f |
499 | Handle(OpenGl_ShaderProgram) myStereoPrograms[Graphic3d_StereoMode_NB]; //!< standard stereo programs |
38a0206f |
500 | |
256f9ac0 |
501 | OpenGl_Context* myContext; //!< OpenGL context |
8625ef7e |
502 | |
503 | protected: |
504 | |
256f9ac0 |
505 | OpenGl_ProjectionState myProjectionState; //!< State of OCCT projection transformation |
506 | OpenGl_ModelWorldState myModelWorldState; //!< State of OCCT model-world transformation |
507 | OpenGl_WorldViewState myWorldViewState; //!< State of OCCT world-view transformation |
8cf06aa2 |
508 | OpenGl_ClippingState myClippingState; //!< State of OCCT clipping planes |
256f9ac0 |
509 | OpenGl_LightSourceState myLightSourceState; //!< State of OCCT light sources |
8613985b |
510 | OpenGl_MaterialState myMaterialState; //!< State of Front and Back materials |
a1073ae2 |
511 | OpenGl_OitState myOitState; //!< State of OIT uniforms |
8613985b |
512 | |
7c3ef2f7 |
513 | gp_XYZ myLocalOrigin; //!< local camera transformation |
514 | Standard_Boolean myHasLocalOrigin; //!< flag indicating that local camera transformation has been set |
515 | |
516 | mutable OpenGl_ShaderLightType myLightTypeArray [OpenGLMaxLights]; |
517 | mutable OpenGl_ShaderLightParameters myLightParamsArray[OpenGLMaxLights]; |
30f0ad28 |
518 | |
519 | private: |
520 | |
256f9ac0 |
521 | const OpenGl_View* myLastView; //!< Pointer to the last view shader manager used with |
8625ef7e |
522 | |
30f0ad28 |
523 | }; |
524 | |
8613985b |
525 | DEFINE_STANDARD_HANDLE(OpenGl_ShaderManager, Standard_Transient) |
526 | |
30f0ad28 |
527 | #endif // _OpenGl_ShaderManager_HeaderFile |