You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
759 B

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "guiOpenGLProvider.h"
  2. guiOpenGLProvider* guiOpenGLProvider::_instance = 0;
  3. /**
  4. * Returns the single instance of the object.
  5. */
  6. guiOpenGLProvider* guiOpenGLProvider::getInstance() {
  7. // check if the instance has been created yet
  8. if (0 == _instance) {
  9. // if not, then create it
  10. _instance = new guiOpenGLProvider;
  11. }
  12. // return the single instance
  13. return _instance;
  14. };
  15. QOpenGLContext *guiOpenGLProvider::grabContext( void ){
  16. m_pContextProtectorMutex->lock();
  17. return m_pContext;
  18. };
  19. QOpenGLContext *guiOpenGLProvider::tryGrabContext( void ){
  20. if( m_pContextProtectorMutex->try_lock() ) return m_pContext;
  21. return NULL;
  22. };
  23. void guiOpenGLProvider::releaseContext( void ){
  24. m_pContextProtectorMutex->unlock();
  25. };