Open CASCADE Technology
6.8.0
|
This class generalize access to the GL context and available extensions. More...
#include <OpenGl_Context.hxx>
Public Member Functions | |
OpenGl_Context (const Handle< OpenGl_Caps > &theCaps=NULL) | |
Empty constructor. You should call Init() to perform initialization with bound GL context. More... | |
virtual | ~OpenGl_Context () |
Destructor. More... | |
void | forcedRelease () |
Release all resources, including shared ones. More... | |
void | Share (const Handle< OpenGl_Context > &theShareCtx) |
Share GL context resources. theShareCtx - handle to context to retrieve handles to shared resources. More... | |
Standard_Boolean | Init () |
Initialize class from currently bound OpenGL context. Method should be called only once. More... | |
Standard_Boolean | IsValid () const |
Standard_Boolean | Init (const Aspect_Drawable theWindow, const Aspect_Display theDisplay, const Aspect_RenderingContext theGContext) |
Initialize class from specified window and rendering context. Method should be called only once. More... | |
Aspect_Drawable | Window () const |
Standard_Boolean | CheckExtension (const char *theExtName) const |
Check if theExtName extension is supported by active GL context. More... | |
template<typename FuncType_t > | |
Standard_Boolean | FindProc (const char *theFuncName, FuncType_t &theFuncPtr) |
Auxiliary template to retrieve GL function pointer. Pointer to function retrieved from library is statically casted to requested type - there no way to check real signature of exported function. The context should be bound before call. More... | |
Standard_Boolean | IsGlGreaterEqual (const Standard_Integer theVerMajor, const Standard_Integer theVerMinor) const |
void | ResetErrors () |
Clean up errors stack for this GL context (glGetError() in loop). More... | |
Standard_Boolean | IsCurrent () const |
This method uses system-dependent API to retrieve information about GL context bound to the current thread. More... | |
Standard_Boolean | MakeCurrent () |
Activates current context. Class should be initialized with appropriate info. More... | |
void | SwapBuffers () |
Swap front/back buffers for this GL context (should be activated before!). More... | |
Standard_Boolean | IsRender () const |
Return true if active mode is GL_RENDER (cached state) More... | |
Standard_Boolean | IsFeedback () const |
Return true if active mode is GL_FEEDBACK (cached state) More... | |
Standard_Size | AvailableMemory () const |
This function retrieves information from GL about free GPU memory that is: More... | |
TCollection_AsciiString | MemoryInfo () const |
This function retrieves information from GL about GPU memory and contains more vendor-specific values than AvailableMemory(). More... | |
const Handle< OpenGl_Resource > & | GetResource (const TCollection_AsciiString &theKey) const |
Access shared resource by its name. More... | |
template<typename TheHandleType > | |
Standard_Boolean | GetResource (const TCollection_AsciiString &theKey, TheHandleType &theValue) const |
Access shared resource by its name. More... | |
Standard_Boolean | ShareResource (const TCollection_AsciiString &theKey, const Handle< OpenGl_Resource > &theResource) |
Register shared resource. Notice that after registration caller shouldn't release it by himself - it will be automatically released on context destruction. More... | |
void | ReleaseResource (const TCollection_AsciiString &theKey, const Standard_Boolean theToDelay=Standard_False) |
Release shared resource. If there are more than one reference to this resource (also used by some other existing object) then call will be ignored. This means that current object itself should nullify handle before this call. Notice that this is unrecommended operation at all and should be used only in case of fat resources to release memory for other needs. More... | |
void | DelayedRelease (Handle< OpenGl_Resource > &theResource) |
Append resource to queue for delayed clean up. Resources in this queue will be released at next redraw call. More... | |
void | ReleaseDelayed () |
Clean up the delayed release queue. More... | |
OpenGl_Clipping & | ChangeClipping () |
const OpenGl_Clipping & | Clipping () const |
const Handle < OpenGl_ShaderManager > & | ShaderManager () const |
Standard_Integer | TextureWrapClamp () const |
Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1). More... | |
Standard_Integer | MaxDegreeOfAnisotropy () const |
Standard_Integer | MaxTextureSize () const |
Standard_Integer | MaxClipPlanes () const |
Get maximum number of clip planes supported by OpenGl. This value is implementation dependent. At least 6 planes should be supported by OpenGl (see specs). More... | |
bool | ToUseVbo () const |
Returns true if VBO is supported and permitted. More... | |
Standard_Boolean | IsGlNormalizeEnabled () const |
Standard_Boolean | SetGlNormalizeEnabled (Standard_Boolean isEnabled) |
Sets GL_NORMALIZE enabled or disabled. More... | |
void | ApplyModelWorldMatrix () |
Applies matrix stored in ModelWorldState to OpenGl. More... | |
void | ApplyWorldViewMatrix () |
Applies matrix stored in WorldViewState to OpenGl. More... | |
void | ApplyModelViewMatrix () |
Applies combination of matrices stored in ModelWorldState and WorldViewState to OpenGl. More... | |
void | ApplyProjectionMatrix () |
Applies matrix stored in ProjectionState to OpenGl. More... | |
const Handle< Message_Messenger > & | Messenger () const |
void | PushMessage (const unsigned int theSource, const unsigned int theType, const unsigned int theId, const unsigned int theSeverity, const TCollection_ExtendedString &theMessage) |
Callback for GL_ARB_debug_output extension. More... | |
Standard_Boolean | HasStereoBuffers () const |
![]() | |
Standard_Transient () | |
Empty constructor. More... | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. More... | |
Standard_Transient & | operator= (const Standard_Transient &) |
Assignment operator, needed to avoid copying reference counter. More... | |
virtual | ~Standard_Transient () |
Destructor must be virtual. More... | |
virtual void | Delete () const |
Memory deallocator for transient classes. More... | |
virtual const Handle_Standard_Type & | DynamicType () const |
Returns a type information object about this object. More... | |
Standard_Boolean | IsInstance (const Handle_Standard_Type &theType) const |
Returns a true value if this is an instance of Type. More... | |
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const |
Returns a true value if this is an instance of TypeName. More... | |
Standard_Boolean | IsKind (const 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. More... | |
Standard_Boolean | IsKind (const Standard_CString 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. More... | |
virtual Handle_Standard_Transient | This () const |
Returns a Handle which references this object. Must never be called to objects created in stack. More... | |
Standard_Integer | GetRefCount () const |
Get the reference counter of this object. More... | |
Static Public Member Functions | |
static Standard_Integer | GetPowerOfTwo (const Standard_Integer theNumber, const Standard_Integer theThreshold) |
Function for getting power of to number larger or equal to input number. More... | |
static Standard_Boolean | CheckExtension (const char *theExtString, const char *theExtName) |
Check if theExtName extension is in extensions string. More... | |
Data Fields | |
core profiles | |
OpenGl_GlCore11 * | core11 |
OpenGL 1.1 core functionality. More... | |
OpenGl_GlCore11Fwd * | core11fwd |
OpenGL 1.1 without deprecated entry points. More... | |
OpenGl_GlCore15 * | core15 |
OpenGL 1.5 core functionality. More... | |
OpenGl_GlCore15Fwd * | core15fwd |
OpenGL 1.5 without deprecated entry points. More... | |
OpenGl_GlCore20 * | core20 |
OpenGL 2.0 core functionality (includes 1.5) More... | |
OpenGl_GlCore20Fwd * | core20fwd |
OpenGL 2.0 without deprecated entry points. More... | |
OpenGl_GlCore32 * | core32 |
OpenGL 3.2 core profile. More... | |
OpenGl_GlCore32Back * | core32back |
OpenGL 3.2 backward compatibility profile. More... | |
OpenGl_GlCore33 * | core33 |
OpenGL 3.3 core profile. More... | |
OpenGl_GlCore33Back * | core33back |
OpenGL 3.3 backward compatibility profile. More... | |
OpenGl_GlCore41 * | core41 |
OpenGL 4.1 core profile. More... | |
OpenGl_GlCore41Back * | core41back |
OpenGL 4.1 backward compatibility profile. More... | |
OpenGl_GlCore42 * | core42 |
OpenGL 4.2 core profile. More... | |
OpenGl_GlCore42Back * | core42back |
OpenGL 4.2 backward compatibility profile. More... | |
OpenGl_GlCore43 * | core43 |
OpenGL 4.3 core profile. More... | |
OpenGl_GlCore43Back * | core43back |
OpenGL 4.3 backward compatibility profile. More... | |
OpenGl_GlCore44 * | core44 |
OpenGL 4.4 core profile. More... | |
OpenGl_GlCore44Back * | core44back |
OpenGL 4.4 backward compatibility profile. More... | |
Handle< OpenGl_Caps > | caps |
context options More... | |
methods to alter or retrieve current state | |
void | SetDrawBufferLeft () |
Switch to left stereographic rendering buffer. This method can be used to keep unchanged choise of front/back/both buffer rendering. More... | |
void | SetDrawBufferRight () |
Switch to right stereographic rendering buffer. This method can be used to keep unchanged choise of front/back/both buffer rendering. More... | |
void | SetDrawBufferMono () |
Switch to non-stereographic rendering buffer. This method can be used to keep unchanged choise of front/back/both buffer rendering. More... | |
void | FetchState () |
Fetch OpenGl context state. This class tracks value of several OpenGl state variables. Consulting the cached values is quicker than doing the same via OpenGl API. Call this method if any of the controlled OpenGl state variables has a possibility of being out-of-date. More... | |
const Handle < OpenGl_ShaderProgram > & | ActiveProgram () const |
const Handle< OpenGl_Sampler > & | TextureSampler () |
Standard_Boolean | BindProgram (const Handle< OpenGl_ShaderProgram > &theProgram) |
Bind specified program to current context, or unbind previous one when NULL specified. More... | |
void | SetColor4fv (const OpenGl_Vec4 &theColor) |
Setup current color. More... | |
void | SetPointSize (const Standard_ShortReal theSize) |
Setup point size. More... | |
extensions | |
Standard_Boolean | hasHighp |
highp in GLSL ES fragment shader is supported More... | |
Standard_Boolean | hasTexRGBA8 |
always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8 More... | |
Standard_Boolean | arbNPTW |
GL_ARB_texture_non_power_of_two. More... | |
Standard_Boolean | arbTexRG |
GL_ARB_texture_rg. More... | |
OpenGl_ArbTexBindless * | arbTexBindless |
GL_ARB_bindless_texture. More... | |
OpenGl_ArbTBO * | arbTBO |
GL_ARB_texture_buffer_object. More... | |
Standard_Boolean | arbTboRGB32 |
GL_ARB_texture_buffer_object_rgb32 (3-component TBO), in core since 4.0. More... | |
OpenGl_ArbIns * | arbIns |
GL_ARB_draw_instanced. More... | |
OpenGl_ArbDbg * | arbDbg |
GL_ARB_debug_output. More... | |
OpenGl_ArbFBO * | arbFBO |
GL_ARB_framebuffer_object. More... | |
OpenGl_ExtGS * | extGS |
GL_EXT_geometry_shader4. More... | |
Standard_Boolean | extBgra |
GL_EXT_bgra or GL_EXT_texture_format_BGRA8888 on OpenGL ES. More... | |
Standard_Boolean | extAnis |
GL_EXT_texture_filter_anisotropic. More... | |
Standard_Boolean | extPDS |
GL_EXT_packed_depth_stencil. More... | |
Standard_Boolean | atiMem |
GL_ATI_meminfo. More... | |
Standard_Boolean | nvxMem |
GL_NVX_gpu_memory_info. More... | |
fields tracking current state | |
OpenGl_Utils::MatrixState < Standard_ShortReal > | ModelWorldState |
state of orientation matrix More... | |
OpenGl_Utils::MatrixState < Standard_ShortReal > | WorldViewState |
state of orientation matrix More... | |
OpenGl_Utils::MatrixState < Standard_ShortReal > | ProjectionState |
state of projection matrix More... | |
DEFINE_STANDARD_RTTI (OpenGl_Context) friend class OpenGl_Window | |
state of orientation matrix More... | |
This class generalize access to the GL context and available extensions.
Functions are grouped into structures and accessed as fields. You should check the group for NULL before usage (if group is not NULL then all functions are available):
Current implementation provide access to OpenGL core functionality up to 2.0 version (core12, core13, core14, core15, fields core20). within several extensions (arbTBO, arbFBO, etc.).
Simplified extensions classification:
Notice that some systems provide mechanisms to simultaneously incorporate with GL contexts with different capabilities. Thats why OpenGl_Context should be initialized and used for each GL context individually.
OpenGl_Context::OpenGl_Context | ( | const Handle< OpenGl_Caps > & | theCaps = NULL | ) |
Empty constructor. You should call Init() to perform initialization with bound GL context.
|
virtual |
Destructor.
|
inline |
void OpenGl_Context::ApplyModelViewMatrix | ( | ) |
Applies combination of matrices stored in ModelWorldState and WorldViewState to OpenGl.
void OpenGl_Context::ApplyModelWorldMatrix | ( | ) |
Applies matrix stored in ModelWorldState to OpenGl.
void OpenGl_Context::ApplyProjectionMatrix | ( | ) |
Applies matrix stored in ProjectionState to OpenGl.
void OpenGl_Context::ApplyWorldViewMatrix | ( | ) |
Applies matrix stored in WorldViewState to OpenGl.
Standard_Size OpenGl_Context::AvailableMemory | ( | ) | const |
This function retrieves information from GL about free GPU memory that is:
Standard_Boolean OpenGl_Context::BindProgram | ( | const Handle< OpenGl_ShaderProgram > & | theProgram | ) |
Bind specified program to current context, or unbind previous one when NULL specified.
|
inline |
Standard_Boolean OpenGl_Context::CheckExtension | ( | const char * | theExtName | ) | const |
Check if theExtName extension is supported by active GL context.
|
static |
Check if theExtName extension is in extensions string.
|
inline |
OpenGl_Context::DEFINE_STANDARD_RTTI | ( | OpenGl_Context | ) |
state of orientation matrix
void OpenGl_Context::DelayedRelease | ( | Handle< OpenGl_Resource > & | theResource | ) |
Append resource to queue for delayed clean up. Resources in this queue will be released at next redraw call.
void OpenGl_Context::FetchState | ( | ) |
Fetch OpenGl context state. This class tracks value of several OpenGl state variables. Consulting the cached values is quicker than doing the same via OpenGl API. Call this method if any of the controlled OpenGl state variables has a possibility of being out-of-date.
|
inline |
Auxiliary template to retrieve GL function pointer. Pointer to function retrieved from library is statically casted to requested type - there no way to check real signature of exported function. The context should be bound before call.
void OpenGl_Context::forcedRelease | ( | ) |
Release all resources, including shared ones.
|
inlinestatic |
Function for getting power of to number larger or equal to input number.
theNumber | number to 'power of two' |
theThreshold | upper threshold |
const Handle< OpenGl_Resource >& OpenGl_Context::GetResource | ( | const TCollection_AsciiString & | theKey | ) | const |
Access shared resource by its name.
theKey | - unique identifier; |
|
inline |
Access shared resource by its name.
theKey | - unique identifier; |
theValue | - handle to fill; |
|
inline |
Standard_Boolean OpenGl_Context::Init | ( | ) |
Initialize class from currently bound OpenGL context. Method should be called only once.
Standard_Boolean OpenGl_Context::Init | ( | const Aspect_Drawable | theWindow, |
const Aspect_Display | theDisplay, | ||
const Aspect_RenderingContext | theGContext | ||
) |
Initialize class from specified window and rendering context. Method should be called only once.
Standard_Boolean OpenGl_Context::IsCurrent | ( | ) | const |
This method uses system-dependent API to retrieve information about GL context bound to the current thread.
|
inline |
Return true if active mode is GL_FEEDBACK (cached state)
|
inline |
|
inline |
|
inline |
Return true if active mode is GL_RENDER (cached state)
|
inline |
Standard_Boolean OpenGl_Context::MakeCurrent | ( | ) |
Activates current context. Class should be initialized with appropriate info.
Standard_Integer OpenGl_Context::MaxClipPlanes | ( | ) | const |
Get maximum number of clip planes supported by OpenGl. This value is implementation dependent. At least 6 planes should be supported by OpenGl (see specs).
Standard_Integer OpenGl_Context::MaxDegreeOfAnisotropy | ( | ) | const |
Standard_Integer OpenGl_Context::MaxTextureSize | ( | ) | const |
TCollection_AsciiString OpenGl_Context::MemoryInfo | ( | ) | const |
This function retrieves information from GL about GPU memory and contains more vendor-specific values than AvailableMemory().
|
inline |
void OpenGl_Context::PushMessage | ( | const unsigned int | theSource, |
const unsigned int | theType, | ||
const unsigned int | theId, | ||
const unsigned int | theSeverity, | ||
const TCollection_ExtendedString & | theMessage | ||
) |
Callback for GL_ARB_debug_output extension.
theSource | message source within GL_DEBUG_SOURCE_ enumeration |
theType | message type within GL_DEBUG_TYPE_ enumeration |
theId | message ID within source |
theSeverity | message severity within GL_DEBUG_SEVERITY_ enumeration |
theMessage | the message itself |
void OpenGl_Context::ReleaseDelayed | ( | ) |
Clean up the delayed release queue.
void OpenGl_Context::ReleaseResource | ( | const TCollection_AsciiString & | theKey, |
const Standard_Boolean | theToDelay = Standard_False |
||
) |
Release shared resource. If there are more than one reference to this resource (also used by some other existing object) then call will be ignored. This means that current object itself should nullify handle before this call. Notice that this is unrecommended operation at all and should be used only in case of fat resources to release memory for other needs.
theKey | unique identifier |
theToDelay | postpone release until next redraw call |
void OpenGl_Context::ResetErrors | ( | ) |
Clean up errors stack for this GL context (glGetError() in loop).
void OpenGl_Context::SetColor4fv | ( | const OpenGl_Vec4 & | theColor | ) |
Setup current color.
void OpenGl_Context::SetDrawBufferLeft | ( | ) |
Switch to left stereographic rendering buffer. This method can be used to keep unchanged choise of front/back/both buffer rendering.
void OpenGl_Context::SetDrawBufferMono | ( | ) |
Switch to non-stereographic rendering buffer. This method can be used to keep unchanged choise of front/back/both buffer rendering.
void OpenGl_Context::SetDrawBufferRight | ( | ) |
Switch to right stereographic rendering buffer. This method can be used to keep unchanged choise of front/back/both buffer rendering.
Standard_Boolean OpenGl_Context::SetGlNormalizeEnabled | ( | Standard_Boolean | isEnabled | ) |
Sets GL_NORMALIZE enabled or disabled.
void OpenGl_Context::SetPointSize | ( | const Standard_ShortReal | theSize | ) |
Setup point size.
|
inline |
void OpenGl_Context::Share | ( | const Handle< OpenGl_Context > & | theShareCtx | ) |
Share GL context resources. theShareCtx - handle to context to retrieve handles to shared resources.
Standard_Boolean OpenGl_Context::ShareResource | ( | const TCollection_AsciiString & | theKey, |
const Handle< OpenGl_Resource > & | theResource | ||
) |
Register shared resource. Notice that after registration caller shouldn't release it by himself - it will be automatically released on context destruction.
theKey | - unique identifier, shouldn't be empty; |
theResource | - new resource to register, shouldn't be NULL. |
void OpenGl_Context::SwapBuffers | ( | ) |
Swap front/back buffers for this GL context (should be activated before!).
|
inline |
|
inline |
Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1).
|
inline |
Returns true if VBO is supported and permitted.
|
inline |
OpenGl_ArbDbg* OpenGl_Context::arbDbg |
GL_ARB_debug_output.
OpenGl_ArbFBO* OpenGl_Context::arbFBO |
GL_ARB_framebuffer_object.
OpenGl_ArbIns* OpenGl_Context::arbIns |
GL_ARB_draw_instanced.
Standard_Boolean OpenGl_Context::arbNPTW |
GL_ARB_texture_non_power_of_two.
OpenGl_ArbTBO* OpenGl_Context::arbTBO |
GL_ARB_texture_buffer_object.
Standard_Boolean OpenGl_Context::arbTboRGB32 |
GL_ARB_texture_buffer_object_rgb32 (3-component TBO), in core since 4.0.
OpenGl_ArbTexBindless* OpenGl_Context::arbTexBindless |
GL_ARB_bindless_texture.
Standard_Boolean OpenGl_Context::arbTexRG |
GL_ARB_texture_rg.
Standard_Boolean OpenGl_Context::atiMem |
GL_ATI_meminfo.
Handle< OpenGl_Caps > OpenGl_Context::caps |
context options
OpenGl_GlCore11* OpenGl_Context::core11 |
OpenGL 1.1 core functionality.
OpenGl_GlCore11Fwd* OpenGl_Context::core11fwd |
OpenGL 1.1 without deprecated entry points.
OpenGl_GlCore15* OpenGl_Context::core15 |
OpenGL 1.5 core functionality.
OpenGl_GlCore15Fwd* OpenGl_Context::core15fwd |
OpenGL 1.5 without deprecated entry points.
OpenGl_GlCore20* OpenGl_Context::core20 |
OpenGL 2.0 core functionality (includes 1.5)
OpenGl_GlCore20Fwd* OpenGl_Context::core20fwd |
OpenGL 2.0 without deprecated entry points.
OpenGl_GlCore32* OpenGl_Context::core32 |
OpenGL 3.2 core profile.
OpenGl_GlCore32Back* OpenGl_Context::core32back |
OpenGL 3.2 backward compatibility profile.
OpenGl_GlCore33* OpenGl_Context::core33 |
OpenGL 3.3 core profile.
OpenGl_GlCore33Back* OpenGl_Context::core33back |
OpenGL 3.3 backward compatibility profile.
OpenGl_GlCore41* OpenGl_Context::core41 |
OpenGL 4.1 core profile.
OpenGl_GlCore41Back* OpenGl_Context::core41back |
OpenGL 4.1 backward compatibility profile.
OpenGl_GlCore42* OpenGl_Context::core42 |
OpenGL 4.2 core profile.
OpenGl_GlCore42Back* OpenGl_Context::core42back |
OpenGL 4.2 backward compatibility profile.
OpenGl_GlCore43* OpenGl_Context::core43 |
OpenGL 4.3 core profile.
OpenGl_GlCore43Back* OpenGl_Context::core43back |
OpenGL 4.3 backward compatibility profile.
OpenGl_GlCore44* OpenGl_Context::core44 |
OpenGL 4.4 core profile.
OpenGl_GlCore44Back* OpenGl_Context::core44back |
OpenGL 4.4 backward compatibility profile.
Standard_Boolean OpenGl_Context::extAnis |
GL_EXT_texture_filter_anisotropic.
Standard_Boolean OpenGl_Context::extBgra |
GL_EXT_bgra or GL_EXT_texture_format_BGRA8888 on OpenGL ES.
OpenGl_ExtGS* OpenGl_Context::extGS |
GL_EXT_geometry_shader4.
Standard_Boolean OpenGl_Context::extPDS |
GL_EXT_packed_depth_stencil.
Standard_Boolean OpenGl_Context::hasHighp |
highp in GLSL ES fragment shader is supported
Standard_Boolean OpenGl_Context::hasTexRGBA8 |
always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8
OpenGl_Utils::MatrixState<Standard_ShortReal> OpenGl_Context::ModelWorldState |
state of orientation matrix
Standard_Boolean OpenGl_Context::nvxMem |
GL_NVX_gpu_memory_info.
OpenGl_Utils::MatrixState<Standard_ShortReal> OpenGl_Context::ProjectionState |
state of projection matrix
OpenGl_Utils::MatrixState<Standard_ShortReal> OpenGl_Context::WorldViewState |
state of orientation matrix