Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes
OpenGl_GraphicDriver Class Reference

This class defines an OpenGl graphic driver. More...

#include <OpenGl_GraphicDriver.hxx>

Inheritance diagram for OpenGl_GraphicDriver:
Inheritance graph
[legend]

Public Member Functions

 OpenGl_GraphicDriver (const occ::handle< Aspect_DisplayConnection > &theDisp, const bool theToInitialize=true)
 Constructor.
 
 ~OpenGl_GraphicDriver () override
 Destructor.
 
void ReleaseContext ()
 Release default context.
 
bool InitContext ()
 Perform initialization of default OpenGL context.
 
bool InitEglContext (Aspect_Display theEglDisplay, Aspect_RenderingContext theEglContext, void *theEglConfig)
 Initialize default OpenGL context using existing one.
 
int InquireLimit (const Graphic3d_TypeOfLimit theType) const override
 Request limit of graphic resource of specific type.
 
occ::handle< Graphic3d_CStructureCreateStructure (const occ::handle< Graphic3d_StructureManager > &theManager) override
 Creates new empty graphic structure.
 
void RemoveStructure (occ::handle< Graphic3d_CStructure > &theCStructure) override
 Removes structure from graphic driver and releases its resources.
 
occ::handle< Graphic3d_CViewCreateView (const occ::handle< Graphic3d_StructureManager > &theMgr) override
 Creates new view for this graphic driver.
 
void RemoveView (const occ::handle< Graphic3d_CView > &theView) override
 Removes view from graphic driver and releases its resources.
 
virtual occ::handle< OpenGl_WindowCreateRenderWindow (const occ::handle< Aspect_Window > &theNativeWindow, const occ::handle< Aspect_Window > &theSizeWindow, const Aspect_RenderingContext theContext)
 Create OpenGL window from native window.
 
void TextSize (const occ::handle< Graphic3d_CView > &theView, const char *const theText, const float theHeight, float &theWidth, float &theAscent, float &theDescent) const override
 Computes text width.
 
float DefaultTextHeight () const override
 
bool ViewExists (const occ::handle< Aspect_Window > &theWindow, occ::handle< Graphic3d_CView > &theView) override
 Returns view associated with the window if it is exists and is activated. Returns true if the view associated to the window exists.
 
void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId, const Graphic3d_ZLayerSettings &theSettings, const Graphic3d_ZLayerId theLayerAfter) override
 Adds a layer to all views.
 
void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId, const Graphic3d_ZLayerSettings &theSettings, const Graphic3d_ZLayerId theLayerBefore) override
 Adds a layer to all views.
 
void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) override
 Removes Z layer. All structures displayed at the moment in layer will be displayed in default layer (the bottom-level z layer). By default, there are always default bottom-level layer that can't be removed. The passed theLayerId should be not less than 0 (reserved for default layers that can not be removed).
 
void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings &theSettings) override
 Sets the settings for a single Z layer.
 
const OpenGl_CapsOptions () const
 
OpenGl_CapsChangeOptions ()
 
void SetBuffersNoSwap (const bool theIsNoSwap)
 Specify swap buffer behavior.
 
void EnableVBO (const bool theToTurnOn) override
 VBO usage can be forbidden by this method even if it is supported by GL driver. Notice that disabling of VBO will cause rendering performance degradation. Warning! This method should be called only before any primitives are displayed in GL scene!
 
bool IsVerticalSync () const override
 Returns TRUE if vertical synchronization with display refresh rate (VSync) should be used; TRUE by default.
 
void SetVerticalSync (bool theToEnable) override
 Set if vertical synchronization with display refresh rate (VSync) should be used.
 
bool MemoryInfo (size_t &theFreeBytes, TCollection_AsciiString &theInfo) const override
 Returns information about GPU memory usage. Please read OpenGl_Context::MemoryInfo() for more description.
 
const occ::handle< OpenGl_Context > & GetSharedContext (bool theBound=false) const
 Method to retrieve valid GL context. Could return NULL-handle if no window created by this driver.
 
Aspect_Display getRawGlDisplay () const
 
Aspect_RenderingContext getRawGlContext () const
 
voidgetRawGlConfig () const
 
void setDeviceLost ()
 Set device lost flag for redrawn views.
 
OpenGl_StateCounterGetStateCounter () const
 State counter for OpenGl structures.
 
