MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00004 00009 //---------------------------------------------------------------------------------- 00010 00011 #ifndef __mlGLContext_H 00012 #define __mlGLContext_H 00013 00014 #include "mlOpenGLSystem.h" 00015 #include "mlOpenGL.h" 00016 00017 ML_OPENGL_START_NAMESPACE 00018 00019 class GLContextStackPrivate; 00020 00023 class MLOPENGL_EXPORT GLContextStack 00024 { 00025 public: 00030 class TemporaryGLContextScope { 00031 public: 00032 TemporaryGLContextScope() { 00033 GLContextStack::createTemporaryContextAndActivate(); 00034 } 00035 ~TemporaryGLContextScope() { 00036 GLContextStack::destroyTemporaryContextAndActivatePreviousContext(); 00037 } 00038 }; 00039 00042 class StoreCurrentGLContextScope { 00043 public: 00044 StoreCurrentGLContextScope() { 00045 GLContextStack::pushCurrentContext(); 00046 } 00047 ~StoreCurrentGLContextScope() { 00048 GLContextStack::popCurrentContext(); 00049 } 00050 }; 00051 00053 static void pushCurrentContext(); 00054 00056 static void popCurrentContext(); 00057 00063 static void createTemporaryContextAndActivate(); 00064 00067 static void destroyTemporaryContextAndActivatePreviousContext(); 00068 00069 private: 00070 static void init(); 00071 00072 static GLContextStackPrivate* _private; 00073 }; 00074 00075 ML_OPENGL_END_NAMESPACE 00076 00078 #define CREATE_AND_ACTIVATE_GLCONTEXT \ 00079 ML_OPENGL_NAMESPACE::GLContextStack::createTemporaryContextAndActivate(); 00080 00082 #define DESTROY_GLCONTEXT_AND_ACTIVATE_PREVIOUS \ 00083 ML_OPENGL_NAMESPACE::GLContextStack::destroyTemporaryContextAndActivatePreviousContext(); 00084 00085 #endif // __mlGLContext_H