diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-07-27 17:28:44 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-07-27 17:28:44 +0300 |
commit | 60499ff25da4be074324694589bb014b1c9466d7 (patch) | |
tree | bf5348de78328a4f1146f09de48240312360e662 /intern | |
parent | 70966af5134b0cf53273e3c6da19ad7d5857b0f2 (diff) |
GHOST: Fix SDL backend.
We use a hidden window for each offscreen context we need.
On X11 (linux) it does not show any other windows in the OS task bar
but it might be the case on other operating systems (untested).
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_ContextSDL.cpp | 20 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ContextSDL.h | 1 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.cpp | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemSDL.cpp | 29 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemSDL.h | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowSDL.cpp | 2 |
6 files changed, 58 insertions, 4 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; diff --git a/intern/ghost/intern/GHOST_ContextSDL.h b/intern/ghost/intern/GHOST_ContextSDL.h index 681d24bb7c6..1829819300c 100644 --- a/intern/ghost/intern/GHOST_ContextSDL.h +++ b/intern/ghost/intern/GHOST_ContextSDL.h @@ -120,6 +120,7 @@ public: private: SDL_Window *m_window; + SDL_Window *m_hidden_window; const int m_contextProfileMask; const int m_contextMajorVersion; diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 0629eacc3ff..c3fd87c65af 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -297,7 +297,9 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown #ifdef WITH_INPUT_NDOF void GHOST_System::setNDOFDeadZone(float deadzone) { - this->m_ndofManager->setDeadZone(deadzone); + if (this->m_ndofManager) { + this->m_ndofManager->setDeadZone(deadzone); + } } #endif diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp index d7860577338..094cbe76cb2 100644 --- a/intern/ghost/intern/GHOST_SystemSDL.cpp +++ b/intern/ghost/intern/GHOST_SystemSDL.cpp @@ -26,6 +26,7 @@ #include <assert.h> +#include "GHOST_ContextSDL.h" #include "GHOST_SystemSDL.h" #include "GHOST_WindowSDL.h" @@ -149,6 +150,34 @@ GHOST_SystemSDL::getNumDisplays() const return SDL_GetNumVideoDisplays(); } +GHOST_IContext * +GHOST_SystemSDL::createOffscreenContext() +{ + GHOST_Context *context = new GHOST_ContextSDL( + 0, + 0, + NULL, + 0, // profile bit + 3, 3, + GHOST_OPENGL_SDL_CONTEXT_FLAGS, + GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY); + + if (context->initializeDrawingContext()) + return context; + else + delete context; + + return NULL; +} + +GHOST_TSuccess +GHOST_SystemSDL::disposeContext(GHOST_IContext *context) +{ + delete context; + + return GHOST_kSuccess; +} + GHOST_TSuccess GHOST_SystemSDL::getModifierKeys(GHOST_ModifierKeys& keys) const { diff --git a/intern/ghost/intern/GHOST_SystemSDL.h b/intern/ghost/intern/GHOST_SystemSDL.h index 41f110ed15d..0610a80ea5f 100644 --- a/intern/ghost/intern/GHOST_SystemSDL.h +++ b/intern/ghost/intern/GHOST_SystemSDL.h @@ -95,6 +95,12 @@ public: getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const; + GHOST_IContext * + createOffscreenContext(); + + GHOST_TSuccess + disposeContext(GHOST_IContext *context); + /** * Informs if the system provides native dialogs (eg. confirm quit) */ diff --git a/intern/ghost/intern/GHOST_WindowSDL.cpp b/intern/ghost/intern/GHOST_WindowSDL.cpp index aeb6188daef..9c41087bd59 100644 --- a/intern/ghost/intern/GHOST_WindowSDL.cpp +++ b/intern/ghost/intern/GHOST_WindowSDL.cpp @@ -93,7 +93,7 @@ GHOST_WindowSDL::newDrawingContext(GHOST_TDrawingContextType type) m_wantNumOfAASamples, m_sdl_win, 0, // profile bit - 0, 0, + 3, 3, GHOST_OPENGL_SDL_CONTEXT_FLAGS, GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY); |