0029768: Visualization, TKOpenGl - structure is entirely clipped by suppressed clipping
[occt.git] / src / OpenGl / OpenGl_SetOfShaderPrograms.hxx
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
19 #include <Graphic3d_TypeOfShadingModel.hxx>
20 #include <NCollection_DataMap.hxx>
21 #include <OpenGl_ShaderProgram.hxx>
22
23 //! Standard GLSL program combination bits.
24 enum OpenGl_ProgramOptions
25 {
26   OpenGl_PO_Point       = 0x001, //!< point marker
27   OpenGl_PO_VertColor   = 0x002, //!< per-vertex color
28   OpenGl_PO_TextureRGB  = 0x004, //!< handle RGB   texturing
29   OpenGl_PO_TextureA    = 0x008, //!< handle Alpha texturing
30   OpenGl_PO_TextureEnv  = 0x010, //!< handle environment map
31   OpenGl_PO_StippleLine = 0x020, //!< stipple line
32   OpenGl_PO_ClipPlanes1 = 0x040, //!< handle 1 clipping plane
33   OpenGl_PO_ClipPlanes2 = 0x080, //!< handle 2 clipping planes
34   OpenGl_PO_ClipPlanesN = 0x100, //!< handle N clipping planes
35   OpenGl_PO_AlphaTest   = 0x200, //!< discard fragment by alpha test (defined by cutoff value)
36   OpenGl_PO_WriteOit    = 0x400, //!< write coverage buffer for Blended Order-Independent Transparency
37   OpenGl_PO_NB          = 0x800  //!< overall number of combinations
38 };
39
40 //! Alias to programs array of predefined length
41 class OpenGl_SetOfShaderPrograms : public Standard_Transient
42 {
43   DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms, Standard_Transient)
44 public:
45
46   //! Empty constructor
47   OpenGl_SetOfShaderPrograms() {}
48
49   //! Access program by index
50   Handle(OpenGl_ShaderProgram)& ChangeValue (Graphic3d_TypeOfShadingModel theShadingModel,
51                                              Standard_Integer theProgramBits)
52   {
53     return myPrograms[theShadingModel][theProgramBits];
54   }
55
56 protected:
57   Handle(OpenGl_ShaderProgram) myPrograms[Graphic3d_TypeOfShadingModel_NB][OpenGl_PO_NB]; //!< programs array
58 };
59
60 DEFINE_STANDARD_HANDLE(OpenGl_SetOfShaderPrograms, Standard_Transient)
61
62 typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_SetOfShaderPrograms)> OpenGl_MapOfShaderPrograms;
63
64 #endif // _OpenGl_SetOfShaderPrograms_HeaderFile