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