mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-24 10:01:06 +00:00
Fixed KMSDRM window creation failing if OpenGL libraries are not available, but GLES 2.0 libraries are
This commit is contained in:
parent
da9ba3a2a1
commit
ff99e56d3a
|
@ -292,8 +292,8 @@ SDL_EGL_UnloadLibrary(_THIS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path)
|
||||||
{
|
{
|
||||||
void *egl_dll_handle = NULL, *opengl_dll_handle = NULL;
|
void *egl_dll_handle = NULL, *opengl_dll_handle = NULL;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
|
@ -304,15 +304,6 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
||||||
SDL_bool vc4 = (0 == access("/sys/module/vc4/", F_OK));
|
SDL_bool vc4 = (0 == access("/sys/module/vc4/", F_OK));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_this->egl_data) {
|
|
||||||
return SDL_SetError("EGL context already created");
|
|
||||||
}
|
|
||||||
|
|
||||||
_this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData));
|
|
||||||
if (!_this->egl_data) {
|
|
||||||
return SDL_OutOfMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
|
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
|
||||||
d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER);
|
d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER);
|
||||||
if (d3dcompiler) {
|
if (d3dcompiler) {
|
||||||
|
@ -473,6 +464,26 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
||||||
|
{
|
||||||
|
if (_this->egl_data) {
|
||||||
|
return SDL_SetError("EGL context already created");
|
||||||
|
}
|
||||||
|
|
||||||
|
_this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData));
|
||||||
|
if (!_this->egl_data) {
|
||||||
|
return SDL_OutOfMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SDL_EGL_LoadLibraryInternal(_this, egl_path) < 0) {
|
||||||
|
SDL_free(_this->egl_data);
|
||||||
|
_this->egl_data = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SDL_EGL_GetVersion(_THIS) {
|
SDL_EGL_GetVersion(_THIS) {
|
||||||
if (_this->egl_data->eglQueryString) {
|
if (_this->egl_data->eglQueryString) {
|
||||||
|
|
|
@ -1456,28 +1456,34 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already
|
/* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already
|
||||||
been called by SDL_CreateWindow() but we don't do anything there,
|
been called by SDL_CreateWindow() but we don't do anything there,
|
||||||
out KMSDRM_EGL_LoadLibrary() is a dummy precisely to be able to load it here.
|
our KMSDRM_EGL_LoadLibrary() is a dummy precisely to be able to load it here.
|
||||||
If we let SDL_CreateWindow() load the lib, it would be loaded
|
If we let SDL_CreateWindow() load the lib, it would be loaded
|
||||||
before we call KMSDRM_GBMInit(), causing all GLES programs to fail. */
|
before we call KMSDRM_GBMInit(), causing all GLES programs to fail. */
|
||||||
if (!_this->egl_data) {
|
if (!_this->egl_data) {
|
||||||
egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
|
egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
|
||||||
if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) {
|
if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA) < 0) {
|
||||||
return (SDL_SetError("Can't load EGL/GL library on window creation."));
|
/* Try again with OpenGL ES 2.0 */
|
||||||
}
|
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||||
|
_this->gl_config.major_version = 2;
|
||||||
|
_this->gl_config.minor_version = 0;
|
||||||
|
if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA) < 0) {
|
||||||
|
return (SDL_SetError("Can't load EGL/GL library on window creation."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_this->gl_config.driver_loaded = 1;
|
_this->gl_config.driver_loaded = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the cursor BO for the display of this window,
|
/* Create the cursor BO for the display of this window,
|
||||||
now that we know this is not a VK window. */
|
now that we know this is not a VK window. */
|
||||||
KMSDRM_CreateCursorBO(display);
|
KMSDRM_CreateCursorBO(display);
|
||||||
|
|
||||||
/* Create and set the default cursor for the display
|
/* Create and set the default cursor for the display
|
||||||
of this window, now that we know this is not a VK window. */
|
of this window, now that we know this is not a VK window. */
|
||||||
KMSDRM_InitMouse(_this, display);
|
KMSDRM_InitMouse(_this, display);
|
||||||
|
|
||||||
/* The FULLSCREEN flags are cut out from window->flags at this point,
|
/* The FULLSCREEN flags are cut out from window->flags at this point,
|
||||||
so we can't know if a window is fullscreen or not, hence all windows
|
so we can't know if a window is fullscreen or not, hence all windows
|
||||||
|
|
Loading…
Reference in a new issue