Open CASCADE Technology  6.5.4
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
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)
 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.
 DEFINE_STANDARD_RTTI (OpenGl_Context) friend class OpenGl_Window

Data Fields

OpenGl_GlCore12core12
OpenGl_GlCore13core13
OpenGl_GlCore14core14
OpenGl_GlCore15core15
OpenGl_GlCore20core20
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 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

virtual OpenGl_Context::~OpenGl_Context ( ) [virtual]

Member Function Documentation

  • 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.
template<typename FuncType_t >
Standard_Boolean OpenGl_Context::FindProc ( const char *  theFuncName,
FuncType_t &  theFuncPtr 
) [inline]
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.
Returns:
true if current thread is bound to this GL context
Returns:
true if detected GL version is greater or equal to requested one.
Parameters:
theKey- unique identifier.
Parameters:
theKey- unique identifier, shouldn't be empty;
theResource- new resource to register, shouldn't be NULL.

Field Documentation


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