Open CASCADE Technology 6.6.0
|
This class generalize access to the GL context and available extensions. More...
#include <OpenGl_Context.hxx>
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_GlCore12 * | core12 |
OpenGl_GlCore13 * | core13 |
OpenGl_GlCore14 * | core14 |
OpenGl_GlCore15 * | core15 |
OpenGl_GlCore20 * | core20 |
Standard_Boolean | arbNPTW |
GL_ARB_texture_non_power_of_two. | |
OpenGl_ArbVBO * | arbVBO |
GL_ARB_vertex_buffer_object. | |
OpenGl_ArbTBO * | arbTBO |
GL_ARB_texture_buffer_object. | |
OpenGl_ArbIns * | arbIns |
GL_ARB_draw_instanced. | |
OpenGl_ExtFBO * | extFBO |
GL_EXT_framebuffer_object. | |
OpenGl_ExtGS * | extGS |
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. |
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.
OpenGl_Context::OpenGl_Context | ( | ) |
virtual OpenGl_Context::~OpenGl_Context | ( | ) | [virtual] |
Standard_Size OpenGl_Context::AvailableMemory | ( | ) | const |
Standard_Boolean OpenGl_Context::CheckExtension | ( | const char * | theExtName | ) | const |
OpenGl_Context::DEFINE_STANDARD_RTTI | ( | OpenGl_Context | ) |
void OpenGl_Context::DelayedRelease | ( | Handle< OpenGl_Resource > & | theResource | ) |
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] |
theNumber | number to 'power of two' |
theThreshold | upper threshold |
const Handle< OpenGl_Resource >& OpenGl_Context::GetResource | ( | const TCollection_AsciiString & | theKey | ) | const |
theKey | - unique identifier; |
Standard_Boolean OpenGl_Context::GetResource | ( | const TCollection_AsciiString & | theKey, |
TheHandleType & | theValue | ||
) | const [inline] |
theKey | - unique identifier; |
theValue | - handle to fill; |
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 |
Standard_Boolean OpenGl_Context::IsFeedback | ( | ) | const |
Standard_Boolean OpenGl_Context::IsGlGreaterEqual | ( | const Standard_Integer | theVerMajor, |
const Standard_Integer | theVerMinor | ||
) | [inline] |
Standard_Boolean OpenGl_Context::MakeCurrent | ( | ) |
Standard_Integer OpenGl_Context::MaxDegreeOfAnisotropy | ( | ) | const |
Standard_Integer OpenGl_Context::MaxTextureSize | ( | ) | const |
TCollection_AsciiString OpenGl_Context::MemoryInfo | ( | ) | const |
void OpenGl_Context::ReleaseDelayed | ( | ) |
void OpenGl_Context::ReleaseResource | ( | const TCollection_AsciiString & | theKey, |
const Standard_Boolean | theToDelay = Standard_False |
||
) |
theKey | unique identifier |
theToDelay | postpone 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 | ||
) |
theKey | - unique identifier, shouldn't be empty; |
theResource | - new resource to register, shouldn't be NULL. |
void OpenGl_Context::SwapBuffers | ( | ) |