Create egl_init_context

This commit is contained in:
twinaphex 2015-11-19 17:52:13 +01:00
parent 7cee03af72
commit ad260fcb7b
3 changed files with 30 additions and 14 deletions

View File

@ -173,11 +173,32 @@ static void egl_sighandler(int sig)
void egl_install_sighandlers(void) void egl_install_sighandlers(void)
{ {
struct sigaction sa = {{0}}; struct sigaction sa;
sa.sa_sigaction = NULL;
sa.sa_handler = egl_sighandler; sa.sa_handler = egl_sighandler;
sa.sa_flags = SA_RESTART; sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, NULL); sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL); sigaction(SIGTERM, &sa, NULL);
} }
bool egl_init_context(NativeDisplayType display,
EGLint *major, EGLint *minor,
EGLint *n, const EGLint *attrib_ptr)
{
g_egl_dpy = eglGetDisplay(display);
if (!g_egl_dpy)
{
RARCH_ERR("[KMS/EGL]: Couldn't get EGL display.\n");
return false;
}
if (!eglInitialize(g_egl_dpy, major, minor))
return false;
if (!eglChooseConfig(g_egl_dpy, attrib_ptr, &g_egl_config, 1, n) || *n != 1)
return false;
return true;
}

View File

@ -51,4 +51,8 @@ void egl_get_video_size(void *data, unsigned *width, unsigned *height);
void egl_install_sighandlers(void); void egl_install_sighandlers(void);
bool egl_init_context(NativeDisplayType display,
EGLint *major, EGLint *minor,
EGLint *n, const EGLint *attrib_ptr);
#endif #endif

View File

@ -722,17 +722,8 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data,
goto error; goto error;
} }
g_egl_dpy = eglGetDisplay((EGLNativeDisplayType)drm->g_gbm_dev); if (!egl_init_context((EGLNativeDisplayType)drm->g_gbm_dev, &major,
if (!g_egl_dpy) &minor, &n, attrib_ptr))
{
RARCH_ERR("[KMS/EGL]: Couldn't get EGL display.\n");
goto error;
}
if (!eglInitialize(g_egl_dpy, &major, &minor))
goto error;
if (!eglChooseConfig(g_egl_dpy, attrib_ptr, &g_egl_config, 1, &n) || n != 1)
goto error; goto error;
attr = egl_fill_attribs(egl_attribs); attr = egl_fill_attribs(egl_attribs);