diff --git a/src/module/module_sdl2.c b/src/module/module_sdl2.c index bb8395a862f73b01d7c069d71e30cf7b81219ef8..7638524c9b206219f1e794a1a80e19d13def8fce 100644 --- a/src/module/module_sdl2.c +++ b/src/module/module_sdl2.c @@ -129,22 +129,6 @@ module_sdl2_new(struct lkt_win *const win) return false; struct module_sdl2_window *sdl2 = win->window; - mpv_render_param params[] = { - { MPV_RENDER_PARAM_API_TYPE, MPV_RENDER_API_TYPE_OPENGL }, - { - MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &(mpv_opengl_init_params) - { - .get_proc_address = get_proc_address_mpv, - } - }, - { - MPV_RENDER_PARAM_ADVANCED_CONTROL, &(int) - { - 1 - } - }, - {0} - }; if (sdl2 == NULL) { sdl2 = calloc(1, sizeof(struct module_sdl2_window)); @@ -168,35 +152,55 @@ module_sdl2_new(struct lkt_win *const win) sdl2->glcontext = SDL_GL_CreateContext(sdl2->window); if (!sdl2->glcontext) goto error; + } - /* Init mpv here */ - if (init_mpv__(&sdl2->mpv)) - goto error; + /* Init mpv here */ + if (init_mpv__(&sdl2->mpv)) + goto error; - /* Init opengl with mpv and sdl2 */ - if (mpv_render_context_create(&sdl2->mpv_gl, sdl2->mpv, params) < 0) - goto error; + mpv_render_param params[] = { + { MPV_RENDER_PARAM_API_TYPE, MPV_RENDER_API_TYPE_OPENGL }, + { + MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &(mpv_opengl_init_params) + { + .get_proc_address = get_proc_address_mpv, + } + }, + { + MPV_RENDER_PARAM_ADVANCED_CONTROL, &(int) + { + 1 + } + }, + {0} + }; - fprintf(stderr, " * Successfully created the SDL2 window\n"); - wakeup_on_mpv_render_update = SDL_RegisterEvents(1); - wakeup_on_mpv_events = SDL_RegisterEvents(1); - if (wakeup_on_mpv_render_update == (Uint32) - 1 || wakeup_on_mpv_events == (Uint32) - 1) - goto error; + /* Init mpv_gl here */ + if (init_mpv_gl__(sdl2->mpv, &sdl2->mpv_gl, params)) + goto error; - mpv_set_wakeup_callback(sdl2->mpv, on_mpv_events, NULL); - mpv_render_context_set_update_callback(sdl2->mpv_gl, on_mpv_render_update, NULL); + if (sdl2->mpv == NULL && init_mpv__(&sdl2->mpv)) + goto error; - /* Init mpv_gl here */ + if (sdl2->mpv_gl == NULL) { + mpv_render_param params[] = { { MPV_RENDER_PARAM_API_TYPE, MPV_RENDER_API_TYPE_OPENGL }, { + MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &(mpv_opengl_init_params) + { + .get_proc_address = get_proc_address_mpv, + } + }, + { + MPV_RENDER_PARAM_ADVANCED_CONTROL, &(int) + { + 1 + } + }, + {0} + }; if (init_mpv_gl__(sdl2->mpv, &sdl2->mpv_gl, params)) goto error; } - if (sdl2->mpv == NULL && init_mpv__(&sdl2->mpv)) - goto error; - - if (sdl2->mpv_gl == NULL && init_mpv_gl__(sdl2->mpv, &sdl2->mpv_gl, params)) - goto error; - SDL_SetWindowTitle(sdl2->window, "Lektord"); SDL_DisableScreenSaver(); win->window = sdl2;