Functions which return function pointers now return SDL_FunctionPointer instead of void*

This fixes the clang warning "Cast between pointer-to-function and pointer-to-object is an extension"

You can define SDL_FUNCTION_POINTER_IS_VOID_POINTER in your project to restore the previous behavior.

Fixes https://github.com/libsdl-org/SDL/issues/2866
main
Sam Lantinga 2023-01-09 14:55:12 -08:00
parent 7275b2b352
commit e9b86eebf3
43 changed files with 272 additions and 356 deletions

View File

@ -406,6 +406,10 @@ The following symbols have been renamed:
* KMOD_SCROLL => SDL_KMOD_SCROLL
* KMOD_SHIFT => SDL_KMOD_SHIFT
## SDL_loadso.h
SDL_LoadFunction() now returns `SDL_FunctionPointer` instead of `void *`, and should be cast to the appropriate function type. You can define SDL_FUNCTION_POINTER_IS_VOID_POINTER in your project to restore the previous behavior.
## SDL_main.h
SDL3 doesn't have a static libSDLmain to link against anymore.
@ -867,6 +871,8 @@ Programs which have access to shaders can implement more robust versions of thos
Removed SDL_GL_CONTEXT_EGL from OpenGL configuration attributes. You can instead use `SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);`
SDL_GL_GetProcAddress() and SDL_EGL_GetProcAddress() now return `SDL_FunctionPointer` instead of `void *`, and should be cast to the appropriate function type. You can define SDL_FUNCTION_POINTER_IS_VOID_POINTER in your project to restore the previous behavior.
SDL_GL_SwapWindow() returns 0 if the function succeeds or a negative error code if there was an error.
SDL_GL_GetSwapInterval() takes the interval as an output parameter and returns 0 if the function succeeds or a negative error code if there was an error.
@ -882,3 +888,5 @@ SDL_Window id type is named SDL_WindowID
SDL_Vulkan_GetInstanceExtensions() no longer takes a window parameter.
SDL_Vulkan_GetVkGetInstanceProcAddr() now returns `SDL_FunctionPointer` instead of `void *`, and should be cast to PFN_vkGetInstanceProcAddr.

View File

@ -89,8 +89,8 @@ extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile);
* \sa SDL_LoadObject
* \sa SDL_UnloadObject
*/
extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
const char *name);
extern DECLSPEC SDL_FunctionPointer SDL_LoadFunction(void *handle,
const char *name);
/**
* Unload a shared object from memory.

View File

@ -738,6 +738,13 @@ SDL_FORCE_INLINE int SDL_size_add_overflow_builtin (size_t a,
#define SDL_size_add_overflow(a, b, ret) (SDL_size_add_overflow_builtin(a, b, ret))
#endif
/* This is a generic function pointer which should be cast to the type you expect */
#ifdef SDL_FUNCTION_POINTER_IS_VOID_POINTER
typedef void *SDL_FunctionPointer;
#else
typedef void (*SDL_FunctionPointer)(void);
#endif
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}

View File

@ -1723,7 +1723,7 @@ extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
* \sa SDL_GL_LoadLibrary
* \sa SDL_GL_UnloadLibrary
*/
extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc);
extern DECLSPEC SDL_FunctionPointer SDLCALL SDL_GL_GetProcAddress(const char *proc);
/**
* Get an EGL library function by name.
@ -1740,7 +1740,7 @@ extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc);
*
* \sa SDL_GL_GetCurrentEGLDisplay
*/
extern DECLSPEC void *SDLCALL SDL_EGL_GetProcAddress(const char *proc);
extern DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc);
/**
* Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().

View File

@ -111,11 +111,17 @@ extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path);
* This should be called after either calling SDL_Vulkan_LoadLibrary() or
* creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag.
*
* The actual type of the returned function pointer is PFN_vkGetInstanceProcAddr,
* but that isn't available because the Vulkan headers are not included here. You
* should cast the return value of this function to that type, e.g.
*
* `vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr();`
*
* \returns the function pointer for `vkGetInstanceProcAddr` or NULL on error.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void *SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void);
extern DECLSPEC SDL_FunctionPointer SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void);
/**
* Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary()

View File

@ -50,7 +50,7 @@ static int aaudio_LoadFunctions(AAUDIO_Data *data)
{
#define SDL_PROC(ret, func, params) \
do { \
data->func = SDL_LoadFunction(data->handle, #func); \
data->func = (ret (*) params)SDL_LoadFunction(data->handle, #func); \
if (!data->func) { \
return SDL_SetError("Couldn't load AAUDIO function %s: %s", #func, SDL_GetError()); \
} \

View File

@ -33,53 +33,53 @@ static SDL_DBusContext dbus;
static int LoadDBUSSyms(void)
{
#define SDL_DBUS_SYM2(x, y) \
if (!(dbus.x = SDL_LoadFunction(dbus_handle, #y))) \
#define SDL_DBUS_SYM2(TYPE, x, y) \
if (!(dbus.x = (TYPE)SDL_LoadFunction(dbus_handle, #y))) \
return -1
#define SDL_DBUS_SYM(x) \
SDL_DBUS_SYM2(x, dbus_##x)
#define SDL_DBUS_SYM(TYPE, x) \
SDL_DBUS_SYM2(TYPE, x, dbus_##x)
SDL_DBUS_SYM(bus_get_private);
SDL_DBUS_SYM(bus_register);
SDL_DBUS_SYM(bus_add_match);
SDL_DBUS_SYM(connection_open_private);
SDL_DBUS_SYM(connection_set_exit_on_disconnect);
SDL_DBUS_SYM(connection_get_is_connected);
SDL_DBUS_SYM(connection_add_filter);
SDL_DBUS_SYM(connection_try_register_object_path);
SDL_DBUS_SYM(connection_send);
SDL_DBUS_SYM(connection_send_with_reply_and_block);
SDL_DBUS_SYM(connection_close);
SDL_DBUS_SYM(connection_ref);
SDL_DBUS_SYM(connection_unref);
SDL_DBUS_SYM(connection_flush);
SDL_DBUS_SYM(connection_read_write);
SDL_DBUS_SYM(connection_dispatch);
SDL_DBUS_SYM(message_is_signal);
SDL_DBUS_SYM(message_new_method_call);
SDL_DBUS_SYM(message_append_args);
SDL_DBUS_SYM(message_append_args_valist);
SDL_DBUS_SYM(message_iter_init_append);
SDL_DBUS_SYM(message_iter_open_container);
SDL_DBUS_SYM(message_iter_append_basic);
SDL_DBUS_SYM(message_iter_close_container);
SDL_DBUS_SYM(message_get_args);
SDL_DBUS_SYM(message_get_args_valist);
SDL_DBUS_SYM(message_iter_init);
SDL_DBUS_SYM(message_iter_next);
SDL_DBUS_SYM(message_iter_get_basic);
SDL_DBUS_SYM(message_iter_get_arg_type);
SDL_DBUS_SYM(message_iter_recurse);
SDL_DBUS_SYM(message_unref);
SDL_DBUS_SYM(threads_init_default);
SDL_DBUS_SYM(error_init);
SDL_DBUS_SYM(error_is_set);
SDL_DBUS_SYM(error_free);
SDL_DBUS_SYM(get_local_machine_id);
SDL_DBUS_SYM(free);
SDL_DBUS_SYM(free_string_array);
SDL_DBUS_SYM(shutdown);
SDL_DBUS_SYM(DBusConnection *(*)(DBusBusType, DBusError *), bus_get_private);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusConnection *, DBusError *), bus_register);
SDL_DBUS_SYM(void (*)(DBusConnection *, const char *, DBusError *), bus_add_match);
SDL_DBUS_SYM(DBusConnection *(*)(const char *, DBusError *), connection_open_private);
SDL_DBUS_SYM(void (*)(DBusConnection *, dbus_bool_t), connection_set_exit_on_disconnect);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusConnection *), connection_get_is_connected);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusConnection *, DBusHandleMessageFunction, void *, DBusFreeFunction), connection_add_filter);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusConnection *, const char *, const DBusObjectPathVTable *, void *, DBusError *), connection_try_register_object_path);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusConnection *, DBusMessage *, dbus_uint32_t *), connection_send);
SDL_DBUS_SYM(DBusMessage *(*)(DBusConnection *, DBusMessage *, int, DBusError *), connection_send_with_reply_and_block);
SDL_DBUS_SYM(void (*)(DBusConnection *), connection_close);
SDL_DBUS_SYM(void (*)(DBusConnection *), connection_ref);
SDL_DBUS_SYM(void (*)(DBusConnection *), connection_unref);
SDL_DBUS_SYM(void (*)(DBusConnection *), connection_flush);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusConnection *, int), connection_read_write);
SDL_DBUS_SYM(DBusDispatchStatus (*)(DBusConnection *), connection_dispatch);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessage *, const char *, const char *), message_is_signal);
SDL_DBUS_SYM(DBusMessage *(*)(const char *, const char *, const char *, const char *), message_new_method_call);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessage *, int, ...), message_append_args);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessage *, int, va_list), message_append_args_valist);
SDL_DBUS_SYM(void (*)(DBusMessage *, DBusMessageIter *), message_iter_init_append);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessageIter *, int, const char *, DBusMessageIter *), message_iter_open_container);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessageIter *, int, const void *), message_iter_append_basic);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessageIter *, DBusMessageIter *), message_iter_close_container);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessage *, DBusError *, int, ...), message_get_args);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessage *, DBusError *, int, va_list), message_get_args_valist);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessage *, DBusMessageIter *), message_iter_init);
SDL_DBUS_SYM(dbus_bool_t (*)(DBusMessageIter *), message_iter_next);
SDL_DBUS_SYM(void (*)(DBusMessageIter *, void *), message_iter_get_basic);
SDL_DBUS_SYM(int (*)(DBusMessageIter *), message_iter_get_arg_type);
SDL_DBUS_SYM(void (*)(DBusMessageIter *, DBusMessageIter *), message_iter_recurse);
SDL_DBUS_SYM(void (*)(DBusMessage *), message_unref);
SDL_DBUS_SYM(dbus_bool_t (*)(void), threads_init_default);
SDL_DBUS_SYM(void (*)(DBusError *), error_init);
SDL_DBUS_SYM(dbus_bool_t (*)(const DBusError *), error_is_set);
SDL_DBUS_SYM(void (*)(DBusError *), error_free);
SDL_DBUS_SYM(char *(*)(void), get_local_machine_id);
SDL_DBUS_SYM(void (*)(void *), free);
SDL_DBUS_SYM(void (*)(char **), free_string_array);
SDL_DBUS_SYM(void (*)(void), shutdown);
#undef SDL_DBUS_SYM
#undef SDL_DBUS_SYM2

View File

@ -199,7 +199,7 @@ SDL_DYNAPI_PROC(void,SDL_DisableScreenSaver,(void),(),)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_DuplicateSurface,(SDL_Surface *a),(a),return)
SDL_DYNAPI_PROC(SDL_EGLConfig,SDL_EGL_GetCurrentEGLConfig,(void),(),return)
SDL_DYNAPI_PROC(SDL_EGLDisplay,SDL_EGL_GetCurrentEGLDisplay,(void),(),return)
SDL_DYNAPI_PROC(void*,SDL_EGL_GetProcAddress,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_EGL_GetProcAddress,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_EGLSurface,SDL_EGL_GetWindowEGLSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_EGL_SetEGLAttributeCallbacks,(SDL_EGLAttribArrayCallback a, SDL_EGLIntArrayCallback b, SDL_EGLIntArrayCallback c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_EnableScreenSaver,(void),(),)
@ -222,7 +222,7 @@ SDL_DYNAPI_PROC(int,SDL_GL_GetAttribute,(SDL_GLattr a, int *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GLContext,SDL_GL_GetCurrentContext,(void),(),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GL_GetCurrentWindow,(void),(),return)
SDL_DYNAPI_PROC(void,SDL_GL_GetDrawableSize,(SDL_Window *a, int *b, int *c),(a,b,c),)
SDL_DYNAPI_PROC(void*,SDL_GL_GetProcAddress,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_GL_GetProcAddress,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_GetSwapInterval,(int *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_LoadLibrary,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_MakeCurrent,(SDL_Window *a, SDL_GLContext b),(a,b),return)
@ -536,7 +536,7 @@ SDL_DYNAPI_PROC(int,SDL_JoystickIsHaptic,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_LoadBMP_RW,(SDL_RWops *a, int b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_LoadFile,(const char *a, size_t *b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_LoadFile_RW,(SDL_RWops *a, size_t *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void*,SDL_LoadFunction,(void *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_LoadFunction,(void *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_LoadObject,(const char *a),(a),return)
SDL_DYNAPI_PROC(SDL_AudioSpec*,SDL_LoadWAV_RW,(SDL_RWops *a, int b, SDL_AudioSpec *c, Uint8 **d, Uint32 *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void,SDL_LockAudioDevice,(SDL_AudioDeviceID a),(a),)
@ -755,7 +755,7 @@ SDL_DYNAPI_PROC(int,SDL_UpdateYUVTexture,(SDL_Texture *a, const SDL_Rect *b, con
SDL_DYNAPI_PROC(SDL_bool,SDL_Vulkan_CreateSurface,(SDL_Window *a, VkInstance b, VkSurfaceKHR *c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_Vulkan_GetDrawableSize,(SDL_Window *a, int *b, int *c),(a,b,c),)
SDL_DYNAPI_PROC(SDL_bool,SDL_Vulkan_GetInstanceExtensions,(unsigned int *a, const char **b),(a,b),return)
SDL_DYNAPI_PROC(void*,SDL_Vulkan_GetVkGetInstanceProcAddr,(void),(),return)
SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_Vulkan_GetVkGetInstanceProcAddr,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_Vulkan_LoadLibrary,(const char *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_Vulkan_UnloadLibrary,(void),(),)
SDL_DYNAPI_PROC(int,SDL_WaitEvent,(SDL_Event *a),(a),return)

View File

@ -32,8 +32,7 @@
#include "../../video/uikit/SDL_uikitvideo.h"
#endif
void *
SDL_LoadObject(const char *sofile)
void *SDL_LoadObject(const char *sofile)
{
void *handle;
const char *loaderror;
@ -53,8 +52,7 @@ SDL_LoadObject(const char *sofile)
return handle;
}
void *
SDL_LoadFunction(void *handle, const char *name)
SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name)
{
void *symbol = dlsym(handle, name);
if (symbol == NULL) {

View File

@ -25,16 +25,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent library loading routines */
void *
SDL_LoadObject(const char *sofile)
void *SDL_LoadObject(const char *sofile)
{
const char *loaderror = "SDL_LoadObject() not implemented";
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
return NULL;
}
void *
SDL_LoadFunction(void *handle, const char *name)
SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name)
{
const char *loaderror = "SDL_LoadFunction() not implemented";
SDL_SetError("Failed loading %s: %s", name, loaderror);

View File

@ -27,8 +27,7 @@
#include "../../core/windows/SDL_windows.h"
void *
SDL_LoadObject(const char *sofile)
void *SDL_LoadObject(const char *sofile)
{
void *handle;
LPTSTR tstr;
@ -59,8 +58,7 @@ SDL_LoadObject(const char *sofile)
return handle;
}
void *
SDL_LoadFunction(void *handle, const char *name)
SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name)
{
void *symbol = (void *)GetProcAddress((HMODULE)handle, name);
if (symbol == NULL) {

View File

@ -242,7 +242,7 @@ static int GL_LoadFunctions(GL_RenderData *data)
int retval = 0;
#define SDL_PROC(ret, func, params) \
do { \
data->func = SDL_GL_GetProcAddress(#func); \
data->func = (ret (APIENTRY *) params)SDL_GL_GetProcAddress(#func); \
if (!data->func) { \
retval = SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \
} \

View File

@ -252,7 +252,7 @@ static int GLES2_LoadFunctions(GLES2_RenderData *data)
#else
#define SDL_PROC(ret, func, params) \
do { \
data->func = SDL_GL_GetProcAddress(#func); \
data->func = (ret (APIENTRY *) params)SDL_GL_GetProcAddress(#func); \
if (!data->func) { \
return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \
} \

View File

@ -115,20 +115,24 @@
#define EGL_PLATFORM_DEVICE_EXT 0x0
#endif
#if SDL_VIDEO_OPENGL
typedef void (APIENTRY* PFNGLGETINTEGERVPROC) (GLenum pname, GLint * params);
#endif
#if defined(SDL_VIDEO_STATIC_ANGLE) || defined(SDL_VIDEO_DRIVER_VITA)
#define LOAD_FUNC(NAME) \
_this->egl_data->NAME = (void *)NAME;
#define LOAD_FUNC(TYPE, NAME) \
_this->egl_data->NAME = NAME;
#else
#define LOAD_FUNC(NAME) \
_this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->egl_dll_handle, #NAME); \
#define LOAD_FUNC(TYPE, NAME) \
_this->egl_data->NAME = (TYPE)SDL_LoadFunction(_this->egl_data->egl_dll_handle, #NAME); \
if (!_this->egl_data->NAME) { \
return SDL_SetError("Could not retrieve EGL function " #NAME); \
}
#endif
/* it is allowed to not have some of the EGL extensions on start - attempts to use them will fail later. */
#define LOAD_FUNC_EGLEXT(NAME) \
_this->egl_data->NAME = _this->egl_data->eglGetProcAddress(#NAME);
#define LOAD_FUNC_EGLEXT(TYPE, NAME) \
_this->egl_data->NAME = (TYPE)_this->egl_data->eglGetProcAddress(#NAME);
static const char *SDL_EGL_GetErrorName(EGLint eglErrorCode)
{
@ -241,10 +245,9 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext
return SDL_FALSE;
}
void *
SDL_EGL_GetProcAddressInternal(_THIS, const char *proc)
SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(_THIS, const char *proc)
{
void *retval = NULL;
SDL_FunctionPointer retval = NULL;
if (_this->egl_data != NULL) {
const Uint32 eglver = (((Uint32)_this->egl_data->egl_version_major) << 16) | ((Uint32)_this->egl_data->egl_version_minor);
const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32)1) << 16) | 5);
@ -424,34 +427,33 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path)
#endif
/* Load new function pointers */
LOAD_FUNC(eglGetDisplay);
LOAD_FUNC(eglInitialize);
LOAD_FUNC(eglTerminate);
LOAD_FUNC(eglGetProcAddress);
LOAD_FUNC(eglChooseConfig);
LOAD_FUNC(eglGetConfigAttrib);
LOAD_FUNC(eglCreateContext);
LOAD_FUNC(eglDestroyContext);
LOAD_FUNC(eglCreatePbufferSurface);
LOAD_FUNC(eglCreateWindowSurface);
LOAD_FUNC(eglDestroySurface);
LOAD_FUNC(eglMakeCurrent);
LOAD_FUNC(eglSwapBuffers);
LOAD_FUNC(eglSwapInterval);
LOAD_FUNC(eglWaitNative);
LOAD_FUNC(eglWaitGL);
LOAD_FUNC(eglBindAPI);
LOAD_FUNC(eglQueryAPI);
LOAD_FUNC(eglQueryString);
LOAD_FUNC(eglGetError);
LOAD_FUNC_EGLEXT(eglQueryDevicesEXT);
LOAD_FUNC_EGLEXT(eglGetPlatformDisplayEXT);
LOAD_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay);
LOAD_FUNC(PFNEGLINITIALIZEPROC, eglInitialize);
LOAD_FUNC(PFNEGLTERMINATEPROC, eglTerminate);
LOAD_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress);
LOAD_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig);
LOAD_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext);
LOAD_FUNC(PFNEGLDESTROYCONTEXTPROC, eglDestroyContext);
LOAD_FUNC(PFNEGLCREATEPBUFFERSURFACEPROC, eglCreatePbufferSurface);
LOAD_FUNC(PFNEGLCREATEWINDOWSURFACEPROC, eglCreateWindowSurface);
LOAD_FUNC(PFNEGLDESTROYSURFACEPROC, eglDestroySurface);
LOAD_FUNC(PFNEGLMAKECURRENTPROC, eglMakeCurrent);
LOAD_FUNC(PFNEGLSWAPBUFFERSPROC, eglSwapBuffers);
LOAD_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval);
LOAD_FUNC(PFNEGLQUERYSTRINGPROC, eglQueryString);
LOAD_FUNC(PFNEGLGETCONFIGATTRIBPROC, eglGetConfigAttrib);
LOAD_FUNC(PFNEGLWAITNATIVEPROC, eglWaitNative);
LOAD_FUNC(PFNEGLWAITGLPROC, eglWaitGL);
LOAD_FUNC(PFNEGLBINDAPIPROC, eglBindAPI);
LOAD_FUNC(PFNEGLGETERRORPROC, eglGetError);
LOAD_FUNC_EGLEXT(PFNEGLQUERYDEVICESEXTPROC, eglQueryDevicesEXT);
LOAD_FUNC_EGLEXT(PFNEGLGETPLATFORMDISPLAYEXTPROC, eglGetPlatformDisplayEXT);
/* Atomic functions */
LOAD_FUNC_EGLEXT(eglCreateSyncKHR);
LOAD_FUNC_EGLEXT(eglDestroySyncKHR);
LOAD_FUNC_EGLEXT(eglDupNativeFenceFDANDROID);
LOAD_FUNC_EGLEXT(eglWaitSyncKHR);
LOAD_FUNC_EGLEXT(eglClientWaitSyncKHR);
LOAD_FUNC_EGLEXT(PFNEGLCREATESYNCKHRPROC, eglCreateSyncKHR);
LOAD_FUNC_EGLEXT(PFNEGLDESTROYSYNCKHRPROC, eglDestroySyncKHR);
LOAD_FUNC_EGLEXT(PFNEGLDUPNATIVEFENCEFDANDROIDPROC, eglDupNativeFenceFDANDROID);
LOAD_FUNC_EGLEXT(PFNEGLWAITSYNCKHRPROC, eglWaitSyncKHR);
LOAD_FUNC_EGLEXT(PFNEGLCLIENTWAITSYNCKHRPROC, eglClientWaitSyncKHR);
/* Atomic functions end */
if (path) {
@ -519,7 +521,7 @@ int SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_di
SDL_EGL_GetVersion(_this);
if (_this->egl_data->egl_version_major == 1 && _this->egl_data->egl_version_minor == 5) {
LOAD_FUNC(eglGetPlatformDisplay);
LOAD_FUNC(PFNEGLGETPLATFORMDISPLAYPROC, eglGetPlatformDisplay);
}
if (_this->egl_data->eglGetPlatformDisplay) {
@ -535,7 +537,7 @@ int SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_di
_this->egl_data->egl_display = _this->egl_data->eglGetPlatformDisplay(platform, (void *)(uintptr_t)native_display, attribs);
} else {
if (SDL_EGL_HasExtension(_this, SDL_EGL_CLIENT_EXTENSION, "EGL_EXT_platform_base")) {
_this->egl_data->eglGetPlatformDisplayEXT = SDL_EGL_GetProcAddressInternal(_this, "eglGetPlatformDisplayEXT");
_this->egl_data->eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)SDL_EGL_GetProcAddressInternal(_this, "eglGetPlatformDisplayEXT");
if (_this->egl_data->eglGetPlatformDisplayEXT) {
_this->egl_data->egl_display = _this->egl_data->eglGetPlatformDisplayEXT(platform, (void *)(uintptr_t)native_display, NULL);
}
@ -1103,8 +1105,7 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
#if SDL_VIDEO_OPENGL && !defined(SDL_VIDEO_DRIVER_VITA)
} else {
/* Desktop OpenGL supports it by default from version 3.0 on. */
void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params);
glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
PFNGLGETINTEGERVPROC glGetIntegervFunc = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress("glGetIntegerv");
if (glGetIntegervFunc) {
GLint v = 0;
glGetIntegervFunc(GL_MAJOR_VERSION, &v);

View File

@ -43,77 +43,35 @@ typedef struct SDL_EGL_VideoData
SDL_bool is_offscreen; /* whether EGL display was offscreen */
EGLenum apitype; /* EGL_OPENGL_ES_API, EGL_OPENGL_API, etc */
EGLDisplay(EGLAPIENTRY *eglGetDisplay)(NativeDisplayType display);
EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplay)(EGLenum platform,
void *native_display,
const EGLAttrib *attrib_list);
EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplayEXT)(EGLenum platform,
void *native_display,
const EGLint *attrib_list);
EGLBoolean(EGLAPIENTRY *eglInitialize)(EGLDisplay dpy, EGLint *major,
EGLint *minor);
EGLBoolean(EGLAPIENTRY *eglTerminate)(EGLDisplay dpy);
void *(EGLAPIENTRY *eglGetProcAddress)(const char *procName);
EGLBoolean(EGLAPIENTRY *eglChooseConfig)(EGLDisplay dpy,
const EGLint *attrib_list,
EGLConfig *configs,
EGLint config_size, EGLint *num_config);
EGLContext(EGLAPIENTRY *eglCreateContext)(EGLDisplay dpy,
EGLConfig config,
EGLContext share_list,
const EGLint *attrib_list);
EGLBoolean(EGLAPIENTRY *eglDestroyContext)(EGLDisplay dpy, EGLContext ctx);
EGLSurface(EGLAPIENTRY *eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
EGLint const *attrib_list);
EGLSurface(EGLAPIENTRY *eglCreateWindowSurface)(EGLDisplay dpy,
EGLConfig config,
NativeWindowType window,
const EGLint *attrib_list);
EGLBoolean(EGLAPIENTRY *eglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
EGLBoolean(EGLAPIENTRY *eglMakeCurrent)(EGLDisplay dpy, EGLSurface draw,
EGLSurface read, EGLContext ctx);
EGLBoolean(EGLAPIENTRY *eglSwapBuffers)(EGLDisplay dpy, EGLSurface draw);
EGLBoolean(EGLAPIENTRY *eglSwapInterval)(EGLDisplay dpy, EGLint interval);
const char *(EGLAPIENTRY *eglQueryString)(EGLDisplay dpy, EGLint name);
EGLenum(EGLAPIENTRY *eglQueryAPI)(void);
EGLBoolean(EGLAPIENTRY *eglGetConfigAttrib)(EGLDisplay dpy, EGLConfig config,
EGLint attribute, EGLint *value);
EGLBoolean(EGLAPIENTRY *eglWaitNative)(EGLint engine);
EGLBoolean(EGLAPIENTRY *eglWaitGL)(void);
EGLBoolean(EGLAPIENTRY *eglBindAPI)(EGLenum);
EGLint(EGLAPIENTRY *eglGetError)(void);
EGLBoolean(EGLAPIENTRY *eglQueryDevicesEXT)(EGLint max_devices,
void **devices,
EGLint *num_devices);
PFNEGLGETDISPLAYPROC eglGetDisplay;
PFNEGLINITIALIZEPROC eglInitialize;
PFNEGLTERMINATEPROC eglTerminate;
PFNEGLGETPROCADDRESSPROC eglGetProcAddress;
PFNEGLCHOOSECONFIGPROC eglChooseConfig;
PFNEGLCREATECONTEXTPROC eglCreateContext;
PFNEGLDESTROYCONTEXTPROC eglDestroyContext;
PFNEGLCREATEPBUFFERSURFACEPROC eglCreatePbufferSurface;
PFNEGLCREATEWINDOWSURFACEPROC eglCreateWindowSurface;
PFNEGLDESTROYSURFACEPROC eglDestroySurface;
PFNEGLMAKECURRENTPROC eglMakeCurrent;
PFNEGLSWAPBUFFERSPROC eglSwapBuffers;
PFNEGLSWAPINTERVALPROC eglSwapInterval;
PFNEGLQUERYSTRINGPROC eglQueryString;
PFNEGLGETCONFIGATTRIBPROC eglGetConfigAttrib;
PFNEGLWAITNATIVEPROC eglWaitNative;
PFNEGLWAITGLPROC eglWaitGL;
PFNEGLBINDAPIPROC eglBindAPI;
PFNEGLGETERRORPROC eglGetError;
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT;
PFNEGLGETPLATFORMDISPLAYPROC eglGetPlatformDisplay;
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
/* Atomic functions */
EGLSyncKHR(EGLAPIENTRY *eglCreateSyncKHR)(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
EGLBoolean(EGLAPIENTRY *eglDestroySyncKHR)(EGLDisplay dpy, EGLSyncKHR sync);
EGLint(EGLAPIENTRY *eglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync);
EGLint(EGLAPIENTRY *eglWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
EGLint(EGLAPIENTRY *eglClientWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR;
PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR;
PFNEGLDUPNATIVEFENCEFDANDROIDPROC eglDupNativeFenceFDANDROID;
PFNEGLWAITSYNCKHRPROC eglWaitSyncKHR;
PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR;
/* Atomic functions end */
} SDL_EGL_VideoData;
@ -133,7 +91,7 @@ extern int SDL_EGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
*/
extern int SDL_EGL_LoadLibraryOnly(_THIS, const char *path);
extern int SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display, EGLenum platform);
extern void *SDL_EGL_GetProcAddressInternal(_THIS, const char *proc);
extern SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(_THIS, const char *proc);
extern void SDL_EGL_UnloadLibrary(_THIS);
extern void SDL_EGL_SetRequiredVisualId(_THIS, int visual_id);
extern int SDL_EGL_ChooseConfig(_THIS);

View File

@ -264,7 +264,7 @@ struct SDL_VideoDevice
* OpenGL support
*/
int (*GL_LoadLibrary)(_THIS, const char *path);
void *(*GL_GetProcAddress)(_THIS, const char *proc);
SDL_FunctionPointer (*GL_GetProcAddress)(_THIS, const char *proc);
void (*GL_UnloadLibrary)(_THIS);
SDL_GLContext (*GL_CreateContext)(_THIS, SDL_Window *window);
int (*GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context);

View File

@ -402,8 +402,7 @@ int SDL_GetNumVideoDrivers(void)
return SDL_arraysize(bootstrap) - 1;
}
const char *
SDL_GetVideoDriver(int index)
const char *SDL_GetVideoDriver(int index)
{
if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
return bootstrap[index]->name;
@ -557,8 +556,7 @@ pre_driver_error:
return -1;
}
const char *
SDL_GetCurrentVideoDriver()
const char *SDL_GetCurrentVideoDriver()
{
if (_this == NULL) {
SDL_UninitializedVideo();
@ -567,14 +565,12 @@ SDL_GetCurrentVideoDriver()
return _this->name;
}
SDL_VideoDevice *
SDL_GetVideoDevice(void)
SDL_VideoDevice *SDL_GetVideoDevice(void)
{
return _this;
}
SDL_bool
SDL_OnVideoThread()
SDL_bool SDL_OnVideoThread()
{
return (_this && SDL_ThreadID() == _this->thread) ? SDL_TRUE : SDL_FALSE;
}
@ -662,22 +658,19 @@ int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
return 0;
}
void *
SDL_GetDisplayDriverData(int displayIndex)
void *SDL_GetDisplayDriverData(int displayIndex)
{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
return _this->displays[displayIndex].driverdata;
}
SDL_bool
SDL_IsVideoContextExternal(void)
SDL_bool SDL_IsVideoContextExternal(void)
{
return SDL_GetHintBoolean(SDL_HINT_VIDEO_EXTERNAL_CONTEXT, SDL_FALSE);
}
const char *
SDL_GetDisplayName(int displayIndex)
const char *SDL_GetDisplayName(int displayIndex)
{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
@ -766,8 +759,7 @@ int SDL_GetDisplayDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi)
return -1;
}
SDL_DisplayOrientation
SDL_GetDisplayOrientation(int displayIndex)
SDL_DisplayOrientation SDL_GetDisplayOrientation(int displayIndex)
{
SDL_VideoDisplay *display;
@ -777,8 +769,7 @@ SDL_GetDisplayOrientation(int displayIndex)
return display->orientation;
}
SDL_bool
SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
{
SDL_DisplayMode *modes;
int i, nmodes;
@ -1006,10 +997,7 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di
return NULL;
}
SDL_DisplayMode *
SDL_GetClosestDisplayMode(int displayIndex,
const SDL_DisplayMode *mode,
SDL_DisplayMode *closest)
SDL_DisplayMode *SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
{
SDL_VideoDisplay *display;
@ -1075,8 +1063,7 @@ static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, const SDL_Dis
return 0;
}
SDL_VideoDisplay *
SDL_GetDisplay(int displayIndex)
SDL_VideoDisplay *SDL_GetDisplay(int displayIndex)
{
CHECK_DISPLAY_INDEX(displayIndex, NULL);
@ -1220,8 +1207,7 @@ int SDL_GetWindowDisplayIndex(SDL_Window *window)
}
}
SDL_VideoDisplay *
SDL_GetDisplayForWindow(SDL_Window *window)
SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window)
{
int displayIndex = SDL_GetWindowDisplayIndex(window);
if (displayIndex >= 0) {
@ -1295,8 +1281,7 @@ int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode)
return 0;
}
void *
SDL_GetWindowICCProfile(SDL_Window *window, size_t *size)
void *SDL_GetWindowICCProfile(SDL_Window *window, size_t *size)
{
if (!_this->GetWindowICCProfile) {
SDL_Unsupported();
@ -1305,8 +1290,7 @@ SDL_GetWindowICCProfile(SDL_Window *window, size_t *size)
return _this->GetWindowICCProfile(_this, window, size);
}
Uint32
SDL_GetWindowPixelFormat(SDL_Window *window)
Uint32 SDL_GetWindowPixelFormat(SDL_Window *window)
{
SDL_VideoDisplay *display;
@ -1574,8 +1558,7 @@ static int SDL_DllNotSupported(const char *name)
return SDL_SetError("No dynamic %s support in current SDL video driver (%s)", name, _this->name);
}
SDL_Window *
SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
{
SDL_Window *window;
Uint32 type_flags, graphics_flags;
@ -1775,8 +1758,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
return window;
}
SDL_Window *
SDL_CreateWindowFrom(const void *data)
SDL_Window *SDL_CreateWindowFrom(const void *data)
{
SDL_Window *window;
Uint32 flags = SDL_WINDOW_FOREIGN;
@ -1984,22 +1966,19 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
return 0;
}
SDL_bool
SDL_HasWindows(void)
SDL_bool SDL_HasWindows(void)
{
return _this && _this->windows != NULL;
}
SDL_WindowID
SDL_GetWindowID(SDL_Window *window)
SDL_WindowID SDL_GetWindowID(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, 0);
return window->id;
}
SDL_Window *
SDL_GetWindowFromID(SDL_WindowID id)
SDL_Window *SDL_GetWindowFromID(SDL_WindowID id)
{
SDL_Window *window;
@ -2014,8 +1993,7 @@ SDL_GetWindowFromID(SDL_WindowID id)
return NULL;
}
Uint32
SDL_GetWindowFlags(SDL_Window *window)
Uint32 SDL_GetWindowFlags(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, 0);
@ -2038,8 +2016,7 @@ void SDL_SetWindowTitle(SDL_Window *window, const char *title)
}
}
const char *
SDL_GetWindowTitle(SDL_Window *window)
const char *SDL_GetWindowTitle(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, "");
@ -2067,8 +2044,7 @@ void SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon)
}
}
void *
SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata)
void *SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata)
{
SDL_WindowUserData *prev, *data;
@ -2114,8 +2090,7 @@ SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata)
return NULL;
}
void *
SDL_GetWindowData(SDL_Window *window, const char *name)
void *SDL_GetWindowData(SDL_Window *window, const char *name)
{
SDL_WindowUserData *data;
@ -2671,8 +2646,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
return SDL_CreateSurfaceFrom(pixels, window->w, window->h, pitch, format);
}
SDL_Surface *
SDL_GetWindowSurface(SDL_Window *window)
SDL_Surface *SDL_GetWindowSurface(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, NULL);
@ -2861,28 +2835,24 @@ void SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed)
SDL_UpdateWindowGrab(window);
}
SDL_bool
SDL_GetWindowGrab(SDL_Window *window)
SDL_bool SDL_GetWindowGrab(SDL_Window *window)
{
return SDL_GetWindowKeyboardGrab(window) || SDL_GetWindowMouseGrab(window);
}
SDL_bool
SDL_GetWindowKeyboardGrab(SDL_Window *window)
SDL_bool SDL_GetWindowKeyboardGrab(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
return window == _this->grabbed_window && ((_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0);
}
SDL_bool
SDL_GetWindowMouseGrab(SDL_Window *window)
SDL_bool SDL_GetWindowMouseGrab(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
return window == _this->grabbed_window && ((_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0);
}
SDL_Window *
SDL_GetGrabbedWindow(void)
SDL_Window *SDL_GetGrabbedWindow(void)
{
if (_this->grabbed_window &&
(_this->grabbed_window->flags & (SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED)) != 0) {
@ -2908,8 +2878,7 @@ int SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect)
return 0;
}
const SDL_Rect *
SDL_GetWindowMouseRect(SDL_Window *window)
const SDL_Rect *SDL_GetWindowMouseRect(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, NULL);
@ -3062,8 +3031,7 @@ void SDL_OnWindowFocusLost(SDL_Window *window)
/* !!! FIXME: is this different than SDL_GetKeyboardFocus()?
!!! FIXME: Also, SDL_GetKeyboardFocus() is O(1), this isn't. */
SDL_Window *
SDL_GetFocusWindow(void)
SDL_Window *SDL_GetFocusWindow(void)
{
SDL_Window *window;
@ -3161,8 +3129,7 @@ void SDL_DestroyWindow(SDL_Window *window)
SDL_free(window);
}
SDL_bool
SDL_ScreenSaverEnabled()
SDL_bool SDL_ScreenSaverEnabled()
{
if (_this == NULL) {
return SDL_TRUE;
@ -3270,8 +3237,7 @@ int SDL_GL_LoadLibrary(const char *path)
return retval;
}
void *
SDL_GL_GetProcAddress(const char *proc)
SDL_FunctionPointer SDL_GL_GetProcAddress(const char *proc)
{
void *func;
@ -3292,8 +3258,7 @@ SDL_GL_GetProcAddress(const char *proc)
return func;
}
void *
SDL_EGL_GetProcAddress(const char *proc)
SDL_FunctionPointer SDL_EGL_GetProcAddress(const char *proc)
{
#if SDL_VIDEO_OPENGL_EGL
void *func;
@ -3334,17 +3299,23 @@ void SDL_GL_UnloadLibrary(void)
}
#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
typedef GLenum (APIENTRY* PFNGLGETERRORPROC) (void);
typedef void (APIENTRY* PFNGLGETINTEGERVPROC) (GLenum pname, GLint * params);
typedef const GLubyte *(APIENTRY* PFNGLGETSTRINGPROC) (GLenum name);
#if !SDL_VIDEO_OPENGL
typedef const GLubyte *(APIENTRY* PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
#endif
static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr)
{
return verstr && (SDL_atoi(verstr) >= 3);
}
#endif
#endif /* SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 */
SDL_bool
SDL_GL_ExtensionSupported(const char *extension)
SDL_bool SDL_GL_ExtensionSupported(const char *extension)
{
#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
const GLubyte *(APIENTRY * glGetStringFunc)(GLenum);
PFNGLGETSTRINGPROC glGetStringFunc;
const char *extensions;
const char *start;
const char *where, *terminator;
@ -3362,19 +3333,19 @@ SDL_GL_ExtensionSupported(const char *extension)
/* Lookup the available extensions */
glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString");
if (glGetStringFunc == NULL) {
return SDL_FALSE;
}
if (isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION))) {
const GLubyte *(APIENTRY * glGetStringiFunc)(GLenum, GLuint);
void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params);
PFNGLGETSTRINGIPROC glGetStringiFunc;
PFNGLGETINTEGERVPROC glGetIntegervFunc;
GLint num_exts = 0;
GLint i;
glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi");
glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
glGetStringiFunc = (PFNGLGETSTRINGIPROC)SDL_GL_GetProcAddress("glGetStringi");
glGetIntegervFunc = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress("glGetIntegerv");
if ((glGetStringiFunc == NULL) || (glGetIntegervFunc == NULL)) {
return SDL_FALSE;
}
@ -3650,7 +3621,7 @@ int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
{
#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
GLenum(APIENTRY * glGetErrorFunc)(void);
PFNGLGETERRORPROC glGetErrorFunc;
GLenum attrib = 0;
GLenum error = 0;
@ -3661,8 +3632,8 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
* the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2.
*/
#if SDL_VIDEO_OPENGL
const GLubyte *(APIENTRY * glGetStringFunc)(GLenum name);
void(APIENTRY * glGetFramebufferAttachmentParameterivFunc)(GLenum target, GLenum attachment, GLenum pname, GLint * params);
PFNGLGETSTRINGPROC glGetStringFunc;
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameterivFunc;
GLenum attachment = GL_BACK_LEFT;
GLenum attachmentattrib = 0;
#endif
@ -3844,7 +3815,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
}
#if SDL_VIDEO_OPENGL
glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString");
if (glGetStringFunc == NULL) {
return -1;
}
@ -3852,13 +3823,13 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
if (attachmentattrib && isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION))) {
/* glGetFramebufferAttachmentParameteriv needs to operate on the window framebuffer for this, so bind FBO 0 if necessary. */
GLint current_fbo = 0;
void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params) = SDL_GL_GetProcAddress("glGetIntegerv");
void(APIENTRY * glBindFramebufferFunc)(GLenum target, GLuint fbo) = SDL_GL_GetProcAddress("glBindFramebuffer");
PFNGLGETINTEGERVPROC glGetIntegervFunc = (PFNGLGETINTEGERVPROC) SDL_GL_GetProcAddress("glGetIntegerv");
PFNGLBINDFRAMEBUFFERPROC glBindFramebufferFunc = (PFNGLBINDFRAMEBUFFERPROC)SDL_GL_GetProcAddress("glBindFramebuffer");
if (glGetIntegervFunc && glBindFramebufferFunc) {
glGetIntegervFunc(GL_DRAW_FRAMEBUFFER_BINDING, &current_fbo);
}
glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
glGetFramebufferAttachmentParameterivFunc = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
if (glGetFramebufferAttachmentParameterivFunc) {
if (glBindFramebufferFunc && (current_fbo != 0)) {
glBindFramebufferFunc(GL_DRAW_FRAMEBUFFER, 0);
@ -3873,8 +3844,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
} else
#endif
{
void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params);
glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv");
PFNGLGETINTEGERVPROC glGetIntegervFunc = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress("glGetIntegerv");
if (glGetIntegervFunc) {
glGetIntegervFunc(attrib, (GLint *)value);
} else {
@ -3882,7 +3852,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
}
}
glGetErrorFunc = SDL_GL_GetProcAddress("glGetError");
glGetErrorFunc = (PFNGLGETERRORPROC)SDL_GL_GetProcAddress("glGetError");
if (glGetErrorFunc == NULL) {
return -1;
}
@ -3904,8 +3874,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
#define NOT_AN_OPENGL_WINDOW "The specified window isn't an OpenGL window"
SDL_GLContext
SDL_GL_CreateContext(SDL_Window *window)
SDL_GLContext SDL_GL_CreateContext(SDL_Window *window)
{
SDL_GLContext ctx = NULL;
CHECK_WINDOW_MAGIC(window, NULL);
@ -3963,8 +3932,7 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context)
return retval;
}
SDL_Window *
SDL_GL_GetCurrentWindow(void)
SDL_Window *SDL_GL_GetCurrentWindow(void)
{
if (_this == NULL) {
SDL_UninitializedVideo();
@ -3973,8 +3941,7 @@ SDL_GL_GetCurrentWindow(void)
return (SDL_Window *)SDL_TLSGet(_this->current_glwin_tls);
}
SDL_GLContext
SDL_GL_GetCurrentContext(void)
SDL_GLContext SDL_GL_GetCurrentContext(void)
{
if (_this == NULL) {
SDL_UninitializedVideo();
@ -3983,8 +3950,7 @@ SDL_GL_GetCurrentContext(void)
return (SDL_GLContext)SDL_TLSGet(_this->current_glctx_tls);
}
SDL_EGLDisplay
SDL_EGL_GetCurrentEGLDisplay(void)
SDL_EGLDisplay SDL_EGL_GetCurrentEGLDisplay(void)
{
#if SDL_VIDEO_OPENGL_EGL
if (!_this) {
@ -4002,8 +3968,7 @@ SDL_EGL_GetCurrentEGLDisplay(void)
#endif
}
SDL_EGLConfig
SDL_EGL_GetCurrentEGLConfig(void)
SDL_EGLConfig SDL_EGL_GetCurrentEGLConfig(void)
{
#if SDL_VIDEO_OPENGL_EGL
if (!_this) {
@ -4021,8 +3986,7 @@ SDL_EGL_GetCurrentEGLConfig(void)
#endif
}
SDL_EGLConfig
SDL_EGL_GetWindowEGLSurface(SDL_Window *window)
SDL_EGLConfig SDL_EGL_GetWindowEGLSurface(SDL_Window *window)
{
#if SDL_VIDEO_OPENGL_EGL
if (!_this) {
@ -4183,8 +4147,7 @@ static void CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int
/*
* Sets the window manager icon for the display window.
*/
void
SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
void SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
{
if (icon && _this->SetIcon) {
/* Generate a mask if necessary, and create the icon! */
@ -4266,8 +4229,7 @@ void SDL_ClearComposition(void)
}
}
SDL_bool
SDL_TextInputShown(void)
SDL_bool SDL_TextInputShown(void)
{
if (_this && _this->IsTextInputShown) {
return _this->IsTextInputShown(_this);
@ -4276,8 +4238,7 @@ SDL_TextInputShown(void)
return SDL_FALSE;
}
SDL_bool
SDL_TextInputActive(void)
SDL_bool SDL_TextInputActive(void)
{
return SDL_EventEnabled(SDL_TEXTINPUT);
}
@ -4309,8 +4270,7 @@ void SDL_SetTextInputRect(const SDL_Rect *rect)
}
}
SDL_bool
SDL_HasScreenKeyboardSupport(void)
SDL_bool SDL_HasScreenKeyboardSupport(void)
{
if (_this && _this->HasScreenKeyboardSupport) {
return _this->HasScreenKeyboardSupport(_this);
@ -4318,8 +4278,7 @@ SDL_HasScreenKeyboardSupport(void)
return SDL_FALSE;
}
SDL_bool
SDL_ScreenKeyboardShown(SDL_Window *window)
SDL_bool SDL_ScreenKeyboardShown(SDL_Window *window)
{
if (window && _this && _this->IsScreenKeyboardShown) {
return _this->IsScreenKeyboardShown(_this, window);
@ -4552,8 +4511,7 @@ int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *messag
#endif
}
SDL_bool
SDL_ShouldAllowTopmost(void)
SDL_bool SDL_ShouldAllowTopmost(void)
{
return SDL_GetHintBoolean(SDL_HINT_ALLOW_TOPMOST, SDL_TRUE);
}
@ -4658,7 +4616,7 @@ int SDL_Vulkan_LoadLibrary(const char *path)
return retval;
}
void *SDL_Vulkan_GetVkGetInstanceProcAddr(void)
SDL_FunctionPointer SDL_Vulkan_GetVkGetInstanceProcAddr(void)
{
if (_this == NULL) {
SDL_UninitializedVideo();
@ -4668,7 +4626,7 @@ void *SDL_Vulkan_GetVkGetInstanceProcAddr(void)
SDL_SetError("No Vulkan loader has been loaded");
return NULL;
}
return _this->vulkan_config.vkGetInstanceProcAddr;
return (SDL_FunctionPointer)_this->vulkan_config.vkGetInstanceProcAddr;
}
void SDL_Vulkan_UnloadLibrary(void)
@ -4732,8 +4690,7 @@ void SDL_Vulkan_GetDrawableSize(SDL_Window *window, int *w, int *h)
}
}
SDL_MetalView
SDL_Metal_CreateView(SDL_Window *window)
SDL_MetalView SDL_Metal_CreateView(SDL_Window *window)
{
CHECK_WINDOW_MAGIC(window, NULL);
@ -4760,8 +4717,7 @@ void SDL_Metal_DestroyView(SDL_MetalView view)
}
}
void *
SDL_Metal_GetLayer(SDL_MetalView view)
void *SDL_Metal_GetLayer(SDL_MetalView view)
{
if (_this && _this->Metal_GetLayer) {
if (view) {

View File

@ -70,7 +70,7 @@ struct SDL_GLDriverData
/* OpenGL functions */
extern int Cocoa_GL_LoadLibrary(_THIS, const char *path);
extern void *Cocoa_GL_GetProcAddress(_THIS, const char *proc);
extern SDL_FunctionPointer Cocoa_GL_GetProcAddress(_THIS, const char *proc);
extern void Cocoa_GL_UnloadLibrary(_THIS);
extern SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window);
extern int Cocoa_GL_MakeCurrent(_THIS, SDL_Window *window,

View File

@ -239,8 +239,7 @@ int Cocoa_GL_LoadLibrary(_THIS, const char *path)
return 0;
}
void *
Cocoa_GL_GetProcAddress(_THIS, const char *proc)
SDL_FunctionPointer Cocoa_GL_GetProcAddress(_THIS, const char *proc)
{
return SDL_LoadFunction(_this->gl_config.dll_handle, proc);
}
@ -251,8 +250,7 @@ void Cocoa_GL_UnloadLibrary(_THIS)
_this->gl_config.dll_handle = NULL;
}
SDL_GLContext
Cocoa_GL_CreateContext(_THIS, SDL_Window *window)
SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);

View File

@ -38,8 +38,7 @@ void Emscripten_GLES_UnloadLibrary(_THIS)
{
}
void *
Emscripten_GLES_GetProcAddress(_THIS, const char *proc)
SDL_FunctionPointer Emscripten_GLES_GetProcAddress(_THIS, const char *proc)
{
return emscripten_webgl_get_proc_address(proc);
}
@ -72,8 +71,7 @@ int Emscripten_GLES_GetSwapInterval(_THIS, int *interval)
}
}
SDL_GLContext
Emscripten_GLES_CreateContext(_THIS, SDL_Window *window)
SDL_GLContext Emscripten_GLES_CreateContext(_THIS, SDL_Window *window)
{
SDL_WindowData *window_data;

View File

@ -30,7 +30,7 @@
/* OpenGLES functions */
extern int Emscripten_GLES_LoadLibrary(_THIS, const char *path);
extern void Emscripten_GLES_UnloadLibrary(_THIS);
extern void *Emscripten_GLES_GetProcAddress(_THIS, const char *proc);
extern SDL_FunctionPointer Emscripten_GLES_GetProcAddress(_THIS, const char *proc);
extern int Emscripten_GLES_SetSwapInterval(_THIS, int interval);
extern int Emscripten_GLES_GetSwapInterval(_THIS, int *interval);
extern SDL_GLContext Emscripten_GLES_CreateContext(_THIS, SDL_Window *window);

View File

@ -63,7 +63,7 @@ int HAIKU_GL_LoadLibrary(_THIS, const char *path)
return 0;
}
void *HAIKU_GL_GetProcAddress(_THIS, const char *proc)
SDL_FunctionPointer HAIKU_GL_GetProcAddress(_THIS, const char *proc)
{
if (_this->gl_config.dll_handle != NULL) {
void *location = NULL;

View File

@ -31,7 +31,7 @@ extern "C" {
#include "../SDL_sysvideo.h"
extern int HAIKU_GL_LoadLibrary(_THIS, const char *path); /* FIXME */
extern void *HAIKU_GL_GetProcAddress(_THIS, const char *proc); /* FIXME */
extern SDL_FunctionPointer HAIKU_GL_GetProcAddress(_THIS, const char *proc); /* FIXME */
extern void HAIKU_GL_UnloadLibrary(_THIS); /* TODO */
extern int HAIKU_GL_MakeCurrent(_THIS, SDL_Window *window,
SDL_GLContext context);

View File

@ -141,7 +141,7 @@ int KMSDRM_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info
/* OpenGL/OpenGL ES functions */
int KMSDRM_GLES_LoadLibrary(_THIS, const char *path);
void *KMSDRM_GLES_GetProcAddress(_THIS, const char *proc);
SDL_FunctionPointer KMSDRM_GLES_GetProcAddress(_THIS, const char *proc);
void KMSDRM_GLES_UnloadLibrary(_THIS);
SDL_GLContext KMSDRM_GLES_CreateContext(_THIS, SDL_Window *window);
int KMSDRM_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);

View File

@ -54,8 +54,7 @@ int PSP_GL_LoadLibrary(_THIS, const char *path)
GLSTUB(glOrtho,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
GLdouble zNear, GLdouble zFar))
*/
void *
PSP_GL_GetProcAddress(_THIS, const char *proc)
SDL_FunctionPointer PSP_GL_GetProcAddress(_THIS, const char *proc)
{
return eglGetProcAddress(proc);
}
@ -68,8 +67,7 @@ void PSP_GL_UnloadLibrary(_THIS)
static EGLint width = 480;
static EGLint height = 272;
SDL_GLContext
PSP_GL_CreateContext(_THIS, SDL_Window *window)
SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window)
{
SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;

View File

@ -35,7 +35,7 @@ typedef struct SDL_GLDriverData
uint32_t swapinterval;
} SDL_GLDriverData;
extern void *PSP_GL_GetProcAddress(_THIS, const char *proc);
extern SDL_FunctionPointer PSP_GL_GetProcAddress(_THIS, const char *proc);
extern int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);
extern void PSP_GL_SwapBuffers(_THIS);

View File

@ -70,7 +70,7 @@ void PSP_DestroyWindow(_THIS, SDL_Window *window);
/* OpenGL/OpenGL ES functions */
int PSP_GL_LoadLibrary(_THIS, const char *path);
void *PSP_GL_GetProcAddress(_THIS, const char *proc);
SDL_FunctionPointer PSP_GL_GetProcAddress(_THIS, const char *proc);
void PSP_GL_UnloadLibrary(_THIS);
SDL_GLContext PSP_GL_CreateContext(_THIS, SDL_Window *window);
int PSP_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);

View File

@ -82,7 +82,7 @@ void RPI_DestroyWindow(_THIS, SDL_Window *window);
/* OpenGL/OpenGL ES functions */
int RPI_GLES_LoadLibrary(_THIS, const char *path);
void *RPI_GLES_GetProcAddress(_THIS, const char *proc);
SDL_FunctionPointer RPI_GLES_GetProcAddress(_THIS, const char *proc);
void RPI_GLES_UnloadLibrary(_THIS);
SDL_GLContext RPI_GLES_CreateContext(_THIS, SDL_Window *window);
int RPI_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);

View File

@ -32,7 +32,7 @@ extern void UIKit_GL_GetDrawableSize(_THIS, SDL_Window *window,
extern int UIKit_GL_SwapWindow(_THIS, SDL_Window *window);
extern SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window *window);
extern void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context);
extern void *UIKit_GL_GetProcAddress(_THIS, const char *proc);
extern SDL_FunctionPointer UIKit_GL_GetProcAddress(_THIS, const char *proc);
extern int UIKit_GL_LoadLibrary(_THIS, const char *path);
extern void UIKit_GL_RestoreCurrentContext(void);

View File

@ -51,8 +51,7 @@
@end
void *
UIKit_GL_GetProcAddress(_THIS, const char *proc)
SDL_FunctionPointer UIKit_GL_GetProcAddress(_THIS, const char *proc)
{
/* Look through all SO's for the proc symbol. Here's why:
* -Looking for the path to the OpenGL Library seems not to work in the iOS Simulator.
@ -128,8 +127,7 @@ int UIKit_GL_SwapWindow(_THIS, SDL_Window *window)
return 0;
}
SDL_GLContext
UIKit_GL_CreateContext(_THIS, SDL_Window *window)
SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window *window)
{
@autoreleasepool {
SDLEAGLContext *context = nil;

View File

@ -26,6 +26,6 @@
extern SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window *window);
extern int VITA_GL_LoadLibrary(_THIS, const char *path);
extern void *VITA_GL_GetProcAddress(_THIS, const char *proc);
extern SDL_FunctionPointer VITA_GL_GetProcAddress(_THIS, const char *proc);
#endif /* SDL_vitagl_pvr_c_h_ */

View File

@ -64,8 +64,7 @@ int VITA_GLES_LoadLibrary(_THIS, const char *path)
return 0;
}
void *
VITA_GLES_GetProcAddress(_THIS, const char *proc)
SDL_FunctionPointer VITA_GLES_GetProcAddress(_THIS, const char *proc)
{
return eglGetProcAddress(proc);
}
@ -78,8 +77,7 @@ void VITA_GLES_UnloadLibrary(_THIS)
static EGLint width = 960;
static EGLint height = 544;
SDL_GLContext
VITA_GLES_CreateContext(_THIS, SDL_Window *window)
SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window *window)
{
SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;

View File

@ -38,7 +38,7 @@ typedef struct SDL_GLDriverData
uint32_t swapinterval;
} SDL_GLDriverData;
extern void *VITA_GLES_GetProcAddress(_THIS, const char *proc);
extern SDL_FunctionPointer VITA_GLES_GetProcAddress(_THIS, const char *proc);
extern int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);
extern void VITA_GLES_SwapBuffers(_THIS);

