#ifndef __GUIOPENGLPROVIDER_H_INCL__ #define __GUIOPENGLPROVIDER_H_INCL__ #include #include "windows.h" #include #include #pragma comment(lib, "opengl32.lib") #pragma comment(lib, "glu32.lib") #include "../components/base/basicMutex.h" #include "gui.h" #include /** * guiOpenGLProvider singletone class to provide OpenGL context globally * * @author gagua */ class guiOpenGLProvider { public: // Method to fetch singleton instance. static guiOpenGLProvider* getInstance(); // Destructor virtual ~guiOpenGLProvider(); QOpenGLContext *grabContext( void ); QOpenGLContext *tryGrabContext( void ); void releaseContext( void ); protected: // Constructor - protected so users cannot call it. guiOpenGLProvider(); private: // private static member referencing the single instance of the object // TODO: Replace guiOpenGLProvider with the type of object you want to // return the single instance of static guiOpenGLProvider *_instance; basicMutex *m_pContextProtectorMutex; // Copy constructor // Declared but not defined to prevent auto-generated // copy constructor. Refer to "Effective C++" by Meyers guiOpenGLProvider(const guiOpenGLProvider& src); // Assignment operator // Declared but not defined to prevent auto-generated // assignment operator. Refer to "Effective C++" by Meyers guiOpenGLProvider& operator=(const guiOpenGLProvider& src); QOpenGLContext *m_pContext; }; // Constructor implementation inline guiOpenGLProvider::guiOpenGLProvider(){ m_pContextProtectorMutex = new basicMutex(); m_pContext = new QOpenGLContext(); //initializeOpenGLFunctions(); } // Destructor implementation inline guiOpenGLProvider::~guiOpenGLProvider(){ emit m_pContext->aboutToBeDestroyed(); delete(m_pContextProtectorMutex); delete(m_pContext); } // TODO: Uncomment the copy constructor when you need it. //inline guiOpenGLProvider::guiOpenGLProvider(const guiOpenGLProvider& src) //{ // // TODO: copy //} // TODO: Uncomment the assignment operator when you need it. //inline guiOpenGLProvider& guiOpenGLProvider::operator=(const guiOpenGLProvider& rhs) //{ // if (this == &rhs) { // return *this; // } // // // TODO: assignment // // return *this; //} #endif // __GUIOPENGLPROVIDER_H_INCL__