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
This commit is contained in:
Sam Lantinga
2023-01-09 14:55:12 -08:00
parent 7275b2b352
commit e9b86eebf3
43 changed files with 272 additions and 356 deletions
+8
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.
+2 -2
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.
+7
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
}
+2 -2
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().
+7 -1
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()
+1 -1
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()); \
} \
+44 -44
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
+4 -4
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)
+2 -4
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) {
+2 -4
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);
+2 -4
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) {
+1 -1
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()); \
} \
+1 -1
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()); \
} \
+41 -40
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);
+28 -70
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);
+1 -1
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);
+73 -117
View File
File diff suppressed because it is too large Load Diff
+1 -1
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,
+2 -4
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);
@@ -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;
@@ -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);
+1 -1
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;
+1 -1
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);
+1 -1
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);
+2 -4
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;
+1 -1
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);
+1 -1
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);
+1 -1
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);
+1 -1
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);
+2 -4
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;
+1 -1
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_ */
+2 -4
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;
+1 -1
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);
+2 -2
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);
+7 -9
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;
+2 -2
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);
+5 -9
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;
+4 -2
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);
+1 -1
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;
+1 -1
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()); \
} \
+1 -1
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()); \
} \
+1 -1
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()); \
} \
+1 -1
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",