0024887: Visualization - revise and extend Raytracing controls
[occt.git] / src / OpenGl / OpenGl_Workspace.hxx
index 9c32f49..d9f9634 100755 (executable)
@@ -34,6 +34,7 @@
 #include <Aspect_CLayer2d.hxx>
 #include <Aspect_Handle.hxx>
 #include <Aspect_PrintAlgo.hxx>
+#include <Aspect_PolygonOffsetMode.hxx>
 
 #include <InterfaceGraphic_Graphic3d.hxx>
 #include <InterfaceGraphic_Visual3d.hxx>
@@ -41,7 +42,6 @@
 #include <NCollection_Sequence.hxx>
 
 #include <OpenGl_AspectFace.hxx>
-#include <OpenGl_Display.hxx>
 #include <OpenGl_FrameBuffer.hxx>
 #include <OpenGl_Matrix.hxx>
 #include <OpenGl_NamedStatus.hxx>
@@ -50,6 +50,7 @@
 #include <OpenGl_TextParam.hxx>
 #include <OpenGl_RenderFilter.hxx>
 #include <OpenGl_Vec.hxx>
+#include <OpenGl_LineAttributes.hxx>
 
 #include <Handle_OpenGl_View.hxx>
 #include <Handle_OpenGl_Texture.hxx>
@@ -98,7 +99,7 @@ class OpenGl_Workspace : public OpenGl_Window
 public:
 
   //! Main constructor - prepare GL context for specified window.
-  OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay,
+  OpenGl_Workspace (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
                     const CALL_DEF_WINDOW&        theCWindow,
                     Aspect_RenderingContext       theGContext,
                     const Handle(OpenGl_Caps)&    theCaps,
@@ -156,6 +157,8 @@ public:
   Standard_Boolean& UseDepthTest() { return myUseDepthTest; }
   Standard_Boolean& UseGLLight()   { return myUseGLLight; }
 
+  Standard_Integer AntiAliasingMode() const { return myAntiAliasingMode; }
+
   //// RELATED TO STATUS ////
 
   Standard_Integer   NamedStatus;
@@ -215,6 +218,12 @@ public:
   //! @return applied model structure matrix.
   inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
 
+  //! Sets and applies current polygon offset.
+  void SetPolygonOffset (int theMode, Standard_ShortReal theFactor, Standard_ShortReal theUnits);
+
+  //! Returns currently applied polygon offset params.
+  const TEL_POFFSET_PARAM& AppliedPolygonOffset() { return PolygonOffset_applied; }
+
 protected:
 
   //! Copy content of Back buffer to the Front buffer
@@ -354,9 +363,34 @@ protected:
 
   };
 
+  //! Default ray-tracing depth.
+  static const Standard_Integer THE_DEFAULT_RAY_DEPTH = 3;
+
   //! Default size of traversal stack.
   static const Standard_Integer THE_DEFAULT_STACK_SIZE = 24;
 
+  //! Compile-time ray-tracing parameters.
+  struct RaytracingParams
+  {
+    //! Actual size of traversal stack in shader program.
+    Standard_Integer StackSize;
+
+    //! Actual ray-tracing depth (number of ray bounces).
+    Standard_Integer TraceDepth;
+
+    //! Sets light propagation through transparent media.
+    Standard_Boolean TransparentShadows;
+
+    //! Creates default compile-time ray-tracing parameters.
+    RaytracingParams()
+    : StackSize (THE_DEFAULT_STACK_SIZE),
+      TraceDepth (THE_DEFAULT_RAY_DEPTH),
+      TransparentShadows (Standard_False)
+    {
+      //
+    }
+  };
+
 protected: //! @name methods related to ray-tracing
 
   //! Updates 3D scene geometry for ray-tracing.
@@ -435,7 +469,7 @@ protected: //! @name methods related to ray-tracing
   Standard_Boolean SafeFailBack (const TCollection_ExtendedString& theMessage);
 
   //! Initializes OpenGL/GLSL shader programs.
-  Standard_Boolean InitRaytraceResources();
+  Standard_Boolean InitRaytraceResources (const Graphic3d_CView& theCView);
 
   //! Releases OpenGL/GLSL shader programs.
   void ReleaseRaytraceResources();
@@ -484,8 +518,8 @@ protected: //! @name fields related to ray-tracing
   //! Scene epsilon to prevent self-intersections.
   Standard_ShortReal myRaytraceSceneEpsilon;
 
-  //! Actual size of traversal stack in shader program.
-  Standard_Integer myTraversalStackSize;
+  //! Compile-time ray-tracing parameters.
+  RaytracingParams myRaytraceParameters;
 
   //! OpenGL/GLSL source of ray-tracing fragment shader.
   ShaderSource myRaytraceShaderSource;
@@ -555,7 +589,9 @@ protected: //! @name fields related to ray-tracing
 protected: //! @name protected fields
 
   Handle(OpenGl_PrinterContext) myPrintContext;
-  Handle(OpenGl_View)    myView;            // WSViews - now just one view is supported
+  Handle(OpenGl_View)           myView;
+  Handle(OpenGl_LineAttributes) myLineAttribs;
+  Standard_Integer       myAntiAliasingMode;
   Standard_Boolean       myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer)
   Standard_Boolean       myBackBufferRestored;
   Standard_Boolean       myIsImmediateDrawn;     //!< flag indicates that immediate mode buffer contains some data
@@ -583,12 +619,11 @@ protected: //! @name fields related to status
   OpenGl_Material myMatTmp;      //!< temporary variable
   TelCullMode     myCullingMode; //!< back face culling mode, applied from face aspect
 
-  //! Model matrix with applied structure transformations
-  OpenGl_Matrix myModelViewMatrix;
+  OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations
 
-  const TEL_POFFSET_PARAM* PolygonOffset_applied;
+  TEL_POFFSET_PARAM PolygonOffset_applied; //!< Currently applied polygon offset.
 
-  OpenGl_AspectFace myAspectFaceHl; // Hiddenline aspect
+  OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect
 
 public: //! @name type definition