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_Point = 0x0001, //!< point marker
27 OpenGl_PO_VertColor = 0x0002, //!< per-vertex color
28 OpenGl_PO_TextureRGB = 0x0004, //!< handle RGB texturing
29 OpenGl_PO_TextureA = 0x0008, //!< handle Alpha texturing (point sprites only)
30 OpenGl_PO_TextureEnv = 0x0010, //!< handle environment map
31 OpenGl_PO_StippleLine = 0x0020, //!< stipple line
32 OpenGl_PO_ClipPlanes1 = 0x0040, //!< handle 1 clipping plane
33 OpenGl_PO_ClipPlanes2 = 0x0080, //!< handle 2 clipping planes
34 OpenGl_PO_ClipPlanesN = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle N clipping planes
35 OpenGl_PO_ClipChains = 0x0100, //!< handle chains of clipping planes
36 OpenGl_PO_MeshEdges = 0x0200, //!< draw mesh edges (wireframe)
37 OpenGl_PO_AlphaTest = 0x0400, //!< discard fragment by alpha test (defined by cutoff value)
38 OpenGl_PO_WriteOit = 0x0800, //!< write coverage buffer for Blended Order-Independent Transparency
40 OpenGl_PO_NB = 0x1000, //!< overall number of combinations
41 OpenGl_PO_HasTextures = OpenGl_PO_TextureRGB|OpenGl_PO_TextureA,
42 OpenGl_PO_NeedsGeomShader = OpenGl_PO_MeshEdges,
45 //! Alias to programs array of predefined length
46 class OpenGl_SetOfPrograms : public Standard_Transient
48 DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfPrograms, Standard_Transient)
52 OpenGl_SetOfPrograms() {}
54 //! Access program by index
55 Handle(OpenGl_ShaderProgram)& ChangeValue (Standard_Integer theProgramBits) { return myPrograms[theProgramBits]; }
58 Handle(OpenGl_ShaderProgram) myPrograms[OpenGl_PO_NB]; //!< programs array
61 //! Alias to 2D programs array of predefined length
62 class OpenGl_SetOfShaderPrograms : public Standard_Transient
64 DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms, Standard_Transient)
68 OpenGl_SetOfShaderPrograms() {}
71 OpenGl_SetOfShaderPrograms (const Handle(OpenGl_SetOfPrograms)& thePrograms)
73 for (Standard_Integer aSetIter = 0; aSetIter < Graphic3d_TypeOfShadingModel_NB - 1; ++aSetIter)
75 myPrograms[aSetIter] = thePrograms;
79 //! Access program by index
80 Handle(OpenGl_ShaderProgram)& ChangeValue (Graphic3d_TypeOfShadingModel theShadingModel,
81 Standard_Integer theProgramBits)
83 Handle(OpenGl_SetOfPrograms)& aSet = myPrograms[theShadingModel - 1];
86 aSet = new OpenGl_SetOfPrograms();
88 return aSet->ChangeValue (theProgramBits);
92 Handle(OpenGl_SetOfPrograms) myPrograms[Graphic3d_TypeOfShadingModel_NB - 1]; //!< programs array, excluding Graphic3d_TOSM_UNLIT
95 typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_SetOfShaderPrograms)> OpenGl_MapOfShaderPrograms;
97 #endif // _OpenGl_SetOfShaderPrograms_HeaderFile