mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
Set EGL surface for foreign X11 windows
Also slightly changes up the cleanup code for SetupWindowData, to avoid copy pasting. See #10611
This commit is contained in:

committed by
Ryan C. Gordon

parent
220a23dad2
commit
780ec8fac0
@@ -285,8 +285,8 @@ static int SetupWindowData(_THIS, SDL_Window *window, Window w, BOOL created)
|
|||||||
1) *
|
1) *
|
||||||
sizeof(*windowlist));
|
sizeof(*windowlist));
|
||||||
if (!windowlist) {
|
if (!windowlist) {
|
||||||
SDL_free(data);
|
SDL_OutOfMemory();
|
||||||
return SDL_OutOfMemory();
|
goto error_cleanup;
|
||||||
}
|
}
|
||||||
windowlist[numwindows] = data;
|
windowlist[numwindows] = data;
|
||||||
videodata->numwindows++;
|
videodata->numwindows++;
|
||||||
@@ -331,9 +331,45 @@ static int SetupWindowData(_THIS, SDL_Window *window, Window w, BOOL created)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) || defined(SDL_VIDEO_OPENGL_EGL)
|
||||||
|
if ((window->flags & SDL_WINDOW_OPENGL) &&
|
||||||
|
((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) ||
|
||||||
|
SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE))
|
||||||
|
#ifdef SDL_VIDEO_OPENGL_GLX
|
||||||
|
&& (!_this->gl_data || X11_GL_UseEGL(_this) )
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||||
|
if (!_this->egl_data) {
|
||||||
|
goto error_cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the GLES window surface */
|
||||||
|
data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)w);
|
||||||
|
|
||||||
|
if (data->egl_surface == EGL_NO_SURFACE) {
|
||||||
|
SDL_SetError("Could not create GLES window surface");
|
||||||
|
goto error_cleanup;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SDL_SetError("Could not create GLES window surface (EGL support not configured)");
|
||||||
|
goto error_cleanup;
|
||||||
|
#endif /* SDL_VIDEO_OPENGL_EGL */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* All done! */
|
/* All done! */
|
||||||
window->driverdata = data;
|
window->driverdata = data;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error_cleanup:
|
||||||
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
|
if (data->ic) {
|
||||||
|
X11_XDestroyIC(data->ic);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
SDL_free(data);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetWindowBordered(Display *display, int screen, Window window, SDL_bool border)
|
static void SetWindowBordered(Display *display, int screen, Window window, SDL_bool border)
|
||||||
@@ -634,31 +670,6 @@ int X11_CreateWindow(_THIS, SDL_Window *window)
|
|||||||
}
|
}
|
||||||
windowdata = (SDL_WindowData *)window->driverdata;
|
windowdata = (SDL_WindowData *)window->driverdata;
|
||||||
|
|
||||||
#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) || defined(SDL_VIDEO_OPENGL_EGL)
|
|
||||||
if ((window->flags & SDL_WINDOW_OPENGL) &&
|
|
||||||
((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) ||
|
|
||||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE))
|
|
||||||
#ifdef SDL_VIDEO_OPENGL_GLX
|
|
||||||
&& (!_this->gl_data || X11_GL_UseEGL(_this) )
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
|
||||||
if (!_this->egl_data) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create the GLES window surface */
|
|
||||||
windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)w);
|
|
||||||
|
|
||||||
if (windowdata->egl_surface == EGL_NO_SURFACE) {
|
|
||||||
return SDL_SetError("Could not create GLES window surface");
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return SDL_SetError("Could not create GLES window surface (EGL support not configured)");
|
|
||||||
#endif /* SDL_VIDEO_OPENGL_EGL */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
if (SDL_X11_HAVE_UTF8 && windowdata->ic) {
|
if (SDL_X11_HAVE_UTF8 && windowdata->ic) {
|
||||||
X11_XGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL);
|
X11_XGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL);
|
||||||
|
Reference in New Issue
Block a user