Open CASCADE Technology 6.6.0
Public Member Functions | Static Public Member Functions | Data Fields
OpenGl_Context Class Reference

This class generalize access to the GL context and available extensions. More...

#include <OpenGl_Context.hxx>

Inheritance diagram for OpenGl_Context:
Inheritance graph
[legend]

Public Member Functions

 OpenGl_Context ()
 Empty constructor. You should call Init() to perform initialization with bound GL context.
virtual ~OpenGl_Context ()
 Destructor.
void Share (const Handle< OpenGl_Context > &theShareCtx)
 Share GL context resources. theShareCtx - handle to context to retrieve handles to shared resources.
Standard_Boolean Init ()
 Initialize available extensions. GL context should be active!
Standard_Boolean Init (const Aspect_Drawable theWindow, const Aspect_Display theDisplay, const Aspect_RenderingContext theGContext)
Standard_Boolean CheckExtension (const char *theExtName) const
 Check if theExtName extension is supported by active GL context.
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.
Standard_Boolean IsGlGreaterEqual (const Standard_Integer theVerMajor, const Standard_Integer theVerMinor)
void ResetErrors ()
 Clean up errors stack for this GL context (glGetError() in loop).
Standard_Boolean IsCurrent () const
 This method uses system-dependent API to retrieve information about GL context bound to the current thread.
Standard_Boolean MakeCurrent ()
 Activates current context. Class should be initialized with appropriate info.
void SwapBuffers ()
 Swap front/back buffers for this GL context (should be activated before!).
Standard_Boolean IsFeedback () const
 Return true if active mode is GL_FEEDBACK (cached state)
void SetFeedback (const Standard_Boolean theFeedbackOn)
 Setup feedback mode cached state.
Standard_Size AvailableMemory () const
 This function retrieves information from GL about free GPU memory that is:
TCollection_AsciiString MemoryInfo () const
 This function retrieves information from GL about GPU memory and contains more vendor-specific values than AvailableMemory().
const Handle< OpenGl_Resource > & GetResource (const TCollection_AsciiString &theKey) const
 Access shared resource by its name.
template<typename TheHandleType >
Standard_Boolean GetResource (const TCollection_AsciiString &theKey, TheHandleType &theValue) const
 Access shared resource by its name.
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.
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.
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.
void ReleaseDelayed ()
 Clean up the delayed release queue.
Standard_Integer MaxDegreeOfAnisotropy () const
Standard_Integer MaxTextureSize () const
 DEFINE_STANDARD_RTTI (OpenGl_Context) friend class OpenGl_Window

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.

Data Fields

OpenGl_GlCore12core12
OpenGl_GlCore13core13
OpenGl_GlCore14core14
OpenGl_GlCore15core15
OpenGl_GlCore20core20
Standard_Boolean arbNPTW
 GL_ARB_texture_non_power_of_two.
OpenGl_ArbVBOarbVBO
 GL_ARB_vertex_buffer_object.
OpenGl_ArbTBOarbTBO
 GL_ARB_texture_buffer_object.
OpenGl_ArbInsarbIns
 GL_ARB_draw_instanced.
OpenGl_ExtFBOextFBO
 GL_EXT_framebuffer_object.
OpenGl_ExtGSextGS
 GL_EXT_geometry_shader4.
Standard_Boolean extBgra
 GL_EXT_bgra.
Standard_Boolean extAnis
 GL_EXT_texture_filter_anisotropic.
Standard_Boolean atiMem
 GL_ATI_meminfo.
Standard_Boolean nvxMem
 GL_NVX_gpu_memory_info.

Detailed Description

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):

   if (myContext->core20 != NULL)
   {
     myGlProgram = myContext->core20->glCreateProgram();
     .. do more stuff ..
   }
   else
   {
     .. compatibility with outdated configurations ..
   }

