#ifndef _OpenGl_Workspace_Header
#define _OpenGl_Workspace_Header
-#include <map>
-#include <set>
-
-#include <Handle_OpenGl_Workspace.hxx>
-#include <OpenGl_Window.hxx>
-
-#include <TColStd_Array2OfReal.hxx>
-#include <Quantity_Color.hxx>
-#include <Graphic3d_CView.hxx>
-#include <Graphic3d_TypeOfComposition.hxx>
-#include <Graphic3d_TypeOfTexture.hxx>
-#include <Graphic3d_PtrFrameBuffer.hxx>
#include <Graphic3d_BufferType.hxx>
-#include <Handle_Graphic3d_TextureParams.hxx>
-
-#include <Aspect_CLayer2d.hxx>
-#include <Aspect_Handle.hxx>
-#include <Aspect_PrintAlgo.hxx>
-#include <Aspect_PolygonOffsetMode.hxx>
-
-#include <InterfaceGraphic_Graphic3d.hxx>
-#include <InterfaceGraphic_Visual3d.hxx>
-
-#include <NCollection_Sequence.hxx>
#include <OpenGl_AspectFace.hxx>
+#include <OpenGl_CappingAlgo.hxx>
#include <OpenGl_FrameBuffer.hxx>
+#include <OpenGl_Material.hxx>
#include <OpenGl_Matrix.hxx>
-#include <OpenGl_NamedStatus.hxx>
-#include <OpenGl_PrinterContext.hxx>
-#include <OpenGl_SceneGeometry.hxx>
-#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>
-
#include <OpenGl_ShaderObject.hxx>
#include <OpenGl_ShaderProgram.hxx>
+#include <OpenGl_TextParam.hxx>
#include <OpenGl_TextureBufferArb.hxx>
+#include <OpenGl_Vec.hxx>
+#include <OpenGl_Window.hxx>
-class OpenGl_AspectLine;
-class OpenGl_AspectMarker;
-class OpenGl_AspectText;
-class OpenGl_FrameBuffer;
-class OpenGl_Structure;
-class OpenGl_Element;
+class OpenGl_View;
class Image_PixMap;
-//! OpenGL material definition
-struct OpenGl_Material
+class OpenGl_RaytraceFilter;
+DEFINE_STANDARD_HANDLE (OpenGl_RaytraceFilter, OpenGl_RenderFilter)
+
+//! Graphical ray-tracing filter.
+//! Filters out all raytracable structures.
+class OpenGl_RaytraceFilter : public OpenGl_RenderFilter
{
+public:
- OpenGl_Vec4 Ambient; //!< ambient reflection coefficient
- OpenGl_Vec4 Diffuse; //!< diffuse reflection coefficient
- OpenGl_Vec4 Specular; //!< glossy reflection coefficient
- OpenGl_Vec4 Emission; //!< material emission
- OpenGl_Vec4 Params; //!< extra packed parameters
+ //! Default constructor.
+ OpenGl_RaytraceFilter() {}
- Standard_ShortReal Shine() const { return Params.x(); }
- Standard_ShortReal& ChangeShine() { return Params.x(); }
+ //! Returns the previously set filter.
+ const Handle(OpenGl_RenderFilter)& PrevRenderFilter()
+ {
+ return myPrevRenderFilter;
+ }
- Standard_ShortReal Transparency() const { return Params.y(); }
- Standard_ShortReal& ChangeTransparency() { return Params.y(); }
+ //! Remembers the previously set filter.
+ void SetPrevRenderFilter (const Handle(OpenGl_RenderFilter)& theFilter)
+ {
+ myPrevRenderFilter = theFilter;
+ }
+
+ //! Checks whether the element can be rendered or not.
+ //! @param theElement [in] the element to check.
+ //! @return True if element can be rendered.
+ virtual Standard_Boolean ShouldRender (const Handle(OpenGl_Workspace)& theWorkspace,
+ const OpenGl_Element* theElement) Standard_OVERRIDE;
- //! Initialize material
- void Init (const OPENGL_SURF_PROP& theProps);
+private:
- //! Returns packed (serialized) representation of material properties
- const OpenGl_Vec4* Packed() const { return reinterpret_cast<const OpenGl_Vec4*> (this); }
- static Standard_Integer NbOfVec4() { return 5; }
+ Handle(OpenGl_RenderFilter) myPrevRenderFilter;
+public:
+
+ DEFINE_STANDARD_RTTIEXT(OpenGl_RaytraceFilter,OpenGl_RenderFilter)
};
-//! Represents window with GL context.
+class OpenGl_Workspace;
+DEFINE_STANDARD_HANDLE(OpenGl_Workspace,Standard_Transient)
+
+//! Rendering workspace.
//! Provides methods to render primitives and maintain GL state.
-class OpenGl_Workspace : public OpenGl_Window
+class OpenGl_Workspace : public Standard_Transient
{
public:
- //! Main constructor - prepare GL context for specified window.
- OpenGl_Workspace (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
- const CALL_DEF_WINDOW& theCWindow,
- Aspect_RenderingContext theGContext,
- const Handle(OpenGl_Caps)& theCaps,
- const Handle(OpenGl_Context)& theShareCtx);
+ //! Constructor of rendering workspace.
+ Standard_EXPORT OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Window)& theWindow);
//! Destructor
- virtual ~OpenGl_Workspace();
+ virtual ~OpenGl_Workspace() {}
- void SetActiveView (const Handle(OpenGl_View)& theView) { myView = theView; }
- const Handle(OpenGl_View)& ActiveView () const { return myView; }
+ //! Activate rendering context.
+ Standard_EXPORT Standard_Boolean Activate();
- //! Redraw the window.
- void Redraw (const Graphic3d_CView& theCView,
- const Aspect_CLayer2d& theCUnderLayer,
- const Aspect_CLayer2d& theCOverLayer);
+ OpenGl_View* View() const { return myView; }
- Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer);
- void RedrawImmediate (const Graphic3d_CView& theCView,
- const Aspect_CLayer2d& theCUnderLayer,
- const Aspect_CLayer2d& theCOverLayer,
- const Standard_Boolean theToForce = Standard_False);
+ const Handle(OpenGl_Context)& GetGlContext() { return myGlContext; }
- void Invalidate (const Graphic3d_CView& /*theCView*/)
- {
- myBackBufferRestored = Standard_False;
- }
+ Standard_EXPORT Handle(OpenGl_FrameBuffer) FBOCreate (const Standard_Integer theWidth, const Standard_Integer theHeight);
+
+ Standard_EXPORT void FBORelease (Handle(OpenGl_FrameBuffer)& theFbo);
+
+ Standard_Boolean BufferDump (const Handle(OpenGl_FrameBuffer)& theFbo,
+ Image_PixMap& theImage,
+ const Graphic3d_BufferType& theBufferType);
+
+ Standard_EXPORT Standard_Integer Width() const;
+
+ Standard_EXPORT Standard_Integer Height() const;
- //! Special method to perform printing.
- //! System-specific and currently only Win platform implemented.
- Standard_Boolean Print (const Handle(OpenGl_PrinterContext)& thePrintContext,
- const Graphic3d_CView& theCView,
- const Aspect_CLayer2d& theCUnderLayer,
- const Aspect_CLayer2d& theCOverLayer,
- const Aspect_Handle theHPrintDC,
- const Standard_Boolean theToShowBackground,
- const Standard_CString theFileName,
- const Aspect_PrintAlgo thePrintAlgorithm,
- const Standard_Real theScaleFactor);
-
- const Handle(OpenGl_PrinterContext)& PrinterContext() const
+ //! Setup Z-buffer usage flag (without affecting GL state!).
+ //! Returns previously set flag.
+ Standard_Boolean SetUseZBuffer (const Standard_Boolean theToUse)
{
- return myPrintContext;
+ const Standard_Boolean wasUsed = myUseZBuffer;
+ myUseZBuffer = theToUse;
+ return wasUsed;
}
- void DisplayCallback (const Graphic3d_CView& theCView, int theReason);
+ //! @return true if usage of Z buffer is enabled.
+ Standard_Boolean& UseZBuffer() { return myUseZBuffer; }
- Graphic3d_PtrFrameBuffer FBOCreate (const Standard_Integer theWidth, const Standard_Integer theHeight);
- void FBORelease (Graphic3d_PtrFrameBuffer theFBOPtr);
- Standard_Boolean BufferDump (OpenGl_FrameBuffer* theFBOPtr,
- Image_PixMap& theImage,
- const Graphic3d_BufferType& theBufferType);
+ //! @return true if depth writing is enabled.
+ Standard_Boolean& UseDepthWrite() { return myUseDepthWrite; }
- void UseTransparency (const Standard_Boolean theFlag);
- Standard_Boolean& UseZBuffer() { return myUseZBuffer; }
- Standard_Boolean& UseDepthTest() { return myUseDepthTest; }
- Standard_Boolean& UseGLLight() { return myUseGLLight; }
-
- Standard_Integer AntiAliasingMode() const { return myAntiAliasingMode; }
+ //! @return true if clipping algorithm enabled
+ Standard_EXPORT Standard_Boolean IsCullingEnabled() const;
//// RELATED TO STATUS ////
- Standard_Integer NamedStatus;
+ //! Return true if active group might activate face culling (e.g. primitives are closed).
+ bool ToAllowFaceCulling() const { return myToAllowFaceCulling; }
+
+ //! Allow or disallow face culling.
+ //! This call does NOT affect current state of back face culling;
+ //! ApplyAspectFace() should be called to update state.
+ void SetAllowFaceCulling (bool theToAllow) { myToAllowFaceCulling = theToAllow; }
+
+ //! Return true if following structures should apply highlight color.
+ bool ToHighlight() const { return !myHighlightStyle.IsNull(); }
+
+ //! Return highlight style.
+ const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const { return myHighlightStyle; }
+
+ //! Set highlight style.
+ void SetHighlightStyle (const Handle(Graphic3d_PresentationAttributes)& theStyle) { myHighlightStyle = theStyle; }
- const TEL_COLOUR* HighlightColor;
+ //! Return line color taking into account highlight flag.
+ const OpenGl_Vec4& LineColor() const
+ {
+ return !myHighlightStyle.IsNull()
+ ? myHighlightStyle->ColorRGBA()
+ : myAspectLineSet->Aspect()->ColorRGBA();
+ }
- const OpenGl_Matrix* SetViewMatrix (const OpenGl_Matrix* );
- const OpenGl_Matrix* SetStructureMatrix (const OpenGl_Matrix*, bool aRevert = false);
+ //! Return edge color taking into account highlight flag.
+ const OpenGl_Vec4& EdgeColor() const
+ {
+ return !myHighlightStyle.IsNull()
+ ? myHighlightStyle->ColorRGBA()
+ : myAspectFaceSet->AspectEdge()->Aspect()->ColorRGBA();
+ }
- //! Updates current model-view matrix
- //! replacing it with StructureMatrixT*ViewMatrix from the workspace.
- const void UpdateModelViewMatrix();
+ //! Return marker color taking into account highlight flag.
+ const OpenGl_Vec4& MarkerColor() const
+ {
+ return !myHighlightStyle.IsNull()
+ ? myHighlightStyle->ColorRGBA()
+ : myAspectMarkerSet->Aspect()->ColorRGBA();
+ }
- const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect);
- const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect);
- const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
- const OpenGl_AspectText* SetAspectText (const OpenGl_AspectText* theAspect);
+ //! Return Interior color taking into account highlight flag.
+ const OpenGl_Vec4& InteriorColor() const
+ {
+ return !myHighlightStyle.IsNull()
+ ? myHighlightStyle->ColorRGBA()
+ : myAspectFaceSet->Aspect()->InteriorColorRGBA();
+ }
- void SetTextParam (const OpenGl_TextParam* theParam) { TextParam_set = theParam; }
+ //! Return text color taking into account highlight flag.
+ const OpenGl_Vec4& TextColor() const
+ {
+ return !myHighlightStyle.IsNull()
+ ? myHighlightStyle->ColorRGBA()
+ : myAspectTextSet->Aspect()->ColorRGBA();
+ }
- //// THESE METHODS ARE EXPORTED AS THEY PROVIDE STATE INFO TO USERDRAW
- Standard_EXPORT const OpenGl_AspectLine* AspectLine (const Standard_Boolean theWithApply);
- Standard_EXPORT const OpenGl_AspectFace* AspectFace (const Standard_Boolean theWithApply);
- Standard_EXPORT const OpenGl_AspectMarker* AspectMarker (const Standard_Boolean theWithApply);
- Standard_EXPORT const OpenGl_AspectText* AspectText (const Standard_Boolean theWithApply);
- inline const OpenGl_TextParam* AspectTextParams() const
+ //! Return text Subtitle color taking into account highlight flag.
+ const OpenGl_Vec4& TextSubtitleColor() const
{
- return TextParam_applied;
+ return !myHighlightStyle.IsNull()
+ ? myHighlightStyle->ColorRGBA()
+ : myAspectTextSet->Aspect()->ColorSubTitleRGBA();
}
- //! Clear the applied aspect state.
+ //! Currently set line aspect (can differ from applied).
+ const OpenGl_AspectLine* AspectLine() const { return myAspectLineSet; }
+
+ //! Currently set face aspect (can differ from applied).
+ const OpenGl_AspectFace* AspectFace() const { return myAspectFaceSet; }
+
+ //! Currently set marker aspect (can differ from applied).
+ const OpenGl_AspectMarker* AspectMarker() const { return myAspectMarkerSet; }
+
+ //! Currently set text aspect (can differ from applied).
+ const OpenGl_AspectText* AspectText() const { return myAspectTextSet; }
+
+ //! Assign new line aspect (will be applied within ApplyAspectLine()).
+ Standard_EXPORT const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect);
+
+ //! Assign new face aspect (will be applied within ApplyAspectFace()).
+ Standard_EXPORT const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect);
+
+ //! Assign new marker aspect (will be applied within ApplyAspectMarker()).
+ Standard_EXPORT const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
+
+ //! Assign new text aspect (will be applied within ApplyAspectText()).
+ Standard_EXPORT const OpenGl_AspectText* SetAspectText (const OpenGl_AspectText* theAspect);
+
+ //! Apply line aspect.
+ //! @return aspect set by SetAspectLine()
+ const OpenGl_AspectLine* ApplyAspectLine() { return myAspectLineSet; }
+
+ //! Apply face aspect.
+ //! @return aspect set by SetAspectFace()
+ Standard_EXPORT const OpenGl_AspectFace* ApplyAspectFace();
+
+ //! Apply marker aspect.
+ //! @return aspect set by SetAspectMarker()
+ Standard_EXPORT const OpenGl_AspectMarker* ApplyAspectMarker();
+
+ //! Apply text aspect.
+ //! @return aspect set by SetAspectText()
+ const OpenGl_AspectText* ApplyAspectText() { return myAspectTextSet; }
+
+ //! Clear the applied aspect state to default values.
void ResetAppliedAspect();
Standard_EXPORT Handle(OpenGl_Texture) DisableTexture();
Standard_EXPORT Handle(OpenGl_Texture) EnableTexture (const Handle(OpenGl_Texture)& theTexture,
const Handle(Graphic3d_TextureParams)& theParams = NULL);
+ const Handle(OpenGl_Texture)& ActiveTexture() const { return myTextureBound; }
//! Set filter for restricting rendering of particular elements.
//! Filter can be applied for rendering passes used by recursive
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);
+ void SetPolygonOffset (const Graphic3d_PolygonOffset& theParams);
- //! Returns currently applied polygon offset params.
- const TEL_POFFSET_PARAM& AppliedPolygonOffset() { return PolygonOffset_applied; }
+ //! Returns currently applied polygon offset parameters.
+ const Graphic3d_PolygonOffset& AppliedPolygonOffset() { return myPolygonOffsetApplied; }
-protected:
-
- //! Copy content of Back buffer to the Front buffer
- void copyBackToFront();
-
- virtual Standard_Boolean Activate();
-
- void redraw1 (const Graphic3d_CView& theCView,
- const Aspect_CLayer2d& theCUnderLayer,
- const Aspect_CLayer2d& theCOverLayer,
- const int theToSwap);
-
- void updateMaterial (const int theFlag);
-
- void setTextureParams (Handle(OpenGl_Texture)& theTexture,
- const Handle(Graphic3d_TextureParams)& theParams);
-
-protected:
-
- //! Result of OpenGL shaders initialization.
- enum RaytraceInitStatus
+ //! Returns capping algorithm rendering filter.
+ const Handle(OpenGl_CappingAlgoFilter)& DefaultCappingAlgoFilter() const
{
- OpenGl_RT_NONE,
- OpenGl_RT_INIT,
- OpenGl_RT_FAIL
- };
+ return myDefaultCappingAlgoFilter;
+ }
- //! Describes update mode (state).
- enum GeomUpdateMode
+ //! Returns face aspect for none culling mode.
+ const OpenGl_AspectFace& NoneCulling() const
{
- OpenGl_GUM_CHECK, //!< check if geometry update is necessary
- OpenGl_GUM_PREPARE, //!< collect unchanged objects
- OpenGl_GUM_UPDATE //!< update raytracing data, rebuild changed objects
- };
+ return myNoneCulling;
+ }
- //! Defines frequently used shader variables.
- enum ShaderVariableIndex
+ //! Returns face aspect for front face culling mode.
+ const OpenGl_AspectFace& FrontCulling() const
{
- OpenGl_RT_aPosition,
-
- OpenGl_RT_uOriginLT,
- OpenGl_RT_uOriginLB,
- OpenGl_RT_uOriginRT,
- OpenGl_RT_uOriginRB,
-
- OpenGl_RT_uDirectLT,
- OpenGl_RT_uDirectLB,
- OpenGl_RT_uDirectRT,
- OpenGl_RT_uDirectRB,
-
- OpenGl_RT_uSceneRad,
- OpenGl_RT_uSceneEps,
-
- OpenGl_RT_uLightAmbnt,
- OpenGl_RT_uLightCount,
-
- OpenGl_RT_uShadEnabled,
- OpenGl_RT_uReflEnabled,
-
- OpenGl_RT_uInputTexture,
-
- OpenGl_RT_uOffsetX,
- OpenGl_RT_uOffsetY,
- OpenGl_RT_uSamples,
-
- OpenGl_RT_uEnvironmentEnable,
-
- OpenGl_RT_NbVariables // special field
- };
+ return myFrontCulling;
+ }
- //! Defines texture samplers.
- enum ShaderSamplerNames
+ //! Sets a new environment texture.
+ void SetEnvironmentTexture (const Handle(OpenGl_Texture)& theTexture)
{
- OpenGl_RT_SceneNodeInfoTexture = 0,
- OpenGl_RT_SceneMinPointTexture = 1,
- OpenGl_RT_SceneMaxPointTexture = 2,
-
- OpenGl_RT_ObjectNodeInfoTexture = 3,
- OpenGl_RT_ObjectMinPointTexture = 4,
- OpenGl_RT_ObjectMaxPointTexture = 5,
-
- OpenGl_RT_GeometryVertexTexture = 6,
- OpenGl_RT_GeometryNormalTexture = 7,
- OpenGl_RT_GeometryTriangTexture = 8,
-
- OpenGl_RT_EnvironmentMapTexture = 9,
-
- OpenGl_RT_RaytraceMaterialTexture = 10,
- OpenGl_RT_RaytraceLightSrcTexture = 11,
+ myEnvironmentTexture = theTexture;
+ }
- OpenGl_RT_FSAAInputTexture = 12,
+ //! Returns environment texture.
+ const Handle(OpenGl_Texture)& EnvironmentTexture() const
+ {
+ return myEnvironmentTexture;
+ }
- OpenGl_RT_SceneTransformTexture = 13
- };
+protected:
- //! Tool class for management of shader sources.
- class ShaderSource
- {
- public:
-
- //! Creates new uninitialized shader source.
- ShaderSource()
- {
- //
- }
-
- //! Creates new shader source from specified file.
- ShaderSource (const TCollection_AsciiString& theFileName)
- {
- Load (&theFileName, 1);
- }
-
- public:
-
- //! Returns prefix to insert before the source.
- const TCollection_AsciiString& Prefix() const
- {
- return myPrefix;
- }
-
- //! Sets prefix to insert before the source.
- void SetPrefix (const TCollection_AsciiString& thePrefix)
- {
- myPrefix = thePrefix;
- }
-
- //! Returns shader source combined with prefix.
- TCollection_AsciiString Source() const;
-
- //! Loads shader source from specified files.
- void Load (const TCollection_AsciiString* theFileNames, const Standard_Integer theCount);
-
- private:
-
- TCollection_AsciiString mySource; //!< Source string of the shader object
- TCollection_AsciiString myPrefix; //!< Prefix to insert before the source
-
- };
-
- //! Default size of traversal stack.
- static const Standard_Integer THE_DEFAULT_STACK_SIZE = 24;
-
-protected: //! @name methods related to ray-tracing
-
- //! Updates 3D scene geometry for ray-tracing.
- Standard_Boolean UpdateRaytraceGeometry (GeomUpdateMode theMode);
-
- //! Checks to see if the structure is modified.
- Standard_Boolean CheckRaytraceStructure (const OpenGl_Structure* theStructure);
-
- //! Updates 3D scene light sources for ray-tracing.
- Standard_Boolean UpdateRaytraceLightSources (const GLdouble theInvModelView[16]);
-
- //! Updates environment map for ray-tracing.
- Standard_Boolean UpdateRaytraceEnvironmentMap();
-
- //! Adds OpenGL structure to ray-traced scene geometry.
- Standard_Boolean AddRaytraceStructure (const OpenGl_Structure* theStructure,
- const Standard_ShortReal* theTransform, std::set<const OpenGl_Structure*>& theElements);
-
- //! Adds OpenGL primitive array to ray-traced scene geometry.
- OpenGl_TriangleSet* AddRaytracePrimitiveArray (
- const OpenGl_PrimitiveArray* theArray, int theMatID, const Standard_ShortReal* theTrans);
-
- //! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
- Standard_Boolean AddRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
- const OpenGl_PrimitiveArray& theArray,
- Standard_Integer theOffset,
- Standard_Integer theCount,
- Standard_Integer theMatID);
-
- //! Adds OpenGL triangle array to ray-traced scene geometry.
- Standard_Boolean AddRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
- const Handle(Graphic3d_IndexBuffer)& theIndices,
- Standard_Integer theOffset,
- Standard_Integer theCount,
- Standard_Integer theMatID);
-
- //! Adds OpenGL triangle fan array to ray-traced scene geometry.
- Standard_Boolean AddRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
- const Handle(Graphic3d_IndexBuffer)& theIndices,
- Standard_Integer theOffset,
- Standard_Integer theCount,
- Standard_Integer theMatID);
-
- //! Adds OpenGL triangle strip array to ray-traced scene geometry.
- Standard_Boolean AddRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
- const Handle(Graphic3d_IndexBuffer)& theIndices,
- Standard_Integer theOffset,
- Standard_Integer theCount,
- Standard_Integer theMatID);
-
- //! Adds OpenGL quadrangle array to ray-traced scene geometry.
- Standard_Boolean AddRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
- const Handle(Graphic3d_IndexBuffer)& theIndices,
- Standard_Integer theOffset,
- Standard_Integer theCount,
- Standard_Integer theMatID);
-
- //! Adds OpenGL quadrangle strip array to ray-traced scene geometry.
- Standard_Boolean AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
- const Handle(Graphic3d_IndexBuffer)& theIndices,
- Standard_Integer theOffset,
- Standard_Integer theCount,
- Standard_Integer theMatID);
-
- //! Adds OpenGL polygon array to ray-traced scene geometry.
- Standard_Boolean AddRaytracePolygonArray (OpenGl_TriangleSet& theSet,
- const Handle(Graphic3d_IndexBuffer)& theIndices,
- Standard_Integer theOffset,
- Standard_Integer theCount,
- Standard_Integer theMatID);
-
- //! Loads and compiles shader object from specified source.
- Handle(OpenGl_ShaderObject) LoadShader (const ShaderSource& theSource, GLenum theType);
-
- //! Performs safe exit when shaders initialization fails.
- Standard_Boolean SafeFailBack (const TCollection_ExtendedString& theMessage);
-
- //! Initializes OpenGL/GLSL shader programs.
- Standard_Boolean InitRaytraceResources();
-
- //! Releases OpenGL/GLSL shader programs.
- void ReleaseRaytraceResources();
-
- //! Uploads ray-trace data to the GPU.
- Standard_Boolean UploadRaytraceData();
-
- //! Resizes OpenGL frame buffers.
- Standard_Boolean ResizeRaytraceBuffers (const Standard_Integer theSizeX,
- const Standard_Integer theSizeY);
-
- //! Generates viewing rays for corners of screen quad.
- void UpdateCamera (const NCollection_Mat4<GLdouble>& theOrientation,
- const NCollection_Mat4<GLdouble>& theViewMapping,
- OpenGl_Vec3 theOrigins[4],
- OpenGl_Vec3 theDirects[4]);
-
- //! Runs ray-tracing shader programs.
- Standard_Boolean RunRaytraceShaders (const Graphic3d_CView& theCView,
- const Standard_Integer theSizeX,
- const Standard_Integer theSizeY,
- const OpenGl_Vec3 theOrigins[4],
- const OpenGl_Vec3 theDirects[4],
- OpenGl_FrameBuffer* theFrameBuffer);
-
- //! Redraws the window using OpenGL/GLSL ray-tracing.
- Standard_Boolean Raytrace (const Graphic3d_CView& theCView,
- const Standard_Integer theSizeX,
- const Standard_Integer theSizeY,
- const Standard_Boolean theToSwap,
- OpenGl_FrameBuffer* theFrameBuffer);
-
-protected: //! @name fields related to ray-tracing
-
- //! Result of shaders initialization.
- RaytraceInitStatus myComputeInitStatus;
-
- //! Is geometry data valid?
- Standard_Boolean myIsRaytraceDataValid;
-
- //! 3D scene geometry data for ray-tracing.
- OpenGl_RaytraceGeometry myRaytraceGeometry;
-
- //! Radius of bounding sphere of the scene.
- Standard_ShortReal myRaytraceSceneRadius;
- //! Scene epsilon to prevent self-intersections.
- Standard_ShortReal myRaytraceSceneEpsilon;
-
- //! Actual size of traversal stack in shader program.
- Standard_Integer myTraversalStackSize;
-
- //! OpenGL/GLSL source of ray-tracing fragment shader.
- ShaderSource myRaytraceShaderSource;
- //! OpenGL/GLSL source of adaptive-AA fragment shader.
- ShaderSource myPostFSAAShaderSource;
-
- //! OpenGL/GLSL ray-tracing fragment shader.
- Handle(OpenGl_ShaderObject) myRaytraceShader;
- //! OpenGL/GLSL adaptive-AA fragment shader.
- Handle(OpenGl_ShaderObject) myPostFSAAShader;
-
- //! OpenGL/GLSL ray-tracing shader program.
- Handle(OpenGl_ShaderProgram) myRaytraceProgram;
- //! OpenGL/GLSL adaptive-AA shader program.
- Handle(OpenGl_ShaderProgram) myPostFSAAProgram;
-
- //! Texture buffer of data records of high-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) mySceneNodeInfoTexture;
- //! Texture buffer of minimum points of high-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) mySceneMinPointTexture;
- //! Texture buffer of maximum points of high-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) mySceneMaxPointTexture;
- //! Texture buffer of transformations of high-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) mySceneTransformTexture;
-
- //! Texture buffer of data records of bottom-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) myObjectNodeInfoTexture;
- //! Texture buffer of minimum points of bottom-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) myObjectMinPointTexture;
- //! Texture buffer of maximum points of bottom-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) myObjectMaxPointTexture;
-
- //! Texture buffer of vertex coords.
- Handle(OpenGl_TextureBufferArb) myGeometryVertexTexture;
- //! Texture buffer of vertex normals.
- Handle(OpenGl_TextureBufferArb) myGeometryNormalTexture;
- //! Texture buffer of triangle indices.
- Handle(OpenGl_TextureBufferArb) myGeometryTriangTexture;
-
- //! Texture buffer of material properties.
- Handle(OpenGl_TextureBufferArb) myRaytraceMaterialTexture;
- //! Texture buffer of light source properties.
- Handle(OpenGl_TextureBufferArb) myRaytraceLightSrcTexture;
-
- //! Vertex buffer (VBO) for drawing dummy quad.
- OpenGl_VertexBuffer myRaytraceScreenQuad;
-
- //! Framebuffer (FBO) to perform adaptive FSAA.
- Handle(OpenGl_FrameBuffer) myRaytraceFBO1;
- //! Framebuffer (FBO) to perform adaptive FSAA.
- Handle(OpenGl_FrameBuffer) myRaytraceFBO2;
-
- //! State of OpenGL view.
- Standard_Size myViewModificationStatus;
- //! State of OpenGL layer list.
- Standard_Size myLayersModificationStatus;
-
- //! State of OpenGL structures reflected to ray-tracing.
- std::map<const OpenGl_Structure*, Standard_Size> myStructureStates;
-
- //! PrimitiveArray to TriangleSet map for scene partial update.
- std::map<const OpenGl_PrimitiveArray*, OpenGl_TriangleSet*> myArrayToTrianglesMap;
-
- //! Cached locations of frequently used uniform variables.
- Standard_Integer myUniformLocations[2][OpenGl_RT_NbVariables];
+ void setTextureParams (Handle(OpenGl_Texture)& theTexture,
+ const Handle(Graphic3d_TextureParams)& theParams);
protected: //! @name protected fields
- Handle(OpenGl_PrinterContext) myPrintContext;
- 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
- Standard_Boolean myUseTransparency;
- Standard_Boolean myUseZBuffer;
- Standard_Boolean myUseDepthTest;
- Standard_Boolean myUseGLLight;
+ OpenGl_View* myView;
+ Handle(OpenGl_Window) myWindow;
+ Handle(OpenGl_Context) myGlContext;
+ Standard_Boolean myUseZBuffer;
+ Standard_Boolean myUseDepthWrite;
+ Handle(OpenGl_CappingAlgoFilter) myDefaultCappingAlgoFilter;
+ OpenGl_AspectFace myNoneCulling;
+ OpenGl_AspectFace myFrontCulling;
protected: //! @name fields related to status
Handle(OpenGl_RenderFilter) myRenderFilter;
Handle(OpenGl_Texture) myTextureBound; //!< currently bound texture (managed by OpenGl_AspectFace and OpenGl_View environment texture)
- const OpenGl_AspectLine *AspectLine_set, *AspectLine_applied;
- const OpenGl_AspectFace *AspectFace_set, *AspectFace_applied;
- const OpenGl_AspectMarker *AspectMarker_set, *AspectMarker_applied;
- const OpenGl_AspectText *AspectText_set, *AspectText_applied;
-
- const OpenGl_TextParam *TextParam_set, *TextParam_applied;
+ const OpenGl_AspectLine* myAspectLineSet;
+ const OpenGl_AspectFace* myAspectFaceSet;
+ Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied;
+ const OpenGl_AspectMarker* myAspectMarkerSet;
+ Handle(Graphic3d_AspectMarker3d) myAspectMarkerApplied;
+ const OpenGl_AspectText* myAspectTextSet;
+ Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL;
const OpenGl_Matrix* ViewMatrix_applied;
const OpenGl_Matrix* StructureMatrix_applied;
- OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates)
- OpenGl_Material myMatBack; //!< current back material state
- OpenGl_Material myMatTmp; //!< temporary variable
- TelCullMode myCullingMode; //!< back face culling mode, applied from face aspect
+ bool myToAllowFaceCulling; //!< allow back face culling
+ Handle(Graphic3d_PresentationAttributes) myHighlightStyle; //!< active highlight style
OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations
- TEL_POFFSET_PARAM PolygonOffset_applied; //!< Currently applied polygon offset.
+ Graphic3d_PolygonOffset myPolygonOffsetApplied; //!< currently applied polygon offset
OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect
+ Handle(OpenGl_Texture) myEnvironmentTexture;
+
public: //! @name type definition
- DEFINE_STANDARD_RTTI(OpenGl_Workspace)
+ DEFINE_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
DEFINE_STANDARD_ALLOC
};