1 // Created on: 2014-10-08
2 // Created by: Kirill Gavrilov
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _OpenGl_SetOfShaderPrograms_HeaderFile
17 #define _OpenGl_SetOfShaderPrograms_HeaderFile
19 #include <Graphic3d_TypeOfShadingModel.hxx>
20 #include <NCollection_DataMap.hxx>
21 #include <OpenGl_ShaderProgram.hxx>
23 //! Standard GLSL program combination bits.
24 enum OpenGl_ProgramOptions
26 OpenGl_PO_VertColor = 0x0001, //!< per-vertex color
27 OpenGl_PO_TextureRGB = 0x0002, //!< handle RGB texturing
28 OpenGl_PO_TextureEnv = 0x0004, //!< handle environment map (obsolete, to be removed)
29 OpenGl_PO_TextureNormal = OpenGl_PO_TextureRGB|OpenGl_PO_TextureEnv, //!< extended texture set (with normal map)
30 OpenGl_PO_PointSimple = 0x0008, //!< point marker without sprite
31 OpenGl_PO_PointSprite = 0x0010, //!< point sprite with RGB image
32 OpenGl_PO_PointSpriteA = OpenGl_PO_PointSimple|OpenGl_PO_PointSprite, //!< point sprite with Alpha image
33 OpenGl_PO_StippleLine = 0x0020, //!< stipple line
34 OpenGl_PO_ClipPlanes1 = 0x0040, //!< handle 1 clipping plane
35 OpenGl_PO_ClipPlanes2 = 0x0080, //!< handle 2 clipping planes
36 OpenGl_PO_ClipPlanesN = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle N clipping planes
37 OpenGl_PO_ClipChains = 0x0100, //!< handle chains of clipping planes
38 OpenGl_PO_MeshEdges = 0x0200, //!< draw mesh edges (wireframe)
39 OpenGl_PO_AlphaTest = 0x0400, //!< discard fragment by alpha test (defined by cutoff value)
40 OpenGl_PO_WriteOit = 0x0800, //!< write coverage buffer for Blended Order-Independent Transparency
42 OpenGl_PO_NB = 0x1000, //!< overall number of combinations
43 OpenGl_PO_IsPoint = OpenGl_PO_PointSimple|OpenGl_PO_PointSprite|OpenGl_PO_PointSpriteA,
44 OpenGl_PO_HasTextures = OpenGl_PO_TextureRGB|OpenGl_PO_TextureEnv,
45 OpenGl_PO_NeedsGeomShader = OpenGl_PO_MeshEdges,
48 //! Alias to programs array of predefined length
49 class OpenGl_SetOfPrograms : public Standard_Transient
51 DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfPrograms, Standard_Transient)
55 OpenGl_SetOfPrograms() {}
57 //! Access program by index
58 Handle(OpenGl_ShaderProgram)& ChangeValue (Standard_Integer theProgramBits) { return myPrograms[theProgramBits]; }
61 Handle(OpenGl_ShaderProgram) myPrograms[OpenGl_PO_NB]; //!< programs array
64 //! Alias to 2D programs array of predefined length
65 class OpenGl_SetOfShaderPrograms : public Standard_Transient
67 DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms, Standard_Transient)
71 OpenGl_SetOfShaderPrograms() {}
74 OpenGl_SetOfShaderPrograms (const Handle(OpenGl_SetOfPrograms)& thePrograms)
76 for (Standard_Integer aSetIter = 0; aSetIter < Graphic3d_TypeOfShadingModel_NB - 1; ++aSetIter)
78 myPrograms[aSetIter] = thePrograms;
82 //! Access program by index
83 Handle(OpenGl_ShaderProgram)& ChangeValue (Graphic3d_TypeOfShadingModel theShadingModel,
84 Standard_Integer theProgramBits)
86 Handle(OpenGl_SetOfPrograms)& aSet = myPrograms[theShadingModel - 1];
89 aSet = new OpenGl_SetOfPrograms();
91 return aSet->ChangeValue (theProgramBits);
95 Handle(OpenGl_SetOfPrograms) myPrograms[Graphic3d_TypeOfShadingModel_NB - 1]; //!< programs array, excluding Graphic3d_TOSM_UNLIT
98 typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_SetOfShaderPrograms)> OpenGl_MapOfShaderPrograms;
100 #endif // _OpenGl_SetOfShaderPrograms_HeaderFile