0029283: Visualization - allow defining more than 8 light sources
[occt.git] / src / Graphic3d / Graphic3d_ShaderProgram.hxx
index 5118e17..b723e9d 100755 (executable)
@@ -34,6 +34,14 @@ typedef NCollection_Sequence<Handle(Graphic3d_ShaderAttribute)> Graphic3d_Shader
 //! This class is responsible for managing shader programs.
 class Graphic3d_ShaderProgram : public Standard_Transient
 {
+  DEFINE_STANDARD_RTTIEXT(Graphic3d_ShaderProgram, Standard_Transient)
+public:
+
+  //! Default value of THE_MAX_LIGHTS macros within GLSL program (see Declarations.glsl).
+  static const Standard_Integer THE_MAX_LIGHTS_DEFAULT = 8;
+
+  //! Default value of THE_MAX_CLIP_PLANES macros within GLSL program (see Declarations.glsl).
+  static const Standard_Integer THE_MAX_CLIP_PLANES_DEFAULT = 8;
 
 public:
 
@@ -61,6 +69,32 @@ public:
   //! @endcode
   void SetHeader (const TCollection_AsciiString& theHeader) { myHeader = theHeader; }
 
+  //! Append line to GLSL header.
+  void AppendToHeader (const TCollection_AsciiString& theHeaderLine)
+  {
+    if (!myHeader.IsEmpty())
+    {
+      myHeader += "\n";
+    }
+    myHeader += theHeaderLine;
+  }
+
+  //! Return the length of array of light sources (THE_MAX_LIGHTS),
+  //! to be used for initialization occLightSources.
+  //! Default value is THE_MAX_LIGHTS_DEFAULT.
+  Standard_Integer NbLightsMax() const { return myNbLightsMax; }
+
+  //! Specify the length of array of light sources (THE_MAX_LIGHTS).
+  void SetNbLightsMax (Standard_Integer theNbLights) { myNbLightsMax = theNbLights; }
+
+  //! Return the length of array of clipping planes (THE_MAX_CLIP_PLANES),
+  //! to be used for initialization occClipPlaneEquations.
+  //! Default value is THE_MAX_CLIP_PLANES_DEFAULT.
+  Standard_Integer NbClipPlanesMax() const { return myNbClipPlanesMax; }
+
+  //! Specify the length of array of clipping planes (THE_MAX_CLIP_PLANES).
+  void SetNbClipPlanesMax (Standard_Integer theNbPlanes) { myNbClipPlanesMax = theNbPlanes; }
+
   //! Attaches shader object to the program object.
   Standard_EXPORT Standard_Boolean AttachShader (const Handle(Graphic3d_ShaderObject)& theShader);
 
@@ -121,10 +155,6 @@ public:
   //! @return the root folder with default GLSL programs.
   Standard_EXPORT static const TCollection_AsciiString& ShadersFolder();
 
-public:
-
-  DEFINE_STANDARD_RTTIEXT(Graphic3d_ShaderProgram,Standard_Transient)
-
 private:
 
   TCollection_AsciiString       myID;            //!< the unique identifier of program object
@@ -132,6 +162,8 @@ private:
   Graphic3d_ShaderVariableList  myVariables;     //!< the list of custom uniform variables
   Graphic3d_ShaderAttributeList myAttributes;    //!< the list of custom vertex attributes
   TCollection_AsciiString       myHeader;        //!< GLSL header with version code and used extensions
+  Standard_Integer              myNbLightsMax;   //!< length of array of light sources (THE_MAX_LIGHTS)
+  Standard_Integer              myNbClipPlanesMax; //!< length of array of clipping planes (THE_MAX_CLIP_PLANES)
 
 };