Current implementation provide access to OpenGL core functionality up to 2.0 version (core12, core13, core14, core15, fields core20). within several extensions (arbVBO, extFBO, 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.


Constructor & Destructor Documentation

OpenGl_Context::OpenGl_Context ( )
virtual OpenGl_Context::~OpenGl_Context ( ) [virtual]

Member Function Documentation

Standard_Size OpenGl_Context::AvailableMemory ( ) const
  • OS-dependent. On some OS it is per-process and on others - for entire system.
  • Vendor-dependent. Currently available only on NVIDIA and AMD/ATi drivers only.
  • Numbers meaning may vary. You should use this info only for diagnostics purposes.
    Returns:
    free GPU dedicated memory in bytes.
Standard_Boolean OpenGl_Context::CheckExtension ( const char *  theExtName) const
OpenGl_Context::DEFINE_STANDARD_RTTI ( OpenGl_Context  )
void OpenGl_Context::DelayedRelease ( Handle< OpenGl_Resource > &  theResource)
template<typename FuncType_t >
Standard_Boolean OpenGl_Context::FindProc ( const char *  theFuncName,
FuncType_t &  theFuncPtr 
) [inline]
static Standard_Integer OpenGl_Context::GetPowerOfTwo ( const Standard_Integer  theNumber,
const Standard_Integer  theThreshold 
) [inline, static]
Parameters:
theNumbernumber to 'power of two'
theThresholdupper threshold
Returns:
power of two number
const Handle< OpenGl_Resource >& OpenGl_Context::GetResource ( const TCollection_AsciiString theKey) const
Parameters:
theKey- unique identifier;
Returns:
handle to shared resource or NULL.
template<typename TheHandleType >
Standard_Boolean OpenGl_Context::GetResource ( const TCollection_AsciiString theKey,
TheHandleType &  theValue 
) const [inline]
Parameters:
theKey- unique identifier;
theValue- handle to fill;
Returns:
true if resource was shared.
Standard_Boolean OpenGl_Context::Init ( const Aspect_Drawable  theWindow,
const Aspect_Display  theDisplay,
const Aspect_RenderingContext  theGContext 
)
Standard_Boolean OpenGl_Context::Init ( )
Standard_Boolean OpenGl_Context::IsCurrent ( ) const
Returns:
true if current thread is bound to this GL context
Standard_Boolean OpenGl_Context::IsFeedback ( ) const
Standard_Boolean OpenGl_Context::IsGlGreaterEqual ( const Standard_Integer  theVerMajor,
const Standard_Integer  theVerMinor 
) [inline]
Returns:
true if detected GL version is greater or equal to requested one.
Standard_Boolean OpenGl_Context::MakeCurrent ( )
Standard_Integer OpenGl_Context::MaxDegreeOfAnisotropy ( ) const
Returns:
maximum degree of anisotropy texture filter
Standard_Integer OpenGl_Context::MaxTextureSize ( ) const
Returns:
value for GL_MAX_TEXTURE_SIZE
TCollection_AsciiString OpenGl_Context::MemoryInfo ( ) const
void OpenGl_Context::ReleaseDelayed ( )
void OpenGl_Context::ReleaseResource ( const TCollection_AsciiString theKey,
const Standard_Boolean  theToDelay = Standard_False 
)
Parameters:
theKeyunique identifier
theToDelaypostpone release until next redraw call
void OpenGl_Context::ResetErrors ( )
void OpenGl_Context::SetFeedback ( const Standard_Boolean  theFeedbackOn)
void OpenGl_Context::Share ( const Handle< OpenGl_Context > &  theShareCtx)
Standard_Boolean OpenGl_Context::ShareResource ( const TCollection_AsciiString theKey,
const Handle< OpenGl_Resource > &  theResource 
)
Parameters:
theKey- unique identifier, shouldn't be empty;
theResource- new resource to register, shouldn't be NULL.
void OpenGl_Context::SwapBuffers ( )

Field Documentation


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines