mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-05 09:26:25 +00:00
egl: implement callbacks for defining custom EGL attributes
Depending on the underlying EGL library, it may be desirable to conditionally set some specific EGL attributes depending on available extensions and other application state. SDL's EGL usage makes this a little bit complicated because: - there are multiple functions used to set up a working EGL context - some of these functions take different types of EGL attributes (EGLAttrib vs EGLint) - the EGL extension list before creating an EGLDisplay differs from the extension list after (i.e. display vs client extensions) - all of the above happens in a single SDL_CreateWindow call This leaves no place for the application to discover what EGL extensions are available and provide custom attribute lists. Until now, if a developer wants to add a custom EGL attribute for eglGetPlatformDisplay, eglCreateWindowSurface or eglCreateContext, they needed to patch SDL itself. This is very undesirable, since such developers would have to disable the SDL dynapi in order to maintain compatibility with their needs. This patch implements some callbacks which developers can use to dynamically generate custom EGL attributes for SDL to use during SDL_CreateWindow.
This commit is contained in:
@@ -223,6 +223,14 @@ typedef void *SDL_GLContext;
|
||||
typedef void *SDL_EGLDisplay;
|
||||
typedef void *SDL_EGLConfig;
|
||||
typedef void *SDL_EGLSurface;
|
||||
typedef intptr_t SDL_EGLAttrib;
|
||||
typedef int SDL_EGLint;
|
||||
|
||||
/**
|
||||
* \brief EGL attribute initialization callback types.
|
||||
*/
|
||||
typedef SDL_EGLAttrib *(SDLCALL *SDL_EGLAttribArrayCallback)(void);
|
||||
typedef SDL_EGLint *(SDLCALL *SDL_EGLIntArrayCallback)(void);
|
||||
|
||||
/**
|
||||
* \brief OpenGL configuration attributes
|
||||
@@ -2089,6 +2097,30 @@ extern DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentEGLConfig(void);
|
||||
*/
|
||||
extern DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowEGLSurface(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* Sets the callbacks for defining custom EGLAttrib arrays for EGL
|
||||
* initialization.
|
||||
*
|
||||
* Each callback should return a pointer to an EGL attribute array terminated
|
||||
* with EGL_NONE. Callbacks may return NULL pointers to signal an error, which
|
||||
* will cause the SDL_CreateWindow process to fail gracefully.
|
||||
*
|
||||
* The arrays returned by each callback will be appended to the existing
|
||||
* attribute arrays defined by SDL.
|
||||
*
|
||||
* NOTE: These callback pointers will be reset after SDL_GL_ResetAttributes.
|
||||
*
|
||||
* \param platformAttribCallback Callback for attributes to pass to
|
||||
* eglGetPlatformDisplay.
|
||||
* \param surfaceAttribCallback Callback for attributes to pass to
|
||||
* eglCreateSurface.
|
||||
* \param contextAttribCallback Callback for attributes to pass to
|
||||
* eglCreateContext.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_EGL_SetEGLAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback,
|
||||
SDL_EGLIntArrayCallback surfaceAttribCallback,
|
||||
SDL_EGLIntArrayCallback contextAttribCallback);
|
||||
|
||||
/**
|
||||
* Get the size of a window's underlying drawable in pixels.
|
||||
*
|
||||
|
Reference in New Issue
Block a user