0029519: Visualization, TKOpenGl - fallback to Graphic3d_TOSM_FACET from Gouraud...
[occt.git] / src / OpenGl / OpenGl_ShaderManager.hxx
1 // Created on: 2013-09-26
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _OpenGl_ShaderManager_HeaderFile
17 #define _OpenGl_ShaderManager_HeaderFile
18
19 #include <Graphic3d_ShaderProgram.hxx>
20 #include <Graphic3d_StereoMode.hxx>
21
22 #include <NCollection_DataMap.hxx>
23 #include <NCollection_Sequence.hxx>
24
25 #include <OpenGl_SetOfShaderPrograms.hxx>
26 #include <OpenGl_ShaderStates.hxx>
27 #include <OpenGl_AspectFace.hxx>
28 #include <OpenGl_AspectLine.hxx>
29 #include <OpenGl_AspectText.hxx>
30 #include <OpenGl_AspectMarker.hxx>
31 #include <OpenGl_MaterialState.hxx>
32 #include <OpenGl_Texture.hxx>
33
34 class OpenGl_View;
35
36 //! List of shader programs.
37 typedef NCollection_Sequence<Handle(OpenGl_ShaderProgram)> OpenGl_ShaderProgramList;
38
39 //! This class is responsible for managing shader programs.
40 class OpenGl_ShaderManager : public Standard_Transient
41 {
42   DEFINE_STANDARD_RTTIEXT(OpenGl_ShaderManager, Standard_Transient)
43   friend class OpenGl_ShaderProgram;
44 public:
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
52   //! Release all resources.
53   Standard_EXPORT void clear();
54
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
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
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);
73
74   //! Unregisters specified shader program.
75   Standard_EXPORT void Unregister (TCollection_AsciiString&      theShareKey,
76                                    Handle(OpenGl_ShaderProgram)& theProgram);
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
84   //! Bind program for filled primitives rendering
85   Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
86                                     const Graphic3d_TypeOfShadingModel  theShadingModel,
87                                     const Standard_Boolean              theHasVertColor,
88                                     const Standard_Boolean              theEnableEnvMap,
89                                     const Handle(OpenGl_ShaderProgram)& theCustomProgram)
90   {
91     if (!theCustomProgram.IsNull()
92      || myContext->caps->ffpEnable)
93     {
94       return bindProgramWithState (theCustomProgram);
95     }
96
97     const Graphic3d_TypeOfShadingModel aShadeModelOnFace = theShadingModel != Graphic3d_TOSM_UNLIT
98                                                         && (theTextures.IsNull() || theTextures->IsModulate())
99                                                         ? theShadingModel
100                                                         : Graphic3d_TOSM_UNLIT;
101     const Standard_Integer        aBits    = getProgramBits (theTextures, theHasVertColor, theEnableEnvMap);
102     Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (aShadeModelOnFace, aBits);
103     return bindProgramWithState (aProgram);
104   }
105
106   //! Bind program for line rendering
107   Standard_Boolean BindLineProgram (const Handle(OpenGl_TextureSet)&    theTextures,
108                                     const Aspect_TypeOfLine             theLineType,
109                                     const Graphic3d_TypeOfShadingModel  theShadingModel,
110                                     const Standard_Boolean              theHasVertColor,
111                                     const Handle(OpenGl_ShaderProgram)& theCustomProgram)
112   {
113     if (!theCustomProgram.IsNull()
114      || myContext->caps->ffpEnable)
115     {
116       return bindProgramWithState (theCustomProgram);
117     }
118
119     Standard_Integer aBits = getProgramBits (theTextures, theHasVertColor);
120     if (theLineType != Aspect_TOL_SOLID)
121     {
122       aBits |= OpenGl_PO_StippleLine;
123     }
124
125     Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
126     return bindProgramWithState (aProgram);
127   }
128
129   //! Bind program for point rendering
130   Standard_Boolean BindMarkerProgram (const Handle(OpenGl_TextureSet)&    theTextures,
131                                       const Graphic3d_TypeOfShadingModel  theShadingModel,
132                                       const Standard_Boolean              theHasVertColor,
133                                       const Handle(OpenGl_ShaderProgram)& theCustomProgram)
134   {
135     if (!theCustomProgram.IsNull()
136      || myContext->caps->ffpEnable)
137     {
138       return bindProgramWithState (theCustomProgram);
139     }
140
141     const Standard_Integer        aBits    = getProgramBits (theTextures, theHasVertColor) | OpenGl_PO_Point;
142     Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
143     return bindProgramWithState (aProgram);
144   }
145
146   //! Bind program for rendering alpha-textured font.
147   Standard_Boolean BindFontProgram (const Handle(OpenGl_ShaderProgram)& theCustomProgram)
148   {
149     if (!theCustomProgram.IsNull()
150      || myContext->caps->ffpEnable)
151     {
152       return bindProgramWithState (theCustomProgram);
153     }
154
155     if (myFontProgram.IsNull())
156     {
157       prepareStdProgramFont();
158     }
159
160     return bindProgramWithState (myFontProgram);
161   }
162
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
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
187   //! Bind program for rendering stereoscopic image.
188   Standard_Boolean BindStereoProgram (const Graphic3d_StereoMode theStereoMode)
189   {
190     if (theStereoMode < 0 || theStereoMode >= Graphic3d_StereoMode_NB)
191     {
192       return Standard_False;
193     }
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);
202   }
203
204 public:
205
206   //! Returns current state of OCCT light sources.
207   const OpenGl_LightSourceState& LightSourceState() const { return myLightSourceState; }
208
209   //! Updates state of OCCT light sources.
210   Standard_EXPORT void UpdateLightSourceStateTo (const Handle(Graphic3d_LightSet)& theLights);
211
212   //! Invalidate state of OCCT light sources.
213   Standard_EXPORT void UpdateLightSourceState();
214
215   //! Pushes current state of OCCT light sources to specified program.
216   Standard_EXPORT void PushLightSourceState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
217
218 public:
219
220   //! Returns current state of OCCT projection transform.
221   const OpenGl_ProjectionState& ProjectionState() const { return myProjectionState; }
222
223   //! Updates state of OCCT projection transform.
224   Standard_EXPORT void UpdateProjectionStateTo (const OpenGl_Mat4& theProjectionMatrix);
225
226   //! Pushes current state of OCCT projection transform to specified program.
227   Standard_EXPORT void PushProjectionState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
228
229 public:
230
231   //! Returns current state of OCCT model-world transform.
232   const OpenGl_ModelWorldState& ModelWorldState() const { return myModelWorldState; }
233
234   //! Updates state of OCCT model-world transform.
235   Standard_EXPORT void UpdateModelWorldStateTo (const OpenGl_Mat4& theModelWorldMatrix);
236
237   //! Pushes current state of OCCT model-world transform to specified program.
238   Standard_EXPORT void PushModelWorldState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
239
240 public:
241
242   //! Returns current state of OCCT world-view transform.
243   const OpenGl_WorldViewState& WorldViewState() const { return myWorldViewState; }
244
245   //! Updates state of OCCT world-view transform.
246   Standard_EXPORT void UpdateWorldViewStateTo (const OpenGl_Mat4& theWorldViewMatrix);
247
248   //! Pushes current state of OCCT world-view transform to specified program.
249   Standard_EXPORT void PushWorldViewState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
250
251 public:
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
262 public:
263
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
286 public:
287
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
300 public:
301
302   //! Pushes current state of OCCT graphics parameters to specified program.
303   Standard_EXPORT void PushState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
304
305 public:
306
307   //! Overwrites context
308   void SetContext (OpenGl_Context* theCtx)
309   {
310     myContext = theCtx;
311   }
312
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
319   //! Choose Shading Model for filled primitives.
320   //! Fallbacks to FACET model if there are no normal attributes.
321   Graphic3d_TypeOfShadingModel ChooseFaceShadingModel (Graphic3d_TypeOfShadingModel theCustomModel,
322                                                        bool theHasNodalNormals) const
323   {
324     if (!myContext->ColorMask())
325     {
326       return Graphic3d_TOSM_UNLIT;
327     }
328     Graphic3d_TypeOfShadingModel aModel = theCustomModel != Graphic3d_TOSM_DEFAULT ? theCustomModel : myShadingModel;
329     switch (aModel)
330     {
331       case Graphic3d_TOSM_DEFAULT:
332       case Graphic3d_TOSM_UNLIT:
333       case Graphic3d_TOSM_FACET:
334         return aModel;
335       case Graphic3d_TOSM_VERTEX:
336       case Graphic3d_TOSM_FRAGMENT:
337         return theHasNodalNormals ? aModel : Graphic3d_TOSM_FACET;
338     }
339     return Graphic3d_TOSM_UNLIT;
340   }
341
342   //! Choose Shading Model for line primitives.
343   //! Fallbacks to UNLIT model if there are no normal attributes.
344   Graphic3d_TypeOfShadingModel ChooseLineShadingModel (Graphic3d_TypeOfShadingModel theCustomModel,
345                                                        bool theHasNodalNormals) const
346   {
347     if (!myContext->ColorMask())
348     {
349       return Graphic3d_TOSM_UNLIT;
350     }
351     Graphic3d_TypeOfShadingModel aModel = theCustomModel != Graphic3d_TOSM_DEFAULT ? theCustomModel : myShadingModel;
352     switch (aModel)
353     {
354       case Graphic3d_TOSM_DEFAULT:
355       case Graphic3d_TOSM_UNLIT:
356       case Graphic3d_TOSM_FACET:
357         return Graphic3d_TOSM_UNLIT;
358       case Graphic3d_TOSM_VERTEX:
359       case Graphic3d_TOSM_FRAGMENT:
360         return theHasNodalNormals ? aModel : Graphic3d_TOSM_UNLIT;
361     }
362     return Graphic3d_TOSM_UNLIT;
363   }
364
365   //! Choose Shading Model for Marker primitives.
366   Graphic3d_TypeOfShadingModel ChooseMarkerShadingModel (Graphic3d_TypeOfShadingModel theCustomModel,
367                                                          bool theHasNodalNormals) const
368   {
369     return ChooseLineShadingModel (theCustomModel, theHasNodalNormals);
370   }
371
372   //! Returns default Shading Model.
373   Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
374
375   //! Sets shading model.
376   Standard_EXPORT void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel);
377
378   //! Sets last view manger used with.
379   //! Helps to handle matrix states in multi-view configurations.
380   void SetLastView (const OpenGl_View* theLastView)
381   {
382     myLastView = theLastView;
383   }
384
385   //! Returns true when provided view is the same as cached one.
386   bool IsSameView (const OpenGl_View* theView) const
387   {
388     return myLastView == theView;
389   }
390
391 protected:
392
393   //! Define program bits.
394   Standard_Integer getProgramBits (const Handle(OpenGl_TextureSet)& theTextures,
395                                    const Standard_Boolean theHasVertColor,
396                                    const Standard_Boolean theEnableEnvMap = Standard_False)
397
398   {
399     Standard_Integer aBits = 0;
400
401     const Standard_Integer aNbPlanes = myContext->Clipping().NbClippingOrCappingOn();
402     if (aNbPlanes > 0)
403     {
404       aBits |= OpenGl_PO_ClipPlanesN;
405       if (aNbPlanes == 1)
406       {
407         aBits |= OpenGl_PO_ClipPlanes1;
408       }
409       else if (aNbPlanes == 2)
410       {
411         aBits |= OpenGl_PO_ClipPlanes2;
412       }
413     }
414
415     if (theEnableEnvMap)
416     {
417       // Environment map overwrites material texture
418       aBits |= OpenGl_PO_TextureEnv;
419     }
420     else if (!theTextures.IsNull()
421           && !theTextures->IsEmpty()
422           && !theTextures->First().IsNull())
423     {
424       aBits |= theTextures->First()->IsAlpha() ? OpenGl_PO_TextureA : OpenGl_PO_TextureRGB;
425     }
426     if (theHasVertColor)
427     {
428       aBits |= OpenGl_PO_VertColor;
429     }
430
431     if (myOitState.ToEnableWrite())
432     {
433       aBits |= OpenGl_PO_WriteOit;
434     }
435     return aBits;
436   }
437
438   //! Prepare standard GLSL program.
439   Handle(OpenGl_ShaderProgram)& getStdProgram (Graphic3d_TypeOfShadingModel theShadingModel,
440                                                Standard_Integer theBits)
441   {
442     if (theShadingModel == Graphic3d_TOSM_UNLIT
443      || (theBits & OpenGl_PO_TextureEnv) != 0)
444     {
445       // If environment map is enabled lighting calculations are
446       // not needed (in accordance with default OCCT behavior)
447       Handle(OpenGl_ShaderProgram)& aProgram = myUnlitPrograms->ChangeValue (Graphic3d_TOSM_UNLIT, theBits);
448       if (aProgram.IsNull())
449       {
450         prepareStdProgramUnlit (aProgram, theBits);
451       }
452       return aProgram;
453     }
454
455     Handle(OpenGl_ShaderProgram)& aProgram = myLightPrograms->ChangeValue (theShadingModel, theBits);
456     if (aProgram.IsNull())
457     {
458       prepareStdProgramLight (aProgram, theShadingModel, theBits);
459     }
460     return aProgram;
461   }
462
463   //! Prepare standard GLSL program for accessing point sprite alpha.
464   Standard_EXPORT TCollection_AsciiString pointSpriteAlphaSrc (const Standard_Integer theBits);
465
466   //! Prepare standard GLSL program for computing point sprite shading.
467   Standard_EXPORT TCollection_AsciiString pointSpriteShadingSrc (const TCollection_AsciiString theBaseColorSrc, const Standard_Integer theBits);
468
469   //! Prepare standard GLSL program for textured font.
470   Standard_EXPORT Standard_Boolean prepareStdProgramFont();
471
472   //! Prepare standard GLSL program for FBO blit operation.
473   Standard_EXPORT Standard_Boolean prepareStdProgramFboBlit();
474
475   //! Prepare standard GLSL programs for OIT compositing operation.
476   Standard_EXPORT Standard_Boolean prepareStdProgramOitCompositing (const Standard_Boolean theMsaa);
477
478   //! Prepare standard GLSL program without lighting.
479   Standard_EXPORT Standard_Boolean prepareStdProgramUnlit (Handle(OpenGl_ShaderProgram)& theProgram,
480                                                            const Standard_Integer        theBits);
481
482   //! Prepare standard GLSL program with lighting.
483   Standard_Boolean prepareStdProgramLight (Handle(OpenGl_ShaderProgram)& theProgram,
484                                            Graphic3d_TypeOfShadingModel theShadingModel,
485                                            Standard_Integer theBits)
486   {
487     switch (theShadingModel)
488     {
489       case Graphic3d_TOSM_UNLIT:    return prepareStdProgramUnlit  (theProgram, theBits);
490       case Graphic3d_TOSM_FACET:    return prepareStdProgramPhong  (theProgram, theBits, true);
491       case Graphic3d_TOSM_VERTEX:   return prepareStdProgramGouraud(theProgram, theBits);
492       case Graphic3d_TOSM_DEFAULT:
493       case Graphic3d_TOSM_FRAGMENT: return prepareStdProgramPhong  (theProgram, theBits, false);
494     }
495     return false;
496   }
497
498   //! Prepare standard GLSL program with per-vertex lighting.
499   Standard_EXPORT Standard_Boolean prepareStdProgramGouraud (Handle(OpenGl_ShaderProgram)& theProgram,
500                                                              const Standard_Integer        theBits);
501
502   //! Prepare standard GLSL program with per-pixel lighting.
503   //! @param theIsFlatNormal when TRUE, the Vertex normals will be ignored and Face normal will be computed instead
504   Standard_EXPORT Standard_Boolean prepareStdProgramPhong (Handle(OpenGl_ShaderProgram)& theProgram,
505                                                            const Standard_Integer        theBits,
506                                                            const Standard_Boolean        theIsFlatNormal = false);
507
508   //! Define computeLighting GLSL function depending on current lights configuration
509   //! @param theNbLights     [out] number of defined light sources
510   //! @param theHasVertColor [in]  flag to use getVertColor() instead of Ambient and Diffuse components of active material
511   Standard_EXPORT TCollection_AsciiString stdComputeLighting (Standard_Integer& theNbLights,
512                                                               Standard_Boolean  theHasVertColor);
513
514   //! Bind specified program to current context and apply state.
515   Standard_EXPORT Standard_Boolean bindProgramWithState (const Handle(OpenGl_ShaderProgram)& theProgram);
516
517   //! Set pointer myLightPrograms to active lighting programs set from myMapOfLightPrograms
518   Standard_EXPORT void switchLightPrograms();
519
520   //! Prepare standard GLSL program for stereoscopic image.
521   Standard_EXPORT Standard_Boolean prepareStdProgramStereo (Handle(OpenGl_ShaderProgram)& theProgram,
522                                                             const Graphic3d_StereoMode    theStereoMode);
523
524 protected:
525
526   //! Packed properties of light source
527   struct OpenGl_ShaderLightParameters
528   {
529     OpenGl_Vec4 Color;
530     OpenGl_Vec4 Position;
531     OpenGl_Vec4 Direction;
532     OpenGl_Vec4 Parameters;
533
534     //! Returns packed (serialized) representation of light source properties
535     const OpenGl_Vec4* Packed() const { return reinterpret_cast<const OpenGl_Vec4*> (this); }
536     static Standard_Integer NbOfVec4() { return 4; }
537   };
538
539   //! Packed light source type information
540   struct OpenGl_ShaderLightType
541   {
542     Standard_Integer Type;
543     Standard_Integer IsHeadlight;
544
545     //! Returns packed (serialized) representation of light source type
546     const OpenGl_Vec2i* Packed() const { return reinterpret_cast<const OpenGl_Vec2i*> (this); }
547     static Standard_Integer NbOfVec2i() { return 1; }
548   };
549
550   //! Fake OpenGL program for tracking FFP state in the way consistent to programmable pipeline.
551   class OpenGl_ShaderProgramFFP : public OpenGl_ShaderProgram
552   {
553     DEFINE_STANDARD_RTTI_INLINE(OpenGl_ShaderProgramFFP, OpenGl_ShaderProgram)
554     friend class OpenGl_ShaderManager;
555   protected:
556     OpenGl_ShaderProgramFFP() {}
557   };
558
559 protected:
560
561   Handle(OpenGl_ShaderProgramFFP)    myFfpProgram;
562
563   Graphic3d_TypeOfShadingModel       myShadingModel;       //!< lighting shading model
564   OpenGl_ShaderProgramList           myProgramList;        //!< The list of shader programs
565   Handle(OpenGl_SetOfShaderPrograms) myLightPrograms;      //!< pointer to active lighting programs matrix
566   Handle(OpenGl_SetOfShaderPrograms) myUnlitPrograms;      //!< programs matrix without  lighting
567   Handle(OpenGl_ShaderProgram)       myFontProgram;        //!< standard program for textured text
568   Handle(OpenGl_ShaderProgram)       myBlitProgram;        //!< standard program for FBO blit emulation
569   Handle(OpenGl_ShaderProgram)       myOitCompositingProgram[2]; //!< standard program for OIT compositing (default and MSAA).
570   OpenGl_MapOfShaderPrograms         myMapOfLightPrograms; //!< map of lighting programs depending on lights configuration
571
572   Handle(OpenGl_ShaderProgram)       myStereoPrograms[Graphic3d_StereoMode_NB]; //!< standard stereo programs
573
574   OpenGl_Context*                    myContext;            //!< OpenGL context
575
576 protected:
577
578   OpenGl_ProjectionState             myProjectionState;    //!< State of OCCT projection  transformation
579   OpenGl_ModelWorldState             myModelWorldState;    //!< State of OCCT model-world transformation
580   OpenGl_WorldViewState              myWorldViewState;     //!< State of OCCT world-view  transformation
581   OpenGl_ClippingState               myClippingState;      //!< State of OCCT clipping planes
582   OpenGl_LightSourceState            myLightSourceState;   //!< State of OCCT light sources
583   OpenGl_MaterialState               myMaterialState;      //!< State of Front and Back materials
584   OpenGl_OitState                    myOitState;           //!< State of OIT uniforms
585
586   gp_XYZ                             myLocalOrigin;        //!< local camera transformation
587   Standard_Boolean                   myHasLocalOrigin;     //!< flag indicating that local camera transformation has been set
588
589   mutable NCollection_Array1<OpenGl_ShaderLightType>       myLightTypeArray;
590   mutable NCollection_Array1<OpenGl_ShaderLightParameters> myLightParamsArray;
591   mutable NCollection_Array1<OpenGl_Vec4>                  myClipPlaneArray;
592   mutable NCollection_Array1<OpenGl_Vec4d>                 myClipPlaneArrayFfp;
593
594 private:
595
596   const OpenGl_View*                 myLastView;           //!< Pointer to the last view shader manager used with
597
598 };
599
600 DEFINE_STANDARD_HANDLE(OpenGl_ShaderManager, Standard_Transient)
601
602 #endif // _OpenGl_ShaderManager_HeaderFile