View File

@ -87,12 +87,12 @@ void VITA_DestroyWindow(_THIS, SDL_Window *window);
/* OpenGL functions */
int VITA_GL_LoadLibrary(_THIS, const char *path);
SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window *window);
void *VITA_GL_GetProcAddress(_THIS, const char *proc);
SDL_FunctionPointer VITA_GL_GetProcAddress(_THIS, const char *proc);
#endif
/* OpenGLES functions */
int VITA_GLES_LoadLibrary(_THIS, const char *path);
void *VITA_GLES_GetProcAddress(_THIS, const char *proc);
SDL_FunctionPointer VITA_GLES_GetProcAddress(_THIS, const char *proc);
void VITA_GLES_UnloadLibrary(_THIS);
SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window *window);
int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context);

View File

@ -131,7 +131,7 @@ int WIN_GL_LoadLibrary(_THIS, const char *path)
/* Load function pointers */
handle = _this->gl_config.dll_handle;
/* *INDENT-OFF* */ /* clang-format off */
_this->gl_data->wglGetProcAddress = (void *(WINAPI *)(const char *))
_this->gl_data->wglGetProcAddress = (PROC (WINAPI *)(const char *))
SDL_LoadFunction(handle, "wglGetProcAddress");
_this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC))
SDL_LoadFunction(handle, "wglCreateContext");
@ -212,8 +212,7 @@ int WIN_GL_LoadLibrary(_THIS, const char *path)
return 0;
}
void *
WIN_GL_GetProcAddress(_THIS, const char *proc)
SDL_FunctionPointer WIN_GL_GetProcAddress(_THIS, const char *proc)
{
void *func;
@ -477,8 +476,10 @@ void WIN_GL_InitExtensions(_THIS)
_this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE;
if (HasExtension("WGL_EXT_swap_control", extensions)) {
_this->gl_data->wglSwapIntervalEXT =
(BOOL (WINAPI *)(int))
WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
_this->gl_data->wglGetSwapIntervalEXT =
(int (WINAPI *)(void))
WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
if (HasExtension("WGL_EXT_swap_control_tear", extensions)) {
_this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE;
@ -687,8 +688,7 @@ int WIN_GL_SetupWindow(_THIS, SDL_Window *window)
return retval;
}
SDL_bool
WIN_GL_UseEGL(_THIS)
SDL_bool WIN_GL_UseEGL(_THIS)
{
SDL_assert(_this->gl_data != NULL);
SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES);
@ -696,8 +696,7 @@ WIN_GL_UseEGL(_THIS)
return SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE) || _this->gl_config.major_version == 1 || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor); /* No WGL extension for OpenGL ES 1.x profiles. */
}
SDL_GLContext
WIN_GL_CreateContext(_THIS, SDL_Window *window)
SDL_GLContext WIN_GL_CreateContext(_THIS, SDL_Window *window)
{
HDC hdc = ((SDL_WindowData *)window->driverdata)->hdc;
HGLRC context, share_context;
@ -894,8 +893,7 @@ void WIN_GL_DeleteContext(_THIS, SDL_GLContext context)
_this->gl_data->wglDeleteContext((HGLRC)context);
}
SDL_bool
WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window *fromWindow, SDL_Window *toWindow)
SDL_bool WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window *fromWindow, SDL_Window *toWindow)
{
HDC hfromdc = ((SDL_WindowData *)fromWindow->driverdata)->hdc;
HDC htodc = ((SDL_WindowData *)toWindow->driverdata)->hdc;

View File

@ -76,7 +76,7 @@ struct SDL_GLDriverData
} es_profile_max_supported_version;
/* *INDENT-OFF* */ /* clang-format off */
void *(WINAPI *wglGetProcAddress)(const char *proc);
PROC (WINAPI *wglGetProcAddress)(const char *proc);
HGLRC (WINAPI *wglCreateContext)(HDC hdc);
BOOL (WINAPI *wglDeleteContext)(HGLRC hglrc);
BOOL (WINAPI *wglMakeCurrent)(HDC hdc, HGLRC hglrc);
@ -103,7 +103,7 @@ struct SDL_GLDriverData
/* OpenGL functions */
extern int WIN_GL_LoadLibrary(_THIS, const char *path);
extern void *WIN_GL_GetProcAddress(_THIS, const char *proc);
extern SDL_FunctionPointer WIN_GL_GetProcAddress(_THIS, const char *proc);
extern void WIN_GL_UnloadLibrary(_THIS);
extern SDL_bool WIN_GL_UseEGL(_THIS);
extern int WIN_GL_SetupWindow(_THIS, SDL_Window *window);

View File

@ -202,7 +202,7 @@ int X11_GL_LoadLibrary(_THIS, const char *path)
(Bool(*)(Display *, int *, int *))
GL_LoadFunction(handle, "glXQueryExtension");
_this->gl_data->glXGetProcAddress =
(void *(*)(const GLubyte *))
(__GLXextFuncPtr (*)(const GLubyte *))
GL_LoadFunction(handle, "glXGetProcAddressARB");
_this->gl_data->glXChooseVisual =
(XVisualInfo * (*)(Display *, int, int *))
@ -270,8 +270,7 @@ int X11_GL_LoadLibrary(_THIS, const char *path)
return 0;
}
void *
X11_GL_GetProcAddress(_THIS, const char *proc)
SDL_FunctionPointer X11_GL_GetProcAddress(_THIS, const char *proc)
{
if (_this->gl_data->glXGetProcAddress) {
return _this->gl_data->glXGetProcAddress((const GLubyte *)proc);
@ -604,8 +603,7 @@ static int X11_GL_GetAttributes(_THIS, Display *display, int screen, int *attrib
return i;
}
XVisualInfo *
X11_GL_GetVisual(_THIS, Display *display, int screen)
XVisualInfo *X11_GL_GetVisual(_THIS, Display *display, int screen)
{
/* 64 seems nice. */
int attribs[64];
@ -676,8 +674,7 @@ static int X11_GL_ErrorHandler(Display *d, XErrorEvent *e)
return (0);
}
SDL_bool
X11_GL_UseEGL(_THIS)
SDL_bool X11_GL_UseEGL(_THIS)
{
SDL_assert(_this->gl_data != NULL);
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) {
@ -690,8 +687,7 @@ X11_GL_UseEGL(_THIS)
|| _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor));
}
SDL_GLContext
X11_GL_CreateContext(_THIS, SDL_Window *window)
SDL_GLContext X11_GL_CreateContext(_THIS, SDL_Window *window)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
Display *display = data->videodata->display;

View File

@ -27,6 +27,8 @@
#include <SDL3/SDL_opengl.h>
#include <GL/glx.h>
typedef void (*__GLXextFuncPtr)(void);
struct SDL_GLDriverData
{
int errorBase, eventBase;
@ -49,7 +51,7 @@ struct SDL_GLDriverData
} es_profile_max_supported_version;
Bool (*glXQueryExtension)(Display *, int *, int *);
void *(*glXGetProcAddress)(const GLubyte *);
__GLXextFuncPtr (*glXGetProcAddress)(const GLubyte *);
XVisualInfo *(*glXChooseVisual)(Display *, int, int *);
GLXContext (*glXCreateContext)(Display *, XVisualInfo *, GLXContext, Bool);
GLXContext (*glXCreateContextAttribsARB)(Display *, GLXFBConfig, GLXContext, Bool, const int *);
@ -67,7 +69,7 @@ struct SDL_GLDriverData
/* OpenGL functions */
extern int X11_GL_LoadLibrary(_THIS, const char *path);
extern void *X11_GL_GetProcAddress(_THIS, const char *proc);
extern SDL_FunctionPointer X11_GL_GetProcAddress(_THIS, const char *proc);
extern void X11_GL_UnloadLibrary(_THIS);
extern SDL_bool X11_GL_UseEGL(_THIS);
extern XVisualInfo *X11_GL_GetVisual(_THIS, Display *display, int screen);

