0024437: Visualization - silhouette edges based on OpenGL
[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{
2a332745 26 OpenGl_PO_Point = 0x0001, //!< point marker
27 OpenGl_PO_VertColor = 0x0002, //!< per-vertex color
28 OpenGl_PO_TextureRGB = 0x0004, //!< handle RGB texturing
6ef0d6f1 29 OpenGl_PO_TextureA = 0x0008, //!< handle Alpha texturing (point sprites only)
2a332745 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
39 //
40 OpenGl_PO_NB = 0x1000, //!< overall number of combinations
6ef0d6f1 41 OpenGl_PO_HasTextures = OpenGl_PO_TextureRGB|OpenGl_PO_TextureA,
2a332745 42 OpenGl_PO_NeedsGeomShader = OpenGl_PO_MeshEdges,
256f9ac0 43};
44
45//! Alias to programs array of predefined length
6ef0d6f1 46class OpenGl_SetOfPrograms : public Standard_Transient
47{
48 DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfPrograms, Standard_Transient)
49public:
50
51 //! Empty constructor
52 OpenGl_SetOfPrograms() {}
53
54 //! Access program by index
55 Handle(OpenGl_ShaderProgram)& ChangeValue (Standard_Integer theProgramBits) { return myPrograms[theProgramBits]; }
56
57protected:
58 Handle(OpenGl_ShaderProgram) myPrograms[OpenGl_PO_NB]; //!< programs array
59};
60
61//! Alias to 2D programs array of predefined length
256f9ac0 62class OpenGl_SetOfShaderPrograms : public Standard_Transient
63{
dc89236f 64 DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms, Standard_Transient)
256f9ac0 65public:
66
67 //! Empty constructor
68 OpenGl_SetOfShaderPrograms() {}
69
6ef0d6f1 70 //! Constructor
71 OpenGl_SetOfShaderPrograms (const Handle(OpenGl_SetOfPrograms)& thePrograms)
72 {
73 for (Standard_Integer aSetIter = 0; aSetIter < Graphic3d_TypeOfShadingModel_NB - 1; ++aSetIter)
74 {
75 myPrograms[aSetIter] = thePrograms;
76 }
77 }
78
256f9ac0 79 //! Access program by index
dc89236f 80 Handle(OpenGl_ShaderProgram)& ChangeValue (Graphic3d_TypeOfShadingModel theShadingModel,
81 Standard_Integer theProgramBits)
82 {
6ef0d6f1 83 Handle(OpenGl_SetOfPrograms)& aSet = myPrograms[theShadingModel - 1];
84 if (aSet.IsNull())
85 {
86 aSet = new OpenGl_SetOfPrograms();
87 }
88 return aSet->ChangeValue (theProgramBits);
dc89236f 89 }
256f9ac0 90
91protected:
6ef0d6f1 92 Handle(OpenGl_SetOfPrograms) myPrograms[Graphic3d_TypeOfShadingModel_NB - 1]; //!< programs array, excluding Graphic3d_TOSM_UNLIT
256f9ac0 93};
94
256f9ac0 95typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_SetOfShaderPrograms)> OpenGl_MapOfShaderPrograms;
96
97#endif // _OpenGl_SetOfShaderPrograms_HeaderFile