Commit Graph

67 Commits

Author SHA1 Message Date
Sam Lantinga a90ad3b0e2 Removed SDL_bool in favor of plain bool
We require stdbool.h in the build environment, so we might as well use the plain bool type.

If your environment doesn't have stdbool.h, this simple replacement will suffice:
typedef signed char bool;
2024-09-18 08:32:30 -07:00
Sam Lantinga 8d223b3037 Renamed atomic functions to match SDL 3.0 naming convention
This will also allow us to cleanly add atomic operations for other types in the future.
2024-09-17 08:53:27 -07:00
Sam Lantinga 9ff3446f03 Use SDL_bool instead an int return code in the SDL API
Most SDL functions used to indicate success or failure using an int return code. These functions have been changed to return SDL_bool.

Here is a coccinelle patch to change code that previously compared the return value to 0 and changes it to a boolean test:
@ bool_return_type  @
identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAlternateImage|SDL_AddVulkanRenderSemaphores|SDL_BindAudioStream|SDL_BindAudioStreams|SDL_BlitSurface|SDL_BlitSurface9Grid|SDL_BlitSurfaceScaled|SDL_BlitSurfaceTiled|SDL_BlitSurfaceTiledWithScale|SDL_BlitSurfaceUnchecked|SDL_BlitSurfaceUncheckedScaled|SDL_CaptureMouse|SDL_ClearAudioStream|SDL_ClearClipboardData|SDL_ClearComposition|SDL_ClearError|SDL_ClearProperty|SDL_ClearSurface|SDL_CloseIO|SDL_CloseStorage|SDL_ConvertAudioSamples|SDL_ConvertEventToRenderCoordinates|SDL_ConvertPixels|SDL_ConvertPixelsAndColorspace|SDL_CopyFile|SDL_CopyProperties|SDL_CopyStorageFile|SDL_CreateDirectory|SDL_CreateStorageDirectory|SDL_CreateWindowAndRenderer|SDL_DateTimeToTime|SDL_DestroyWindowSurface|SDL_DetachVirtualJoystick|SDL_DisableScreenSaver|SDL_EnableScreenSaver|SDL_EnumerateDirectory|SDL_EnumerateProperties|SDL_EnumerateStorageDirectory|SDL_FillSurfaceRect|SDL_FillSurfaceRects|SDL_FlashWindow|SDL_FlipSurface|SDL_FlushAudioStream|SDL_FlushRenderer|SDL_GL_DestroyContext|SDL_GL_GetAttribute|SDL_GL_GetSwapInterval|SDL_GL_LoadLibrary|SDL_GL_MakeCurrent|SDL_GL_SetAttribute|SDL_GL_SetSwapInterval|SDL_GL_SwapWindow|SDL_GetAudioDeviceFormat|SDL_GetAudioStreamFormat|SDL_GetCameraFormat|SDL_GetClosestFullscreenDisplayMode|SDL_GetCurrentRenderOutputSize|SDL_GetCurrentTime|SDL_GetDXGIOutputInfo|SDL_GetDateTimeLocalePreferences|SDL_GetDisplayBounds|SDL_GetDisplayUsableBounds|SDL_GetGDKDefaultUser|SDL_GetGDKTaskQueue|SDL_GetGamepadSensorData|SDL_GetGamepadTouchpadFinger|SDL_GetHapticEffectStatus|SDL_GetJoystickBall|SDL_GetMasksForPixelFormat|SDL_GetPathInfo|SDL_GetRectUnion|SDL_GetRectUnionFloat|SDL_GetRenderClipRect|SDL_GetRenderColorScale|SDL_GetRenderDrawBlendMode|SDL_GetRenderDrawColor|SDL_GetRenderDrawColorFloat|SDL_GetRenderLogicalPresentation|SDL_GetRenderLogicalPresentationRect|SDL_GetRenderOutputSize|SDL_GetRenderSafeArea|SDL_GetRenderScale|SDL_GetRenderVSync|SDL_GetRenderViewport|SDL_GetSensorData|SDL_GetStorageFileSize|SDL_GetStoragePathInfo|SDL_GetSurfaceAlphaMod|SDL_GetSurfaceBlendMode|SDL_GetSurfaceClipRect|SDL_GetSurfaceColorKey|SDL_GetSurfaceColorMod|SDL_GetTextInputArea|SDL_GetTextureAlphaMod|SDL_GetTextureAlphaModFloat|SDL_GetTextureBlendMode|SDL_GetTextureColorMod|SDL_GetTextureColorModFloat|SDL_GetTextureScaleMode|SDL_GetTextureSize|SDL_GetWindowAspectRatio|SDL_GetWindowBordersSize|SDL_GetWindowMaximumSize|SDL_GetWindowMinimumSize|SDL_GetWindowPosition|SDL_GetWindowRelativeMouseMode|SDL_GetWindowSafeArea|SDL_GetWindowSize|SDL_GetWindowSizeInPixels|SDL_GetWindowSurfaceVSync|SDL_HideCursor|SDL_HideWindow|SDL_Init|SDL_InitHapticRumble|SDL_InitSubSystem|SDL_LoadWAV|SDL_LoadWAV_IO|SDL_LockAudioStream|SDL_LockProperties|SDL_LockSurface|SDL_LockTexture|SDL_LockTextureToSurface|SDL_MaximizeWindow|SDL_MinimizeWindow|SDL_MixAudio|SDL_OpenURL|SDL_OutOfMemory|SDL_PauseAudioDevice|SDL_PauseAudioStreamDevice|SDL_PauseHaptic|SDL_PlayHapticRumble|SDL_PremultiplyAlpha|SDL_PremultiplySurfaceAlpha|SDL_PushEvent|SDL_PutAudioStreamData|SDL_RaiseWindow|SDL_ReadStorageFile|SDL_ReadSurfacePixel|SDL_ReadSurfacePixelFloat|SDL_RegisterApp|SDL_ReloadGamepadMappings|SDL_RemovePath|SDL_RemoveStoragePath|SDL_RemoveTimer|SDL_RenamePath|SDL_RenameStoragePath|SDL_RenderClear|SDL_RenderCoordinatesFromWindow|SDL_RenderCoordinatesToWindow|SDL_RenderFillRect|SDL_RenderFillRects|SDL_RenderGeometry|SDL_RenderGeometryRaw|SDL_RenderLine|SDL_RenderLines|SDL_RenderPoint|SDL_RenderPoints|SDL_RenderPresent|SDL_RenderRect|SDL_RenderRects|SDL_RenderTexture|SDL_RenderTexture9Grid|SDL_RenderTextureRotated|SDL_RenderTextureTiled|SDL_RequestAndroidPermission|SDL_RestoreWindow|SDL_ResumeAudioDevice|SDL_ResumeAudioStreamDevice|SDL_ResumeHaptic|SDL_RumbleGamepad|SDL_RumbleGamepadTriggers|SDL_RumbleJoystick|SDL_RumbleJoystickTriggers|SDL_RunHapticEffect|SDL_SaveBMP|SDL_SaveBMP_IO|SDL_SendAndroidMessage|SDL_SendGamepadEffect|SDL_SendJoystickEffect|SDL_SendJoystickVirtualSensorData|SDL_SetAppMetadata|SDL_SetAppMetadataProperty|SDL_SetAudioDeviceGain|SDL_SetAudioPostmixCallback|SDL_SetAudioStreamFormat|SDL_SetAudioStreamFrequencyRatio|SDL_SetAudioStreamGain|SDL_SetAudioStreamGetCallback|SDL_SetAudioStreamInputChannelMap|SDL_SetAudioStreamOutputChannelMap|SDL_SetAudioStreamPutCallback|SDL_SetBooleanProperty|SDL_SetClipboardData|SDL_SetClipboardText|SDL_SetCursor|SDL_SetFloatProperty|SDL_SetGamepadLED|SDL_SetGamepadMapping|SDL_SetGamepadPlayerIndex|SDL_SetGamepadSensorEnabled|SDL_SetHapticAutocenter|SDL_SetHapticGain|SDL_SetJoystickLED|SDL_SetJoystickPlayerIndex|SDL_SetJoystickVirtualAxis|SDL_SetJoystickVirtualBall|SDL_SetJoystickVirtualButton|SDL_SetJoystickVirtualHat|SDL_SetJoystickVirtualTouchpad|SDL_SetLinuxThreadPriority|SDL_SetLinuxThreadPriorityAndPolicy|SDL_SetLogPriorityPrefix|SDL_SetMemoryFunctions|SDL_SetNumberProperty|SDL_SetPaletteColors|SDL_SetPointerProperty|SDL_SetPointerPropertyWithCleanup|SDL_SetPrimarySelectionText|SDL_SetRenderClipRect|SDL_SetRenderColorScale|SDL_SetRenderDrawBlendMode|SDL_SetRenderDrawColor|SDL_SetRenderDrawColorFloat|SDL_SetRenderLogicalPresentation|SDL_SetRenderScale|SDL_SetRenderTarget|SDL_SetRenderVSync|SDL_SetRenderViewport|SDL_SetScancodeName|SDL_SetStringProperty|SDL_SetSurfaceAlphaMod|SDL_SetSurfaceBlendMode|SDL_SetSurfaceColorKey|SDL_SetSurfaceColorMod|SDL_SetSurfaceColorspace|SDL_SetSurfacePalette|SDL_SetSurfaceRLE|SDL_SetTLS|SDL_SetTextInputArea|SDL_SetTextureAlphaMod|SDL_SetTextureAlphaModFloat|SDL_SetTextureBlendMode|SDL_SetTextureColorMod|SDL_SetTextureColorModFloat|SDL_SetTextureScaleMode|SDL_SetThreadPriority|SDL_SetWindowAlwaysOnTop|SDL_SetWindowAspectRatio|SDL_SetWindowBordered|SDL_SetWindowFocusable|SDL_SetWindowFullscreen|SDL_SetWindowFullscreenMode|SDL_SetWindowHitTest|SDL_SetWindowIcon|SDL_SetWindowKeyboardGrab|SDL_SetWindowMaximumSize|SDL_SetWindowMinimumSize|SDL_SetWindowModalFor|SDL_SetWindowMouseGrab|SDL_SetWindowMouseRect|SDL_SetWindowOpacity|SDL_SetWindowPosition|SDL_SetWindowRelativeMouseMode|SDL_SetWindowResizable|SDL_SetWindowShape|SDL_SetWindowSize|SDL_SetWindowSurfaceVSync|SDL_SetWindowTitle|SDL_SetiOSAnimationCallback|SDL_ShowAndroidToast|SDL_ShowCursor|SDL_ShowMessageBox|SDL_ShowSimpleMessageBox|SDL_ShowWindow|SDL_ShowWindowSystemMenu|SDL_StartTextInput|SDL_StartTextInputWithProperties|SDL_StopHapticEffect|SDL_StopHapticEffects|SDL_StopHapticRumble|SDL_StopTextInput|SDL_SyncWindow|SDL_TimeToDateTime|SDL_TryLockMutex|SDL_TryLockRWLockForReading|SDL_TryLockRWLockForWriting|SDL_TryWaitSemaphore|SDL_UnlockAudioStream|SDL_UpdateHapticEffect|SDL_UpdateNVTexture|SDL_UpdateTexture|SDL_UpdateWindowSurface|SDL_UpdateWindowSurfaceRects|SDL_UpdateYUVTexture|SDL_Vulkan_CreateSurface|SDL_Vulkan_LoadLibrary|SDL_WaitConditionTimeout|SDL_WaitSemaphoreTimeout|SDL_WarpMouseGlobal|SDL_WriteStorageFile|SDL_WriteSurfacePixel|SDL_WriteSurfacePixelFloat)$";
@@
(
  func(
  ...
  )
- == 0
|
- func(
+ !func(
  ...
  )
- < 0
|
- func(
+ !func(
  ...
  )
- != 0
|
- func(
+ !func(
  ...
  )
- == -1
)
2024-08-27 10:31:46 -07:00
Anonymous Maarten 6f1136c6ce testgles2: fix leaks 2024-07-27 13:06:54 +02:00
Sam Lantinga a7c0192017 Renamed SDL_PostSemaphore() to SDL_SignalSemphore() 2024-07-24 13:37:40 -07:00
Ryan C. Gordon af2dbf3ff3 video: Rename SDL_GL_DeleteContext to SDL_GL_DestroyContext.
Turns out that there isn't a strong OpenGL naming convention for "Delete" ...
WGL offers "wglDeleteContext" but the GLX equivalent is "glxDestroyContext"
and then EGL sealed the deal by going with Destroy as well! Since it matches
SDL3 naming conventions (Create/Destroy), we're renaming it.

Fixes #10197.
2024-07-10 15:54:08 -04:00
Anonymous Maarten a919774fe4
Build with -Wfloat-conversion + fix all warnings 2024-06-03 21:33:29 +00:00
Sam Lantinga 17520c2e6e Removed SDL_RendererFlags
The flags parameter has been removed from SDL_CreateRenderer() and SDL_RENDERER_PRESENTVSYNC has been replaced with SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER during window creation and SDL_PROP_RENDERER_VSYNC_NUMBER after renderer creation.

SDL_SetRenderVSync() now takes additional values besides 0 and 1.

The maximum texture size has been removed from SDL_RendererInfo, replaced with SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER.
2024-05-13 15:06:11 -07:00
Ozkan Sezer 205c417f74 testgles2.c, testgles2_sdf.c: adjust for new SDL_PLATFORM_WINDOWS meaning. 2024-01-24 21:20:50 +03:00
Anonymous Maarten 31d133db40
Define SDL_PLATFORM_* macros instead of underscored ones (#8875) 2024-01-24 01:40:51 +00:00
Sam Lantinga a2665f54c8 Updated the atomic API for SDL 3.0 naming conventions
Fixes https://github.com/libsdl-org/SDL/issues/7388
2024-01-18 04:41:34 -08:00
Sam Lantinga 5b3ee51c6c Updated copyright for 2024 2024-01-01 13:15:26 -08:00
Sylvain d8600f717e Pointer as bool (libsdl-org#7214) 2023-11-09 14:18:36 -08:00
Frank Praznik ef4ce8cec5 test: Add flag to suspend drawing when occluded
Add the flag "--suspend-when-occluded" to testgl, testgles2, and testsprite, which, when used, will suspend rendering and throttle the event loop when the occlusion flag is set on the window.
2023-07-18 16:42:05 -04:00
Ozkan Sezer 5c019bc97e style fixes for SDL_PROC macros. 2023-05-19 14:10:02 +03:00
Sylvain c101e719fd testprogram: let main() return normally, don't exit for platform (eg Android) where there is some cleanup afterward. 2023-04-12 11:37:26 +02:00
Anonymous Maarten b6ae281e97 Use #ifdef/#ifndef instead of #if defined/#if \!defined 2023-03-30 21:35:01 +00:00
Anonymous Maarten 3472dc11d6
Fix uses of undefined macro identifiers (-Wundef)
* Fix -Wundef warnings due to use of unguarded SDL_LOADSO_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_WINDOWS

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_ANDROID

* Fix -Wundef warnings due to use of unguarded SDL_LOADSO_DUMMY

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_COCOA

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_UIKIT

* Fix -Wundef warnings due to use of unguarded SDL_TIMERS_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_EVENTS_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_TIMER_DUMMY

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_HAPTIC_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_SENSOR_DISABLED

* Fix -Wundef warnings due to use of unguarded __ANDROID__

* Fix -Wundef warnings due to use of unguarded __IOS__

* Fix -Wundef warnings due to use of unguarded EMULATE_CAS

* Fix -Wundef warnings due to use of unguarded SDL_ATOMIC_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_THREADS_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_SNDIO

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_NETBSD

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_WASAPI

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_DSOUND

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_HAIKU

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_COREAUDIO

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_AAUDIO

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_OPENSLES

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_ANDROID

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_PS2

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_PSP

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_VITA

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_N3DS

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_EMSCRIPTEN

* Fix -Wundef warnings due to use of unguarded SDL_NEON_INTRINSICS

* Fix -Wundef warnings due to use of unguarded SDL_ALTIVEC_BLITTERS

* Fix -Wundef warnings due to use of unguarded __VITA__

* Fix -Wundef warnings due to use of unguarded __3DS__

* Fix -Wundef warnings due to use of unguarded SDL_DYNAPI_PROC_NO_VARARGS

* Fix -Wundef warnings due to use of unguarded __APPLE__

* Fix -Wundef warnings due to use of unguarded __WINRT__

* Fix -Wundef warnings due to use of unguarded SDL_HIDAPI_DISABLED

* Fix -Wundef warnings due to use of unguarded __TVOS__

* Fix -Wundef warnings due to use of unguarded HAVE_DRIVER_BACKEND

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_XINPUT

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_WGI

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_DINPUT

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_MFI

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_EMSCRIPTEN

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_PS2

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_PSP

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_VITA

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_N3DS

* Fix -Wundef warnings due to use of unguarded __MACOS__

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_RENDER_D3D

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_WINRT

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_RPI

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_VITA_PVR_OGL

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_VIVANTE

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_RENDER_D3D11

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_RENDER_D3D12

* Fix -Wundef warnings due to use of unguarded SDL_RENDER_DISABLED

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_RENDER_METAL

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_RENDER_PS2

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_RENDER_PSP

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_RENDER_VITA_GXM

* Fix -Wundef warnings due to use of unguarded SDL_ARM_SIMD_BLITTERS

* Fix -Wundef warnings due to use of unguarded SDL_ARM_NEON_BLITTERS

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_HAIKU

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_PS2

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_PSP

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_VITA

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_N3DS

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_KMSDRM

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_RISCOS

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_EMSCRIPTEN

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_NGAGE

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_METAL

* Fix -Wundef warnings due to use of unguarded SDL_LSX_INTRINSICS

* Fix -Wundef warnings due to use of unguarded HAVE_PTHREAD_NP_H

* Fix -Wundef warnings due to use of unguarded __RISCOS__

* Fix -Wundef warnings due to use of unguarded FAKE_RECURSIVE_MUTEX

* Fix -Wundef warnings due to use of unguarded USE_POSIX_SPAWN

* textureData is only needed when SDL is built with YUV support

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_ALSA

* Fix -Wundef warnings due to use of unguarded SDL_SSE3_INTRINSICS

* Fix -Wundef warnings due to use of unguarded SDL_SSE4_2_INTRINSICS

* Fix -Wundef warnings due to use of unguarded SDL_SSE4_1_INTRINSICS

* Fix -Wundef warnings due to use of unguarded SDL_AVX512F_INTRINSICS

* Fix -Wundef warnings due to use of unguarded SDL_SSE2_INTRINSICS

* Fix -Wundef warnings due to use of unguarded SDL_AVX_INTRINSICS

* Fix -Wundef warnings due to use of unguarded SDL_AVX2_INTRINSICS

* Fix -Wundef warnings due to use of unguarded SDL_SSE_INTRINSICS

* Fix -Wundef warnings due to use of unguarded SDL_MMX_INTRINSICS

* Fix -Wundef warnings due to use of unguarded HAVE_CLOCK_GETTIME

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_DISK

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_DUMMY

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_DUMMY

* Fix -Wundef warnings due to use of unguarded HAVE_GCC_ATOMICS

* Fix -Wundef warnings due to use of unguarded HAVE_GCC_SYNC_LOCK_TEST_AND_SET

* Fix -Wundef warnings due to use of unguarded SDL_USE_LIBDBUS

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_JACK

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_VIRTUAL

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_LINUX

* Fix -Wundef warnings due to use of unguarded HAVE_LIBC

* Fix -Wundef warnings due to disabling SDL_LIBC

* Fix -Wundef warnings due to use of unguarded HAVE_PLATFORM_BACKEND

* Fix -Wundef warnings due to use of unguarded DEBUG

* Fix -Wundef warnings due to use of unguarded HAVE_LINUX_INPUT_H

* Fix -Werror=unused-variable when building with SDL_LIBC=OFF

* Fix -Wundef warnings due to use of unguqrded SDL_USE_LIBUDEV

* Use SDL alloc functions in libusb/hid.c

* Fix -Wundef warnings due to use of unguarded HAVE_LIBUDEV_H

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_VULKAN

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_OFFSCREEN

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_RENDER_OGL

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_OPENGL

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_OPENGL_GLX

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_OPENGL_ES

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_OPENGL_ES2

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_RENDER_OGL_ES2

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_OSS

* Remove SDL_AUDIO_DRIVER_SUNAUDIO reference since it is never set

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_PIPEWIRE

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_PULSEAUDIO

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_X11_XCURSOR

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_X11_XDBE

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_X11_XFIXES

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_X11_XINPUT2

* Fix -Wundef warnings due to use of unguarded #if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH

* Fix -Wundef warnings due to use of unguarded #if SDL_VIDEO_DRIVER_X11_XRANDR

* Fix -Wundef warnings due to use of unguarded #if SDL_VIDEO_DRIVER_X11_XSCRNSAVER

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_X11_XSHAPE

* Don't call XShape functions when XShape is diabled

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_WAYLAND

* Fix -Wundef warnings due to use of unuarded SDL_VIDEO_DRIVER_X11

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_RISCOS

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_OPENGL_EGL

* Disable array when compiled with SDL_EVENTS=OFF

* Fix -Wundef warnings due to use of unguarded SDL_INPUT_LINUXEV

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_PTHREAD

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_WINDOWS

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_PS2

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_PSP

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_VITA

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_N3DS

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_STDCPP

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_NGAGE

* Fix -Wundef warnings due to use of unguarded __WINDOWS__

* Fix -Wundef warnings due to use of unguarded __WINGDK__

* Fix -Wundef warnings due to use of unguarded __ANDROID__

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_GENERIC_COND_SUFFIX

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_VITA_PIB

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_VITA_PVR

* Fix -Wundef warnings due to use of unguarded SDL_FILE_DISABLED

* Fix -Wundef warnings due to use of unguarded __XBOXONE__

* Fix -Wundef warnings due to use of unguarded __XBOXSERIES__

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_OPENGL_WGL

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_QNX

* Fix -Wundef warnings due to use of unguarded SDL_AUDIO_DRIVER_DISK

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_QNX

* Fix -Wundef warnings due to use of unguarded DEBUG_RAZOR

* Fix -Wundef warnings due to use of unguarded WINAPI_FAMILY_PHONE_APP

* Fix -Wundef warnings due to use of unguarded SDL_MAC_NO_SANDBOX

* Fix -Wundef warnings due to use of unguarded __(IPHONE|APPLETV|MAC)_OS_VERSION_MAX_ALLOWED

* Fix C4090 warning ('function': different 'const' qualifiers)

* ci: use -isystem for include dirs of pspdev toolchain

* cmake: add -Wundef option

* Fix remaining -Wundef warnings due to use of unguarded SDL_VIDEO_VULKAN and SDL_VIDEO_METAL

* Fix -Wundef warnings due to use of unguarded __MACOS__

* DEBUG_CONVERT is guaranteed to be defined in src/audio/SDL_audiocvt.c

* Fix -Wundef warnings due to use of unguarded HAVE_NANOSLEEP

* Fix -Wundef warnings due to use of unguarded HAVE_DXGI_H

* Fix -Wundef warnings due to use of unguarded HAVE_LINUX_INPUT_H

* fix SDL_VIDEO_DRIVER_WAYLAND

* fix SDL_VIDEO_DRIVER_X11

* Fix -Wundef warnings due to use of unguarded HAVE_MMDEVICEAPI_H

* Fix -Wundef warnings due to use of unguarded HAVE_PTHREAD_SETNAME_NP

* Fix -Wundef warnings due to use of unguarded HAVE_PTHREAD_SET_NAME_NP

* Fix -Wundef warnings due to use of unguarded HAVE_SETJMP

* Fix -Wundef warnings due to use of unguarded HAVE_SIGNAL_H

* Fix -Wundef warnings due to use of unguarded HAVE_TPCSHRD_H

* Fix -Wundef warnings due to use of unguarded MACOSX_COREAUDIO

* Fix -Wundef warnings due to use of unguarded SDL_HAPTIC_DINPUT

* Fix -Wundef warnings due to use of unguarded SDL_HAPTIC_IOKIT

* Fix -Wundef warnings due to use of unguarded SDL_HAPTIC_XINPUT

* Fix -Wundef warnings due to use of unguarded SDL_IPHONE_KEYBOARD

* Fix -Wundef warnings due to use of unguarded SDL_JOYSTICK_RAWINPUT

* Fix -Wundef warnings due to use of unguarded SDL_POWER_ANDROID

* Fix -Wundef warnings due to use of unguarded SDL_POWER_EMSCRIPTEN

* Fix -Wundef warnings due to use of unguarded SDL_POWER_HAIKU

* Fix -Wundef warnings due to use of unguarded SDL_POWER_LINUX

* Fix -Wundef warnings due to use of unguarded SDL_POWER_MACOSX

* Fix -Wundef warnings due to use of unguarded SDL_POWER_PSP

* Fix -Wundef warnings due to use of unguarded SDL_POWER_UIKIT

* Fix -Wundef warnings due to use of unguarded SDL_POWER_VITA

* Fix -Wundef warnings due to use of unguarded SDL_POWER_WINDOWS

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_PTHREAD_RECURSIVE_MUTEX

* Fix -Wundef warnings due to use of unguarded SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_VIVANTE_VDK

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_WAYLAND

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_OPENGL_CGL

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_OPENGL_EGL

* Fix -Wundef warnings due to use of unguarded __MACOS__

* Fix -Wundef warnings due to use of unguarded __OpenBSD__

* Fix -Wundef warnings due to use of unguarded __FreeBSD__

* Fix -Wundef warnings due to use of unguarded __MWERKS__

* Fix -Wundef warnings due to use of unguarded __WIN32__

* Fix -Wundef warnings due to use of unguarded SDL_IPHONE_LAUNCHSCREEN

* Fix -Wundef warnings due to use of unguarded SDL_VIDEO_OPENGL_ES2

* Remove unused HAVE_CONST, HAVE_INLINE and HAVE_VOLATILE

* Revert "Use SDL alloc functions in libusb/hid.c"

This reverts commit 847c64b00d.

* Handle FAKE_RECURSIVE_MUTEX in similar way as SDL2

* Don't use defined in macro
2023-03-29 21:49:01 +00:00
Anonymous Maarten 4a6528e3f0 testprograms: parse arguments using SDLTest_CommonState 2023-03-17 17:54:16 +01:00
Sam Lantinga 91b328c2c6 Fixed emscripten build 2023-03-08 08:58:26 -08:00
Sylvain c963f02571 More fix warnings about static function and prototype 2023-03-08 16:14:09 +01:00
Anonymous Maarten 08bcee8570 test: don't use wiki urls for documentation comments
Also make consistent use of \ as documentation escape character.
2023-02-02 00:49:09 +01:00
Sam Lantinga 6b137579ea Windows default to fullscreen desktop mode if they don't pick an explicit video mode
Rather than iterating over display modes using an index, there is a new function SDL_GetFullscreenDisplayModes() to get the list of available fullscreen modes on a display.
{
    SDL_DisplayID display = SDL_GetPrimaryDisplay();
    int num_modes = 0;
    SDL_DisplayMode **modes = SDL_GetFullscreenDisplayModes(display, &num_modes);
    if (modes) {
        for (i = 0; i < num_modes; ++i) {
            SDL_DisplayMode *mode = modes[i];
            SDL_Log("Display %" SDL_PRIu32 " mode %d:  %dx%d@%gHz, %d%% scale\n",
                    display, i, mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f));
        }
        SDL_free(modes);
    }
}

SDL_GetDesktopDisplayMode() and SDL_GetCurrentDisplayMode() return pointers to display modes rather than filling in application memory.

Windows now have an explicit fullscreen mode that is set, using SDL_SetWindowFullscreenMode(). The fullscreen mode for a window can be queried with SDL_GetWindowFullscreenMode(), which returns a pointer to the mode, or NULL if the window will be fullscreen desktop. SDL_SetWindowFullscreen() just takes a boolean value, setting the correct fullscreen state based on the selected mode.
2023-02-01 12:05:25 -08:00
Sam Lantinga 22c69bccdf Displays are now referenced by instance ID instead of index 2023-01-29 19:25:15 -08:00
Sasha Szpakowski 90795291e4 Remove SDL_GL/Metal/Vulkan_GetDrawableSize().
SDL_GetWindowSizeInPixels supersedes those functions.
2023-01-29 11:20:33 -08:00
Sam Lantinga 7b50bae524 Renamed SDL events for clarity
Fixes https://github.com/libsdl-org/SDL/issues/6877
2023-01-24 07:26:48 -08:00
Sam Lantinga e9b86eebf3 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
2023-01-09 15:46:21 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sylvain Becker d7d3c22dbf
Remove more reserved identifiers (#6925) 2022-12-29 13:58:16 -08:00
Sam Lantinga 63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
Sam Lantinga 909b513c33 Made SDL_WINDOWEVENT_* and SDL_DISPLAYEVENT_* first class event types
Fixes https://github.com/libsdl-org/SDL/issues/6772
2022-12-22 07:38:13 -08:00
Daniel Gibson 22e22ba196 Add SDL_main.h includes to tests
.. including cmake/test/*.c, whatever that does

(this is needed now because SDL.h doesn't include SDL_main.h anymore)
2022-12-15 08:01:01 -08:00
Sam Lantinga 8121bbd083 Convert ticks to 64-bit, added nanosecond precision to the API
Fixes https://github.com/libsdl-org/SDL/issues/5512
Fixes https://github.com/libsdl-org/SDL/issues/6731
2022-12-02 12:37:41 -08:00
Pierre Wendling 3c501b963d
Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sam Lantinga 5750bcb174
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
2022-11-30 12:51:59 -08:00
Sylvain Becker 6a2200823c
Cleanup add brace (#6545)
* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line
2022-11-27 08:38:43 -08:00
Sam Lantinga 0a48abc860 Switch header convention from `#include "SDL.h"` to `#include <SDL3/SDLh>`
I ran this script in the include directory:
```sh
sed -i '' -e 's,#include "\(SDL.*\)",#include <SDL3/\1>,' *.h
```

I ran this script in the src directory:
```sh
for i in ../include/SDL3/SDL*.h
do hdr=$(basename $i)
   if [ x"$(echo $hdr | egrep 'SDL_main|SDL_name|SDL_test|SDL_syswm|SDL_opengl|SDL_egl|SDL_vulkan')" != x ]; then
        find . -type f -exec sed -i '' -e 's,#include "\('$hdr'\)",#include <SDL3/\1>,' {} \;
    else
        find . -type f -exec sed -i '' -e '/#include "'$hdr'"/d' {} \;
    fi
done
```

Fixes https://github.com/libsdl-org/SDL/issues/6575
2022-11-26 22:15:18 -08:00
Sam Lantinga 63f307fe1f Remove SDL_config.h from the public headers
The SDL headers are no longer dependent on the build configuration.

Fixes https://github.com/libsdl-org/SDL/issues/6643 and https://github.com/libsdl-org/SDL/issues/6641
2022-11-26 04:48:36 -08:00
Sam Lantinga cc1f9eb983 Use Apple's nomenclature for macOS and iOS
Fixes https://github.com/libsdl-org/SDL/issues/6621
2022-11-25 16:00:06 -08:00
Ozkan Sezer 0b8309da0c renamed SDL PI constants to SDL_PI_D and SDL_PI_F. 2022-11-25 22:35:24 +03:00
Sam Lantinga 199423612c Updated test programs with SDL_M_PI* 2022-11-25 10:57:12 -08:00
Ozkan Sezer e89a1f9157 removed NaCL support. 2022-11-22 20:10:47 +03:00
Ozkan Sezer 63243eb3a5 removed pandora support 2022-11-22 18:50:00 +03:00
Sylvain 71f2864b3a
Fix usage of sizeof() in test/testgles*.c files 2022-11-17 14:55:49 +01:00
Anonymous Maarten d8884b845e emscripten: fix warnings in tests 2022-11-16 15:42:08 +01:00
Cameron Gutman 99e9156ff5 testgles2: Fix typo in help text 2022-08-16 20:38:55 -07:00
Cameron Gutman 222f1a2693 testgles2: Add --threaded option to use a render thread per window
This is helpful for reproducing bugs like #6056
2022-08-16 07:29:07 -07:00
Eric Wasylishen 2830895740 testgles2.c: refresh cached SDL_GL_GetDrawableSize() on SDL_WINDOWEVENT_SIZE_CHANGED, not SDL_WINDOWEVENT_RESIZED
Fixes bug with viewport not updating when moving window between monitors with different scale
factors on Windows (this should also fix the same issue on other OS'es, though untested)
2022-06-11 14:19:01 -07:00
capehill 006a5a9e03 testgles2: Fix buffer object sizes 2022-04-05 13:05:51 -04:00
capehill 0dcfa92e4c testgles2: Call correct function to get shader info log and add link status checking 2022-03-27 09:44:48 -07:00