diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 06341c49bf..1d93d9d45d 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -549,7 +549,7 @@ static void SDL_EGL_GetVersion(SDL_VideoDevice *_this) } } -bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisplayType native_display, EGLenum platform) +bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisplayType native_display) { if (!SDL_EGL_LoadLibraryOnly(_this, egl_path)) { return false; @@ -558,6 +558,7 @@ bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDis _this->egl_data->egl_display = EGL_NO_DISPLAY; #ifndef SDL_VIDEO_DRIVER_VITA + EGLenum platform = _this->gl_config.egl_platform; if (platform) { /* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY * -- diff --git a/src/video/SDL_egl_c.h b/src/video/SDL_egl_c.h index c56d5cbc46..fdb3f721b7 100644 --- a/src/video/SDL_egl_c.h +++ b/src/video/SDL_egl_c.h @@ -118,11 +118,8 @@ typedef enum SDL_EGL_ExtensionType extern bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type, const char *ext); extern bool SDL_EGL_GetAttribute(SDL_VideoDevice *_this, SDL_GLAttr attrib, int *value); -/* SDL_EGL_LoadLibrary can get a display for a specific platform (EGL_PLATFORM_*) - * or, if 0 is passed, let the implementation decide. - */ extern bool SDL_EGL_LoadLibraryOnly(SDL_VideoDevice *_this, const char *path); -extern bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *path, NativeDisplayType native_display, EGLenum platform); +extern bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *path, NativeDisplayType native_display); extern SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(SDL_VideoDevice *_this, const char *proc); extern void SDL_EGL_UnloadLibrary(SDL_VideoDevice *_this); extern void SDL_EGL_SetRequiredVisualId(SDL_VideoDevice *_this, int visual_id); diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 84233a62b6..a7c30a5f37 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -331,7 +331,7 @@ struct SDL_VideoDevice bool (*GL_GetSwapInterval)(SDL_VideoDevice *_this, int *interval); bool (*GL_SwapWindow)(SDL_VideoDevice *_this, SDL_Window *window); bool (*GL_DestroyContext)(SDL_VideoDevice *_this, SDL_GLContext context); - void (*GL_DefaultProfileConfig)(SDL_VideoDevice *_this, int *mask, int *major, int *minor); + void (*GL_SetDefaultProfileConfig)(SDL_VideoDevice *_this); /* * * */ /* diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index a7133b11d6..16f5d92efd 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -4964,12 +4964,6 @@ void SDL_GL_ResetAttributes(void) _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; #endif - if (_this->GL_DefaultProfileConfig) { - _this->GL_DefaultProfileConfig(_this, &_this->gl_config.profile_mask, - &_this->gl_config.major_version, - &_this->gl_config.minor_version); - } - _this->gl_config.flags = 0; _this->gl_config.framebuffer_srgb_capable = -1; _this->gl_config.no_error = 0; @@ -4979,6 +4973,10 @@ void SDL_GL_ResetAttributes(void) _this->gl_config.share_with_current_context = 0; _this->gl_config.egl_platform = 0; + + if (_this->GL_SetDefaultProfileConfig) { + _this->GL_SetDefaultProfileConfig(_this); + } } bool SDL_GL_SetAttribute(SDL_GLAttr attr, int value) diff --git a/src/video/android/SDL_androidgl.c b/src/video/android/SDL_androidgl.c index fb98d03a69..e9de25fce6 100644 --- a/src/video/android/SDL_androidgl.c +++ b/src/video/android/SDL_androidgl.c @@ -82,7 +82,7 @@ bool Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) bool Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { - return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY); } #endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/src/video/cocoa/SDL_cocoaopengles.m b/src/video/cocoa/SDL_cocoaopengles.m index daf4c79d4f..5f84270015 100644 --- a/src/video/cocoa/SDL_cocoaopengles.m +++ b/src/video/cocoa/SDL_cocoaopengles.m @@ -51,7 +51,7 @@ bool Cocoa_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) } if (_this->egl_data == NULL) { - return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform); + return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY); } return true; @@ -127,7 +127,7 @@ bool Cocoa_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) #if 0 // When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. SDL_assert(!_this->gl_config.driver_loaded); #endif - if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform)) { + if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY)) { SDL_EGL_UnloadLibrary(_this); return false; } diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c index bab95e3c37..47fcf8ab5c 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -49,16 +49,18 @@ // EGL implementation of SDL OpenGL support -void KMSDRM_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor) +void KMSDRM_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this) { /* if SDL was _also_ built with the Raspberry Pi driver (so we're definitely a Pi device) or with the ROCKCHIP video driver (it's a ROCKCHIP device), default to GLES2. */ #if defined(SDL_VIDEO_DRIVER_RPI) || defined(SDL_VIDEO_DRIVER_ROCKCHIP) - *mask = SDL_GL_CONTEXT_PROFILE_ES; - *major = 2; - *minor = 0; + _this->gl_config.mask = SDL_GL_CONTEXT_PROFILE_ES; + _this->gl_config.major = 2; + _this->gl_config.minor = 0; #endif + + _this->gl_config.egl_platform = EGL_PLATFORM_GBM_MESA; } bool KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) @@ -70,7 +72,7 @@ bool KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) call order in SDL_CreateWindow(). */ #if 0 NativeDisplayType display = (NativeDisplayType)_this->internal->gbm_dev; - return SDL_EGL_LoadLibrary(_this, path, display, EGL_PLATFORM_GBM_MESA); + return SDL_EGL_LoadLibrary(_this, path, display); #endif return true; } diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.h b/src/video/kmsdrm/SDL_kmsdrmopengles.h index e8eb016c53..8c36a24da0 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.h +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.h @@ -31,7 +31,7 @@ #define KMSDRM_GLES_DestroyContext SDL_EGL_DestroyContext #define KMSDRM_GLES_GetSwapInterval SDL_EGL_GetSwapInterval -extern void KMSDRM_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor); +extern void KMSDRM_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this); extern bool KMSDRM_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval); extern bool KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); extern void KMSDRM_GLES_UnloadLibrary(SDL_VideoDevice *_this); diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 888451f32a..7d5c13e19b 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -74,10 +74,6 @@ static char kmsdrm_dri_cardpath[32]; #define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0) #endif -#ifndef EGL_PLATFORM_GBM_MESA -#define EGL_PLATFORM_GBM_MESA 0x31D7 -#endif - static int get_driindex(void) { int available = -ENOENT; @@ -696,7 +692,7 @@ static SDL_VideoDevice *KMSDRM_CreateDevice(void) device->GL_GetSwapInterval = KMSDRM_GLES_GetSwapInterval; device->GL_SwapWindow = KMSDRM_GLES_SwapWindow; device->GL_DestroyContext = KMSDRM_GLES_DestroyContext; - device->GL_DefaultProfileConfig = KMSDRM_GLES_DefaultProfileConfig; + device->GL_SetDefaultProfileConfig = KMSDRM_GLES_SetDefaultProfileConfig; #ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = KMSDRM_Vulkan_LoadLibrary; @@ -2132,12 +2128,12 @@ bool KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert before we call KMSDRM_GBMInit(), causing all GLES programs to fail. */ if (!_this->egl_data) { egl_display = (NativeDisplayType)_this->internal->gbm_dev; - if (!SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) { + if (!SDL_EGL_LoadLibrary(_this, NULL, egl_display)) { // 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)) { + if (!SDL_EGL_LoadLibrary(_this, NULL, egl_display)) { return SDL_SetError("Can't load EGL/GL library on window creation."); } } diff --git a/src/video/openvr/SDL_openvrvideo.c b/src/video/openvr/SDL_openvrvideo.c index dae1fc3d1a..c866d07627 100644 --- a/src/video/openvr/SDL_openvrvideo.c +++ b/src/video/openvr/SDL_openvrvideo.c @@ -1029,7 +1029,7 @@ static bool SDL_EGL_InitInternal(SDL_VideoData * vd) // Linux, EGL, etc. static bool OVR_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *path) { - return SDL_EGL_LoadLibrary(_this, path, /*displaydata->native_display*/0, 0); + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY); } static SDL_FunctionPointer OVR_EGL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) diff --git a/src/video/raspberry/SDL_rpiopengles.c b/src/video/raspberry/SDL_rpiopengles.c index e409720145..23fec4ca2c 100644 --- a/src/video/raspberry/SDL_rpiopengles.c +++ b/src/video/raspberry/SDL_rpiopengles.c @@ -27,16 +27,16 @@ // EGL implementation of SDL OpenGL support -void RPI_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor) +void RPI_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this) { - *mask = SDL_GL_CONTEXT_PROFILE_ES; - *major = 2; - *minor = 0; + _this->gl_config.mask = SDL_GL_CONTEXT_PROFILE_ES; + _this->gl_config.major = 2; + _this->gl_config.minor = 0; } bool RPI_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { - return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY, 0); + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY); } bool RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) diff --git a/src/video/raspberry/SDL_rpiopengles.h b/src/video/raspberry/SDL_rpiopengles.h index cc344bb9fd..bd22e3f180 100644 --- a/src/video/raspberry/SDL_rpiopengles.h +++ b/src/video/raspberry/SDL_rpiopengles.h @@ -40,7 +40,7 @@ extern bool RPI_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); extern SDL_GLContext RPI_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); extern bool RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern bool RPI_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); -extern void RPI_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor); +extern void RPI_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this); #endif // SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index 31a6fb9c13..8f00155549 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -124,7 +124,7 @@ static SDL_VideoDevice *RPI_Create(void) device->GL_GetSwapInterval = RPI_GLES_GetSwapInterval; device->GL_SwapWindow = RPI_GLES_SwapWindow; device->GL_DestroyContext = RPI_GLES_DestroyContext; - device->GL_DefaultProfileConfig = RPI_GLES_DefaultProfileConfig; + device->GL_SetDefaultProfileConfig = RPI_GLES_SetDefaultProfileConfig; device->PumpEvents = RPI_PumpEvents; diff --git a/src/video/vita/SDL_vitagl_pvr.c b/src/video/vita/SDL_vitagl_pvr.c index ded34a20ee..e3df6dbf8c 100644 --- a/src/video/vita/SDL_vitagl_pvr.c +++ b/src/video/vita/SDL_vitagl_pvr.c @@ -76,7 +76,7 @@ bool VITA_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) PVRSRVCreateVirtualAppHint(&hint); } - return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY); } SDL_GLContext VITA_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) diff --git a/src/video/vita/SDL_vitagles_pvr.c b/src/video/vita/SDL_vitagles_pvr.c index dcd841220c..207ebb003e 100644 --- a/src/video/vita/SDL_vitagles_pvr.c +++ b/src/video/vita/SDL_vitagles_pvr.c @@ -62,7 +62,7 @@ bool VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) PVRSRVCreateVirtualAppHint(&hint); } - return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY); } SDL_GLContext VITA_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) diff --git a/src/video/vivante/SDL_vivanteopengles.c b/src/video/vivante/SDL_vivanteopengles.c index 8ce0aa3d61..c42d5cc617 100644 --- a/src/video/vivante/SDL_vivanteopengles.c +++ b/src/video/vivante/SDL_vivanteopengles.c @@ -31,7 +31,7 @@ bool VIVANTE_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(SDL_GetPrimaryDisplay()); - return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display, 0); + return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display); } SDL_EGL_CreateContext_impl(VIVANTE) diff --git a/src/video/wayland/SDL_waylandopengles.c b/src/video/wayland/SDL_waylandopengles.c index 7826721b5a..5f06d7dd62 100644 --- a/src/video/wayland/SDL_waylandopengles.c +++ b/src/video/wayland/SDL_waylandopengles.c @@ -34,16 +34,20 @@ // EGL implementation of SDL OpenGL ES support +void Wayland_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this) +{ +#if defined(SDL_PLATFORM_QNXNTO) + // QNX defaults to EGL_PLATFORM_SCREEN_QNX unless this is explicitly specified + _this->gl_config.egl_platform = EGL_PLATFORM_WAYLAND_EXT; +#endif +} + bool Wayland_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) { bool result; SDL_VideoData *data = _this->internal; -#if defined(SDL_PLATFORM_QNXNTO) - SDL_GL_SetAttribute(SDL_GL_EGL_PLATFORM, EGL_PLATFORM_WAYLAND_EXT); -#endif - - result = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display, _this->gl_config.egl_platform); + result = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display); Wayland_PumpEvents(_this); WAYLAND_wl_display_flush(data->display); diff --git a/src/video/wayland/SDL_waylandopengles.h b/src/video/wayland/SDL_waylandopengles.h index 15e2972747..e505c26f3f 100644 --- a/src/video/wayland/SDL_waylandopengles.h +++ b/src/video/wayland/SDL_waylandopengles.h @@ -43,6 +43,7 @@ extern bool Wayland_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval); extern bool Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); extern bool Wayland_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); extern bool Wayland_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); +extern void Wayland_GLES_SetDefaultProfileConfig(SDL_VideoDevice *_this); extern SDL_EGLSurface Wayland_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window); #endif // SDL_waylandopengles_h_ diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 36ec2aca66..2b0cfad3d3 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -634,6 +634,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(bool require_preferred_protocols) device->GL_UnloadLibrary = Wayland_GLES_UnloadLibrary; device->GL_GetProcAddress = Wayland_GLES_GetProcAddress; device->GL_DestroyContext = Wayland_GLES_DestroyContext; + device->GL_SetDefaultProfileConfig = Wayland_GLES_SetDefaultProfileConfig; device->GL_GetEGLSurface = Wayland_GLES_GetEGLSurface; #endif diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index a0e966a43f..d5e3e0b521 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -54,7 +54,7 @@ bool WIN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) } if (!_this->egl_data) { - return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform); + return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY); } return true; @@ -115,7 +115,7 @@ bool WIN_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) #if 0 // When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. SDL_assert(!_this->gl_config.driver_loaded); #endif - if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform)) { + if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY)) { SDL_EGL_UnloadLibrary(_this); return false; } diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index 147576d29b..3ea4c4e427 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -53,7 +53,7 @@ bool X11_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) #endif } - return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display, _this->gl_config.egl_platform); + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display); } XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent)