0030748: Visualization - Marker displayed in immediate layer ruins QT Quick view...
[occt.git] / src / OpenGl / OpenGl_SetOfShaderPrograms.hxx
CommitLineData
256f9ac0 1// Created on: 2014-10-08
2// Created by: Kirill Gavrilov
3// Copyright (c) 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_SetOfShaderPrograms_HeaderFile
17#define _OpenGl_SetOfShaderPrograms_HeaderFile
18
dc89236f 19#include <Graphic3d_TypeOfShadingModel.hxx>
256f9ac0 20#include <NCollection_DataMap.hxx>
21#include <OpenGl_ShaderProgram.hxx>
22
23//! Standard GLSL program combination bits.
24enum OpenGl_ProgramOptions
25{
737e9a8d 26 OpenGl_PO_VertColor = 0x0001, //!< per-vertex color
27 OpenGl_PO_TextureRGB = 0x0002, //!< handle RGB texturing
28 OpenGl_PO_PointSimple = 0x0004, //!< point marker without sprite
29 OpenGl_PO_PointSprite = 0x0008, //!< point sprite with RGB image
30 OpenGl_PO_PointSpriteA = OpenGl_PO_PointSimple|OpenGl_PO_PointSprite, //!< point sprite with Alpha image
2a332745 31 OpenGl_PO_TextureEnv = 0x0010, //!< handle environment map
32 OpenGl_PO_StippleLine = 0x0020, //!< stipple line
33 OpenGl_PO_ClipPlanes1 = 0x0040, //!< handle 1 clipping plane
34 OpenGl_PO_ClipPlanes2 = 0x0080, //!< handle 2 clipping planes
35 OpenGl_PO_ClipPlanesN = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle N clipping planes
36 OpenGl_PO_ClipChains = 0x0100, //!< handle chains of clipping planes
37 OpenGl_PO_MeshEdges = 0x0200, //!< draw mesh edges (wireframe)
38 OpenGl_PO_AlphaTest = 0x0400, //!< discard fragment by alpha test (defined by cutoff value)
39 OpenGl_PO_WriteOit = 0x0800, //!< write coverage buffer for Blended Order-Independent Transparency
40 //
41 OpenGl_PO_NB = 0x1000, //!< overall number of combinations
737e9a8d 42 OpenGl_PO_IsPoint = OpenGl_PO_PointSimple|OpenGl_PO_PointSprite|OpenGl_PO_PointSpriteA,
43 OpenGl_PO_HasTextures = OpenGl_PO_TextureRGB,
2a332745 44 OpenGl_PO_NeedsGeomShader = OpenGl_PO_MeshEdges,
256f9ac0 45};
46
47//! Alias to programs array of predefined length
6ef0d6f1 48class OpenGl_SetOfPrograms : public Standard_Transient
49{
50 DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfPrograms, Standard_Transient)
51public:
52
53 //! Empty constructor
54 OpenGl_SetOfPrograms() {}
55
56 //! Access program by index
57 Handle(OpenGl_ShaderProgram)& ChangeValue (Standard_Integer theProgramBits) { return myPrograms[theProgramBits]; }
58
59protected:
60 Handle(OpenGl_ShaderProgram) myPrograms[OpenGl_PO_NB]; //!< programs array
61};
62
63//! Alias to 2D programs array of predefined length
256f9ac0 64class OpenGl_SetOfShaderPrograms : public Standard_Transient
65{
dc89236f 66 DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms, Standard_Transient)
256f9ac0 67public:
68
69 //! Empty constructor
70 OpenGl_SetOfShaderPrograms() {}
71
6ef0d6f1 72 //! Constructor
73 OpenGl_SetOfShaderPrograms (const Handle(OpenGl_SetOfPrograms)& thePrograms)
74 {
75 for (Standard_Integer aSetIter = 0; aSetIter < Graphic3d_TypeOfShadingModel_NB - 1; ++aSetIter)
76 {
77 myPrograms[aSetIter] = thePrograms;
78 }
79 }
80
256f9ac0 81 //! Access program by index
dc89236f 82 Handle(OpenGl_ShaderProgram)& ChangeValue (Graphic3d_TypeOfShadingModel theShadingModel,
83 Standard_Integer theProgramBits)
84 {
6ef0d6f1 85 Handle(OpenGl_SetOfPrograms)& aSet = myPrograms[theShadingModel - 1];
86 if (aSet.IsNull())
87 {
88 aSet = new OpenGl_SetOfPrograms();
89 }
90 return aSet->ChangeValue (theProgramBits);
dc89236f 91 }
256f9ac0 92
93protected:
6ef0d6f1 94 Handle(OpenGl_SetOfPrograms) myPrograms[Graphic3d_TypeOfShadingModel_NB - 1]; //!< programs array, excluding Graphic3d_TOSM_UNLIT
256f9ac0 95};
96
256f9ac0 97typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_SetOfShaderPrograms)> OpenGl_MapOfShaderPrograms;
98
99#endif // _OpenGl_SetOfShaderPrograms_HeaderFile