#ifndef _OpenGl_State_HeaderFile
#define _OpenGl_State_HeaderFile
-#include <InterfaceGraphic_tgl_all.hxx>
-
-#include <OpenGl_Element.hxx>
-#include <OpenGl_Light.hxx>
-
#include <NCollection_List.hxx>
+#include <Graphic3d_LightSet.hxx>
+#include <OpenGl_Element.hxx>
+#include <OpenGl_Vec.hxx>
//! Defines interface for OpenGL state.
class OpenGl_StateInterface
{
public:
- //! Creates new OCCT state.
- OpenGl_StateInterface();
+ //! Creates new state.
+ Standard_EXPORT OpenGl_StateInterface();
//! Returns current state index.
- Standard_Size Index() const;
-
- //! Updates current state.
- void Update();
+ Standard_Size Index() const { return myIndex; }
- //! Reverts current state.
- void Revert();
+ //! Increment current state.
+ void Update() { ++myIndex; }
protected:
- Standard_Size myIndex; //!< Current state index
- Standard_Size myNextIndex; //!< Next state index
- NCollection_List<Standard_Size> myStateStack; //!< Stack of previous states.
+ Standard_Size myIndex; //!< current state index
};
public:
//! Creates uninitialized projection state.
- OpenGl_ProjectionState();
+ Standard_EXPORT OpenGl_ProjectionState();
//! Sets new projection matrix.
- void Set (const Tmatrix3* theProjectionMatrix);
+ Standard_EXPORT void Set (const OpenGl_Mat4& theProjectionMatrix);
//! Returns current projection matrix.
- const Tmatrix3& ProjectionMatrix() const;
+ Standard_EXPORT const OpenGl_Mat4& ProjectionMatrix() const;
//! Returns inverse of current projection matrix.
- const Tmatrix3& ProjectionMatrixInverse() const;
+ Standard_EXPORT const OpenGl_Mat4& ProjectionMatrixInverse() const;
private:
- Tmatrix3 myProjectionMatrix; //!< OCCT projection matrix
- mutable Tmatrix3 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
- bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
+ OpenGl_Mat4 myProjectionMatrix; //!< OCCT projection matrix
+ mutable OpenGl_Mat4 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
+ bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
};
public:
//! Creates uninitialized model-world state.
- OpenGl_ModelWorldState();
+ Standard_EXPORT OpenGl_ModelWorldState();
//! Sets new model-world matrix.
- void Set (const Tmatrix3* theModelWorldMatrix);
+ Standard_EXPORT void Set (const OpenGl_Mat4& theModelWorldMatrix);
//! Returns current model-world matrix.
- const Tmatrix3& ModelWorldMatrix() const;
+ Standard_EXPORT const OpenGl_Mat4& ModelWorldMatrix() const;
//! Returns inverse of current model-world matrix.
- const Tmatrix3& ModelWorldMatrixInverse() const;
+ Standard_EXPORT const OpenGl_Mat4& ModelWorldMatrixInverse() const;
private:
- Tmatrix3 myModelWorldMatrix; //!< OCCT model-world matrix
- mutable Tmatrix3 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix
- bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
+ OpenGl_Mat4 myModelWorldMatrix; //!< OCCT model-world matrix
+ mutable OpenGl_Mat4 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix
+ bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
};
public:
//! Creates uninitialized world-view state.
- OpenGl_WorldViewState();
-
+ Standard_EXPORT OpenGl_WorldViewState();
+
//! Sets new world-view matrix.
- void Set (const Tmatrix3* theWorldViewMatrix);
+ Standard_EXPORT void Set (const OpenGl_Mat4& theWorldViewMatrix);
//! Returns current world-view matrix.
- const Tmatrix3& WorldViewMatrix() const;
+ Standard_EXPORT const OpenGl_Mat4& WorldViewMatrix() const;
//! Returns inverse of current world-view matrix.
- const Tmatrix3& WorldViewMatrixInverse() const;
+ Standard_EXPORT const OpenGl_Mat4& WorldViewMatrixInverse() const;
private:
- Tmatrix3 myWorldViewMatrix; //!< OCCT world-view matrix
- mutable Tmatrix3 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix
- bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
+ OpenGl_Mat4 myWorldViewMatrix; //!< OCCT world-view matrix
+ mutable OpenGl_Mat4 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix
+ bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
};
public:
//! Creates uninitialized state of light sources.
- OpenGl_LightSourceState();
+ OpenGl_LightSourceState() {}
//! Sets new light sources.
- void Set (const OpenGl_ListOfLight* theLightSources);
+ void Set (const Handle(Graphic3d_LightSet)& theLightSources) { myLightSources = theLightSources; }
//! Returns current list of light sources.
- const OpenGl_ListOfLight* LightSources() const;
+ const Handle(Graphic3d_LightSet)& LightSources() const { return myLightSources; }
private:
- const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources
+ Handle(Graphic3d_LightSet) myLightSources; //!< List of OCCT light sources
};
-//! Defines generic state of OCCT material properties.
-class OpenGl_MaterialState : public OpenGl_StateInterface
+//! Defines generic state of OCCT clipping state.
+class OpenGl_ClippingState
{
public:
- //! Creates new material state.
- OpenGl_MaterialState (const OpenGl_Element* theAspect = NULL);
-
- //! Sets new material aspect.
- void Set (const OpenGl_Element* theAspect);
+ //! Creates new clipping state.
+ Standard_EXPORT OpenGl_ClippingState();
- //! Returns material aspect.
- const OpenGl_Element* Aspect() const;
+ //! Returns current state index.
+ Standard_Size Index() const { return myIndex; }
-private:
+ //! Updates current state.
+ Standard_EXPORT void Update();
- const OpenGl_Element* myAspect; //!< OCCT material aspect
+ //! Reverts current state.
+ Standard_EXPORT void Revert();
+
+protected:
+
+ Standard_Size myIndex; //!< Current state index
+ Standard_Size myNextIndex; //!< Next state index
+ NCollection_List<Standard_Size> myStateStack; //!< Stack of previous states
};
-//! Defines generic state of OCCT clipping state.
-class OpenGl_ClippingState : public OpenGl_StateInterface
+//! Defines generic state of order-independent transparency rendering properties.
+class OpenGl_OitState : public OpenGl_StateInterface
{
public:
- //! Creates new clipping state.
- OpenGl_ClippingState();
+ //! Creates new uniform state.
+ OpenGl_OitState() : myToEnableWrite (false), myDepthFactor (0.5f) {}
+
+ //! Sets the uniform values.
+ //! @param theToEnableWrite [in] flag indicating whether color and coverage
+ //! values for OIT processing should be written by shader program.
+ //! @param theDepthFactor [in] scalar factor [0-1] defining influence of depth
+ //! component of a fragment to its final coverage coefficient.
+ void Set (const bool theToEnableWrite,
+ const float theDepthFactor)
+ {
+ myToEnableWrite = theToEnableWrite;
+ myDepthFactor = static_cast<float> (Max (0.f, Min (1.f, theDepthFactor)));
+ }
+
+ //! Returns flag indicating whether writing of output for OIT processing
+ //! should be enabled/disabled.
+ bool ToEnableWrite() const { return myToEnableWrite; }
+
+ //! Returns factor defining influence of depth component of a fragment
+ //! to its final coverage coefficient.
+ float DepthFactor() const { return myDepthFactor; }
+
+private:
+ bool myToEnableWrite; //!< writing color and coverage.
+ float myDepthFactor; //!< factor of depth influence to coverage.
};
#endif // _OpenGl_State_HeaderFile