View File

@ -114,7 +114,7 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path)
goto fail;
}
videoData->vulkan_XGetXCBConnection =
SDL_LoadFunction(videoData->vulkan_xlib_xcb_library, "XGetXCBConnection");
(PFN_XGetXCBConnection)SDL_LoadFunction(videoData->vulkan_xlib_xcb_library, "XGetXCBConnection");
if (!videoData->vulkan_XGetXCBConnection) {
SDL_UnloadObject(videoData->vulkan_xlib_xcb_library);
goto fail;

View File

@ -45,7 +45,7 @@ static int LoadContext(GL_Context *data)
#else
#define SDL_PROC(ret, func, params) \
do { \
data->func = SDL_GL_GetProcAddress(#func); \
data->func = (ret (APIENTRY *) params)SDL_GL_GetProcAddress(#func); \
if (!data->func) { \
return SDL_SetError("Couldn't load GL function %s: %s", #func, SDL_GetError()); \
} \

View File

@ -71,7 +71,7 @@ static int LoadContext(GLES2_Context *data)
#else
#define SDL_PROC(ret, func, params) \
do { \
data->func = SDL_GL_GetProcAddress(#func); \
data->func = (ret (APIENTRY *) params)SDL_GL_GetProcAddress(#func); \
if (!data->func) { \
return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \
} \

View File

@ -73,7 +73,7 @@ static int LoadContext(GLES2_Context *data)
#else
#define SDL_PROC(ret, func, params) \
do { \
data->func = SDL_GL_GetProcAddress(#func); \
data->func = (ret (APIENTRY *) params)SDL_GL_GetProcAddress(#func); \
if (!data->func) { \
return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \
} \

View File

@ -192,7 +192,7 @@ static void quit(int rc)
static void loadGlobalFunctions(void)
{
vkGetInstanceProcAddr = SDL_Vulkan_GetVkGetInstanceProcAddr();
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr();
if (!vkGetInstanceProcAddr) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_Vulkan_GetVkGetInstanceProcAddr(): %s\n",