From eda234f5e156d376541044b351fd2e1e766700a3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 2 Jul 2014 19:33:01 +0300 Subject: Fix resize in modernopengl with own context in SDL1.2 build. --- src/utils/glxhelper.cpp | 9 ++++++++- src/utils/glxhelper.h | 6 +++++- src/utils/sdl2helper.cpp | 4 ++++ src/utils/sdl2helper.h | 2 ++ src/utils/sdlhelper.cpp | 14 ++++++++++++++ src/utils/sdlhelper.h | 2 ++ 6 files changed, 35 insertions(+), 2 deletions(-) (limited to 'src/utils') diff --git a/src/utils/glxhelper.cpp b/src/utils/glxhelper.cpp index 1fedeb9c6..1624b6309 100644 --- a/src/utils/glxhelper.cpp +++ b/src/utils/glxhelper.cpp @@ -36,7 +36,7 @@ static int ErrorHandler(Display *d A_UNUSED, XErrorEvent *e A_UNUSED) return 0; } -void *GlxHelper::createContext(unsigned int window, +void *GlxHelper::createContext(const unsigned int window, void *const display0, const int major, const int minor) @@ -117,4 +117,11 @@ void *GlxHelper::createContext(unsigned int window, return context2; } +bool GlxHelper::makeCurrent(const unsigned int window, + void *const display, + void *const context) +{ + return mglXMakeCurrent(static_cast(display), window, context); +} + #endif // defined(USE_OPENGL) && defined(USE_X11) diff --git a/src/utils/glxhelper.h b/src/utils/glxhelper.h index 0378256d0..ce3a5568d 100644 --- a/src/utils/glxhelper.h +++ b/src/utils/glxhelper.h @@ -31,10 +31,14 @@ namespace GlxHelper { - void *createContext(unsigned int window, + void *createContext(const unsigned int window, void *const display, const int major, const int minor); + + bool makeCurrent(const unsigned int window, + void *const display, + void *const context); } // namespace Glx #endif // defined(USE_OPENGL) && defined(USE_X11) diff --git a/src/utils/sdl2helper.cpp b/src/utils/sdl2helper.cpp index 3b2b988a0..07f8d965c 100644 --- a/src/utils/sdl2helper.cpp +++ b/src/utils/sdl2helper.cpp @@ -126,4 +126,8 @@ void *SDL::createGLContext(SDL_Window *const window, return context; } +void SDL::makeCurrentContext(void *const context A_UNUSED) +{ +} + #endif // USE_SDL2 diff --git a/src/utils/sdl2helper.h b/src/utils/sdl2helper.h index 6f59b27a6..b7ab35d84 100644 --- a/src/utils/sdl2helper.h +++ b/src/utils/sdl2helper.h @@ -55,6 +55,8 @@ namespace SDL void *createGLContext(SDL_Window *const window, const int major, const int minor); + + void makeCurrentContext(void *const context); } // namespace SDL #endif // USE_SDL2 diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp index 19cffa0a6..b809fd76b 100644 --- a/src/utils/sdlhelper.cpp +++ b/src/utils/sdlhelper.cpp @@ -140,6 +140,16 @@ void *SDL::createGLContext(SDL_Surface *const window A_UNUSED, } return context; } + +void SDL::makeCurrentContext(void *const context) +{ + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + SDL_GetWMInfo(&info); + GlxHelper::makeCurrent(info.info.x11.window, + info.info.x11.display, + context); +} #else void *SDL::createGLContext(SDL_Surface *const window A_UNUSED, const int major A_UNUSED, @@ -147,6 +157,10 @@ void *SDL::createGLContext(SDL_Surface *const window A_UNUSED, { return nullptr; } + +void SDL::makeCurrentContext(void *const context A_UNUSED) +{ +} #endif #endif // USE_SDL2 diff --git a/src/utils/sdlhelper.h b/src/utils/sdlhelper.h index 328c093cd..92fcaba65 100644 --- a/src/utils/sdlhelper.h +++ b/src/utils/sdlhelper.h @@ -60,6 +60,8 @@ namespace SDL void *createGLContext(SDL_Surface *const window A_UNUSED, const int major, const int minor); + + void makeCurrentContext(void *const context); } // namespace SDL #endif // USE_SDL2 -- cgit v1.2.3-60-g2f50