size_t GetNextPrimitiveArrayUID () const
 Returns unique ID for primitive arrays.
 
- Public Member Functions inherited from Graphic3d_GraphicDriver
int InquireLightLimit () const
 Request maximum number of active light sources supported by driver and hardware.
 
int InquirePlaneLimit () const
 Request maximum number of active clipping planes supported by driver and hardware.
 
int InquireViewLimit () const
 Request maximum number of views supported by driver.
 
virtual void ZLayers (NCollection_Sequence< int > &theLayerSeq) const
 Returns list of Z layers defined for the graphical driver.
 
virtual const Graphic3d_ZLayerSettingsZLayerSettings (const Graphic3d_ZLayerId theLayerId) const
 Returns the settings of a single Z layer.
 
const occ::handle< Aspect_DisplayConnection > & GetDisplayConnection () const
 returns Handle to display connection
 
int NewIdentification ()
 Returns a new identification number for a new structure.
 
void RemoveIdentification (const int theId)
 Frees the identifier of a structure.
 
void DumpJson (Standard_OStream &theOStream, int theDepth=-1) const
 Dumps the content of me into the stream.
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor.
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing.
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter.
 
virtual ~Standard_Transient ()=default
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
bool IsInstance (const char *const theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
bool IsKind (const opencascade::handle< Standard_Type > &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
bool IsKind (const char *const theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero.
 
int GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
 
int DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

Protected Member Functions

void chooseVisualInfo ()
 Choose default visual for new windows created by Aspect_DisplayConnection.
 
- Protected Member Functions inherited from Graphic3d_GraphicDriver
 Graphic3d_GraphicDriver (const occ::handle< Aspect_DisplayConnection > &theDisp)
 Initializes the Driver.
 

Protected Attributes

bool myIsOwnContext
 indicates that shared context has been created within OpenGl_GraphicDriver
 
Aspect_Display myEglDisplay
 EGL connection to the Display : EGLDisplay.
 
Aspect_RenderingContext myEglContext
 EGL rendering context : EGLContext.
 
voidmyEglConfig
 EGL configuration : EGLConfig.
 
occ::handle< OpenGl_CapsmyCaps
 
NCollection_Map< occ::handle< OpenGl_View > > myMapOfView
 
NCollection_DataMap< int, OpenGl_Structure * > myMapOfStructure
 
OpenGl_StateCounter myStateCounter
 State counter for OpenGl structures.
 
OpenGl_StateCounter myUIDGenerator
 Unique ID counter for primitive arrays.
 
- Protected Attributes inherited from Graphic3d_GraphicDriver
occ::handle< Aspect_DisplayConnectionmyDisplayConnection
 
Aspect_GenId myStructGenId
 
NCollection_List< occ::handle< Graphic3d_Layer > > myLayers
 
NCollection_DataMap< Graphic3d_ZLayerId, occ::handle< Graphic3d_Layer > > myLayerIds
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object.
 
- Static Public Member Functions inherited from Standard_Transient
static constexpr const charget_type_name ()
 Returns a type descriptor about this object.
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class.
 

Detailed Description

This class defines an OpenGl graphic driver.

Constructor & Destructor Documentation

◆ OpenGl_GraphicDriver()

OpenGl_GraphicDriver::OpenGl_GraphicDriver ( const occ::handle< Aspect_DisplayConnection > & theDisp,
const bool theToInitialize = true )

Constructor.

Parameters
theDispconnection to display, required on Linux but optional on other systems
theToInitializeperform initialization of default OpenGL context on construction

◆ ~OpenGl_GraphicDriver()

OpenGl_GraphicDriver::~OpenGl_GraphicDriver ( )
override

Destructor.

Member Function Documentation

◆ ChangeOptions()

OpenGl_Caps & OpenGl_GraphicDriver::ChangeOptions ( )
inline
Returns
the visualization options

◆ chooseVisualInfo()

void OpenGl_GraphicDriver::chooseVisualInfo ( )
protected

Choose default visual for new windows created by Aspect_DisplayConnection.

◆ CreateRenderWindow()

virtual occ::handle< OpenGl_Window > OpenGl_GraphicDriver::CreateRenderWindow ( const occ::handle< Aspect_Window > & theNativeWindow,
const occ::handle< Aspect_Window > & theSizeWindow,
const Aspect_RenderingContext theContext )
virtual

Create OpenGL window from native window.

Parameters
[in]theNativeWindownative window holder
[in]theSizeWindowobject defining window dimensions
[in]theContextexisting native rendering context

◆ CreateStructure()

occ::handle< Graphic3d_CStructure > OpenGl_GraphicDriver::CreateStructure ( const occ::handle< Graphic3d_StructureManager > & theManager)
overridevirtual

Creates new empty graphic structure.

Implements Graphic3d_GraphicDriver.

◆ CreateView()

occ::handle< Graphic3d_CView > OpenGl_GraphicDriver::CreateView ( const occ::handle< Graphic3d_StructureManager > & theMgr)
overridevirtual

Creates new view for this graphic driver.

Implements Graphic3d_GraphicDriver.

◆ DefaultTextHeight()

float OpenGl_GraphicDriver::DefaultTextHeight ( ) const
overridevirtual

◆ EnableVBO()

void OpenGl_GraphicDriver::EnableVBO ( const bool theToTurnOn)
overridevirtual

VBO usage can be forbidden by this method even if it is supported by GL driver. Notice that disabling of VBO will cause rendering performance degradation. Warning! This method should be called only before any primitives are displayed in GL scene!

Implements Graphic3d_GraphicDriver.

◆ GetNextPrimitiveArrayUID()

size_t OpenGl_GraphicDriver::GetNextPrimitiveArrayUID ( ) const
inline

Returns unique ID for primitive arrays.

◆ getRawGlConfig()

void * OpenGl_GraphicDriver::getRawGlConfig ( ) const
inline

◆ getRawGlContext()

Aspect_RenderingContext OpenGl_GraphicDriver::getRawGlContext ( ) const
inline

◆ getRawGlDisplay()

Aspect_Display OpenGl_GraphicDriver::getRawGlDisplay ( ) const
inline

◆ GetSharedContext()

const occ::handle< OpenGl_Context > & OpenGl_GraphicDriver::GetSharedContext ( bool theBound = false) const

Method to retrieve valid GL context. Could return NULL-handle if no window created by this driver.

Parameters
theBoundif TRUE then currently bound context will be returned, any context will be returned otherwise

◆ GetStateCounter()

OpenGl_StateCounter * OpenGl_GraphicDriver::GetStateCounter ( ) const
inline

State counter for OpenGl structures.

◆ InitContext()

bool OpenGl_GraphicDriver::InitContext ( )

Perform initialization of default OpenGL context.

◆ InitEglContext()

bool OpenGl_GraphicDriver::InitEglContext ( Aspect_Display theEglDisplay,
Aspect_RenderingContext theEglContext,
void * theEglConfig )

Initialize default OpenGL context using existing one.

Parameters
theEglDisplayEGL connection to the Display
theEglContextEGL rendering context
theEglConfigEGL configuration

◆ InquireLimit()

int OpenGl_GraphicDriver::InquireLimit ( const Graphic3d_TypeOfLimit theType) const
overridevirtual

Request limit of graphic resource of specific type.

Implements Graphic3d_GraphicDriver.

◆ InsertLayerAfter()

void OpenGl_GraphicDriver::InsertLayerAfter ( const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings & theSettings,
const Graphic3d_ZLayerId theLayerBefore )
overridevirtual

Adds a layer to all views.

Parameters
[in]theNewLayerIdid of created layer
[in]theSettingsnew layer settings
[in]theLayerBeforeid of layer to append new layer after

Implements Graphic3d_GraphicDriver.

◆ InsertLayerBefore()

void OpenGl_GraphicDriver::InsertLayerBefore ( const Graphic3d_ZLayerId theNewLayerId,
const Graphic3d_ZLayerSettings & theSettings,
const Graphic3d_ZLayerId theLayerAfter )
overridevirtual

Adds a layer to all views.

Parameters
[in]theNewLayerIdid of new layer, should be > 0 (negative values are reserved for default layers).
[in]theSettingsnew layer settings
[in]theLayerAfterid of layer to append new layer before

Implements Graphic3d_GraphicDriver.

◆ IsVerticalSync()

bool OpenGl_GraphicDriver::IsVerticalSync ( ) const
overridevirtual

Returns TRUE if vertical synchronization with display refresh rate (VSync) should be used; TRUE by default.

Implements Graphic3d_GraphicDriver.

◆ MemoryInfo()

bool OpenGl_GraphicDriver::MemoryInfo ( size_t & theFreeBytes,
TCollection_AsciiString & theInfo ) const
overridevirtual

Returns information about GPU memory usage. Please read OpenGl_Context::MemoryInfo() for more description.

Implements Graphic3d_GraphicDriver.

◆ Options()

const OpenGl_Caps & OpenGl_GraphicDriver::Options ( ) const
inline
Returns
the visualization options

◆ ReleaseContext()

void OpenGl_GraphicDriver::ReleaseContext ( )

Release default context.

◆ RemoveStructure()

void OpenGl_GraphicDriver::RemoveStructure ( occ::handle< Graphic3d_CStructure > & theCStructure)
overridevirtual

Removes structure from graphic driver and releases its resources.

Implements Graphic3d_GraphicDriver.

◆ RemoveView()

void OpenGl_GraphicDriver::RemoveView ( const occ::handle< Graphic3d_CView > & theView)
overridevirtual

Removes view from graphic driver and releases its resources.

Implements Graphic3d_GraphicDriver.

◆ RemoveZLayer()

void OpenGl_GraphicDriver::RemoveZLayer ( const Graphic3d_ZLayerId theLayerId)
overridevirtual

Removes Z layer. All structures displayed at the moment in layer will be displayed in default layer (the bottom-level z layer). By default, there are always default bottom-level layer that can't be removed. The passed theLayerId should be not less than 0 (reserved for default layers that can not be removed).

Implements Graphic3d_GraphicDriver.

◆ SetBuffersNoSwap()

void OpenGl_GraphicDriver::SetBuffersNoSwap ( const bool theIsNoSwap)

Specify swap buffer behavior.

◆ setDeviceLost()

void OpenGl_GraphicDriver::setDeviceLost ( )

Set device lost flag for redrawn views.

◆ SetVerticalSync()

void OpenGl_GraphicDriver::SetVerticalSync ( bool theToEnable)
overridevirtual

Set if vertical synchronization with display refresh rate (VSync) should be used.

Implements Graphic3d_GraphicDriver.

◆ SetZLayerSettings()

void OpenGl_GraphicDriver::SetZLayerSettings ( const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings & theSettings )
overridevirtual

Sets the settings for a single Z layer.

Implements Graphic3d_GraphicDriver.

◆ TextSize()

void OpenGl_GraphicDriver::TextSize ( const occ::handle< Graphic3d_CView > & theView,
const char *const theText,
const float theHeight,
float & theWidth,
float & theAscent,
float & theDescent ) const
overridevirtual

Computes text width.

Implements Graphic3d_GraphicDriver.

◆ ViewExists()

bool OpenGl_GraphicDriver::ViewExists ( const occ::handle< Aspect_Window > & theWindow,
occ::handle< Graphic3d_CView > & theView )
overridevirtual

Returns view associated with the window if it is exists and is activated. Returns true if the view associated to the window exists.

Implements Graphic3d_GraphicDriver.

Field Documentation

◆ myCaps

occ::handle<OpenGl_Caps> OpenGl_GraphicDriver::myCaps
protected

◆ myEglConfig

void* OpenGl_GraphicDriver::myEglConfig
protected

EGL configuration : EGLConfig.

◆ myEglContext

Aspect_RenderingContext OpenGl_GraphicDriver::myEglContext
protected

EGL rendering context : EGLContext.

◆ myEglDisplay

Aspect_Display OpenGl_GraphicDriver::myEglDisplay
protected

EGL connection to the Display : EGLDisplay.

◆ myIsOwnContext

bool OpenGl_GraphicDriver::myIsOwnContext
protected

indicates that shared context has been created within OpenGl_GraphicDriver

◆ myMapOfStructure

NCollection_DataMap<int, OpenGl_Structure*> OpenGl_GraphicDriver::myMapOfStructure
protected

◆ myMapOfView

NCollection_Map<occ::handle<OpenGl_View> > OpenGl_GraphicDriver::myMapOfView
protected

◆ myStateCounter

OpenGl_StateCounter OpenGl_GraphicDriver::myStateCounter
mutableprotected

State counter for OpenGl structures.

◆ myUIDGenerator

OpenGl_StateCounter OpenGl_GraphicDriver::myUIDGenerator
mutableprotected

Unique ID counter for primitive arrays.


The documentation for this class was generated from the following file: