diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_init_exit.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 8d6741dcfb6..7f5ec77e16d 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -59,6 +59,7 @@ #include "BKE_mask.h" /* free mask clipboard */ #include "BKE_material.h" /* BKE_material_copybuf_clear */ #include "BKE_studiolight.h" +#include "BKE_subdiv.h" #include "BKE_tracking.h" /* free tracking clipboard */ #include "RE_engine.h" @@ -114,9 +115,6 @@ #include "GPU_init_exit.h" #include "GPU_material.h" -#include "BKE_sound.h" -#include "BKE_subdiv.h" - #include "COM_compositor.h" #include "DEG_depsgraph.h" @@ -171,6 +169,10 @@ void WM_init_opengl(void) wm_ghost_init(NULL); } + if (!GPU_backend_supported()) { + return; + } + /* Needs to be first to have an OpenGL context bound. */ DRW_opengl_context_create(); @@ -312,6 +314,7 @@ void WM_init(bContext *C, int argc, const char **argv) IMB_thumb_clear_translations(); if (!G.background) { + GPU_render_begin(); #ifdef WITH_INPUT_NDOF /* Sets 3D mouse dead-zone. */ @@ -324,7 +327,10 @@ void WM_init(bContext *C, int argc, const char **argv) exit(-1); } + GPU_context_begin_frame(GPU_context_active_get()); UI_init(); + GPU_context_end_frame(GPU_context_active_get()); + GPU_render_end(); } BKE_subdiv_init(); @@ -340,10 +346,10 @@ void WM_init(bContext *C, int argc, const char **argv) if (!G.background) { if (wm_start_with_console) { - setConsoleWindowState(GHOST_kConsoleWindowStateShow); + GHOST_setConsoleWindowState(GHOST_kConsoleWindowStateShow); } else { - setConsoleWindowState(GHOST_kConsoleWindowStateHideForNonConsoleLaunch); + GHOST_setConsoleWindowState(GHOST_kConsoleWindowStateHideForNonConsoleLaunch); } } @@ -382,7 +388,7 @@ static void free_openrecent(void) } #ifdef WIN32 -/* Read console events until there is a key event. Also returns on any error. */ +/* Read console events until there is a key event. Also returns on any error. */ static void wait_for_console_key(void) { HANDLE hConsoleInput = GetStdHandle(STD_INPUT_HANDLE); @@ -570,14 +576,6 @@ void WM_exit_ex(bContext *C, const bool do_python) BLF_exit(); - if (opengl_is_init) { - DRW_opengl_context_enable_ex(false); - GPU_pass_cache_free(); - GPU_exit(); - DRW_opengl_context_disable_ex(false); - DRW_opengl_context_destroy(); - } - BLT_lang_free(); ANIM_keyingset_infos_exit(); @@ -602,13 +600,24 @@ void WM_exit_ex(bContext *C, const bool do_python) ED_file_exit(); /* for fsmenu */ - UI_exit(); + /* Delete GPU resources and context. The UI also uses GPU resources and so + * is also deleted with the context active. */ + if (opengl_is_init) { + DRW_opengl_context_enable_ex(false); + UI_exit(); + GPU_pass_cache_free(); + GPU_exit(); + DRW_opengl_context_disable_ex(false); + DRW_opengl_context_destroy(); + } + else { + UI_exit(); + } + BKE_blender_userdef_data_free(&U, false); RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */ - GPU_backend_exit(); - wm_ghost_exit(); CTX_free(C); |