diff options
Diffstat (limited to 'intern/ghost/intern/GHOST_ContextSDL.cpp')
-rw-r--r-- | intern/ghost/intern/GHOST_ContextSDL.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/intern/ghost/intern/GHOST_ContextSDL.cpp b/intern/ghost/intern/GHOST_ContextSDL.cpp index 1ba591bd0b2..3b3cf7a2962 100644 --- a/intern/ghost/intern/GHOST_ContextSDL.cpp +++ b/intern/ghost/intern/GHOST_ContextSDL.cpp @@ -55,6 +55,7 @@ GHOST_ContextSDL::GHOST_ContextSDL( int contextResetNotificationStrategy) : GHOST_Context(stereoVisual, numOfAASamples), m_window(window), + m_hidden_window(NULL), m_contextProfileMask(contextProfileMask), m_contextMajorVersion(contextMajorVersion), m_contextMinorVersion(contextMinorVersion), @@ -62,7 +63,7 @@ GHOST_ContextSDL::GHOST_ContextSDL( m_contextResetNotificationStrategy(contextResetNotificationStrategy), m_context(NULL) { - assert(m_window != NULL); + // assert(m_window != NULL); } @@ -70,7 +71,7 @@ GHOST_ContextSDL::~GHOST_ContextSDL() { if (m_context != NULL) { if (m_window != NULL && m_context == SDL_GL_GetCurrentContext()) - SDL_GL_MakeCurrent(m_window, m_context); + SDL_GL_MakeCurrent(m_window, NULL); if (m_context != s_sharedContext || s_sharedCount == 1) { assert(s_sharedCount > 0); @@ -82,6 +83,9 @@ GHOST_ContextSDL::~GHOST_ContextSDL() SDL_GL_DeleteContext(m_context); } + + if (m_hidden_window != NULL) + SDL_DestroyWindow(m_hidden_window); } } @@ -160,6 +164,18 @@ GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext() SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, m_numOfAASamples); } + if (m_window == NULL) { + m_hidden_window = SDL_CreateWindow( + "Offscreen Context Windows", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 1, 1, + SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN + ); + + m_window = m_hidden_window; + } + m_context = SDL_GL_CreateContext(m_window); GHOST_TSuccess success; |