mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-03 16:36:25 +00:00
hints: replace SDL_HINT_VIDEO_X11_FORCE_EGL with platform-agnostic SDL_HINT_VIDEO_FORCE_EGL
This adds support for forcing the use of EGL on Windows and MacOS. The SDL_HINT_VIDEO_X11_FORCE_EGL hint is retained for backwards compatibility but is now deprecated.
This commit is contained in:
@@ -506,7 +506,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
||||
* Khronos doc: "EGL_BAD_DISPLAY is generated if display is not an EGL display connection, unless display is EGL_NO_DISPLAY and name is EGL_EXTENSIONS."
|
||||
* Therefore SDL_EGL_GetVersion() shouldn't work with uninitialized display.
|
||||
* - it actually doesn't work on Android that has 1.5 egl client
|
||||
* - it works on desktop X11 (using SDL_VIDEO_X11_FORCE_EGL=1) */
|
||||
* - it works on desktop X11 (using SDL_VIDEO_FORCE_EGL=1) */
|
||||
SDL_EGL_GetVersion(_this);
|
||||
|
||||
if (_this->egl_data->egl_version_major == 1 && _this->egl_data->egl_version_minor == 5) {
|
||||
|
@@ -139,16 +139,23 @@ Cocoa_CreateDevice(void)
|
||||
device->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval;
|
||||
device->GL_SwapWindow = Cocoa_GL_SwapWindow;
|
||||
device->GL_DeleteContext = Cocoa_GL_DeleteContext;
|
||||
#elif SDL_VIDEO_OPENGL_EGL
|
||||
device->GL_LoadLibrary = Cocoa_GLES_LoadLibrary;
|
||||
device->GL_GetProcAddress = Cocoa_GLES_GetProcAddress;
|
||||
device->GL_UnloadLibrary = Cocoa_GLES_UnloadLibrary;
|
||||
device->GL_CreateContext = Cocoa_GLES_CreateContext;
|
||||
device->GL_MakeCurrent = Cocoa_GLES_MakeCurrent;
|
||||
device->GL_SetSwapInterval = Cocoa_GLES_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = Cocoa_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = Cocoa_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = Cocoa_GLES_DeleteContext;
|
||||
#endif
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
#if SDL_VIDEO_OPENGL_CGL
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) {
|
||||
#endif
|
||||
device->GL_LoadLibrary = Cocoa_GLES_LoadLibrary;
|
||||
device->GL_GetProcAddress = Cocoa_GLES_GetProcAddress;
|
||||
device->GL_UnloadLibrary = Cocoa_GLES_UnloadLibrary;
|
||||
device->GL_CreateContext = Cocoa_GLES_CreateContext;
|
||||
device->GL_MakeCurrent = Cocoa_GLES_MakeCurrent;
|
||||
device->GL_SetSwapInterval = Cocoa_GLES_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = Cocoa_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = Cocoa_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = Cocoa_GLES_DeleteContext;
|
||||
#if SDL_VIDEO_OPENGL_CGL
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_VULKAN
|
||||
|
@@ -226,17 +226,24 @@ WIN_CreateDevice(void)
|
||||
device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
|
||||
device->GL_SwapWindow = WIN_GL_SwapWindow;
|
||||
device->GL_DeleteContext = WIN_GL_DeleteContext;
|
||||
#elif SDL_VIDEO_OPENGL_EGL
|
||||
/* Use EGL based functions */
|
||||
device->GL_LoadLibrary = WIN_GLES_LoadLibrary;
|
||||
device->GL_GetProcAddress = WIN_GLES_GetProcAddress;
|
||||
device->GL_UnloadLibrary = WIN_GLES_UnloadLibrary;
|
||||
device->GL_CreateContext = WIN_GLES_CreateContext;
|
||||
device->GL_MakeCurrent = WIN_GLES_MakeCurrent;
|
||||
device->GL_SetSwapInterval = WIN_GLES_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = WIN_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = WIN_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = WIN_GLES_DeleteContext;
|
||||
#endif
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
#if SDL_VIDEO_OPENGL_WGL
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) {
|
||||
#endif
|
||||
/* Use EGL based functions */
|
||||
device->GL_LoadLibrary = WIN_GLES_LoadLibrary;
|
||||
device->GL_GetProcAddress = WIN_GLES_GetProcAddress;
|
||||
device->GL_UnloadLibrary = WIN_GLES_UnloadLibrary;
|
||||
device->GL_CreateContext = WIN_GLES_CreateContext;
|
||||
device->GL_MakeCurrent = WIN_GLES_MakeCurrent;
|
||||
device->GL_SetSwapInterval = WIN_GLES_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = WIN_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = WIN_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = WIN_GLES_DeleteContext;
|
||||
#if SDL_VIDEO_OPENGL_WGL
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if SDL_VIDEO_VULKAN
|
||||
device->Vulkan_LoadLibrary = WIN_Vulkan_LoadLibrary;
|
||||
|
@@ -253,6 +253,7 @@ X11_GL_LoadLibrary(_THIS, const char *path)
|
||||
* GLX_EXT_create_context_es2_profile extension, switch over to X11_GLES functions
|
||||
*/
|
||||
if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) ||
|
||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE) ||
|
||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) &&
|
||||
X11_GL_UseEGL(_this) ) {
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
@@ -691,7 +692,8 @@ SDL_bool
|
||||
X11_GL_UseEGL(_THIS)
|
||||
{
|
||||
SDL_assert(_this->gl_data != NULL);
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE))
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE) ||
|
||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE))
|
||||
{
|
||||
/* use of EGL has been requested, even for desktop GL */
|
||||
return SDL_TRUE;
|
||||
|
@@ -36,6 +36,7 @@ X11_GLES_LoadLibrary(_THIS, const char *path)
|
||||
|
||||
/* If the profile requested is not GL ES, switch over to X11_GL functions */
|
||||
if ((_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) &&
|
||||
!SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE) &&
|
||||
!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) {
|
||||
#if SDL_VIDEO_OPENGL_GLX
|
||||
X11_GLES_UnloadLibrary(_this);
|
||||
|
@@ -282,7 +282,8 @@ X11_CreateDevice(void)
|
||||
#endif
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
#if SDL_VIDEO_OPENGL_GLX
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE) ||
|
||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) {
|
||||
#endif
|
||||
device->GL_LoadLibrary = X11_GLES_LoadLibrary;
|
||||
device->GL_GetProcAddress = X11_GLES_GetProcAddress;
|
||||
|
@@ -429,6 +429,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) ||
|
||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE) ||
|
||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE))
|
||||
#if SDL_VIDEO_OPENGL_GLX
|
||||
&& ( !_this->gl_data || X11_GL_UseEGL(_this) )
|
||||
|
Reference in New Issue
Block a user