#include <Aspect_Drawable.hxx>
#include <Aspect_Display.hxx>
#include <Aspect_RenderingContext.hxx>
-#include <Handle_OpenGl_Context.hxx>
-#include <Handle_OpenGl_FrameBuffer.hxx>
-#include <Handle_OpenGl_Sampler.hxx>
-#include <Handle_OpenGl_ShaderManager.hxx>
-#include <Handle_OpenGl_ShaderProgram.hxx>
+#include <Aspect_TypeOfLine.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_List.hxx>
#include <Message.hxx>
#include <OpenGl_Caps.hxx>
+#include <OpenGl_MatrixState.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_Resource.hxx>
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
+#include <TColStd_PackedMapOfInteger.hxx>
#include <OpenGl_Clipping.hxx>
#include <OpenGl_GlCore11.hxx>
-#include <OpenGl_Utils.hxx>
+#include <OpenGl_ShaderProgram.hxx>
+
+#include <NCollection_Shared.hxx>
//! Forward declarations
#if defined(__APPLE__)
typedef OpenGl_TmplCore44<OpenGl_GlCore43Back> OpenGl_GlCore44Back;
typedef OpenGl_TmplCore44<OpenGl_GlCore43> OpenGl_GlCore44;
+class OpenGl_ShaderManager;
+class OpenGl_Sampler;
+class OpenGl_FrameBuffer;
+
+class OpenGl_Context;
+DEFINE_STANDARD_HANDLE(OpenGl_Context, Standard_Transient)
+
//! This class generalize access to the GL context and available extensions.
//!
//! Functions related to specific OpenGL version or extension are grouped into structures which can be accessed as fields of this class.
|| (myGlVerMajor == theVerMajor && myGlVerMinor >= theVerMinor);
}
+ //! Access entire map of loaded OpenGL functions.
+ const OpenGl_GlFunctions* Functions() const { return myFuncs.operator->(); }
+
//! Clean up errors stack for this GL context (glGetError() in loop).
Standard_EXPORT void ResetErrors();
//! Swap front/back buffers for this GL context (should be activated before!).
Standard_EXPORT void SwapBuffers();
+ //! Setup swap interval (VSync).
+ Standard_EXPORT Standard_Boolean SetSwapInterval (const Standard_Integer theInterval);
+
//! Return true if active mode is GL_RENDER (cached state)
Standard_Boolean IsRender() const
{
Standard_EXPORT Standard_Boolean SetGlNormalizeEnabled (Standard_Boolean isEnabled);
//! Applies matrix stored in ModelWorldState to OpenGl.
- void ApplyModelWorldMatrix();
+ Standard_EXPORT void ApplyModelWorldMatrix();
//! Applies matrix stored in WorldViewState to OpenGl.
- void ApplyWorldViewMatrix();
+ Standard_EXPORT void ApplyWorldViewMatrix();
//! Applies combination of matrices stored in ModelWorldState and WorldViewState to OpenGl.
- void ApplyModelViewMatrix();
+ Standard_EXPORT void ApplyModelViewMatrix();
//! Applies matrix stored in ProjectionState to OpenGl.
- void ApplyProjectionMatrix();
+ Standard_EXPORT void ApplyProjectionMatrix();
public:
const unsigned int theSeverity,
const TCollection_ExtendedString& theMessage);
+ //! Adds a filter for messages with theId and theSource (GL_DEBUG_SOURCE_)
+ Standard_EXPORT Standard_Boolean ExcludeMessage (const unsigned int theSource,
+ const unsigned int theId);
+ //! Removes a filter for messages with theId and theSource (GL_DEBUG_SOURCE_)
+ Standard_EXPORT Standard_Boolean IncludeMessage (const unsigned int theSource,
+ const unsigned int theId);
//! @return true if OpenGl context supports left and
//! right rendering buffers.
public: //! @name methods to alter or retrieve current state
- //! Switch to left stereographic rendering buffer.
- //! This method can be used to keep unchanged choise
- //! of front/back/both buffer rendering.
- Standard_EXPORT void SetDrawBufferLeft();
+ //! Return active read buffer.
+ Standard_Integer ReadBuffer() { return myReadBuffer; }
+
+ //! Switch read buffer, wrapper for ::glReadBuffer().
+ Standard_EXPORT void SetReadBuffer (const Standard_Integer theReadBuffer);
+
+ //! Return active draw buffer.
+ Standard_Integer DrawBuffer() { return myDrawBuffer; }
- //! Switch to right stereographic rendering buffer.
- //! This method can be used to keep unchanged choise
- //! of front/back/both buffer rendering.
- Standard_EXPORT void SetDrawBufferRight();
+ //! Switch draw buffer, wrapper for ::glDrawBuffer().
+ Standard_EXPORT void SetDrawBuffer (const Standard_Integer theDrawBuffer);
- //! Switch to non-stereographic rendering buffer.
- //! This method can be used to keep unchanged choise
- //! of front/back/both buffer rendering.
- Standard_EXPORT void SetDrawBufferMono();
+ //! Switch read/draw buffers.
+ void SetReadDrawBuffer (const Standard_Integer theBuffer)
+ {
+ SetReadBuffer (theBuffer);
+ SetDrawBuffer (theBuffer);
+ }
//! Fetch OpenGl context state. This class tracks value of several OpenGl
//! state variables. Consulting the cached values is quicker than
//! Setup current color.
Standard_EXPORT void SetColor4fv (const OpenGl_Vec4& theColor);
+ //! Setup type of line.
+ Standard_EXPORT void SetTypeOfLine (const Aspect_TypeOfLine theType,
+ const Standard_ShortReal theFactor = 1.0f);
+
+ //! Setup width of line.
+ Standard_EXPORT void SetLineWidth (const Standard_ShortReal theWidth);
+
//! Setup point size.
Standard_EXPORT void SetPointSize (const Standard_ShortReal theSize);
+ //! Setup texture matrix to active GLSL program or to FFP global state using glMatrixMode (GL_TEXTURE).
+ Standard_EXPORT void SetTextureMatrix (const Handle(Graphic3d_TextureParams)& theParams);
+
//! Bind default Vertex Array Object
Standard_EXPORT void BindDefaultVao();
return myIsGlDebugCtx;
}
+ Standard_EXPORT void EnableFeatures() const;
+
+ Standard_EXPORT void DisableFeatures() const;
+
private:
//! Wrapper to system function to retrieve GL function pointer by name.
public: //! @name extensions
Standard_Boolean hasHighp; //!< highp in GLSL ES fragment shader is supported
+ Standard_Boolean hasUintIndex; //!< GLuint for index buffer is supported (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_element_index_uint)
Standard_Boolean hasTexRGBA8; //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8
Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two
Standard_Boolean arbTexRG; //!< GL_ARB_texture_rg
private: // context info
- typedef NCollection_DataMap<TCollection_AsciiString, Standard_Integer> OpenGl_DelayReleaseMap;
- typedef NCollection_Handle<OpenGl_DelayReleaseMap> Handle(OpenGl_DelayReleaseMap);
- typedef NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_Resource)> OpenGl_ResourcesMap;
- typedef NCollection_Handle<OpenGl_ResourcesMap> Handle(OpenGl_ResourcesMap);
- typedef NCollection_List<Handle(OpenGl_Resource)> OpenGl_ResourcesStack;
- typedef NCollection_Handle<OpenGl_ResourcesStack> Handle(OpenGl_ResourcesStack);
+ typedef NCollection_Shared< NCollection_DataMap<TCollection_AsciiString, Standard_Integer> > OpenGl_DelayReleaseMap;
+ typedef NCollection_Shared< NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_Resource)> > OpenGl_ResourcesMap;
+ typedef NCollection_Shared< NCollection_List<Handle(OpenGl_Resource)> > OpenGl_ResourcesStack;
Handle(OpenGl_ResourcesMap) mySharedResources; //!< shared resources with unique identification key
Handle(OpenGl_DelayReleaseMap) myDelayed; //!< shared resources for delayed release
Handle(OpenGl_Sampler) myTexSampler; //!< currently active sampler object
Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object
Standard_Integer myRenderMode; //!< value for active rendering mode
+ Standard_Integer myReadBuffer; //!< current read buffer
Standard_Integer myDrawBuffer; //!< current draw buffer
unsigned int myDefaultVao; //!< default Vertex Array Object
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
+ TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
+ TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB)
public:
- OpenGl_Utils::MatrixState<Standard_ShortReal> ModelWorldState; //!< state of orientation matrix
- OpenGl_Utils::MatrixState<Standard_ShortReal> WorldViewState; //!< state of orientation matrix
- OpenGl_Utils::MatrixState<Standard_ShortReal> ProjectionState; //!< state of projection matrix
+ OpenGl_MatrixState<Standard_ShortReal> ModelWorldState; //!< state of orientation matrix
+ OpenGl_MatrixState<Standard_ShortReal> WorldViewState; //!< state of orientation matrix
+ OpenGl_MatrixState<Standard_ShortReal> ProjectionState; //!< state of projection matrix
private:
public:
- DEFINE_STANDARD_RTTI(OpenGl_Context) // Type definition
+ DEFINE_STANDARD_RTTI(OpenGl_Context, Standard_Transient) // Type definition
friend class OpenGl_Window;