diff options
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 42 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_window.h | 1 |
5 files changed, 56 insertions, 0 deletions
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 0da45202730..234491a2186 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -35,6 +35,7 @@ set(INC ../compositor ../depsgraph ../editors/include + ../draw ../gpu ../imbuf ../makesdna diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 4449736d2a5..bf894b2ad03 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -119,6 +119,11 @@ struct bScreen *WM_window_get_active_screen(const struct wmWindow *win) ATTR_NON void WM_window_set_active_screen(struct wmWindow *win, struct WorkSpace *workspace, struct bScreen *screen) ATTR_NONNULL(1); bool WM_window_is_temp_screen(const struct wmWindow *win) ATTR_WARN_UNUSED_RESULT; +void *WM_opengl_context_create(void); +void WM_opengl_context_dispose(void *context); +void WM_opengl_context_activate(void *context); +void WM_opengl_context_release(void *context); + /* defines for 'type' WM_window_open_temp */ enum { WM_WINDOW_RENDER = 1, diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 43e4f7757f5..a2f5f1b1e10 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -125,6 +125,8 @@ #include "DEG_depsgraph.h" +#include "DRW_engine.h" + #ifdef WITH_OPENSUBDIV # include "BKE_subsurf.h" #endif @@ -207,6 +209,7 @@ void WM_init(bContext *C, int argc, const char **argv) /* sets 3D mouse deadzone */ WM_ndof_deadzone_set(U.ndof_deadzone); #endif + DRW_opengl_context_create(); GPU_init(); @@ -549,6 +552,10 @@ void WM_exit_ext(bContext *C, const bool do_python) BLF_exit(); + if (!G.background) { + DRW_opengl_context_destroy(); + } + #ifdef WITH_INTERNATIONAL BLF_free_unifont(); BLF_free_unifont_mono(); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 103f8d580c1..278a70b9c9d 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1038,6 +1038,26 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) } } +/* Reset active the current window opengl drawing context. */ +void wm_window_reset_drawable(void) +{ + BLI_assert(BLI_thread_is_main()); + wmWindowManager *wm = G.main->wm.first; + + if (wm == NULL) + return; + + wmWindow *win = wm->windrawable; + + if (win && win->ghostwin) { + gpu_batch_presets_reset(); + immDeactivate(); + GHOST_ActivateWindowDrawingContext(win->ghostwin); + GWN_context_active_set(win->gwnctx); + immActivate(); + } +} + /* called by ghost, here we handle events for windows themselves or send to event system */ /* mouse coordinate converversion happens here */ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr) @@ -2044,3 +2064,25 @@ void wm_window_IME_end(wmWindow *win) win->ime_data = NULL; } #endif /* WITH_INPUT_IME */ + +/* ****** direct opengl context management ****** */ + +void *WM_opengl_context_create(void) +{ + return GHOST_CreateOpenGLContext(g_system); +} + +void WM_opengl_context_dispose(void *context) +{ + GHOST_DisposeOpenGLContext(g_system, (GHOST_ContextHandle)context); +} + +void WM_opengl_context_activate(void *context) +{ + GHOST_ActivateOpenGLContext((GHOST_ContextHandle)context); +} + +void WM_opengl_context_release(void *context) +{ + GHOST_ReleaseOpenGLContext((GHOST_ContextHandle)context); +} diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index 0264955a4c5..652cefb1a54 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -58,6 +58,7 @@ void wm_window_process_events (const bContext *C); void wm_window_process_events_nosleep(void); void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win); +void wm_window_reset_drawable(void); void wm_window_raise (wmWindow *win); void wm_window_lower (wmWindow *win); |