Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1392-2-2-15-attempting-to-draw-a-hud-graphic-with-the-same-lump-name-as-a-lua-script-crashes-the
  • 21-installer-nodd
  • 2210-pre1
  • 2210-pre2
  • 2210-rc1
  • 2210-rc2
  • 2210-rc3
  • 2211-pre1
  • 2211-pre2
  • 2211-rc1
  • 2212-pre1
  • 2212-pre2
  • 2212-pre3
  • 2212-rc1
  • 2213
  • 2214-pre1
  • 2214-pre2
  • 2214-pre3
  • 2214-pre4
  • 2_2_12
  • 64-gl-log
  • COM_ImmedExecute-lua
  • DJGPP
  • accel-momentum
  • acs
  • action-args
  • alpha-fixes
  • any-resolution
  • appveyor
  • blend-locking
  • blentran
  • blua-unary-not-fix
  • boost-tickrate
  • bustablesoundz
  • cleanup-opengl
  • cleanupmusic
  • clipmidtex
  • cmake-valgrind
  • crawlacommander-sprites
  • custom-map-names
  • custom-teams
  • cutscene-cleanup
  • dd-music-bypass
  • dd-music-fix
  • delfile2
  • deprecate-lua-dedicated-server
  • dpl-2
  • dropshadows-spawning
  • dynabsp
  • emblem-drawing
  • exchndl-xp-fix
  • extra-textures
  • few-kart-lua-changes
  • ffloorclip
  • fix-167
  • fix-cvar-conflicts
  • fix-opengl-parameter-crash
  • fix-opengl-shear-roll
  • flipfuncpointers
  • fof-lightlist-fixes
  • font-FUCK
  • frictionrefactor
  • fuck-macros-1
  • gamepad-luakeydown
  • gamepad-morefixes
  • gamepad_experiments
  • gametype-refactor
  • gametype-refactor-1
  • gametype-refactor-player-spawns
  • ghost-networking
  • gif-splitting
  • grr-lj
  • hitboxviewer
  • hwr-texture-cache-refactor
  • hwrender2
  • improve-439
  • increase-maxconditionsets
  • increase-packet-tics
  • input-display
  • input-display-translucency
  • io
  • joystick-juggling-maz
  • just-in-case
  • keycodes-only
  • ksf-wadfiles
  • ld413-mp-fix
  • levelstruct
  • libpng-version-support
  • linedef-actions
  • lj-test
  • lol-states
  • loopedsounds
  • lower-unpegged-fix
  • lua-change-gametype
  • lua-command-netids
  • lua-gfx-2
  • lua-gfx-sprites
  • lua-local
  • makefile-auto-mingw-gcc
  • makefile-tinkering
  • SRB2_release_2.1
  • SRB2_release_2.1.1
  • SRB2_release_2.1.10
  • SRB2_release_2.1.11
  • SRB2_release_2.1.12
  • SRB2_release_2.1.14
  • SRB2_release_2.1.15
  • SRB2_release_2.1.16
  • SRB2_release_2.1.16a
  • SRB2_release_2.1.17
  • SRB2_release_2.1.18
  • SRB2_release_2.1.19
  • SRB2_release_2.1.2
  • SRB2_release_2.1.20
  • SRB2_release_2.1.21
  • SRB2_release_2.1.22
  • SRB2_release_2.1.23
  • SRB2_release_2.1.24
  • SRB2_release_2.1.25
  • SRB2_release_2.1.3
  • SRB2_release_2.1.4
  • SRB2_release_2.1.5
  • SRB2_release_2.1.6
  • SRB2_release_2.1.7
  • SRB2_release_2.1.8
  • SRB2_release_2.1.9
  • SRB2_release_2.2.0
  • SRB2_release_2.2.1
  • SRB2_release_2.2.10
  • SRB2_release_2.2.11
  • SRB2_release_2.2.12
  • SRB2_release_2.2.13
  • SRB2_release_2.2.15
  • SRB2_release_2.2.2
  • SRB2_release_2.2.3
  • SRB2_release_2.2.4
  • SRB2_release_2.2.5
  • SRB2_release_2.2.6
  • SRB2_release_2.2.7
  • SRB2_release_2.2.8
  • SRB2_release_2.2.9
  • td-release-v1.0.0
142 results

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
  • Jisk/srb-2-beef-jerky
117 results
Select Git revision
  • 21-installer-nodd
  • 64-gl-log
  • DJGPP
  • S_SKIN-missing-flag
  • angle-for-spawn-object
  • appveyor
  • better-refusal
  • blend-locking
  • boost-tickrate
  • cleanup-opengl
  • colorstesting
  • colorstesting-224
  • comparepolygons-fix
  • continue_tweaks
  • crawlacommander-sprites
  • cutscene-cleanup
  • dd-music-bypass
  • dd-music-fix
  • delete-lua
  • delete-slopes
  • depth-buffer-24
  • disable-titlemap-in-netgames
  • dropshadows-spawning
  • dynres
  • exchndl-xp-fix
  • fix-allowjoin
  • fix-ded-servers
  • fix-fire-shield
  • fix-keepbody-ping
  • fix-major-issue
  • fix-mouse-controls-setup
  • fix-mouse-grabbing
  • fix-node-player-mixups
  • fix-nohw-perfstats-next
  • fix-nonslope-slopes
  • fix-perfstats-3
  • fix-playernode-crash
  • fix-portals
  • fix-splitscreen
  • flipfuncpointers
  • flipfuncpointers-master
  • float-stepup
  • fof-lightlist-fixes
  • fuck-macros-1
  • g_findmap-lua
  • gamepad_experiments
  • gl-deletetexture-fix
  • gles2-desktop-stuff
  • grr-lj
  • gtr-fixes
  • hide-useless-1p-menu-options
  • hmods-dev
  • hwcleanupstuff
  • hwportals
  • hwportalswip
  • ignore-glsegs
  • increase-input-buffer
  • input-display
  • input-display-translucency
  • io
  • joystick-juggling-maz
  • keep-body
  • keycodes-only
  • larger-chat
  • ld413-mp-fix
  • libpng-version-support
  • lol-states
  • lower-unpegged-fix
  • lua-hook-cleanup
  • lua-io
  • lua-local
  • lua-opt-dev
  • lua-opt-dev-alt-cache
  • lua-opt-dev-baseline
  • lua-opt-dev-optoption2
  • lua-optimized-constants
  • lua-timestamp
  • makefile-tinkering
  • map-components-signedness-fixes
  • master
  • master-use-sse3
  • more-cleanup
  • more-lua-map-names
  • more-stats
  • musicdef-lua
  • netcode-tests
  • next
  • ogl-batching
  • ogl-better-gpu-error
  • ogl-big-room-fix
  • ogl-blend-var-fix
  • ogl-compileshaders-bug
  • ogl-driver-error
  • ogl-fof-wall-slope-fix
  • ogl-fof-wall-slope-fix-test
  • ogl-fof-wall-slope-fix2
  • ogl-fog-block-fix
  • ogl-linkdraw
  • ogl-midtexture-zfighting-fix
  • ogl-midtexture-zfix-test
  • SRB2_release_2.1
  • SRB2_release_2.1.1
  • SRB2_release_2.1.10
  • SRB2_release_2.1.11
  • SRB2_release_2.1.12
  • SRB2_release_2.1.14
  • SRB2_release_2.1.15
  • SRB2_release_2.1.16
  • SRB2_release_2.1.16a
  • SRB2_release_2.1.17
  • SRB2_release_2.1.18
  • SRB2_release_2.1.19
  • SRB2_release_2.1.2
  • SRB2_release_2.1.20
  • SRB2_release_2.1.21
  • SRB2_release_2.1.22
  • SRB2_release_2.1.23
  • SRB2_release_2.1.24
  • SRB2_release_2.1.25
  • SRB2_release_2.1.3
  • SRB2_release_2.1.4
  • SRB2_release_2.1.5
  • SRB2_release_2.1.6
  • SRB2_release_2.1.7
  • SRB2_release_2.1.8
  • SRB2_release_2.1.9
  • SRB2_release_2.2.0
  • SRB2_release_2.2.1
  • SRB2_release_2.2.2
  • td-release-v1.0.0
130 results
Show changes
Showing
with 4661 additions and 1210 deletions
...@@ -640,6 +640,7 @@ EXCLUDE = ../include/SDL_opengles2_gl2ext.h \ ...@@ -640,6 +640,7 @@ EXCLUDE = ../include/SDL_opengles2_gl2ext.h \
../include/SDL_opengles.h \ ../include/SDL_opengles.h \
../include/SDL_opengl.h \ ../include/SDL_opengl.h \
../include/SDL_egl.h \ ../include/SDL_egl.h \
./release_checklist.md \
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or # The EXCLUDE_SYMLINKS tag can be used select whether or not files or
......
# Release checklist
When changing the version, run `build-scripts/update-version.sh X Y Z`,
where `X Y Z` are the major version, minor version, and patch level. So
`2 28 1` means "change the version to 2.28.1". This script does much of the
mechanical work.
## New feature release
* Update `WhatsNew.txt`
* Bump version number to 2.EVEN.0:
* `./build-scripts/update-version.sh 2 EVEN 0`
* Do the release
* Update the website file include/header.inc.php to reflect the new version
## New bugfix release
* Check that no new API/ABI was added
* If it was, do a new feature release (see above) instead
* Bump version number from 2.Y.Z to 2.Y.(Z+1) (Y is even)
* `./build-scripts/update-version.sh 2 Y Z+1`
* Do the release
* Update the website file include/header.inc.php to reflect the new version
## After a feature release
* Create a branch like `release-2.24.x`
* Bump version number to 2.ODD.0 for next development branch
* `./build-scripts/update-version.sh 2 ODD 0`
## New development prerelease
* Bump version number from 2.Y.Z to 2.Y.(Z+1) (Y is odd)
* `./build-scripts/update-version.sh 2 Y Z+1`
* Do the release
No preview for this file type
#!/bin/sh #!/bin/sh
prefix=/opt/local/i686-w64-mingw32 # Get the canonical path of the folder containing this script
bindir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
# Calculate the canonical path of the prefix, relative to the folder of this script
prefix=$(cd -P -- "$bindir/.." && printf '%s\n' "$(pwd -P)")
exec_prefix=${prefix} exec_prefix=${prefix}
exec_prefix_set=no exec_prefix_set=no
libdir=${exec_prefix}/lib libdir=${exec_prefix}/lib
...@@ -39,7 +43,7 @@ while test $# -gt 0; do ...@@ -39,7 +43,7 @@ while test $# -gt 0; do
echo $exec_prefix echo $exec_prefix
;; ;;
--version) --version)
echo 2.0.10 echo 2.28.5
;; ;;
--cflags) --cflags)
echo -I${prefix}/include/SDL2 -Dmain=SDL_main echo -I${prefix}/include/SDL2 -Dmain=SDL_main
...@@ -49,7 +53,8 @@ while test $# -gt 0; do ...@@ -49,7 +53,8 @@ while test $# -gt 0; do
;; ;;
--static-libs) --static-libs)
# --libs|--static-libs) # --libs|--static-libs)
echo -L${exec_prefix}/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc sdl_static_libs=$(echo "-lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--dynamicbase -Wl,--nxcompat -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid" | sed -E "s#-lSDL2[ $]#$libdir/libSDL2.a #g")
echo -L${exec_prefix}/lib $sdl_static_libs
;; ;;
*) *)
echo "${usage}" 1>&2 echo "${usage}" 1>&2
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -41,12 +41,15 @@ ...@@ -41,12 +41,15 @@
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_filesystem.h" #include "SDL_filesystem.h"
#include "SDL_gamecontroller.h" #include "SDL_gamecontroller.h"
#include "SDL_guid.h"
#include "SDL_haptic.h" #include "SDL_haptic.h"
#include "SDL_hidapi.h"
#include "SDL_hints.h" #include "SDL_hints.h"
#include "SDL_joystick.h" #include "SDL_joystick.h"
#include "SDL_loadso.h" #include "SDL_loadso.h"
#include "SDL_log.h" #include "SDL_log.h"
#include "SDL_messagebox.h" #include "SDL_messagebox.h"
#include "SDL_metal.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#include "SDL_power.h" #include "SDL_power.h"
#include "SDL_render.h" #include "SDL_render.h"
...@@ -58,6 +61,8 @@ ...@@ -58,6 +61,8 @@
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_version.h" #include "SDL_version.h"
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_locale.h"
#include "SDL_misc.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
...@@ -90,37 +95,130 @@ extern "C" { ...@@ -90,37 +95,130 @@ extern "C" {
/* @} */ /* @} */
/** /**
* This function initializes the subsystems specified by \c flags * Initialize the SDL library.
*
* SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the
* two may be used interchangeably. Though for readability of your code
* SDL_InitSubSystem() might be preferred.
*
* The file I/O (for example: SDL_RWFromFile) and threading (SDL_CreateThread)
* subsystems are initialized by default. Message boxes
* (SDL_ShowSimpleMessageBox) also attempt to work without initializing the
* video subsystem, in hopes of being useful in showing an error dialog when
* SDL_Init fails. You must specifically initialize other subsystems if you
* use them in your application.
*
* Logging (such as SDL_Log) works without initialization, too.
*
* `flags` may be any of the following OR'd together:
*
* - `SDL_INIT_TIMER`: timer subsystem
* - `SDL_INIT_AUDIO`: audio subsystem
* - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
* subsystem
* - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the
* events subsystem
* - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem
* - `SDL_INIT_GAMECONTROLLER`: controller subsystem; automatically
* initializes the joystick subsystem
* - `SDL_INIT_EVENTS`: events subsystem
* - `SDL_INIT_EVERYTHING`: all of the above subsystems
* - `SDL_INIT_NOPARACHUTE`: compatibility; this flag is ignored
*
* Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()
* for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then
* this call will increase the ref-count and return.
*
* \param flags subsystem initialization flags
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_InitSubSystem
* \sa SDL_Quit
* \sa SDL_SetMainReady
* \sa SDL_WasInit
*/ */
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
/** /**
* This function initializes specific SDL subsystems * Compatibility function to initialize the SDL library.
*
* In SDL2, this function and SDL_Init() are interchangeable.
* *
* Subsystem initialization is ref-counted, you must call * \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
* SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly * \returns 0 on success or a negative error code on failure; call
* shutdown a subsystem manually (or call SDL_Quit() to force shutdown). * SDL_GetError() for more information.
* If a subsystem is already loaded then this call will *
* increase the ref-count and return. * \since This function is available since SDL 2.0.0.
*
* \sa SDL_Init
* \sa SDL_Quit
* \sa SDL_QuitSubSystem
*/ */
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
/** /**
* This function cleans up specific SDL subsystems * Shut down specific SDL subsystems.
*
* If you start a subsystem using a call to that subsystem's init function
* (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(),
* SDL_QuitSubSystem() and SDL_WasInit() will not work. You will need to use
* that subsystem's quit function (SDL_VideoQuit()) directly instead. But
* generally, you should not be using those functions directly anyhow; use
* SDL_Init() instead.
*
* You still need to call SDL_Quit() even if you close all open subsystems
* with SDL_QuitSubSystem().
*
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_InitSubSystem
* \sa SDL_Quit
*/ */
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
/** /**
* This function returns a mask of the specified subsystems which have * Get a mask of the specified subsystems which are currently initialized.
* previously been initialized. *
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
* \returns a mask of all initialized subsystems if `flags` is 0, otherwise it
* returns the initialization status of the specified subsystems.
*
* The return value does not include SDL_INIT_NOPARACHUTE.
* *
* If \c flags is 0, it returns a mask of all initialized subsystems. * \since This function is available since SDL 2.0.0.
*
* \sa SDL_Init
* \sa SDL_InitSubSystem
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
/** /**
* This function cleans up all initialized subsystems. You should * Clean up all initialized subsystems.
* call it upon all exit conditions. *
* You should call this function even if you have already shutdown each
* initialized subsystem with SDL_QuitSubSystem(). It is safe to call this
* function even in the case of errors in initialization.
*
* If you start a subsystem using a call to that subsystem's init function
* (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(),
* then you must use that subsystem's quit function (SDL_VideoQuit()) to shut
* it down before calling SDL_Quit(). But generally, you should not be using
* those functions directly anyhow; use SDL_Init() instead.
*
* You can use this function with atexit() to ensure that it is run when your
* application is shutdown, but it is not wise to do this from a library or
* other dynamically loaded code.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Init
* \sa SDL_QuitSubSystem
*/ */
extern DECLSPEC void SDLCALL SDL_Quit(void); extern DECLSPEC void SDLCALL SDL_Quit(void);
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#ifndef SDL_assert_h_ #ifndef SDL_assert_h_
#define SDL_assert_h_ #define SDL_assert_h_
#include "SDL_config.h" #include "SDL_stdinc.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
...@@ -51,8 +51,16 @@ assert can have unique static variables associated with it. ...@@ -51,8 +51,16 @@ assert can have unique static variables associated with it.
/* Don't include intrin.h here because it contains C++ code */ /* Don't include intrin.h here because it contains C++ code */
extern void __cdecl __debugbreak(void); extern void __cdecl __debugbreak(void);
#define SDL_TriggerBreakpoint() __debugbreak() #define SDL_TriggerBreakpoint() __debugbreak()
#elif _SDL_HAS_BUILTIN(__builtin_debugtrap)
#define SDL_TriggerBreakpoint() __builtin_debugtrap()
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) ) #elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
#elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv)
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" )
#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
#elif defined(__APPLE__) && defined(__arm__)
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
#elif defined(__386__) && defined(__WATCOMC__) #elif defined(__386__) && defined(__WATCOMC__)
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } } #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__) #elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
...@@ -65,7 +73,7 @@ assert can have unique static variables associated with it. ...@@ -65,7 +73,7 @@ assert can have unique static variables associated with it.
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
# define SDL_FUNCTION __func__ # define SDL_FUNCTION __func__
#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__)) #elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
# define SDL_FUNCTION __FUNCTION__ # define SDL_FUNCTION __FUNCTION__
#else #else
# define SDL_FUNCTION "???" # define SDL_FUNCTION "???"
...@@ -119,12 +127,10 @@ typedef struct SDL_AssertData ...@@ -119,12 +127,10 @@ typedef struct SDL_AssertData
const struct SDL_AssertData *next; const struct SDL_AssertData *next;
} SDL_AssertData; } SDL_AssertData;
#if (SDL_ASSERT_LEVEL > 0)
/* Never call this directly. Use the SDL_assert* macros. */ /* Never call this directly. Use the SDL_assert* macros. */
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
const char *, const char *,
const char *, int) const char *, int)
#if defined(__clang__) #if defined(__clang__)
#if __has_feature(attribute_analyzer_noreturn) #if __has_feature(attribute_analyzer_noreturn)
/* this tells Clang's static analysis that we're a custom assert function, /* this tells Clang's static analysis that we're a custom assert function,
...@@ -145,9 +151,7 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, ...@@ -145,9 +151,7 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
#define SDL_enabled_assert(condition) \ #define SDL_enabled_assert(condition) \
do { \ do { \
while ( !(condition) ) { \ while ( !(condition) ) { \
static struct SDL_AssertData sdl_assert_data = { \ static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
0, 0, #condition, 0, 0, 0, 0 \
}; \
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \ continue; /* go again. */ \
...@@ -158,8 +162,6 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, ...@@ -158,8 +162,6 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
} \ } \
} while (SDL_NULL_WHILE_LOOP_CONDITION) } while (SDL_NULL_WHILE_LOOP_CONDITION)
#endif /* enabled assertions support code */
/* Enable various levels of assertions. */ /* Enable various levels of assertions. */
#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ #if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
# define SDL_assert(condition) SDL_disabled_assert(condition) # define SDL_assert(condition) SDL_disabled_assert(condition)
...@@ -185,92 +187,121 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, ...@@ -185,92 +187,121 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
#define SDL_assert_always(condition) SDL_enabled_assert(condition) #define SDL_assert_always(condition) SDL_enabled_assert(condition)
/**
* A callback that fires when an SDL assertion fails.
*
* \param data a pointer to the SDL_AssertData structure corresponding to the
* current assertion
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler()
* \returns an SDL_AssertState value indicating how to handle the failure.
*/
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)( typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
const SDL_AssertData* data, void* userdata); const SDL_AssertData* data, void* userdata);
/** /**
* \brief Set an application-defined assertion handler. * Set an application-defined assertion handler.
* *
* This allows an app to show its own assertion UI and/or force the * This function allows an application to show its own assertion UI and/or
* response to an assertion failure. If the app doesn't provide this, SDL * force the response to an assertion failure. If the application doesn't
* will try to do the right thing, popping up a system-specific GUI dialog, * provide this, SDL will try to do the right thing, popping up a
* and probably minimizing any fullscreen windows. * system-specific GUI dialog, and probably minimizing any fullscreen windows.
* *
* This callback may fire from any thread, but it runs wrapped in a mutex, so * This callback may fire from any thread, but it runs wrapped in a mutex, so
* it will only fire from one thread at a time. * it will only fire from one thread at a time.
* *
* Setting the callback to NULL restores SDL's original internal handler. * This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
* *
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()! * \param handler the SDL_AssertionHandler function to call when an assertion
* fails or NULL for the default handler
* \param userdata a pointer that is passed to `handler`
* *
* Return SDL_AssertState value of how to handle the assertion failure. * \since This function is available since SDL 2.0.0.
* *
* \param handler Callback function, called when an assertion fails. * \sa SDL_GetAssertionHandler
* \param userdata A pointer passed to the callback as-is.
*/ */
extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
SDL_AssertionHandler handler, SDL_AssertionHandler handler,
void *userdata); void *userdata);
/** /**
* \brief Get the default assertion handler. * Get the default assertion handler.
*
* This returns the function pointer that is called by default when an
* assertion is triggered. This is an internal function provided by SDL, that
* is used for assertions when SDL_SetAssertionHandler() hasn't been used to
* provide a different function.
*
* \returns the default SDL_AssertionHandler that is called when an assert
* triggers.
* *
* This returns the function pointer that is called by default when an * \since This function is available since SDL 2.0.2.
* assertion is triggered. This is an internal function provided by SDL,
* that is used for assertions when SDL_SetAssertionHandler() hasn't been
* used to provide a different function.
* *
* \return The default SDL_AssertionHandler that is called when an assert triggers. * \sa SDL_GetAssertionHandler
*/ */
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void);
/** /**
* \brief Get the current assertion handler. * Get the current assertion handler.
* *
* This returns the function pointer that is called when an assertion is * This returns the function pointer that is called when an assertion is
* triggered. This is either the value last passed to * triggered. This is either the value last passed to
* SDL_SetAssertionHandler(), or if no application-specified function is * SDL_SetAssertionHandler(), or if no application-specified function is set,
* set, is equivalent to calling SDL_GetDefaultAssertionHandler(). * is equivalent to calling SDL_GetDefaultAssertionHandler().
* *
* \param puserdata Pointer to a void*, which will store the "userdata" * The parameter `puserdata` is a pointer to a void*, which will store the
* pointer that was passed to SDL_SetAssertionHandler(). * "userdata" pointer that was passed to SDL_SetAssertionHandler(). This value
* This value will always be NULL for the default handler. * will always be NULL for the default handler. If you don't care about this
* If you don't care about this data, it is safe to pass * data, it is safe to pass a NULL pointer to this function to ignore it.
* a NULL pointer to this function to ignore it. *
* \return The SDL_AssertionHandler that is called when an assert triggers. * \param puserdata pointer which is filled with the "userdata" pointer that
* was passed to SDL_SetAssertionHandler()
* \returns the SDL_AssertionHandler that is called when an assert triggers.
*
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_SetAssertionHandler
*/ */
extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata);
/** /**
* \brief Get a list of all assertion failures. * Get a list of all assertion failures.
* *
* Get all assertions triggered since last call to SDL_ResetAssertionReport(), * This function gets all assertions triggered since the last call to
* or the start of the program. * SDL_ResetAssertionReport(), or the start of the program.
* *
* The proper way to examine this data looks something like this: * The proper way to examine this data looks something like this:
* *
* <code> * ```c
* const SDL_AssertData *item = SDL_GetAssertionReport(); * const SDL_AssertData *item = SDL_GetAssertionReport();
* while (item) { * while (item) {
* printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n", * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n",
* item->condition, item->function, item->filename, * item->condition, item->function, item->filename,
* item->linenum, item->trigger_count, * item->linenum, item->trigger_count,
* item->always_ignore ? "yes" : "no"); * item->always_ignore ? "yes" : "no");
* item = item->next; * item = item->next;
* } * }
* </code> * ```
* *
* \return List of all assertions. * \returns a list of all failed assertions or NULL if the list is empty. This
* \sa SDL_ResetAssertionReport * memory should not be modified or freed by the application.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ResetAssertionReport
*/ */
extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void); extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
/** /**
* \brief Reset the list of all assertion failures. * Clear the list of all assertion failures.
*
* This function will clear the list of all assertions triggered up to that
* point. Immediately following this call, SDL_GetAssertionReport will return
* no items. In addition, any previously-triggered assertions will be reset to
* a trigger_count of zero, and their always_ignore state will be false.
* *
* Reset list of all assertions triggered. * \since This function is available since SDL 2.0.0.
* *
* \sa SDL_GetAssertionReport * \sa SDL_GetAssertionReport
*/ */
extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -89,25 +89,51 @@ extern "C" { ...@@ -89,25 +89,51 @@ extern "C" {
typedef int SDL_SpinLock; typedef int SDL_SpinLock;
/** /**
* \brief Try to lock a spin lock by setting it to a non-zero value. * Try to lock a spin lock by setting it to a non-zero value.
* *
* \param lock Points to the lock. * ***Please note that spinlocks are dangerous if you don't know what you're
* doing. Please be careful using any sort of spinlock!***
* *
* \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. * \param lock a pointer to a lock variable
* \returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already
* held.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AtomicLock
* \sa SDL_AtomicUnlock
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock);
/** /**
* \brief Lock a spin lock by setting it to a non-zero value. * Lock a spin lock by setting it to a non-zero value.
*
* ***Please note that spinlocks are dangerous if you don't know what you're
* doing. Please be careful using any sort of spinlock!***
*
* \param lock a pointer to a lock variable
*
* \since This function is available since SDL 2.0.0.
* *
* \param lock Points to the lock. * \sa SDL_AtomicTryLock
* \sa SDL_AtomicUnlock
*/ */
extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock);
/** /**
* \brief Unlock a spin lock by setting it to 0. Always returns immediately * Unlock a spin lock by setting it to 0.
* *
* \param lock Points to the lock. * Always returns immediately.
*
* ***Please note that spinlocks are dangerous if you don't know what you're
* doing. Please be careful using any sort of spinlock!***
*
* \param lock a pointer to a lock variable
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AtomicLock
* \sa SDL_AtomicTryLock
*/ */
extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock);
...@@ -126,7 +152,7 @@ void _ReadWriteBarrier(void); ...@@ -126,7 +152,7 @@ void _ReadWriteBarrier(void);
/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */ /* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */
#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") #define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory")
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
extern _inline void SDL_CompilerBarrier (void); extern __inline void SDL_CompilerBarrier(void);
#pragma aux SDL_CompilerBarrier = "" parm [] modify exact []; #pragma aux SDL_CompilerBarrier = "" parm [] modify exact [];
#else #else
#define SDL_CompilerBarrier() \ #define SDL_CompilerBarrier() \
...@@ -137,20 +163,22 @@ extern _inline void SDL_CompilerBarrier (void); ...@@ -137,20 +163,22 @@ extern _inline void SDL_CompilerBarrier (void);
* Memory barriers are designed to prevent reads and writes from being * Memory barriers are designed to prevent reads and writes from being
* reordered by the compiler and being seen out of order on multi-core CPUs. * reordered by the compiler and being seen out of order on multi-core CPUs.
* *
* A typical pattern would be for thread A to write some data and a flag, * A typical pattern would be for thread A to write some data and a flag, and
* and for thread B to read the flag and get the data. In this case you * for thread B to read the flag and get the data. In this case you would
* would insert a release barrier between writing the data and the flag, * insert a release barrier between writing the data and the flag,
* guaranteeing that the data write completes no later than the flag is * guaranteeing that the data write completes no later than the flag is
* written, and you would insert an acquire barrier between reading the * written, and you would insert an acquire barrier between reading the flag
* flag and reading the data, to ensure that all the reads associated * and reading the data, to ensure that all the reads associated with the flag
* with the flag have completed. * have completed.
* *
* In this pattern you should always see a release barrier paired with * In this pattern you should always see a release barrier paired with an
* an acquire barrier and you should gate the data reads/writes with a * acquire barrier and you should gate the data reads/writes with a single
* single flag variable. * flag variable.
* *
* For more information on these semantics, take a look at the blog post: * For more information on these semantics, take a look at the blog post:
* http://preshing.com/20120913/acquire-and-release-semantics * http://preshing.com/20120913/acquire-and-release-semantics
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void); extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void);
extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);
...@@ -209,6 +237,25 @@ typedef void (*SDL_KernelMemoryBarrierFunc)(); ...@@ -209,6 +237,25 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
#endif #endif
#endif #endif
/* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */
#if (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */
#elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__aarch64__)
#define SDL_CPUPauseInstruction() __asm__ __volatile__("yield" ::: "memory")
#elif (defined(__powerpc__) || defined(__powerpc64__))
#define SDL_CPUPauseInstruction() __asm__ __volatile__("or 27,27,27");
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
#define SDL_CPUPauseInstruction() _mm_pause() /* this is actually "rep nop" and not a SIMD instruction. No inline asm in MSVC x86-64! */
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
#define SDL_CPUPauseInstruction() __yield()
#elif defined(__WATCOMC__) && defined(__386__)
extern __inline void SDL_CPUPauseInstruction(void);
#pragma aux SDL_CPUPauseInstruction = ".686p" ".xmm2" "pause"
#else
#define SDL_CPUPauseInstruction()
#endif
/** /**
* \brief A type representing an atomic integer value. It is a struct * \brief A type representing an atomic integer value. It is a struct
* so people don't accidentally use numeric operations on it. * so people don't accidentally use numeric operations on it.
...@@ -216,32 +263,73 @@ typedef void (*SDL_KernelMemoryBarrierFunc)(); ...@@ -216,32 +263,73 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
typedef struct { int value; } SDL_atomic_t; typedef struct { int value; } SDL_atomic_t;
/** /**
* \brief Set an atomic variable to a new value if it is currently an old value. * Set an atomic variable to a new value if it is currently an old value.
* *
* \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. * ***Note: If you don't know what this function is for, you shouldn't use
* it!***
* *
* \note If you don't know what this function is for, you shouldn't use it! * \param a a pointer to an SDL_atomic_t variable to be modified
*/ * \param oldval the old value
* \param newval the new value
* \returns SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AtomicCASPtr
* \sa SDL_AtomicGet
* \sa SDL_AtomicSet
*/
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval); extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval);
/** /**
* \brief Set an atomic variable to a value. * Set an atomic variable to a value.
*
* This function also acts as a full memory barrier.
*
* ***Note: If you don't know what this function is for, you shouldn't use
* it!***
* *
* \return The previous value of the atomic variable. * \param a a pointer to an SDL_atomic_t variable to be modified
* \param v the desired value
* \returns the previous value of the atomic variable.
*
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicGet
*/ */
extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v);
/** /**
* \brief Get the value of an atomic variable * Get the value of an atomic variable.
*
* ***Note: If you don't know what this function is for, you shouldn't use
* it!***
*
* \param a a pointer to an SDL_atomic_t variable
* \returns the current value of an atomic variable.
*
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicSet
*/ */
extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);
/** /**
* \brief Add to an atomic variable. * Add to an atomic variable.
*
* This function also acts as a full memory barrier.
*
* ***Note: If you don't know what this function is for, you shouldn't use
* it!***
* *
* \return The previous value of the atomic variable. * \param a a pointer to an SDL_atomic_t variable to be modified
* \param v the desired value to add
* \returns the previous value of the atomic variable.
* *
* \note This same style can be used for any number operation * \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicDecRef
* \sa SDL_AtomicIncRef
*/ */
extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v);
...@@ -263,23 +351,54 @@ extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); ...@@ -263,23 +351,54 @@ extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v);
#endif #endif
/** /**
* \brief Set a pointer to a new value if it is currently an old value. * Set a pointer to a new value if it is currently an old value.
* *
* \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise. * ***Note: If you don't know what this function is for, you shouldn't use
* it!***
* *
* \note If you don't know what this function is for, you shouldn't use it! * \param a a pointer to a pointer
*/ * \param oldval the old pointer value
* \param newval the new pointer value
* \returns SDL_TRUE if the pointer was set, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AtomicCAS
* \sa SDL_AtomicGetPtr
* \sa SDL_AtomicSetPtr
*/
extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval); extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval);
/** /**
* \brief Set a pointer to a value atomically. * Set a pointer to a value atomically.
*
* ***Note: If you don't know what this function is for, you shouldn't use
* it!***
*
* \param a a pointer to a pointer
* \param v the desired pointer value
* \returns the previous value of the pointer.
* *
* \return The previous value of the pointer. * \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicCASPtr
* \sa SDL_AtomicGetPtr
*/ */
extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v); extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v);
/** /**
* \brief Get the value of a pointer atomically. * Get the value of a pointer atomically.
*
* ***Note: If you don't know what this function is for, you shouldn't use
* it!***
*
* \param a a pointer to a pointer
* \returns the current value of a pointer.
*
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_AtomicCASPtr
* \sa SDL_AtomicSetPtr
*/ */
extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a); extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a);
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* !!! FIXME: several functions in here need Doxygen comments. */
/** /**
* \file SDL_audio.h * \file SDL_audio.h
* *
...@@ -167,13 +169,13 @@ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream, ...@@ -167,13 +169,13 @@ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
* The calculated values in this structure are calculated by SDL_OpenAudio(). * The calculated values in this structure are calculated by SDL_OpenAudio().
* *
* For multi-channel audio, the default SDL channel mapping is: * For multi-channel audio, the default SDL channel mapping is:
* 2: FL FR (stereo) * 2: FL FR (stereo)
* 3: FL FR LFE (2.1 surround) * 3: FL FR LFE (2.1 surround)
* 4: FL FR BL BR (quad) * 4: FL FR BL BR (quad)
* 5: FL FR FC BL BR (quad + center) * 5: FL FR LFE BL BR (4.1 surround)
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR) * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
* 7: FL FR FC LFE BC SL SR (6.1 surround) * 7: FL FR FC LFE BC SL SR (6.1 surround)
* 8: FL FR FC LFE BL BR SL SR (7.1 surround) * 8: FL FR FC LFE BL BR SL SR (7.1 surround)
*/ */
typedef struct SDL_AudioSpec typedef struct SDL_AudioSpec
{ {
...@@ -212,9 +214,12 @@ typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt, ...@@ -212,9 +214,12 @@ typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt,
* set both its (buf) field to a pointer that is aligned to 16 bytes, and its * set both its (buf) field to a pointer that is aligned to 16 bytes, and its
* (len) field to something that's a multiple of 16, if possible. * (len) field to something that's a multiple of 16, if possible.
*/ */
#ifdef __GNUC__ #if defined(__GNUC__) && !defined(__CHERI_PURE_CAPABILITY__)
/* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't /* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't
pad it out to 88 bytes to guarantee ABI compatibility between compilers. pad it out to 88 bytes to guarantee ABI compatibility between compilers.
This is not a concern on CHERI architectures, where pointers must be stored
at aligned locations otherwise they will become invalid, and thus structs
containing pointers cannot be packed without giving a warning or error.
vvv vvv
The next time we rev the ABI, make sure to size the ints and add padding. The next time we rev the ABI, make sure to size the ints and add padding.
*/ */
...@@ -248,7 +253,48 @@ typedef struct SDL_AudioCVT ...@@ -248,7 +253,48 @@ typedef struct SDL_AudioCVT
* order that they are normally initialized by default. * order that they are normally initialized by default.
*/ */
/* @{ */ /* @{ */
/**
* Use this function to get the number of built-in audio drivers.
*
* This function returns a hardcoded number. This never returns a negative
* value; if there are no drivers compiled into this build of SDL, this
* function returns zero. The presence of a driver in this list does not mean
* it will function, it just means SDL is capable of interacting with that
* interface. For example, a build of SDL might have esound support, but if
* there's no esound server available, SDL's esound driver would fail if used.
*
* By default, SDL tries all drivers, in its preferred order, until one is
* found to be usable.
*
* \returns the number of built-in audio drivers.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetAudioDriver
*/
extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
/**
* Use this function to get the name of a built in audio driver.
*
* The list of audio drivers is given in the order that they are normally
* initialized by default; the drivers that seem more reasonable to choose
* first (as far as the SDL developers believe) are earlier in the list.
*
* The names of drivers are all simple, low-ASCII identifiers, like "alsa",
* "coreaudio" or "xaudio2". These never have Unicode characters, and are not
* meant to be proper names.
*
* \param index the index of the audio driver; the value ranges from 0 to
* SDL_GetNumAudioDrivers() - 1
* \returns the name of the audio driver at the requested index, or NULL if an
* invalid index was specified.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumAudioDrivers
*/
extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
/* @} */ /* @} */
...@@ -260,60 +306,103 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); ...@@ -260,60 +306,103 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
* use. You should normally use SDL_Init() or SDL_InitSubSystem(). * use. You should normally use SDL_Init() or SDL_InitSubSystem().
*/ */
/* @{ */ /* @{ */
/**
* Use this function to initialize a particular audio driver.
*
* This function is used internally, and should not be used unless you have a
* specific need to designate the audio driver you want to use. You should
* normally use SDL_Init() or SDL_InitSubSystem().
*
* \param driver_name the name of the desired audio driver
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AudioQuit
*/
extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
/**
* Use this function to shut down audio if you initialized it with
* SDL_AudioInit().
*
* This function is used internally, and should not be used unless you have a
* specific need to specify the audio driver you want to use. You should
* normally use SDL_Quit() or SDL_QuitSubSystem().
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AudioInit
*/
extern DECLSPEC void SDLCALL SDL_AudioQuit(void); extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
/* @} */ /* @} */
/** /**
* This function returns the name of the current audio driver, or NULL * Get the name of the current audio driver.
* if no driver has been initialized. *
* The returned string points to internal static memory and thus never becomes
* invalid, even if you quit the audio subsystem and initialize a new driver
* (although such a case would return a different static string from another
* call to this function, of course). As such, you should not modify or free
* the returned string.
*
* \returns the name of the current audio driver or NULL if no driver has been
* initialized.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AudioInit
*/ */
extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
/** /**
* This function opens the audio device with the desired parameters, and * This function is a legacy means of opening the audio device.
* returns 0 if successful, placing the actual hardware parameters in the *
* structure pointed to by \c obtained. If \c obtained is NULL, the audio * This function remains for compatibility with SDL 1.2, but also because it's
* data passed to the callback function will be guaranteed to be in the * slightly easier to use than the new functions in SDL 2.0. The new, more
* requested format, and will be automatically converted to the hardware * powerful, and preferred way to do this is SDL_OpenAudioDevice().
* audio format if necessary. This function returns -1 if it failed *
* to open the audio device, or couldn't set up the audio thread. * This function is roughly equivalent to:
* *
* When filling in the desired audio spec structure, * ```c
* - \c desired->freq should be the desired audio frequency in samples-per- * SDL_OpenAudioDevice(NULL, 0, desired, obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
* second. * ```
* - \c desired->format should be the desired audio format. *
* - \c desired->samples is the desired size of the audio buffer, in * With two notable exceptions:
* samples. This number should be a power of two, and may be adjusted by *
* the audio driver to a value more suitable for the hardware. Good values * - If `obtained` is NULL, we use `desired` (and allow no changes), which
* seem to range between 512 and 8096 inclusive, depending on the * means desired will be modified to have the correct values for silence,
* application and CPU speed. Smaller values yield faster response time, * etc, and SDL will convert any differences between your app's specific
* but can lead to underflow if the application is doing heavy processing * request and the hardware behind the scenes.
* and cannot fill the audio buffer in time. A stereo sample consists of * - The return value is always success or failure, and not a device ID, which
* both right and left channels in LR ordering. * means you can only have one device open at a time with this function.
* Note that the number of samples is directly related to time by the *
* following formula: \code ms = (samples*1000)/freq \endcode * \param desired an SDL_AudioSpec structure representing the desired output
* - \c desired->size is the size in bytes of the audio buffer, and is * format. Please refer to the SDL_OpenAudioDevice
* calculated by SDL_OpenAudio(). * documentation for details on how to prepare this structure.
* - \c desired->silence is the value used to set the buffer to silence, * \param obtained an SDL_AudioSpec structure filled in with the actual
* and is calculated by SDL_OpenAudio(). * parameters, or NULL.
* - \c desired->callback should be set to a function that will be called * \returns 0 if successful, placing the actual hardware parameters in the
* when the audio device is ready for more data. It is passed a pointer * structure pointed to by `obtained`.
* to the audio buffer, and the length in bytes of the audio buffer. *
* This function usually runs in a separate thread, and so you should * If `obtained` is NULL, the audio data passed to the callback
* protect data structures that it accesses by calling SDL_LockAudio() * function will be guaranteed to be in the requested format, and
* and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL * will be automatically converted to the actual hardware audio
* pointer here, and call SDL_QueueAudio() with some frequency, to queue * format if necessary. If `obtained` is NULL, `desired` will have
* more audio samples to be played (or for capture devices, call * fields modified.
* SDL_DequeueAudio() with some frequency, to obtain audio samples). *
* - \c desired->userdata is passed as the first parameter to your callback * This function returns a negative error code on failure to open the
* function. If you passed a NULL callback, this value is ignored. * audio device or failure to set up the audio thread; call
* * SDL_GetError() for more information.
* The audio device starts out playing silence when it's opened, and should *
* be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready * \since This function is available since SDL 2.0.0.
* for your audio callback function to be called. Since the audio driver *
* may modify the requested size of the audio buffer, you should allocate * \sa SDL_CloseAudio
* any local mixing buffers after you open the audio device. * \sa SDL_LockAudio
* \sa SDL_PauseAudio
* \sa SDL_UnlockAudio
*/ */
extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
SDL_AudioSpec * obtained); SDL_AudioSpec * obtained);
...@@ -330,59 +419,259 @@ extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, ...@@ -330,59 +419,259 @@ extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
typedef Uint32 SDL_AudioDeviceID; typedef Uint32 SDL_AudioDeviceID;
/** /**
* Get the number of available devices exposed by the current driver. * Get the number of built-in audio devices.
* Only valid after a successfully initializing the audio subsystem. *
* Returns -1 if an explicit list of devices can't be determined; this is * This function is only valid after successfully initializing the audio
* not an error. For example, if SDL is set up to talk to a remote audio * subsystem.
* server, it can't list every one available on the Internet, but it will *
* still allow a specific host to be specified to SDL_OpenAudioDevice(). * Note that audio capture support is not implemented as of SDL 2.0.4, so the
* `iscapture` parameter is for future expansion and should always be zero for
* now.
*
* This function will return -1 if an explicit list of devices can't be
* determined. Returning -1 is not an error. For example, if SDL is set up to
* talk to a remote audio server, it can't list every one available on the
* Internet, but it will still allow a specific host to be specified in
* SDL_OpenAudioDevice().
*
* In many common cases, when this function returns a value <= 0, it can still
* successfully open the default device (NULL for first argument of
* SDL_OpenAudioDevice()).
*
* This function may trigger a complete redetect of available hardware. It
* should not be called for each iteration of a loop, but rather once at the
* start of a loop:
* *
* In many common cases, when this function returns a value <= 0, it can still * ```c
* successfully open the default device (NULL for first argument of * // Don't do this:
* SDL_OpenAudioDevice()). * for (int i = 0; i < SDL_GetNumAudioDevices(0); i++)
*
* // do this instead:
* const int count = SDL_GetNumAudioDevices(0);
* for (int i = 0; i < count; ++i) { do_something_here(); }
* ```
*
* \param iscapture zero to request playback devices, non-zero to request
* recording devices
* \returns the number of available devices exposed by the current driver or
* -1 if an explicit list of devices can't be determined. A return
* value of -1 does not necessarily mean an error condition.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetAudioDeviceName
* \sa SDL_OpenAudioDevice
*/ */
extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture); extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
/** /**
* Get the human-readable name of a specific audio device. * Get the human-readable name of a specific audio device.
* Must be a value between 0 and (number of audio devices-1). *
* Only valid after a successfully initializing the audio subsystem. * This function is only valid after successfully initializing the audio
* The values returned by this function reflect the latest call to * subsystem. The values returned by this function reflect the latest call to
* SDL_GetNumAudioDevices(); recall that function to redetect available * SDL_GetNumAudioDevices(); re-call that function to redetect available
* hardware. * hardware.
* *
* The string returned by this function is UTF-8 encoded, read-only, and * The string returned by this function is UTF-8 encoded, read-only, and
* managed internally. You are not to free it. If you need to keep the * managed internally. You are not to free it. If you need to keep the string
* string for any length of time, you should make your own copy of it, as it * for any length of time, you should make your own copy of it, as it will be
* will be invalid next time any of several other SDL functions is called. * invalid next time any of several other SDL functions are called.
*
* \param index the index of the audio device; valid values range from 0 to
* SDL_GetNumAudioDevices() - 1
* \param iscapture non-zero to query the list of recording devices, zero to
* query the list of output devices.
* \returns the name of the audio device at the requested index, or NULL on
* error.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetNumAudioDevices
* \sa SDL_GetDefaultAudioInfo
*/ */
extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
int iscapture); int iscapture);
/** /**
* Open a specific audio device. Passing in a device name of NULL requests * Get the preferred audio format of a specific audio device.
* the most reasonable default (and is equivalent to calling SDL_OpenAudio()). *
* This function is only valid after a successfully initializing the audio
* subsystem. The values returned by this function reflect the latest call to
* SDL_GetNumAudioDevices(); re-call that function to redetect available
* hardware.
*
* `spec` will be filled with the sample rate, sample format, and channel
* count.
* *
* The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but * \param index the index of the audio device; valid values range from 0 to
* some drivers allow arbitrary and driver-specific strings, such as a * SDL_GetNumAudioDevices() - 1
* hostname/IP address for a remote audio server, or a filename in the * \param iscapture non-zero to query the list of recording devices, zero to
* diskaudio driver. * query the list of output devices.
* \param spec The SDL_AudioSpec to be initialized by this function.
* \returns 0 on success, nonzero on error
* *
* \return 0 on error, a valid device ID that is >= 2 on success. * \since This function is available since SDL 2.0.16.
* *
* SDL_OpenAudio(), unlike this function, always acts on device ID 1. * \sa SDL_GetNumAudioDevices
* \sa SDL_GetDefaultAudioInfo
*/
extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
int iscapture,
SDL_AudioSpec *spec);
/**
* Get the name and preferred format of the default audio device.
*
* Some (but not all!) platforms have an isolated mechanism to get information
* about the "default" device. This can actually be a completely different
* device that's not in the list you get from SDL_GetAudioDeviceSpec(). It can
* even be a network address! (This is discussed in SDL_OpenAudioDevice().)
*
* As a result, this call is not guaranteed to be performant, as it can query
* the sound server directly every time, unlike the other query functions. You
* should call this function sparingly!
*
* `spec` will be filled with the sample rate, sample format, and channel
* count, if a default device exists on the system. If `name` is provided,
* will be filled with either a dynamically-allocated UTF-8 string or NULL.
*
* \param name A pointer to be filled with the name of the default device (can
* be NULL). Please call SDL_free() when you are done with this
* pointer!
* \param spec The SDL_AudioSpec to be initialized by this function.
* \param iscapture non-zero to query the default recording device, zero to
* query the default output device.
* \returns 0 on success, nonzero on error
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GetAudioDeviceName
* \sa SDL_GetAudioDeviceSpec
* \sa SDL_OpenAudioDevice
*/
extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
SDL_AudioSpec *spec,
int iscapture);
/**
* Open a specific audio device.
*
* SDL_OpenAudio(), unlike this function, always acts on device ID 1. As such,
* this function will never return a 1 so as not to conflict with the legacy
* function.
*
* Please note that SDL 2.0 before 2.0.5 did not support recording; as such,
* this function would fail if `iscapture` was not zero. Starting with SDL
* 2.0.5, recording is implemented and this value can be non-zero.
*
* Passing in a `device` name of NULL requests the most reasonable default
* (and is equivalent to what SDL_OpenAudio() does to choose a device). The
* `device` name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but
* some drivers allow arbitrary and driver-specific strings, such as a
* hostname/IP address for a remote audio server, or a filename in the
* diskaudio driver.
*
* An opened audio device starts out paused, and should be enabled for playing
* by calling SDL_PauseAudioDevice(devid, 0) when you are ready for your audio
* callback function to be called. Since the audio driver may modify the
* requested size of the audio buffer, you should allocate any local mixing
* buffers after you open the audio device.
*
* The audio callback runs in a separate thread in most cases; you can prevent
* race conditions between your callback and other threads without fully
* pausing playback with SDL_LockAudioDevice(). For more information about the
* callback, see SDL_AudioSpec.
*
* Managing the audio spec via 'desired' and 'obtained':
*
* When filling in the desired audio spec structure:
*
* - `desired->freq` should be the frequency in sample-frames-per-second (Hz).
* - `desired->format` should be the audio format (`AUDIO_S16SYS`, etc).
* - `desired->samples` is the desired size of the audio buffer, in _sample
* frames_ (with stereo output, two samples--left and right--would make a
* single sample frame). This number should be a power of two, and may be
* adjusted by the audio driver to a value more suitable for the hardware.
* Good values seem to range between 512 and 8096 inclusive, depending on
* the application and CPU speed. Smaller values reduce latency, but can
* lead to underflow if the application is doing heavy processing and cannot
* fill the audio buffer in time. Note that the number of sample frames is
* directly related to time by the following formula: `ms =
* (sampleframes*1000)/freq`
* - `desired->size` is the size in _bytes_ of the audio buffer, and is
* calculated by SDL_OpenAudioDevice(). You don't initialize this.
* - `desired->silence` is the value used to set the buffer to silence, and is
* calculated by SDL_OpenAudioDevice(). You don't initialize this.
* - `desired->callback` should be set to a function that will be called when
* the audio device is ready for more data. It is passed a pointer to the
* audio buffer, and the length in bytes of the audio buffer. This function
* usually runs in a separate thread, and so you should protect data
* structures that it accesses by calling SDL_LockAudioDevice() and
* SDL_UnlockAudioDevice() in your code. Alternately, you may pass a NULL
* pointer here, and call SDL_QueueAudio() with some frequency, to queue
* more audio samples to be played (or for capture devices, call
* SDL_DequeueAudio() with some frequency, to obtain audio samples).
* - `desired->userdata` is passed as the first parameter to your callback
* function. If you passed a NULL callback, this value is ignored.
*
* `allowed_changes` can have the following flags OR'd together:
*
* - `SDL_AUDIO_ALLOW_FREQUENCY_CHANGE`
* - `SDL_AUDIO_ALLOW_FORMAT_CHANGE`
* - `SDL_AUDIO_ALLOW_CHANNELS_CHANGE`
* - `SDL_AUDIO_ALLOW_SAMPLES_CHANGE`
* - `SDL_AUDIO_ALLOW_ANY_CHANGE`
*
* These flags specify how SDL should behave when a device cannot offer a
* specific feature. If the application requests a feature that the hardware
* doesn't offer, SDL will always try to get the closest equivalent.
*
* For example, if you ask for float32 audio format, but the sound card only
* supports int16, SDL will set the hardware to int16. If you had set
* SDL_AUDIO_ALLOW_FORMAT_CHANGE, SDL will change the format in the `obtained`
* structure. If that flag was *not* set, SDL will prepare to convert your
* callback's float32 audio to int16 before feeding it to the hardware and
* will keep the originally requested format in the `obtained` structure.
*
* The resulting audio specs, varying depending on hardware and on what
* changes were allowed, will then be written back to `obtained`.
*
* If your application can only handle one specific data format, pass a zero
* for `allowed_changes` and let SDL transparently handle any differences.
*
* \param device a UTF-8 string reported by SDL_GetAudioDeviceName() or a
* driver-specific name as appropriate. NULL requests the most
* reasonable default device.
* \param iscapture non-zero to specify a device should be opened for
* recording, not playback
* \param desired an SDL_AudioSpec structure representing the desired output
* format; see SDL_OpenAudio() for more information
* \param obtained an SDL_AudioSpec structure filled in with the actual output
* format; see SDL_OpenAudio() for more information
* \param allowed_changes 0, or one or more flags OR'd together
* \returns a valid device ID that is > 0 on success or 0 on failure; call
* SDL_GetError() for more information.
*
* For compatibility with SDL 1.2, this will never return 1, since
* SDL reserves that ID for the legacy SDL_OpenAudio() function.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_CloseAudioDevice
* \sa SDL_GetAudioDeviceName
* \sa SDL_LockAudioDevice
* \sa SDL_OpenAudio
* \sa SDL_PauseAudioDevice
* \sa SDL_UnlockAudioDevice
*/ */
extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(
*device, const char *device,
int iscapture, int iscapture,
const const SDL_AudioSpec *desired,
SDL_AudioSpec * SDL_AudioSpec *obtained,
desired, int allowed_changes);
SDL_AudioSpec *
obtained,
int
allowed_changes);
...@@ -398,10 +687,39 @@ typedef enum ...@@ -398,10 +687,39 @@ typedef enum
SDL_AUDIO_PLAYING, SDL_AUDIO_PLAYING,
SDL_AUDIO_PAUSED SDL_AUDIO_PAUSED
} SDL_AudioStatus; } SDL_AudioStatus;
/**
* This function is a legacy means of querying the audio device.
*
* New programs might want to use SDL_GetAudioDeviceStatus() instead. This
* function is equivalent to calling...
*
* ```c
* SDL_GetAudioDeviceStatus(1);
* ```
*
* ...and is only useful if you used the legacy SDL_OpenAudio() function.
*
* \returns the SDL_AudioStatus of the audio device opened by SDL_OpenAudio().
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetAudioDeviceStatus
*/
extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void);
extern DECLSPEC SDL_AudioStatus SDLCALL /**
SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); * Use this function to get the current audio state of an audio device.
*
* \param dev the ID of an audio device previously opened with
* SDL_OpenAudioDevice()
* \returns the SDL_AudioStatus of the specified audio device.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PauseAudioDevice
*/
extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev);
/* @} *//* Audio State */ /* @} *//* Audio State */
/** /**
...@@ -414,62 +732,140 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); ...@@ -414,62 +732,140 @@ SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev);
* Silence will be written to the audio device during the pause. * Silence will be written to the audio device during the pause.
*/ */
/* @{ */ /* @{ */
extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
int pause_on);
/* @} *//* Pause audio functions */
/** /**
* \brief Load the audio data of a WAVE file into memory * This function is a legacy means of pausing the audio device.
* *
* Loading a WAVE file requires \c src, \c spec, \c audio_buf and \c audio_len * New programs might want to use SDL_PauseAudioDevice() instead. This
* to be valid pointers. The entire data portion of the file is then loaded * function is equivalent to calling...
* into memory and decoded if necessary.
* *
* If \c freesrc is non-zero, the data source gets automatically closed and * ```c
* freed before the function returns. * SDL_PauseAudioDevice(1, pause_on);
* ```
* *
* Supported are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 bits), * ...and is only useful if you used the legacy SDL_OpenAudio() function.
* IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law and
* µ-law (8 bits). Other formats are currently unsupported and cause an error.
* *
* If this function succeeds, the pointer returned by it is equal to \c spec * \param pause_on non-zero to pause, 0 to unpause
* and the pointer to the audio data allocated by the function is written to
* \c audio_buf and its length in bytes to \c audio_len. The \ref SDL_AudioSpec
* members \c freq, \c channels, and \c format are set to the values of the
* audio data in the buffer. The \c samples member is set to a sane default and
* all others are set to zero.
* *
* It's necessary to use SDL_FreeWAV() to free the audio data returned in * \since This function is available since SDL 2.0.0.
* \c audio_buf when it is no longer used.
* *
* Because of the underspecification of the Waveform format, there are many * \sa SDL_GetAudioStatus
* problematic files in the wild that cause issues with strict decoders. To * \sa SDL_PauseAudioDevice
* provide compatibility with these files, this decoder is lenient in regards */
* to the truncation of the file, the fact chunk, and the size of the RIFF extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
* chunk. The hints SDL_HINT_WAVE_RIFF_CHUNK_SIZE, SDL_HINT_WAVE_TRUNCATION,
* and SDL_HINT_WAVE_FACT_CHUNK can be used to tune the behavior of the /**
* loading process. * Use this function to pause and unpause audio playback on a specified
* device.
*
* This function pauses and unpauses the audio callback processing for a given
* device. Newly-opened audio devices start in the paused state, so you must
* call this function with **pause_on**=0 after opening the specified audio
* device to start playing sound. This allows you to safely initialize data
* for your callback function after opening the audio device. Silence will be
* written to the audio device while paused, and the audio callback is
* guaranteed to not be called. Pausing one device does not prevent other
* unpaused devices from running their callbacks.
*
* Pausing state does not stack; even if you pause a device several times, a
* single unpause will start the device playing again, and vice versa. This is
* different from how SDL_LockAudioDevice() works.
* *
* Any file that is invalid (due to truncation, corruption, or wrong values in * If you just need to protect a few variables from race conditions vs your
* the headers), too big, or unsupported causes an error. Additionally, any * callback, you shouldn't pause the audio device, as it will lead to dropouts
* critical I/O error from the data source will terminate the loading process * in the audio playback. Instead, you should use SDL_LockAudioDevice().
* with an error. The function returns NULL on error and in all cases (with the
* exception of \c src being NULL), an appropriate error message will be set.
* *
* It is required that the data source supports seeking. * \param dev a device opened by SDL_OpenAudioDevice()
* \param pause_on non-zero to pause, 0 to unpause
* *
* Example: * \since This function is available since SDL 2.0.0.
* \code
* SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
* \endcode
* *
* \param src The data source with the WAVE data * \sa SDL_LockAudioDevice
* \param freesrc A integer value that makes the function close the data source if non-zero */
* \param spec A pointer filled with the audio format of the audio data extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
* \param audio_buf A pointer filled with the audio data allocated by the function int pause_on);
* \param audio_len A pointer filled with the length of the audio data buffer in bytes /* @} *//* Pause audio functions */
* \return NULL on error, or non-NULL on success.
/**
* Load the audio data of a WAVE file into memory.
*
* Loading a WAVE file requires `src`, `spec`, `audio_buf` and `audio_len` to
* be valid pointers. The entire data portion of the file is then loaded into
* memory and decoded if necessary.
*
* If `freesrc` is non-zero, the data source gets automatically closed and
* freed before the function returns.
*
* Supported formats are RIFF WAVE files with the formats PCM (8, 16, 24, and
* 32 bits), IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and
* A-law and mu-law (8 bits). Other formats are currently unsupported and
* cause an error.
*
* If this function succeeds, the pointer returned by it is equal to `spec`
* and the pointer to the audio data allocated by the function is written to
* `audio_buf` and its length in bytes to `audio_len`. The SDL_AudioSpec
* members `freq`, `channels`, and `format` are set to the values of the audio
* data in the buffer. The `samples` member is set to a sane default and all
* others are set to zero.
*
* It's necessary to use SDL_FreeWAV() to free the audio data returned in
* `audio_buf` when it is no longer used.
*
* Because of the underspecification of the .WAV format, there are many
* problematic files in the wild that cause issues with strict decoders. To
* provide compatibility with these files, this decoder is lenient in regards
* to the truncation of the file, the fact chunk, and the size of the RIFF
* chunk. The hints `SDL_HINT_WAVE_RIFF_CHUNK_SIZE`,
* `SDL_HINT_WAVE_TRUNCATION`, and `SDL_HINT_WAVE_FACT_CHUNK` can be used to
* tune the behavior of the loading process.
*
* Any file that is invalid (due to truncation, corruption, or wrong values in
* the headers), too big, or unsupported causes an error. Additionally, any
* critical I/O error from the data source will terminate the loading process
* with an error. The function returns NULL on error and in all cases (with
* the exception of `src` being NULL), an appropriate error message will be
* set.
*
* It is required that the data source supports seeking.
*
* Example:
*
* ```c
* SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, &spec, &buf, &len);
* ```
*
* Note that the SDL_LoadWAV macro does this same thing for you, but in a less
* messy way:
*
* ```c
* SDL_LoadWAV("sample.wav", &spec, &buf, &len);
* ```
*
* \param src The data source for the WAVE data
* \param freesrc If non-zero, SDL will _always_ free the data source
* \param spec An SDL_AudioSpec that will be filled in with the wave file's
* format details
* \param audio_buf A pointer filled with the audio data, allocated by the
* function.
* \param audio_len A pointer filled with the length of the audio data buffer
* in bytes
* \returns This function, if successfully called, returns `spec`, which will
* be filled with the audio data format of the wave source data.
* `audio_buf` will be filled with a pointer to an allocated buffer
* containing the audio data, and `audio_len` is filled with the
* length of that audio buffer in bytes.
*
* This function returns NULL if the .WAV file cannot be opened, uses
* an unknown data format, or is corrupt; call SDL_GetError() for
* more information.
*
* When the application is done with the data returned in
* `audio_buf`, it should call SDL_FreeWAV() to dispose of it.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FreeWAV
* \sa SDL_LoadWAV
*/ */
extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
int freesrc, int freesrc,
...@@ -485,18 +881,53 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, ...@@ -485,18 +881,53 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
/** /**
* This function frees data previously allocated with SDL_LoadWAV_RW() * Free data previously allocated with SDL_LoadWAV() or SDL_LoadWAV_RW().
*
* After a WAVE file has been opened with SDL_LoadWAV() or SDL_LoadWAV_RW()
* its data can eventually be freed with SDL_FreeWAV(). It is safe to call
* this function with a NULL pointer.
*
* \param audio_buf a pointer to the buffer created by SDL_LoadWAV() or
* SDL_LoadWAV_RW()
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LoadWAV
* \sa SDL_LoadWAV_RW
*/ */
extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf); extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf);
/** /**
* This function takes a source format and rate and a destination format * Initialize an SDL_AudioCVT structure for conversion.
* and rate, and initializes the \c cvt structure with information needed *
* by SDL_ConvertAudio() to convert a buffer of audio data from one format * Before an SDL_AudioCVT structure can be used to convert audio data it must
* to the other. An unsupported format causes an error and -1 will be returned. * be initialized with source and destination information.
* *
* \return 0 if no conversion is needed, 1 if the audio filter is set up, * This function will zero out every field of the SDL_AudioCVT, so it must be
* or -1 on error. * called before the application fills in the final buffer information.
*
* Once this function has returned successfully, and reported that a
* conversion is necessary, the application fills in the rest of the fields in
* SDL_AudioCVT, now that it knows how large a buffer it needs to allocate,
* and then can call SDL_ConvertAudio() to complete the conversion.
*
* \param cvt an SDL_AudioCVT structure filled in with audio conversion
* information
* \param src_format the source format of the audio data; for more info see
* SDL_AudioFormat
* \param src_channels the number of channels in the source
* \param src_rate the frequency (sample-frames-per-second) of the source
* \param dst_format the destination format of the audio data; for more info
* see SDL_AudioFormat
* \param dst_channels the number of channels in the destination
* \param dst_rate the frequency (sample-frames-per-second) of the destination
* \returns 1 if the audio filter is prepared, 0 if no conversion is needed,
* or a negative error code on failure; call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ConvertAudio
*/ */
extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
SDL_AudioFormat src_format, SDL_AudioFormat src_format,
...@@ -507,16 +938,42 @@ extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, ...@@ -507,16 +938,42 @@ extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
int dst_rate); int dst_rate);
/** /**
* Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(), * Convert audio data to a desired audio format.
* created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of *
* audio data in the source format, this function will convert it in-place * This function does the actual audio data conversion, after the application
* to the desired format. * has called SDL_BuildAudioCVT() to prepare the conversion information and
* * then filled in the buffer details.
* The data conversion may expand the size of the audio data, so the buffer *
* \c cvt->buf should be allocated after the \c cvt structure is initialized by * Once the application has initialized the `cvt` structure using
* SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long. * SDL_BuildAudioCVT(), allocated an audio buffer and filled it with audio
* * data in the source format, this function will convert the buffer, in-place,
* \return 0 on success or -1 if \c cvt->buf is NULL. * to the desired format.
*
* The data conversion may go through several passes; any given pass may
* possibly temporarily increase the size of the data. For example, SDL might
* expand 16-bit data to 32 bits before resampling to a lower frequency,
* shrinking the data size after having grown it briefly. Since the supplied
* buffer will be both the source and destination, converting as necessary
* in-place, the application must allocate a buffer that will fully contain
* the data during its largest conversion pass. After SDL_BuildAudioCVT()
* returns, the application should set the `cvt->len` field to the size, in
* bytes, of the source data, and allocate a buffer that is `cvt->len *
* cvt->len_mult` bytes long for the `buf` field.
*
* The source data should be copied into this buffer before the call to
* SDL_ConvertAudio(). Upon successful return, this buffer will contain the
* converted audio, and `cvt->len_cvt` will be the size of the converted data,
* in bytes. Any bytes in the buffer past `cvt->len_cvt` are undefined once
* this function returns.
*
* \param cvt an SDL_AudioCVT structure that was previously set up by
* SDL_BuildAudioCVT().
* \returns 0 if the conversion was completed successfully or a negative error
* code on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BuildAudioCVT
*/ */
extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt); extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt);
...@@ -532,22 +989,24 @@ struct _SDL_AudioStream; ...@@ -532,22 +989,24 @@ struct _SDL_AudioStream;
typedef struct _SDL_AudioStream SDL_AudioStream; typedef struct _SDL_AudioStream SDL_AudioStream;
/** /**
* Create a new audio stream * Create a new audio stream.
* *
* \param src_format The format of the source audio * \param src_format The format of the source audio
* \param src_channels The number of channels of the source audio * \param src_channels The number of channels of the source audio
* \param src_rate The sampling rate of the source audio * \param src_rate The sampling rate of the source audio
* \param dst_format The format of the desired audio output * \param dst_format The format of the desired audio output
* \param dst_channels The number of channels of the desired audio output * \param dst_channels The number of channels of the desired audio output
* \param dst_rate The sampling rate of the desired audio output * \param dst_rate The sampling rate of the desired audio output
* \return 0 on success, or -1 on error. * \returns 0 on success, or -1 on error.
* *
* \sa SDL_AudioStreamPut * \since This function is available since SDL 2.0.7.
* \sa SDL_AudioStreamGet *
* \sa SDL_AudioStreamAvailable * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamFlush * \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamClear * \sa SDL_AudioStreamAvailable
* \sa SDL_FreeAudioStream * \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
*/ */
extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioFormat src_format, extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioFormat src_format,
const Uint8 src_channels, const Uint8 src_channels,
...@@ -557,110 +1016,164 @@ extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioForm ...@@ -557,110 +1016,164 @@ extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioForm
const int dst_rate); const int dst_rate);
/** /**
* Add data to be converted/resampled to the stream * Add data to be converted/resampled to the stream.
*
* \param stream The stream the audio data is being added to
* \param buf A pointer to the audio data to add
* \param len The number of bytes to write to the stream
* \returns 0 on success, or -1 on error.
* *
* \param stream The stream the audio data is being added to * \since This function is available since SDL 2.0.7.
* \param buf A pointer to the audio data to add
* \param len The number of bytes to write to the stream
* \return 0 on success, or -1 on error.
* *
* \sa SDL_NewAudioStream * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamGet * \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable * \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush * \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear * \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream * \sa SDL_FreeAudioStream
*/ */
extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len); extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len);
/** /**
* Get converted/resampled data from the stream * Get converted/resampled data from the stream
* *
* \param stream The stream the audio is being requested from * \param stream The stream the audio is being requested from
* \param buf A buffer to fill with audio data * \param buf A buffer to fill with audio data
* \param len The maximum number of bytes to fill * \param len The maximum number of bytes to fill
* \return The number of bytes read from the stream, or -1 on error * \returns the number of bytes read from the stream, or -1 on error
* *
* \sa SDL_NewAudioStream * \since This function is available since SDL 2.0.7.
* \sa SDL_AudioStreamPut *
* \sa SDL_AudioStreamAvailable * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamFlush * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamClear * \sa SDL_AudioStreamAvailable
* \sa SDL_FreeAudioStream * \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
*/ */
extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len); extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len);
/** /**
* Get the number of converted/resampled bytes available. The stream may be * Get the number of converted/resampled bytes available.
* buffering data behind the scenes until it has enough to resample *
* correctly, so this number might be lower than what you expect, or even * The stream may be buffering data behind the scenes until it has enough to
* be zero. Add more data or flush the stream if you need the data now. * resample correctly, so this number might be lower than what you expect, or
* even be zero. Add more data or flush the stream if you need the data now.
*
* \since This function is available since SDL 2.0.7.
* *
* \sa SDL_NewAudioStream * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet * \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamFlush * \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear * \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream * \sa SDL_FreeAudioStream
*/ */
extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream); extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream);
/** /**
* Tell the stream that you're done sending data, and anything being buffered * Tell the stream that you're done sending data, and anything being buffered
* should be converted/resampled and made available immediately. * should be converted/resampled and made available immediately.
* *
* It is legal to add more data to a stream after flushing, but there will * It is legal to add more data to a stream after flushing, but there will be
* be audio gaps in the output. Generally this is intended to signal the * audio gaps in the output. Generally this is intended to signal the end of
* end of input, so the complete output becomes available. * input, so the complete output becomes available.
* *
* \sa SDL_NewAudioStream * \since This function is available since SDL 2.0.7.
* \sa SDL_AudioStreamPut *
* \sa SDL_AudioStreamGet * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamAvailable * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamClear * \sa SDL_AudioStreamGet
* \sa SDL_FreeAudioStream * \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamClear
* \sa SDL_FreeAudioStream
*/ */
extern DECLSPEC int SDLCALL SDL_AudioStreamFlush(SDL_AudioStream *stream); extern DECLSPEC int SDLCALL SDL_AudioStreamFlush(SDL_AudioStream *stream);
/** /**
* Clear any pending data in the stream without converting it * Clear any pending data in the stream without converting it
*
* \since This function is available since SDL 2.0.7.
* *
* \sa SDL_NewAudioStream * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamPut * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamGet * \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamAvailable * \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush * \sa SDL_AudioStreamFlush
* \sa SDL_FreeAudioStream * \sa SDL_FreeAudioStream
*/ */
extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream); extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream);
/** /**
* Free an audio stream * Free an audio stream
* *
* \sa SDL_NewAudioStream * \since This function is available since SDL 2.0.7.
* \sa SDL_AudioStreamPut *
* \sa SDL_AudioStreamGet * \sa SDL_NewAudioStream
* \sa SDL_AudioStreamAvailable * \sa SDL_AudioStreamPut
* \sa SDL_AudioStreamFlush * \sa SDL_AudioStreamGet
* \sa SDL_AudioStreamClear * \sa SDL_AudioStreamAvailable
* \sa SDL_AudioStreamFlush
* \sa SDL_AudioStreamClear
*/ */
extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream); extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
#define SDL_MIX_MAXVOLUME 128 #define SDL_MIX_MAXVOLUME 128
/** /**
* This takes two audio buffers of the playing audio format and mixes * This function is a legacy means of mixing audio.
* them, performing addition, volume adjustment, and overflow clipping. *
* The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME * This function is equivalent to calling...
* for full audio volume. Note this does not change hardware volume. *
* This is provided for convenience -- you can mix your own audio data. * ```c
* SDL_MixAudioFormat(dst, src, format, len, volume);
* ```
*
* ...where `format` is the obtained format of the audio device from the
* legacy SDL_OpenAudio() function.
*
* \param dst the destination for the mixed audio
* \param src the source audio buffer to be mixed
* \param len the length of the audio buffer in bytes
* \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
* for full audio volume
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_MixAudioFormat
*/ */
extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src, extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
Uint32 len, int volume); Uint32 len, int volume);
/** /**
* This works like SDL_MixAudio(), but you specify the audio format instead of * Mix audio data in a specified format.
* using the format of audio device 1. Thus it can be used when no audio *
* device is open at all. * This takes an audio buffer `src` of `len` bytes of `format` data and mixes
* it into `dst`, performing addition, volume adjustment, and overflow
* clipping. The buffer pointed to by `dst` must also be `len` bytes of
* `format` data.
*
* This is provided for convenience -- you can mix your own audio data.
*
* Do not use this function for mixing together more than two streams of
* sample data. The output from repeated application of this function may be
* distorted by clipping, because there is no accumulator with greater range
* than the input (not to mention this being an inefficient way of doing it).
*
* It is a common misconception that this function is required to write audio
* data to an output stream in an audio callback. While you can do that,
* SDL_MixAudioFormat() is really only needed when you're mixing a single
* audio stream with a volume adjustment.
*
* \param dst the destination for the mixed audio
* \param src the source audio buffer to be mixed
* \param format the SDL_AudioFormat structure representing the desired audio
* format
* \param len the length of the audio buffer in bytes
* \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
* for full audio volume
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
const Uint8 * src, const Uint8 * src,
...@@ -668,184 +1181,312 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, ...@@ -668,184 +1181,312 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
Uint32 len, int volume); Uint32 len, int volume);
/** /**
* Queue more audio on non-callback devices. * Queue more audio on non-callback devices.
*
* If you are looking to retrieve queued audio from a non-callback capture
* device, you want SDL_DequeueAudio() instead. SDL_QueueAudio() will return
* -1 to signify an error if you use it with capture devices.
*
* SDL offers two ways to feed audio to the device: you can either supply a
* callback that SDL triggers with some frequency to obtain more audio (pull
* method), or you can supply no callback, and then SDL will expect you to
* supply data at regular intervals (push method) with this function.
*
* There are no limits on the amount of data you can queue, short of
* exhaustion of address space. Queued data will drain to the device as
* necessary without further intervention from you. If the device needs audio
* but there is not enough queued, it will play silence to make up the
* difference. This means you will have skips in your audio playback if you
* aren't routinely queueing sufficient data.
*
* This function copies the supplied data, so you are safe to free it when the
* function returns. This function is thread-safe, but queueing to the same
* device from two threads at once does not promise which buffer will be
* queued first.
*
* You may not queue audio on a device that is using an application-supplied
* callback; doing so returns an error. You have to use the audio callback or
* queue audio with this function, but not both.
*
* You should not call SDL_LockAudio() on the device before queueing; SDL
* handles locking internally for this function.
*
* Note that SDL2 does not support planar audio. You will need to resample
* from planar audio formats into a non-planar one (see SDL_AudioFormat)
* before queuing audio.
*
* \param dev the device ID to which we will queue audio
* \param data the data to queue to the device for later playback
* \param len the number of bytes (not samples!) to which `data` points
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.4.
*
* \sa SDL_ClearQueuedAudio
* \sa SDL_GetQueuedAudioSize
*/
extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len);
/**
* Dequeue more audio on non-callback devices.
*
* If you are looking to queue audio for output on a non-callback playback
* device, you want SDL_QueueAudio() instead. SDL_DequeueAudio() will always
* return 0 if you use it with playback devices.
*
* SDL offers two ways to retrieve audio from a capture device: you can either
* supply a callback that SDL triggers with some frequency as the device
* records more audio data, (push method), or you can supply no callback, and
* then SDL will expect you to retrieve data at regular intervals (pull
* method) with this function.
*
* There are no limits on the amount of data you can queue, short of
* exhaustion of address space. Data from the device will keep queuing as
* necessary without further intervention from you. This means you will
* eventually run out of memory if you aren't routinely dequeueing data.
*
* Capture devices will not queue data when paused; if you are expecting to
* not need captured audio for some length of time, use SDL_PauseAudioDevice()
* to stop the capture device from queueing more data. This can be useful
* during, say, level loading times. When unpaused, capture devices will start
* queueing data from that point, having flushed any capturable data available
* while paused.
*
* This function is thread-safe, but dequeueing from the same device from two
* threads at once does not promise which thread will dequeue data first.
*
* You may not dequeue audio from a device that is using an
* application-supplied callback; doing so returns an error. You have to use
* the audio callback, or dequeue audio with this function, but not both.
*
* You should not call SDL_LockAudio() on the device before dequeueing; SDL
* handles locking internally for this function.
*
* \param dev the device ID from which we will dequeue audio
* \param data a pointer into where audio data should be copied
* \param len the number of bytes (not samples!) to which (data) points
* \returns the number of bytes dequeued, which could be less than requested;
* call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.5.
*
* \sa SDL_ClearQueuedAudio
* \sa SDL_GetQueuedAudioSize
*/
extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len);
/**
* Get the number of bytes of still-queued audio.
* *
* (If you are looking to retrieve queued audio from a non-callback capture * For playback devices: this is the number of bytes that have been queued for
* device, you want SDL_DequeueAudio() instead. This will return -1 to * playback with SDL_QueueAudio(), but have not yet been sent to the hardware.
* signify an error if you use it with capture devices.)
* *
* SDL offers two ways to feed audio to the device: you can either supply a * Once we've sent it to the hardware, this function can not decide the exact
* callback that SDL triggers with some frequency to obtain more audio * byte boundary of what has been played. It's possible that we just gave the
* (pull method), or you can supply no callback, and then SDL will expect * hardware several kilobytes right before you called this function, but it
* you to supply data at regular intervals (push method) with this function. * hasn't played any of it yet, or maybe half of it, etc.
* *
* There are no limits on the amount of data you can queue, short of * For capture devices, this is the number of bytes that have been captured by
* exhaustion of address space. Queued data will drain to the device as * the device and are waiting for you to dequeue. This number may grow at any
* necessary without further intervention from you. If the device needs * time, so this only informs of the lower-bound of available data.
* audio but there is not enough queued, it will play silence to make up
* the difference. This means you will have skips in your audio playback
* if you aren't routinely queueing sufficient data.
* *
* This function copies the supplied data, so you are safe to free it when * You may not queue or dequeue audio on a device that is using an
* the function returns. This function is thread-safe, but queueing to the * application-supplied callback; calling this function on such a device
* same device from two threads at once does not promise which buffer will * always returns 0. You have to use the audio callback or queue audio, but
* be queued first. * not both.
* *
* You may not queue audio on a device that is using an application-supplied * You should not call SDL_LockAudio() on the device before querying; SDL
* callback; doing so returns an error. You have to use the audio callback * handles locking internally for this function.
* or queue audio with this function, but not both.
* *
* You should not call SDL_LockAudio() on the device before queueing; SDL * \param dev the device ID of which we will query queued audio size
* handles locking internally for this function. * \returns the number of bytes (not samples!) of queued audio.
* *
* \param dev The device ID to which we will queue audio. * \since This function is available since SDL 2.0.4.
* \param data The data to queue to the device for later playback.
* \param len The number of bytes (not samples!) to which (data) points.
* \return 0 on success, or -1 on error.
* *
* \sa SDL_GetQueuedAudioSize * \sa SDL_ClearQueuedAudio
* \sa SDL_ClearQueuedAudio * \sa SDL_QueueAudio
* \sa SDL_DequeueAudio
*/ */
extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len); extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev);
/** /**
* Dequeue more audio on non-callback devices. * Drop any queued audio data waiting to be sent to the hardware.
* *
* (If you are looking to queue audio for output on a non-callback playback * Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For
* device, you want SDL_QueueAudio() instead. This will always return 0 * output devices, the hardware will start playing silence if more audio isn't
* if you use it with playback devices.) * queued. For capture devices, the hardware will start filling the empty
* queue with new data if the capture device isn't paused.
* *
* SDL offers two ways to retrieve audio from a capture device: you can * This will not prevent playback of queued audio that's already been sent to
* either supply a callback that SDL triggers with some frequency as the * the hardware, as we can not undo that, so expect there to be some fraction
* device records more audio data, (push method), or you can supply no * of a second of audio that might still be heard. This can be useful if you
* callback, and then SDL will expect you to retrieve data at regular * want to, say, drop any pending music or any unprocessed microphone input
* intervals (pull method) with this function. * during a level change in your game.
* *
* There are no limits on the amount of data you can queue, short of * You may not queue or dequeue audio on a device that is using an
* exhaustion of address space. Data from the device will keep queuing as * application-supplied callback; calling this function on such a device
* necessary without further intervention from you. This means you will * always returns 0. You have to use the audio callback or queue audio, but
* eventually run out of memory if you aren't routinely dequeueing data. * not both.
* *
* Capture devices will not queue data when paused; if you are expecting * You should not call SDL_LockAudio() on the device before clearing the
* to not need captured audio for some length of time, use * queue; SDL handles locking internally for this function.
* SDL_PauseAudioDevice() to stop the capture device from queueing more
* data. This can be useful during, say, level loading times. When
* unpaused, capture devices will start queueing data from that point,
* having flushed any capturable data available while paused.
* *
* This function is thread-safe, but dequeueing from the same device from * This function always succeeds and thus returns void.
* two threads at once does not promise which thread will dequeued data
* first.
* *
* You may not dequeue audio from a device that is using an * \param dev the device ID of which to clear the audio queue
* application-supplied callback; doing so returns an error. You have to use
* the audio callback, or dequeue audio with this function, but not both.
* *
* You should not call SDL_LockAudio() on the device before queueing; SDL * \since This function is available since SDL 2.0.4.
* handles locking internally for this function.
* *
* \param dev The device ID from which we will dequeue audio. * \sa SDL_GetQueuedAudioSize
* \param data A pointer into where audio data should be copied. * \sa SDL_QueueAudio
* \param len The number of bytes (not samples!) to which (data) points. * \sa SDL_DequeueAudio
* \return number of bytes dequeued, which could be less than requested. */
extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev);
/**
* \name Audio lock functions
* *
* \sa SDL_GetQueuedAudioSize * The lock manipulated by these functions protects the callback function.
* \sa SDL_ClearQueuedAudio * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that
* the callback function is not running. Do not call these from the callback
* function or you will cause deadlock.
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len); /* @{ */
/** /**
* Get the number of bytes of still-queued audio. * This function is a legacy means of locking the audio device.
* *
* For playback device: * New programs might want to use SDL_LockAudioDevice() instead. This function
* is equivalent to calling...
* *
* This is the number of bytes that have been queued for playback with * ```c
* SDL_QueueAudio(), but have not yet been sent to the hardware. This * SDL_LockAudioDevice(1);
* number may shrink at any time, so this only informs of pending data. * ```
* *
* Once we've sent it to the hardware, this function can not decide the * ...and is only useful if you used the legacy SDL_OpenAudio() function.
* exact byte boundary of what has been played. It's possible that we just
* gave the hardware several kilobytes right before you called this
* function, but it hasn't played any of it yet, or maybe half of it, etc.
* *
* For capture devices: * \since This function is available since SDL 2.0.0.
* *
* This is the number of bytes that have been captured by the device and * \sa SDL_LockAudioDevice
* are waiting for you to dequeue. This number may grow at any time, so * \sa SDL_UnlockAudio
* this only informs of the lower-bound of available data. * \sa SDL_UnlockAudioDevice
*/
extern DECLSPEC void SDLCALL SDL_LockAudio(void);
/**
* Use this function to lock out the audio callback function for a specified
* device.
* *
* You may not queue audio on a device that is using an application-supplied * The lock manipulated by these functions protects the audio callback
* callback; calling this function on such a device always returns 0. * function specified in SDL_OpenAudioDevice(). During a
* You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use * SDL_LockAudioDevice()/SDL_UnlockAudioDevice() pair, you can be guaranteed
* the audio callback, but not both. * that the callback function for that device is not running, even if the
* device is not paused. While a device is locked, any other unpaused,
* unlocked devices may still run their callbacks.
* *
* You should not call SDL_LockAudio() on the device before querying; SDL * Calling this function from inside your audio callback is unnecessary. SDL
* handles locking internally for this function. * obtains this lock before calling your function, and releases it when the
* function returns.
* *
* \param dev The device ID of which we will query queued audio size. * You should not hold the lock longer than absolutely necessary. If you hold
* \return Number of bytes (not samples!) of queued audio. * it too long, you'll experience dropouts in your audio playback. Ideally,
* your application locks the device, sets a few variables and unlocks again.
* Do not do heavy work while holding the lock for a device.
* *
* \sa SDL_QueueAudio * It is safe to lock the audio device multiple times, as long as you unlock
* \sa SDL_ClearQueuedAudio * it an equivalent number of times. The callback will not run until the
* device has been unlocked completely in this way. If your application fails
* to unlock the device appropriately, your callback will never run, you might
* hear repeating bursts of audio, and SDL_CloseAudioDevice() will probably
* deadlock.
*
* Internally, the audio device lock is a mutex; if you lock from two threads
* at once, not only will you block the audio callback, you'll block the other
* thread.
*
* \param dev the ID of the device to be locked
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_UnlockAudioDevice
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
/** /**
* Drop any queued audio data. For playback devices, this is any queued data * This function is a legacy means of unlocking the audio device.
* still waiting to be submitted to the hardware. For capture devices, this
* is any data that was queued by the device that hasn't yet been dequeued by
* the application.
*
* Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For
* playback devices, the hardware will start playing silence if more audio
* isn't queued. Unpaused capture devices will start filling the queue again
* as soon as they have more data available (which, depending on the state
* of the hardware and the thread, could be before this function call
* returns!).
*
* This will not prevent playback of queued audio that's already been sent
* to the hardware, as we can not undo that, so expect there to be some
* fraction of a second of audio that might still be heard. This can be
* useful if you want to, say, drop any pending music during a level change
* in your game.
* *
* You may not queue audio on a device that is using an application-supplied * New programs might want to use SDL_UnlockAudioDevice() instead. This
* callback; calling this function on such a device is always a no-op. * function is equivalent to calling...
* You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use
* the audio callback, but not both.
* *
* You should not call SDL_LockAudio() on the device before clearing the * ```c
* queue; SDL handles locking internally for this function. * SDL_UnlockAudioDevice(1);
* ```
* *
* This function always succeeds and thus returns void. * ...and is only useful if you used the legacy SDL_OpenAudio() function.
* *
* \param dev The device ID of which to clear the audio queue. * \since This function is available since SDL 2.0.0.
* *
* \sa SDL_QueueAudio * \sa SDL_LockAudio
* \sa SDL_GetQueuedAudioSize * \sa SDL_UnlockAudioDevice
*/ */
extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
/** /**
* \name Audio lock functions * Use this function to unlock the audio callback function for a specified
* device.
* *
* The lock manipulated by these functions protects the callback function. * This function should be paired with a previous SDL_LockAudioDevice() call.
* During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that *
* the callback function is not running. Do not call these from the callback * \param dev the ID of the device to be unlocked
* function or you will cause deadlock. *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LockAudioDevice
*/ */
/* @{ */
extern DECLSPEC void SDLCALL SDL_LockAudio(void);
extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev);
extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
/* @} *//* Audio lock functions */ /* @} *//* Audio lock functions */
/** /**
* This function shuts down audio processing and closes the audio device. * This function is a legacy means of closing the audio device.
*
* This function is equivalent to calling...
*
* ```c
* SDL_CloseAudioDevice(1);
* ```
*
* ...and is only useful if you used the legacy SDL_OpenAudio() function.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_OpenAudio
*/ */
extern DECLSPEC void SDLCALL SDL_CloseAudio(void); extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
/**
* Use this function to shut down audio processing and close the audio device.
*
* The application should close open audio devices once they are no longer
* needed. Calling this function will wait until the device's audio callback
* is not running, release the audio hardware and then clean up internal
* state. No further audio will play from this device once this function
* returns.
*
* This function may block briefly while pending audio data is played by the
* hardware, so that applications don't drop the last buffer of data they
* supplied.
*
* The device ID is invalid as soon as the device is closed, and is eligible
* for reuse in a new SDL_OpenAudioDevice() call immediately.
*
* \param dev an audio device previously opened with SDL_OpenAudioDevice()
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_OpenAudioDevice
*/
extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev); extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -45,13 +45,12 @@ extern "C" { ...@@ -45,13 +45,12 @@ extern "C" {
* with 0. This operation can also be stated as "count leading zeroes" and * with 0. This operation can also be stated as "count leading zeroes" and
* "log base 2". * "log base 2".
* *
* \return Index of the most significant bit, or -1 if the value is 0. * \return the index of the most significant bit, or -1 if the value is 0.
*/ */
#if defined(__WATCOMC__) && defined(__386__) #if defined(__WATCOMC__) && defined(__386__)
extern _inline int _SDL_clz_watcom (Uint32); extern __inline int _SDL_bsr_watcom(Uint32);
#pragma aux _SDL_clz_watcom = \ #pragma aux _SDL_bsr_watcom = \
"bsr eax, eax" \ "bsr eax, eax" \
"xor eax, 31" \
parm [eax] nomemory \ parm [eax] nomemory \
value [eax] \ value [eax] \
modify exact [eax] nomemory; modify exact [eax] nomemory;
...@@ -72,7 +71,13 @@ SDL_MostSignificantBitIndex32(Uint32 x) ...@@ -72,7 +71,13 @@ SDL_MostSignificantBitIndex32(Uint32 x)
if (x == 0) { if (x == 0) {
return -1; return -1;
} }
return 31 - _SDL_clz_watcom(x); return _SDL_bsr_watcom(x);
#elif defined(_MSC_VER)
unsigned long index;
if (_BitScanReverse(&index, x)) {
return index;
}
return -1;
#else #else
/* Based off of Bit Twiddling Hacks by Sean Eron Anderson /* Based off of Bit Twiddling Hacks by Sean Eron Anderson
* <seander@cs.stanford.edu>, released in the public domain. * <seander@cs.stanford.edu>, released in the public domain.
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -50,6 +50,9 @@ typedef enum ...@@ -50,6 +50,9 @@ typedef enum
SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate
dstRGB = srcRGB * dstRGB dstRGB = srcRGB * dstRGB
dstA = dstA */ dstA = dstA */
SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply
dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
dstA = dstA */
SDL_BLENDMODE_INVALID = 0x7FFFFFFF SDL_BLENDMODE_INVALID = 0x7FFFFFFF
/* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */ /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
...@@ -64,9 +67,8 @@ typedef enum ...@@ -64,9 +67,8 @@ typedef enum
SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */
SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */ SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */ SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D11 */ SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D9, D3D11 */
SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D11 */ SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D9, D3D11 */
} SDL_BlendOperation; } SDL_BlendOperation;
/** /**
...@@ -84,23 +86,99 @@ typedef enum ...@@ -84,23 +86,99 @@ typedef enum
SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */ SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */
SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */ SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */ SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */
} SDL_BlendFactor; } SDL_BlendFactor;
/** /**
* \brief Create a custom blend mode, which may or may not be supported by a given renderer * Compose a custom blend mode for renderers.
* *
* \param srcColorFactor source color factor * The functions SDL_SetRenderDrawBlendMode and SDL_SetTextureBlendMode accept
* \param dstColorFactor destination color factor * the SDL_BlendMode returned by this function if the renderer supports it.
* \param colorOperation color operation *
* \param srcAlphaFactor source alpha factor * A blend mode controls how the pixels from a drawing operation (source) get
* \param dstAlphaFactor destination alpha factor * combined with the pixels from the render target (destination). First, the
* \param alphaOperation alpha operation * components of the source and destination pixels get multiplied with their
* * blend factors. Then, the blend operation takes the two products and
* The result of the blend mode operation will be: * calculates the result that will get stored in the render target.
* dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor *
* and * Expressed in pseudocode, it would look like this:
* dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor *
* ```c
* dstRGB = colorOperation(srcRGB * srcColorFactor, dstRGB * dstColorFactor);
* dstA = alphaOperation(srcA * srcAlphaFactor, dstA * dstAlphaFactor);
* ```
*
* Where the functions `colorOperation(src, dst)` and `alphaOperation(src,
* dst)` can return one of the following:
*
* - `src + dst`
* - `src - dst`
* - `dst - src`
* - `min(src, dst)`
* - `max(src, dst)`
*
* The red, green, and blue components are always multiplied with the first,
* second, and third components of the SDL_BlendFactor, respectively. The
* fourth component is not used.
*
* The alpha component is always multiplied with the fourth component of the
* SDL_BlendFactor. The other components are not used in the alpha
* calculation.
*
* Support for these blend modes varies for each renderer. To check if a
* specific SDL_BlendMode is supported, create a renderer and pass it to
* either SDL_SetRenderDrawBlendMode or SDL_SetTextureBlendMode. They will
* return with an error if the blend mode is not supported.
*
* This list describes the support of custom blend modes for each renderer in
* SDL 2.0.6. All renderers support the four blend modes listed in the
* SDL_BlendMode enumeration.
*
* - **direct3d**: Supports all operations with all factors. However, some
* factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and
* `SDL_BLENDOPERATION_MAXIMUM`.
* - **direct3d11**: Same as Direct3D 9.
* - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all
* factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly with SDL
* 2.0.6.
* - **opengles**: Supports the `SDL_BLENDOPERATION_ADD` operation with all
* factors. Color and alpha factors need to be the same. OpenGL ES 1
* implementation specific: May also support `SDL_BLENDOPERATION_SUBTRACT`
* and `SDL_BLENDOPERATION_REV_SUBTRACT`. May support color and alpha
* operations being different from each other. May support color and alpha
* factors being different from each other.
* - **opengles2**: Supports the `SDL_BLENDOPERATION_ADD`,
* `SDL_BLENDOPERATION_SUBTRACT`, `SDL_BLENDOPERATION_REV_SUBTRACT`
* operations with all factors.
* - **psp**: No custom blend mode support.
* - **software**: No custom blend mode support.
*
* Some renderers do not provide an alpha component for the default render
* target. The `SDL_BLENDFACTOR_DST_ALPHA` and
* `SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA` factors do not have an effect in this
* case.
*
* \param srcColorFactor the SDL_BlendFactor applied to the red, green, and
* blue components of the source pixels
* \param dstColorFactor the SDL_BlendFactor applied to the red, green, and
* blue components of the destination pixels
* \param colorOperation the SDL_BlendOperation used to combine the red,
* green, and blue components of the source and
* destination pixels
* \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of
* the source pixels
* \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of
* the destination pixels
* \param alphaOperation the SDL_BlendOperation used to combine the alpha
* component of the source and destination pixels
* \returns an SDL_BlendMode that represents the chosen factors and
* operations.
*
* \since This function is available since SDL 2.0.6.
*
* \sa SDL_SetRenderDrawBlendMode
* \sa SDL_GetRenderDrawBlendMode
* \sa SDL_SetTextureBlendMode
* \sa SDL_GetTextureBlendMode
*/ */
extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor,
SDL_BlendFactor dstColorFactor, SDL_BlendFactor dstColorFactor,
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -39,26 +39,96 @@ extern "C" { ...@@ -39,26 +39,96 @@ extern "C" {
/* Function prototypes */ /* Function prototypes */
/** /**
* \brief Put UTF-8 text into the clipboard * Put UTF-8 text into the clipboard.
* *
* \sa SDL_GetClipboardText() * \param text the text to store in the clipboard
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetClipboardText
* \sa SDL_HasClipboardText
*/ */
extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
/** /**
* \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() * Get UTF-8 text from the clipboard, which must be freed with SDL_free().
*
* This functions returns empty string if there was not enough memory left for
* a copy of the clipboard's content.
*
* \returns the clipboard text on success or an empty string on failure; call
* SDL_GetError() for more information. Caller must call SDL_free()
* on the returned pointer when done with it (even if there was an
* error).
* *
* \sa SDL_SetClipboardText() * \since This function is available since SDL 2.0.0.
*
* \sa SDL_HasClipboardText
* \sa SDL_SetClipboardText
*/ */
extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
/** /**
* \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty * Query whether the clipboard exists and contains a non-empty text string.
*
* \returns SDL_TRUE if the clipboard has text, or SDL_FALSE if it does not.
*
* \since This function is available since SDL 2.0.0.
* *
* \sa SDL_GetClipboardText() * \sa SDL_GetClipboardText
* \sa SDL_SetClipboardText
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
/**
* Put UTF-8 text into the primary selection.
*
* \param text the text to store in the primary selection
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.26.0.
*
* \sa SDL_GetPrimarySelectionText
* \sa SDL_HasPrimarySelectionText
*/
extern DECLSPEC int SDLCALL SDL_SetPrimarySelectionText(const char *text);
/**
* Get UTF-8 text from the primary selection, which must be freed with
* SDL_free().
*
* This functions returns empty string if there was not enough memory left for
* a copy of the primary selection's content.
*
* \returns the primary selection text on success or an empty string on
* failure; call SDL_GetError() for more information. Caller must
* call SDL_free() on the returned pointer when done with it (even if
* there was an error).
*
* \since This function is available since SDL 2.26.0.
*
* \sa SDL_HasPrimarySelectionText
* \sa SDL_SetPrimarySelectionText
*/
extern DECLSPEC char * SDLCALL SDL_GetPrimarySelectionText(void);
/**
* Query whether the primary selection exists and contains a non-empty text
* string.
*
* \returns SDL_TRUE if the primary selection has text, or SDL_FALSE if it
* does not.
*
* \since This function is available since SDL 2.26.0.
*
* \sa SDL_GetPrimarySelectionText
* \sa SDL_SetPrimarySelectionText
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasPrimarySelectionText(void);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -25,12 +25,36 @@ ...@@ -25,12 +25,36 @@
#include "SDL_platform.h" #include "SDL_platform.h"
/* winsdkver.h defines _WIN32_MAXVER for SDK version detection. It is present since at least the Windows 7 SDK,
* but out of caution we'll only use it if the compiler supports __has_include() to confirm its presence.
* If your compiler doesn't support __has_include() but you have winsdkver.h, define HAVE_WINSDKVER_H. */
#if !defined(HAVE_WINSDKVER_H) && defined(__has_include)
#if __has_include(<winsdkver.h>)
#define HAVE_WINSDKVER_H 1
#endif
#endif
#ifdef HAVE_WINSDKVER_H
#include <winsdkver.h>
#endif
/* sdkddkver.h defines more specific SDK version numbers. This is needed because older versions of the
* Windows 10 SDK have broken declarations for the C API for DirectX 12. */
#if !defined(HAVE_SDKDDKVER_H) && defined(__has_include)
#if __has_include(<sdkddkver.h>)
#define HAVE_SDKDDKVER_H 1
#endif
#endif
#ifdef HAVE_SDKDDKVER_H
#include <sdkddkver.h>
#endif
/* This is a set of defines to configure the SDL features */ /* This is a set of defines to configure the SDL features */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) #if !defined(HAVE_STDINT_H) && !defined(_STDINT_H_)
#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) /* Most everything except Visual Studio 2008 and earlier has stdint.h now */
#define HAVE_STDINT_H 1 #if defined(_MSC_VER) && (_MSC_VER < 1600)
#elif defined(_MSC_VER)
typedef signed __int8 int8_t; typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t; typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t; typedef signed __int16 int16_t;
...@@ -47,28 +71,9 @@ typedef unsigned int uintptr_t; ...@@ -47,28 +71,9 @@ typedef unsigned int uintptr_t;
#endif #endif
#define _UINTPTR_T_DEFINED #define _UINTPTR_T_DEFINED
#endif #endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ #else
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) #define HAVE_STDINT_H 1
#define DWORD_PTR DWORD #endif /* Visual Studio 2008 */
#endif
#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
#endif
#else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __GNUC__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ #endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#ifdef _WIN64 #ifdef _WIN64
...@@ -77,14 +82,41 @@ typedef unsigned int uintptr_t; ...@@ -77,14 +82,41 @@ typedef unsigned int uintptr_t;
# define SIZEOF_VOIDP 4 # define SIZEOF_VOIDP 4
#endif #endif
#ifdef __clang__
# define HAVE_GCC_ATOMICS 1
#endif
#define HAVE_DDRAW_H 1 #define HAVE_DDRAW_H 1
#define HAVE_DINPUT_H 1 #define HAVE_DINPUT_H 1
#define HAVE_DSOUND_H 1 #define HAVE_DSOUND_H 1
#ifndef __WATCOMC__
#define HAVE_DXGI_H 1 #define HAVE_DXGI_H 1
#define HAVE_XINPUT_H 1 #define HAVE_XINPUT_H 1
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0A00 /* Windows 10 SDK */
#define HAVE_WINDOWS_GAMING_INPUT_H 1
#endif
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0602 /* Windows 8 SDK */
#define HAVE_D3D11_H 1
#define HAVE_ROAPI_H 1
#endif
#if defined(WDK_NTDDI_VERSION) && WDK_NTDDI_VERSION > 0x0A000008 /* 10.0.19041.0 */
#define HAVE_D3D12_H 1
#endif
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0603 /* Windows 8.1 SDK */
#define HAVE_SHELLSCALINGAPI_H 1
#endif
#define HAVE_MMDEVICEAPI_H 1 #define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1 #define HAVE_AUDIOCLIENT_H 1
#define HAVE_ENDPOINTVOLUME_H 1 #define HAVE_TPCSHRD_H 1
#define HAVE_SENSORSAPI_H 1
#endif
#if (defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64)) && (defined(_MSC_VER) && _MSC_VER >= 1600)
#define HAVE_IMMINTRIN_H 1
#elif defined(__has_include) && (defined(__i386__) || defined(__x86_64))
# if __has_include(<immintrin.h>)
# define HAVE_IMMINTRIN_H 1
# endif
#endif
/* This is disabled by default to avoid C runtime dependencies and manifest requirements */ /* This is disabled by default to avoid C runtime dependencies and manifest requirements */
#ifdef HAVE_LIBC #ifdef HAVE_LIBC
...@@ -104,7 +136,11 @@ typedef unsigned int uintptr_t; ...@@ -104,7 +136,11 @@ typedef unsigned int uintptr_t;
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1 #define HAVE_ALLOCA 1
/* OpenWatcom requires specific calling conventions for qsort and bsearch */
#ifndef __WATCOMC__
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1
#endif
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1
#define HAVE_MEMCPY 1 #define HAVE_MEMCPY 1
...@@ -118,6 +154,7 @@ typedef unsigned int uintptr_t; ...@@ -118,6 +154,7 @@ typedef unsigned int uintptr_t;
#define HAVE_STRCHR 1 #define HAVE_STRCHR 1
#define HAVE_STRRCHR 1 #define HAVE_STRRCHR 1
#define HAVE_STRSTR 1 #define HAVE_STRSTR 1
/* #undef HAVE_STRTOK_R */
/* These functions have security warnings, so we won't use them */ /* These functions have security warnings, so we won't use them */
/* #undef HAVE__LTOA */ /* #undef HAVE__LTOA */
/* #undef HAVE__ULTOA */ /* #undef HAVE__ULTOA */
...@@ -130,52 +167,75 @@ typedef unsigned int uintptr_t; ...@@ -130,52 +167,75 @@ typedef unsigned int uintptr_t;
#define HAVE_STRNCMP 1 #define HAVE_STRNCMP 1
#define HAVE__STRICMP 1 #define HAVE__STRICMP 1
#define HAVE__STRNICMP 1 #define HAVE__STRNICMP 1
#define HAVE__WCSICMP 1
#define HAVE__WCSNICMP 1
#define HAVE__WCSDUP 1
#define HAVE_ACOS 1 #define HAVE_ACOS 1
#define HAVE_ACOSF 1
#define HAVE_ASIN 1 #define HAVE_ASIN 1
#define HAVE_ASINF 1
#define HAVE_ATAN 1 #define HAVE_ATAN 1
#define HAVE_ATANF 1
#define HAVE_ATAN2 1 #define HAVE_ATAN2 1
#define HAVE_CEIL 1
#define HAVE_COS 1
#define HAVE_EXP 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_FMOD 1
#define HAVE_LOG 1
#define HAVE_LOG10 1
#define HAVE_POW 1
#define HAVE_SIN 1
#define HAVE_SQRT 1
#define HAVE_TAN 1
#ifndef __WATCOMC__
#define HAVE_ACOSF 1
#define HAVE_ASINF 1
#define HAVE_ATANF 1
#define HAVE_ATAN2F 1 #define HAVE_ATAN2F 1
#define HAVE_CEILF 1 #define HAVE_CEILF 1
#define HAVE__COPYSIGN 1 #define HAVE__COPYSIGN 1
#define HAVE_COS 1
#define HAVE_COSF 1 #define HAVE_COSF 1
#define HAVE_EXP 1
#define HAVE_EXPF 1 #define HAVE_EXPF 1
#define HAVE_FABS 1
#define HAVE_FABSF 1 #define HAVE_FABSF 1
#define HAVE_FLOOR 1
#define HAVE_FLOORF 1 #define HAVE_FLOORF 1
#define HAVE_FMOD 1
#define HAVE_FMODF 1 #define HAVE_FMODF 1
#define HAVE_LOG 1
#define HAVE_LOGF 1 #define HAVE_LOGF 1
#define HAVE_LOG10 1
#define HAVE_LOG10F 1 #define HAVE_LOG10F 1
#define HAVE_POW 1
#define HAVE_POWF 1 #define HAVE_POWF 1
#define HAVE_SIN 1
#define HAVE_SINF 1 #define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE_SQRTF 1 #define HAVE_SQRTF 1
#define HAVE_TAN 1
#define HAVE_TANF 1 #define HAVE_TANF 1
#endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
/* These functions were added with the VC++ 2013 C runtime library */ /* These functions were added with the VC++ 2013 C runtime library */
#if _MSC_VER >= 1800 #if _MSC_VER >= 1800
#define HAVE_STRTOLL 1 #define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_VSSCANF 1 #define HAVE_VSSCANF 1
#define HAVE_LROUND 1
#define HAVE_LROUNDF 1
#define HAVE_ROUND 1
#define HAVE_ROUNDF 1
#define HAVE_SCALBN 1 #define HAVE_SCALBN 1
#define HAVE_SCALBNF 1 #define HAVE_SCALBNF 1
#define HAVE_TRUNC 1
#define HAVE_TRUNCF 1
#endif #endif
/* This function is available with at least the VC++ 2008 C runtime library */ /* This function is available with at least the VC++ 2008 C runtime library */
#if _MSC_VER >= 1400 #if _MSC_VER >= 1400
#define HAVE__FSEEKI64 1 #define HAVE__FSEEKI64 1
#endif #endif
#ifdef _USE_MATH_DEFINES
#define HAVE_M_PI 1
#endif #endif
#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) #elif defined(__WATCOMC__)
#define HAVE__FSEEKI64 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_VSSCANF 1
#define HAVE_ROUND 1
#define HAVE_SCALBN 1
#define HAVE_TRUNC 1
#else
#define HAVE_M_PI 1 #define HAVE_M_PI 1
#endif #endif
#else #else
...@@ -184,7 +244,9 @@ typedef unsigned int uintptr_t; ...@@ -184,7 +244,9 @@ typedef unsigned int uintptr_t;
#endif #endif
/* Enable various audio drivers */ /* Enable various audio drivers */
#if defined(HAVE_MMDEVICEAPI_H) && defined(HAVE_AUDIOCLIENT_H)
#define SDL_AUDIO_DRIVER_WASAPI 1 #define SDL_AUDIO_DRIVER_WASAPI 1
#endif
#define SDL_AUDIO_DRIVER_DSOUND 1 #define SDL_AUDIO_DRIVER_DSOUND 1
#define SDL_AUDIO_DRIVER_WINMM 1 #define SDL_AUDIO_DRIVER_WINMM 1
#define SDL_AUDIO_DRIVER_DISK 1 #define SDL_AUDIO_DRIVER_DISK 1
...@@ -192,18 +254,30 @@ typedef unsigned int uintptr_t; ...@@ -192,18 +254,30 @@ typedef unsigned int uintptr_t;
/* Enable various input drivers */ /* Enable various input drivers */
#define SDL_JOYSTICK_DINPUT 1 #define SDL_JOYSTICK_DINPUT 1
#define SDL_JOYSTICK_XINPUT 1
#define SDL_JOYSTICK_HIDAPI 1 #define SDL_JOYSTICK_HIDAPI 1
#ifndef __WINRT__
#define SDL_JOYSTICK_RAWINPUT 1
#endif
#define SDL_JOYSTICK_VIRTUAL 1
#ifdef HAVE_WINDOWS_GAMING_INPUT_H
#define SDL_JOYSTICK_WGI 1
#endif
#define SDL_JOYSTICK_XINPUT 1
#define SDL_HAPTIC_DINPUT 1 #define SDL_HAPTIC_DINPUT 1
#define SDL_HAPTIC_XINPUT 1 #define SDL_HAPTIC_XINPUT 1
/* Enable the dummy sensor driver */ /* Enable the sensor driver */
#define SDL_SENSOR_DUMMY 1 #ifdef HAVE_SENSORSAPI_H
#define SDL_SENSOR_WINDOWS 1
#else
#define SDL_SENSOR_DUMMY 1
#endif
/* Enable various shared object loading systems */ /* Enable various shared object loading systems */
#define SDL_LOADSO_WINDOWS 1 #define SDL_LOADSO_WINDOWS 1
/* Enable various threading systems */ /* Enable various threading systems */
#define SDL_THREAD_GENERIC_COND_SUFFIX 1
#define SDL_THREAD_WINDOWS 1 #define SDL_THREAD_WINDOWS 1
/* Enable various timer systems */ /* Enable various timer systems */
...@@ -216,8 +290,11 @@ typedef unsigned int uintptr_t; ...@@ -216,8 +290,11 @@ typedef unsigned int uintptr_t;
#ifndef SDL_VIDEO_RENDER_D3D #ifndef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D 1 #define SDL_VIDEO_RENDER_D3D 1
#endif #endif
#ifndef SDL_VIDEO_RENDER_D3D11 #if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
#define SDL_VIDEO_RENDER_D3D11 0 #define SDL_VIDEO_RENDER_D3D11 1
#endif
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
#define SDL_VIDEO_RENDER_D3D12 1
#endif #endif
/* Enable OpenGL support */ /* Enable OpenGL support */
...@@ -249,9 +326,6 @@ typedef unsigned int uintptr_t; ...@@ -249,9 +326,6 @@ typedef unsigned int uintptr_t;
/* Enable filesystem support */ /* Enable filesystem support */
#define SDL_FILESYSTEM_WINDOWS 1 #define SDL_FILESYSTEM_WINDOWS 1
/* Enable assembly routines (Win64 doesn't have inline asm) */
#ifndef _WIN64
#define SDL_ASSEMBLY_ROUTINES 1
#endif
#endif /* SDL_config_windows_h_ */ #endif /* SDL_config_windows_h_ */
/* vi: set ts=4 sw=4 expandtab: */
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -34,11 +34,20 @@ ...@@ -34,11 +34,20 @@
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
#ifdef __clang__ #ifdef __clang__
/* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */ /* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
#undef __MMX__ so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
#undef __SSE__
#undef __SSE2__ #ifndef __PRFCHWINTRIN_H
#else #define __PRFCHWINTRIN_H
static __inline__ void __attribute__((__always_inline__, __nodebug__))
_m_prefetch(void *__P)
{
__builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
}
#endif /* __PRFCHWINTRIN_H */
#endif /* __clang__ */
#include <intrin.h> #include <intrin.h>
#ifndef _WIN64 #ifndef _WIN64
#ifndef __MMX__ #ifndef __MMX__
...@@ -54,9 +63,14 @@ ...@@ -54,9 +63,14 @@
#ifndef __SSE2__ #ifndef __SSE2__
#define __SSE2__ #define __SSE2__
#endif #endif
#endif /* __clang__ */ #ifndef __SSE3__
#define __SSE3__
#endif
#elif defined(__MINGW64_VERSION_MAJOR) #elif defined(__MINGW64_VERSION_MAJOR)
#include <intrin.h> #include <intrin.h>
#if !defined(SDL_DISABLE_ARM_NEON_H) && defined(__ARM_NEON)
# include <arm_neon.h>
#endif
#else #else
/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */ /* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */
#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H) #if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
...@@ -65,7 +79,7 @@ ...@@ -65,7 +79,7 @@
#if !defined(SDL_DISABLE_ARM_NEON_H) #if !defined(SDL_DISABLE_ARM_NEON_H)
# if defined(__ARM_NEON) # if defined(__ARM_NEON)
# include <arm_neon.h> # include <arm_neon.h>
# elif defined(__WINDOWS__) || defined(__WINRT__) # elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)
/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ /* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
# if defined(_M_ARM) # if defined(_M_ARM)
# include <armintr.h> # include <armintr.h>
...@@ -73,15 +87,26 @@ ...@@ -73,15 +87,26 @@
# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
# endif # endif
# if defined (_M_ARM64) # if defined (_M_ARM64)
# include <armintr.h> # include <arm64intr.h>
# include <arm_neon.h> # include <arm64_neon.h>
# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ # define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
# define __ARM_ARCH 8
# endif # endif
# endif # endif
#endif #endif
#endif /* compiler version */
#if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H) #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H)
#include <mm3dnow.h> #include <mm3dnow.h>
#endif #endif
#if defined(__loongarch_sx) && !defined(SDL_DISABLE_LSX_H)
#include <lsxintrin.h>
#define __LSX__
#endif
#if defined(__loongarch_asx) && !defined(SDL_DISABLE_LASX_H)
#include <lasxintrin.h>
#define __LASX__
#endif
#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H) #if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H)
#include <immintrin.h> #include <immintrin.h>
#else #else
...@@ -98,7 +123,6 @@ ...@@ -98,7 +123,6 @@
#include <pmmintrin.h> #include <pmmintrin.h>
#endif #endif
#endif /* HAVE_IMMINTRIN_H */ #endif /* HAVE_IMMINTRIN_H */
#endif /* compiler version */
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
...@@ -114,151 +138,451 @@ extern "C" { ...@@ -114,151 +138,451 @@ extern "C" {
#define SDL_CACHELINE_SIZE 128 #define SDL_CACHELINE_SIZE 128
/** /**
* This function returns the number of CPU cores available. * Get the number of CPU cores available.
*
* \returns the total number of logical CPU cores. On CPUs that include
* technologies such as hyperthreading, the number of logical cores
* may be more than the number of physical cores.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
/** /**
* This function returns the L1 cache line size of the CPU * Determine the L1 cache line size of the CPU.
* *
* This is useful for determining multi-threaded structure padding * This is useful for determining multi-threaded structure padding or SIMD
* or SIMD prefetch sizes. * prefetch sizes.
*
* \returns the L1 cache line size of the CPU, in bytes.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
/** /**
* This function returns true if the CPU has the RDTSC instruction. * Determine whether the CPU has the RDTSC instruction.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has the RDTSC instruction or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
/** /**
* This function returns true if the CPU has AltiVec features. * Determine whether the CPU has AltiVec features.
*
* This always returns false on CPUs that aren't using PowerPC instruction
* sets.
*
* \returns SDL_TRUE if the CPU has AltiVec features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
/** /**
* This function returns true if the CPU has MMX features. * Determine whether the CPU has MMX features.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has MMX features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
/** /**
* This function returns true if the CPU has 3DNow! features. * Determine whether the CPU has 3DNow! features.
*
* This always returns false on CPUs that aren't using AMD instruction sets.
*
* \returns SDL_TRUE if the CPU has 3DNow! features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
/** /**
* This function returns true if the CPU has SSE features. * Determine whether the CPU has SSE features.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has SSE features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
/** /**
* This function returns true if the CPU has SSE2 features. * Determine whether the CPU has SSE2 features.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has SSE2 features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
/** /**
* This function returns true if the CPU has SSE3 features. * Determine whether the CPU has SSE3 features.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has SSE3 features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
/** /**
* This function returns true if the CPU has SSE4.1 features. * Determine whether the CPU has SSE4.1 features.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has SSE4.1 features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
/** /**
* This function returns true if the CPU has SSE4.2 features. * Determine whether the CPU has SSE4.2 features.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has SSE4.2 features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
/** /**
* This function returns true if the CPU has AVX features. * Determine whether the CPU has AVX features.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has AVX features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.2.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX2
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
/** /**
* This function returns true if the CPU has AVX2 features. * Determine whether the CPU has AVX2 features.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has AVX2 features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.4.
*
* \sa SDL_Has3DNow
* \sa SDL_HasAltiVec
* \sa SDL_HasAVX
* \sa SDL_HasMMX
* \sa SDL_HasRDTSC
* \sa SDL_HasSSE
* \sa SDL_HasSSE2
* \sa SDL_HasSSE3
* \sa SDL_HasSSE41
* \sa SDL_HasSSE42
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
/** /**
* This function returns true if the CPU has AVX-512F (foundation) features. * Determine whether the CPU has AVX-512F (foundation) features.
*
* This always returns false on CPUs that aren't using Intel instruction sets.
*
* \returns SDL_TRUE if the CPU has AVX-512F features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.9.
*
* \sa SDL_HasAVX
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void);
/** /**
* This function returns true if the CPU has NEON (ARM SIMD) features. * Determine whether the CPU has ARM SIMD (ARMv6) features.
*
* This is different from ARM NEON, which is a different instruction set.
*
* This always returns false on CPUs that aren't using ARM instruction sets.
*
* \returns SDL_TRUE if the CPU has ARM SIMD features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_HasNEON
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void);
/**
* Determine whether the CPU has NEON (ARM SIMD) features.
*
* This always returns false on CPUs that aren't using ARM instruction sets.
*
* \returns SDL_TRUE if the CPU has ARM NEON features or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void);
/** /**
* This function returns the amount of RAM configured in the system, in MB. * Determine whether the CPU has LSX (LOONGARCH SIMD) features.
*
* This always returns false on CPUs that aren't using LOONGARCH instruction
* sets.
*
* \returns SDL_TRUE if the CPU has LOONGARCH LSX features or SDL_FALSE if
* not.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasLSX(void);
/**
* Determine whether the CPU has LASX (LOONGARCH SIMD) features.
*
* This always returns false on CPUs that aren't using LOONGARCH instruction
* sets.
*
* \returns SDL_TRUE if the CPU has LOONGARCH LASX features or SDL_FALSE if
* not.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasLASX(void);
/**
* Get the amount of RAM configured in the system.
*
* \returns the amount of RAM configured in the system in MiB.
*
* \since This function is available since SDL 2.0.1.
*/ */
extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
/** /**
* \brief Report the alignment this system needs for SIMD allocations. * Report the alignment this system needs for SIMD allocations.
* *
* This will return the minimum number of bytes to which a pointer must be * This will return the minimum number of bytes to which a pointer must be
* aligned to be compatible with SIMD instructions on the current machine. * aligned to be compatible with SIMD instructions on the current machine. For
* For example, if the machine supports SSE only, it will return 16, but if * example, if the machine supports SSE only, it will return 16, but if it
* it supports AVX-512F, it'll return 64 (etc). This only reports values for * supports AVX-512F, it'll return 64 (etc). This only reports values for
* instruction sets SDL knows about, so if your SDL build doesn't have * instruction sets SDL knows about, so if your SDL build doesn't have
* SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and
* not 64 for the AVX-512 instructions that exist but SDL doesn't know about. * not 64 for the AVX-512 instructions that exist but SDL doesn't know about.
* Plan accordingly. * Plan accordingly.
*
* \returns the alignment in bytes needed for available, known SIMD
* instructions.
*
* \since This function is available since SDL 2.0.10.
*/ */
extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void);
/** /**
* \brief Allocate memory in a SIMD-friendly way. * Allocate memory in a SIMD-friendly way.
* *
* This will allocate a block of memory that is suitable for use with SIMD * This will allocate a block of memory that is suitable for use with SIMD
* instructions. Specifically, it will be properly aligned and padded for * instructions. Specifically, it will be properly aligned and padded for the
* the system's supported vector instructions. * system's supported vector instructions.
* *
* The memory returned will be padded such that it is safe to read or write * The memory returned will be padded such that it is safe to read or write an
* an incomplete vector at the end of the memory block. This can be useful * incomplete vector at the end of the memory block. This can be useful so you
* so you don't have to drop back to a scalar fallback at the end of your * don't have to drop back to a scalar fallback at the end of your SIMD
* SIMD processing loop to deal with the final elements without overflowing * processing loop to deal with the final elements without overflowing the
* the allocated buffer. * allocated buffer.
* *
* You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() * You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() or
* or delete[], etc. * delete[], etc.
* *
* Note that SDL will only deal with SIMD instruction sets it is aware of; * Note that SDL will only deal with SIMD instruction sets it is aware of; for
* for example, SDL 2.0.8 knows that SSE wants 16-byte vectors * example, SDL 2.0.8 knows that SSE wants 16-byte vectors (SDL_HasSSE()), and
* (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't * AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't know that AVX-512 wants
* know that AVX-512 wants 64. To be clear: if you can't decide to use an * 64. To be clear: if you can't decide to use an instruction set with an
* instruction set with an SDL_Has*() function, don't use that instruction * SDL_Has*() function, don't use that instruction set with memory allocated
* set with memory allocated through here. * through here.
* *
* SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't * SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't
* out of memory. * out of memory, but you are not allowed to dereference it (because you only
* own zero bytes of that buffer).
*
* \param len The length, in bytes, of the block to allocate. The actual
* allocated block might be larger due to padding, etc.
* \returns a pointer to the newly-allocated block, NULL if out of memory.
* *
* \param len The length, in bytes, of the block to allocated. The actual * \since This function is available since SDL 2.0.10.
* allocated block might be larger due to padding, etc.
* \return Pointer to newly-allocated block, NULL if out of memory.
* *
* \sa SDL_SIMDAlignment * \sa SDL_SIMDGetAlignment
* \sa SDL_SIMDRealloc
* \sa SDL_SIMDFree * \sa SDL_SIMDFree
*/ */
extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len); extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len);
/** /**
* \brief Deallocate memory obtained from SDL_SIMDAlloc * Reallocate memory obtained from SDL_SIMDAlloc
* *
* It is not valid to use this function on a pointer from anything but * It is not valid to use this function on a pointer from anything but
* SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc,
* SDL_malloc, memalign, new[], etc. * SDL_malloc, memalign, new[], etc.
*
* \param mem The pointer obtained from SDL_SIMDAlloc. This function also
* accepts NULL, at which point this function is the same as
* calling SDL_SIMDAlloc with a NULL pointer.
* \param len The length, in bytes, of the block to allocated. The actual
* allocated block might be larger due to padding, etc. Passing 0
* will return a non-NULL pointer, assuming the system isn't out of
* memory.
* \returns a pointer to the newly-reallocated block, NULL if out of memory.
*
* \since This function is available since SDL 2.0.14.
*
* \sa SDL_SIMDGetAlignment
* \sa SDL_SIMDAlloc
* \sa SDL_SIMDFree
*/
extern DECLSPEC void * SDLCALL SDL_SIMDRealloc(void *mem, const size_t len);
/**
* Deallocate memory obtained from SDL_SIMDAlloc
*
* It is not valid to use this function on a pointer from anything but
* SDL_SIMDAlloc() or SDL_SIMDRealloc(). It can't be used on pointers from
* malloc, realloc, SDL_malloc, memalign, new[], etc.
* *
* However, SDL_SIMDFree(NULL) is a legal no-op. * However, SDL_SIMDFree(NULL) is a legal no-op.
* *
* The memory pointed to by `ptr` is no longer valid for access upon return,
* and may be returned to the system or reused by a future allocation. The
* pointer passed to this function is no longer safe to dereference once this
* function returns, and should be discarded.
*
* \param ptr The pointer, returned from SDL_SIMDAlloc or SDL_SIMDRealloc, to
* deallocate. NULL is a legal no-op.
*
* \since This function is available since SDL 2.0.10.
*
* \sa SDL_SIMDAlloc * \sa SDL_SIMDAlloc
* \sa SDL_SIMDRealloc
*/ */
extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr); extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr);
/* vi: set ts=4 sw=4 expandtab: */
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -24,7 +24,11 @@ ...@@ -24,7 +24,11 @@
* *
* This is a simple file to encapsulate the EGL API headers. * This is a simple file to encapsulate the EGL API headers.
*/ */
#if !defined(_MSC_VER) && !defined(__ANDROID__) #if !defined(_MSC_VER) && !defined(__ANDROID__) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS)
#if defined(__vita__) || defined(__psp2__)
#include <psp2/types.h>
#endif
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
...@@ -37,7 +41,7 @@ ...@@ -37,7 +41,7 @@
#define __khrplatform_h_ #define __khrplatform_h_
/* /*
** Copyright (c) 2008-2009 The Khronos Group Inc. ** Copyright (c) 2008-2018 The Khronos Group Inc.
** **
** Permission is hereby granted, free of charge, to any person obtaining a ** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the ** copy of this software and/or associated documentation files (the
...@@ -60,104 +64,112 @@ ...@@ -60,104 +64,112 @@
*/ */
/* Khronos platform-specific types and definitions. /* Khronos platform-specific types and definitions.
* *
* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ * The master copy of khrplatform.h is maintained in the Khronos EGL
* * Registry repository at https://github.com/KhronosGroup/EGL-Registry
* Adopters may modify this file to suit their platform. Adopters are * The last semantic modification to khrplatform.h was at commit ID:
* encouraged to submit platform specific modifications to the Khronos * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
* group so that they can be included in future versions of this file. *
* Please submit changes by sending them to the public Khronos Bugzilla * Adopters may modify this file to suit their platform. Adopters are
* (http://khronos.org/bugzilla) by filing a bug against product * encouraged to submit platform specific modifications to the Khronos
* "Khronos (general)" component "Registry". * group so that they can be included in future versions of this file.
* * Please submit changes by filing pull requests or issues on
* A predefined template which fills in some of the bug fields can be * the EGL Registry repository linked above.
* reached using http://tinyurl.com/khrplatform-h-bugreport, but you *
* must create a Bugzilla login first. *
* * See the Implementer's Guidelines for information about where this file
* * should be located on your system and for more details of its use:
* See the Implementer's Guidelines for information about where this file * http://www.khronos.org/registry/implementers_guide.pdf
* should be located on your system and for more details of its use: *
* http://www.khronos.org/registry/implementers_guide.pdf * This file should be included as
* * #include <KHR/khrplatform.h>
* This file should be included as * by Khronos client API header files that use its types and defines.
* #include <KHR/khrplatform.h> *
* by Khronos client API header files that use its types and defines. * The types in khrplatform.h should only be used to define API-specific types.
* *
* The types in khrplatform.h should only be used to define API-specific types. * Types defined in khrplatform.h:
* * khronos_int8_t signed 8 bit
* Types defined in khrplatform.h: * khronos_uint8_t unsigned 8 bit
* khronos_int8_t signed 8 bit * khronos_int16_t signed 16 bit
* khronos_uint8_t unsigned 8 bit * khronos_uint16_t unsigned 16 bit
* khronos_int16_t signed 16 bit * khronos_int32_t signed 32 bit
* khronos_uint16_t unsigned 16 bit * khronos_uint32_t unsigned 32 bit
* khronos_int32_t signed 32 bit * khronos_int64_t signed 64 bit
* khronos_uint32_t unsigned 32 bit * khronos_uint64_t unsigned 64 bit
* khronos_int64_t signed 64 bit * khronos_intptr_t signed same number of bits as a pointer
* khronos_uint64_t unsigned 64 bit * khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_intptr_t signed same number of bits as a pointer * khronos_ssize_t signed size
* khronos_uintptr_t unsigned same number of bits as a pointer * khronos_usize_t unsigned size
* khronos_ssize_t signed size * khronos_float_t signed 32 bit floating point
* khronos_usize_t unsigned size * khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_float_t signed 32 bit floating point * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* khronos_time_ns_t unsigned 64 bit time in nanoseconds * nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in * khronos_stime_nanoseconds_t signed time interval in nanoseconds
* nanoseconds * khronos_boolean_enum_t enumerated boolean type. This should
* khronos_stime_nanoseconds_t signed time interval in nanoseconds * only be used as a base type when a client API's boolean type is
* khronos_boolean_enum_t enumerated boolean type. This should * an enum. Client APIs which use an integer or other type for
* only be used as a base type when a client API's boolean type is * booleans cannot use this as the base type for their boolean.
* an enum. Client APIs which use an integer or other type for *
* booleans cannot use this as the base type for their boolean. * Tokens defined in khrplatform.h:
* *
* Tokens defined in khrplatform.h: * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
* *
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. *
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. * Calling convention macros defined in this file:
* * KHRONOS_APICALL
* Calling convention macros defined in this file: * KHRONOS_APIENTRY
* KHRONOS_APICALL * KHRONOS_APIATTRIBUTES
* KHRONOS_APIENTRY *
* KHRONOS_APIATTRIBUTES * These may be used in function prototypes as:
* *
* These may be used in function prototypes as: * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* * int arg1,
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname( * int arg2) KHRONOS_APIATTRIBUTES;
* int arg1, */
* int arg2) KHRONOS_APIATTRIBUTES;
*/ #if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
# define KHRONOS_STATIC 1
#endif
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL * Definition of KHRONOS_APICALL
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype. * This precedes the return type of the function in the function prototype.
*/ */
#if defined(_WIN32) && !defined(__SCITECH_SNAP__) && !defined(SDL_VIDEO_STATIC_ANGLE) #if defined(KHRONOS_STATIC)
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
* header compatible with static linking. */
# define KHRONOS_APICALL
#elif defined(_WIN32)
# define KHRONOS_APICALL __declspec(dllimport) # define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__) #elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C # define KHRONOS_APICALL IMPORT_C
#elif defined(__ANDROID__)
# define KHRONOS_APICALL __attribute__((visibility("default")))
#else #else
# define KHRONOS_APICALL # define KHRONOS_APICALL
#endif #endif
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY * Definition of KHRONOS_APIENTRY
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function * This follows the return type of the function and precedes the function
* name in the function prototype. * name in the function prototype.
*/ */
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
/* Win32 but not WinCE */ /* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall # define KHRONOS_APIENTRY __stdcall
#else #else
# define KHRONOS_APIENTRY # define KHRONOS_APIENTRY
#endif #endif
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES * Definition of KHRONOS_APIATTRIBUTES
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments. * This follows the closing parenthesis of the function prototype arguments.
*/ */
#if defined (__ARMCC_2__) #if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp #define KHRONOS_APIATTRIBUTES __softfp
#else #else
...@@ -165,14 +177,14 @@ ...@@ -165,14 +177,14 @@
#endif #endif
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* basic type definitions * basic type definitions
*-----------------------------------------------------------------------*/ *-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/* /*
* Using <stdint.h> * Using <stdint.h>
*/ */
#include <stdint.h> #include <stdint.h>
typedef int32_t khronos_int32_t; typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t; typedef uint32_t khronos_uint32_t;
...@@ -180,12 +192,26 @@ typedef int64_t khronos_int64_t; ...@@ -180,12 +192,26 @@ typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t; typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1 #define KHRONOS_SUPPORT_FLOAT 1
/*
* To support platform where unsigned long cannot be used interchangeably with
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
* unsigned long long or similar (this results in different C++ name mangling).
* To avoid changes for existing platforms, we restrict usage of intptr_t to
* platforms where the size of a pointer is larger than the size of long.
*/
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
#define KHRONOS_USE_INTPTR_T
#endif
#endif
#elif defined(__VMS ) || defined(__sgi) #elif defined(__VMS ) || defined(__sgi)
/* /*
* Using <inttypes.h> * Using <inttypes.h>
*/ */
#include <inttypes.h> #include <inttypes.h>
typedef int32_t khronos_int32_t; typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t; typedef uint32_t khronos_uint32_t;
...@@ -197,8 +223,8 @@ typedef uint64_t khronos_uint64_t; ...@@ -197,8 +223,8 @@ typedef uint64_t khronos_uint64_t;
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) #elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/* /*
* Win32 * Win32
*/ */
typedef __int32 khronos_int32_t; typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t; typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t; typedef __int64 khronos_int64_t;
...@@ -209,8 +235,8 @@ typedef unsigned __int64 khronos_uint64_t; ...@@ -209,8 +235,8 @@ typedef unsigned __int64 khronos_uint64_t;
#elif defined(__sun__) || defined(__digital__) #elif defined(__sun__) || defined(__digital__)
/* /*
* Sun or Digital * Sun or Digital
*/ */
typedef int khronos_int32_t; typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t; typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64) #if defined(__arch64__) || defined(_LP64)
...@@ -226,8 +252,8 @@ typedef unsigned long long int khronos_uint64_t; ...@@ -226,8 +252,8 @@ typedef unsigned long long int khronos_uint64_t;
#elif 0 #elif 0
/* /*
* Hypothetical platform with no float or int64 support * Hypothetical platform with no float or int64 support
*/ */
typedef int khronos_int32_t; typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t; typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0 #define KHRONOS_SUPPORT_INT64 0
...@@ -236,8 +262,8 @@ typedef unsigned int khronos_uint32_t; ...@@ -236,8 +262,8 @@ typedef unsigned int khronos_uint32_t;
#else #else
/* /*
* Generic fallback * Generic fallback
*/ */
#include <stdint.h> #include <stdint.h>
typedef int32_t khronos_int32_t; typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t; typedef uint32_t khronos_uint32_t;
...@@ -250,67 +276,74 @@ typedef uint64_t khronos_uint64_t; ...@@ -250,67 +276,74 @@ typedef uint64_t khronos_uint64_t;
/* /*
* Types that are (so far) the same on all platforms * Types that are (so far) the same on all platforms
*/ */
typedef signed char khronos_int8_t; typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t; typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t; typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t; typedef unsigned short int khronos_uint16_t;
/* /*
* Types that differ between LLP64 and LP64 architectures - in LLP64, * Types that differ between LLP64 and LP64 architectures - in LLP64,
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use. * to be the only LLP64 architecture in current use.
*/ */
#ifdef _WIN64 #ifdef KHRONOS_USE_INTPTR_T
typedef intptr_t khronos_intptr_t;
typedef uintptr_t khronos_uintptr_t;
#elif defined(_WIN64)
typedef signed long long int khronos_intptr_t; typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t; typedef unsigned long long int khronos_uintptr_t;
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else #else
typedef signed long int khronos_intptr_t; typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t; typedef unsigned long int khronos_uintptr_t;
#endif
#if defined(_WIN64)
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_ssize_t; typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t; typedef unsigned long int khronos_usize_t;
#endif #endif
#if KHRONOS_SUPPORT_FLOAT #if KHRONOS_SUPPORT_FLOAT
/* /*
* Float type * Float type
*/ */
typedef float khronos_float_t; typedef float khronos_float_t;
#endif #endif
#if KHRONOS_SUPPORT_INT64 #if KHRONOS_SUPPORT_INT64
/* Time types /* Time types
* *
* These types can be used to represent a time interval in nanoseconds or * These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number * an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last * of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned * time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals * 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned. * may be either signed or unsigned.
*/ */
typedef khronos_uint64_t khronos_utime_nanoseconds_t; typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t; typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif #endif
/* /*
* Dummy value used to pad enum types to 32 bits. * Dummy value used to pad enum types to 32 bits.
*/ */
#ifndef KHRONOS_MAX_ENUM #ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF #define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif #endif
/* /*
* Enumerated boolean type * Enumerated boolean type
* *
* Values other than zero should be considered to be true. Therefore * Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE. * comparisons should not be made against KHRONOS_TRUE.
*/ */
typedef enum { typedef enum {
KHRONOS_FALSE = 0, KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1, KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t; } khronos_boolean_enum_t;
...@@ -321,49 +354,30 @@ typedef enum { ...@@ -321,49 +354,30 @@ typedef enum {
#define __eglplatform_h_ #define __eglplatform_h_
/* /*
** Copyright (c) 2007-2009 The Khronos Group Inc. ** Copyright 2007-2020 The Khronos Group Inc.
** ** SPDX-License-Identifier: Apache-2.0
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/ */
/* Platform-specific types and definitions for egl.h /* Platform-specific types and definitions for egl.h
* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $ *
* * Adopters may modify khrplatform.h and this file to suit their platform.
* Adopters may modify khrplatform.h and this file to suit their platform. * You are encouraged to submit all modifications to the Khronos group so that
* You are encouraged to submit all modifications to the Khronos group so that * they can be included in future versions of this file. Please submit changes
* they can be included in future versions of this file. Please submit changes * by filing an issue or pull request on the public Khronos EGL Registry, at
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) * https://www.github.com/KhronosGroup/EGL-Registry/
* by filing a bug against product "EGL" component "Registry". */
*/
/*#include <KHR/khrplatform.h>*/ /*#include <KHR/khrplatform.h>*/
/* Macros used in EGL function prototype declarations. /* Macros used in EGL function prototype declarations.
* *
* EGL functions should be prototyped as: * EGL functions should be prototyped as:
* *
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments); * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
* *
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
*/ */
#ifndef EGLAPI #ifndef EGLAPI
#define EGLAPI KHRONOS_APICALL #define EGLAPI KHRONOS_APICALL
...@@ -375,39 +389,44 @@ typedef enum { ...@@ -375,39 +389,44 @@ typedef enum {
#define EGLAPIENTRYP EGLAPIENTRY* #define EGLAPIENTRYP EGLAPIENTRY*
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType /* The types NativeDisplayType, NativeWindowType, and NativePixmapType
* are aliases of window-system-dependent types, such as X Display * or * are aliases of window-system-dependent types, such as X Display * or
* Windows Device Context. They must be defined in platform-specific * Windows Device Context. They must be defined in platform-specific
* code below. The EGL-prefixed versions of Native*Type are the same * code below. The EGL-prefixed versions of Native*Type are the same
* types, renamed in EGL 1.3 so all types in the API start with "EGL". * types, renamed in EGL 1.3 so all types in the API start with "EGL".
* *
* Khronos STRONGLY RECOMMENDS that you use the default definitions * Khronos STRONGLY RECOMMENDS that you use the default definitions
* provided below, since these changes affect both binary and source * provided below, since these changes affect both binary and source
* portability of applications using EGL running on different EGL * portability of applications using EGL running on different EGL
* implementations. * implementations.
*/ */
#if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES)
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ typedef void *EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
#elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1 #define WIN32_LEAN_AND_MEAN 1
#endif #endif
#include <windows.h> #include <windows.h>
#if __WINRT__
#include <Unknwn.h>
typedef IUnknown * EGLNativeWindowType;
typedef IUnknown * EGLNativePixmapType;
typedef IUnknown * EGLNativeDisplayType;
#else
typedef HDC EGLNativeDisplayType; typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType; typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType; typedef HWND EGLNativeWindowType;
#endif
#elif defined(__EMSCRIPTEN__)
typedef int EGLNativeDisplayType;
typedef int EGLNativePixmapType;
typedef int EGLNativeWindowType;
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ #elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
typedef int EGLNativeDisplayType; typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType; typedef void *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
#elif defined(WL_EGL_PLATFORM) #elif defined(WL_EGL_PLATFORM)
...@@ -421,31 +440,22 @@ typedef struct gbm_device *EGLNativeDisplayType; ...@@ -421,31 +440,22 @@ typedef struct gbm_device *EGLNativeDisplayType;
typedef struct gbm_bo *EGLNativePixmapType; typedef struct gbm_bo *EGLNativePixmapType;
typedef void *EGLNativeWindowType; typedef void *EGLNativeWindowType;
#elif defined(__ANDROID__) /* Android */ #elif defined(__ANDROID__) || defined(ANDROID)
struct ANativeWindow; struct ANativeWindow;
struct egl_native_pixmap_t; struct egl_native_pixmap_t;
typedef struct ANativeWindow *EGLNativeWindowType; typedef void* EGLNativeDisplayType;
typedef struct egl_native_pixmap_t *EGLNativePixmapType; typedef struct egl_native_pixmap_t* EGLNativePixmapType;
typedef void *EGLNativeDisplayType; typedef struct ANativeWindow* EGLNativeWindowType;
#elif defined(MIR_EGL_PLATFORM)
#include <mir_toolkit/mir_client_library.h> #elif defined(USE_OZONE)
typedef MirEGLNativeDisplayType EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef MirEGLNativeWindowType EGLNativeWindowType;
#elif defined(__unix__) typedef intptr_t EGLNativeDisplayType;
typedef intptr_t EGLNativePixmapType;
typedef intptr_t EGLNativeWindowType;
#ifdef MESA_EGL_NO_X11_HEADERS #elif defined(USE_X11)
typedef void *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;
#else
/* X11 (tentative) */ /* X11 (tentative) */
#include <X11/Xlib.h> #include <X11/Xlib.h>
...@@ -455,7 +465,31 @@ typedef Display *EGLNativeDisplayType; ...@@ -455,7 +465,31 @@ typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType; typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType; typedef Window EGLNativeWindowType;
#endif /* MESA_EGL_NO_X11_HEADERS */ #elif defined(__unix__)
typedef void *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;
#elif defined(__APPLE__)
typedef int EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
#elif defined(__HAIKU__)
#include <kernel/image.h>
typedef void *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;
#elif defined(__Fuchsia__)
typedef void *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;
#else #else
#error "Platform not recognized" #error "Platform not recognized"
...@@ -468,16 +502,25 @@ typedef EGLNativeWindowType NativeWindowType; ...@@ -468,16 +502,25 @@ typedef EGLNativeWindowType NativeWindowType;
/* Define EGLint. This must be a signed integral type large enough to contain /* Define EGLint. This must be a signed integral type large enough to contain
* all legal attribute names and values passed into and out of EGL, whether * all legal attribute names and values passed into and out of EGL, whether
* their type is boolean, bitmask, enumerant (symbolic constant), integer, * their type is boolean, bitmask, enumerant (symbolic constant), integer,
* handle, or other. While in general a 32-bit integer will suffice, if * handle, or other. While in general a 32-bit integer will suffice, if
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit * handles are 64 bit types, then EGLint should be defined as a signed 64-bit
* integer type. * integer type.
*/ */
typedef khronos_int32_t EGLint; typedef khronos_int32_t EGLint;
/* C++ / C typecast macros for special EGL handle values */
#if defined(__cplusplus)
#define EGL_CAST(type, value) (static_cast<type>(value))
#else
#define EGL_CAST(type, value) ((type) (value))
#endif
#endif /* __eglplatform_h */ #endif /* __eglplatform_h */
#ifndef __egl_h_ #ifndef __egl_h_
#define __egl_h_ 1 #define __egl_h_ 1
...@@ -486,39 +529,24 @@ extern "C" { ...@@ -486,39 +529,24 @@ extern "C" {
#endif #endif
/* /*
** Copyright (c) 2013-2015 The Khronos Group Inc. ** Copyright 2013-2020 The Khronos Group Inc.
** ** SPDX-License-Identifier: Apache-2.0
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
** **
** The above copyright notice and this permission notice shall be included ** This header is generated from the Khronos EGL XML API Registry.
** in all copies or substantial portions of the Materials. ** The current version of the Registry, generator scripts
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/*
** This header is generated from the Khronos OpenGL / OpenGL ES XML
** API Registry. The current version of the Registry, generator scripts
** used to make the header, and the header can be found at ** used to make the header, and the header can be found at
** http://www.opengl.org/registry/ ** http://www.khronos.org/registry/egl
** **
** Khronos $Revision: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun 2015) $ ** Khronos $Git commit SHA1: 6fb1daea15 $ on $Git commit date: 2022-05-25 09:41:13 -0600 $
*/ */
/*#include <EGL/eglplatform.h>*/ /*#include <EGL/eglplatform.h>*/
/* Generated on date 20150623 */ #ifndef EGL_EGL_PROTOTYPES
#define EGL_EGL_PROTOTYPES 1
#endif
/* Generated on date 20220525 */
/* Generated C header for: /* Generated C header for:
* API: egl * API: egl
...@@ -533,6 +561,8 @@ extern "C" { ...@@ -533,6 +561,8 @@ extern "C" {
#define EGL_VERSION_1_0 1 #define EGL_VERSION_1_0 1
typedef unsigned int EGLBoolean; typedef unsigned int EGLBoolean;
typedef void *EGLDisplay; typedef void *EGLDisplay;
/*#include <KHR/khrplatform.h>*/
/*#include <EGL/eglplatform.h>*/
typedef void *EGLConfig; typedef void *EGLConfig;
typedef void *EGLSurface; typedef void *EGLSurface;
typedef void *EGLContext; typedef void *EGLContext;
...@@ -556,7 +586,7 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); ...@@ -556,7 +586,7 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void);
#define EGL_CONFIG_ID 0x3028 #define EGL_CONFIG_ID 0x3028
#define EGL_CORE_NATIVE_ENGINE 0x305B #define EGL_CORE_NATIVE_ENGINE 0x305B
#define EGL_DEPTH_SIZE 0x3025 #define EGL_DEPTH_SIZE 0x3025
#define EGL_DONT_CARE ((EGLint)-1) #define EGL_DONT_CARE EGL_CAST(EGLint,-1)
#define EGL_DRAW 0x3059 #define EGL_DRAW 0x3059
#define EGL_EXTENSIONS 0x3055 #define EGL_EXTENSIONS 0x3055
#define EGL_FALSE 0 #define EGL_FALSE 0
...@@ -573,9 +603,9 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); ...@@ -573,9 +603,9 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void);
#define EGL_NONE 0x3038 #define EGL_NONE 0x3038
#define EGL_NON_CONFORMANT_CONFIG 0x3051 #define EGL_NON_CONFORMANT_CONFIG 0x3051
#define EGL_NOT_INITIALIZED 0x3001 #define EGL_NOT_INITIALIZED 0x3001
#define EGL_NO_CONTEXT ((EGLContext)0) #define EGL_NO_CONTEXT EGL_CAST(EGLContext,0)
#define EGL_NO_DISPLAY ((EGLDisplay)0) #define EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0)
#define EGL_NO_SURFACE ((EGLSurface)0) #define EGL_NO_SURFACE EGL_CAST(EGLSurface,0)
#define EGL_PBUFFER_BIT 0x0001 #define EGL_PBUFFER_BIT 0x0001
#define EGL_PIXMAP_BIT 0x0002 #define EGL_PIXMAP_BIT 0x0002
#define EGL_READ 0x305A #define EGL_READ 0x305A
...@@ -596,6 +626,31 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); ...@@ -596,6 +626,31 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void);
#define EGL_VERSION 0x3054 #define EGL_VERSION 0x3054
#define EGL_WIDTH 0x3057 #define EGL_WIDTH 0x3057
#define EGL_WINDOW_BIT 0x0004 #define EGL_WINDOW_BIT 0x0004
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSECONFIGPROC) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
typedef EGLContext (EGLAPIENTRYP PFNEGLCREATECONTEXTPROC) (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERSURFACEPROC) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGATTRIBPROC) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGSPROC) (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETCURRENTDISPLAYPROC) (void);
typedef EGLSurface (EGLAPIENTRYP PFNEGLGETCURRENTSURFACEPROC) (EGLint readdraw);
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDISPLAYPROC) (EGLNativeDisplayType display_id);
typedef EGLint (EGLAPIENTRYP PFNEGLGETERRORPROC) (void);
typedef __eglMustCastToProperFunctionPointerType (EGLAPIENTRYP PFNEGLGETPROCADDRESSPROC) (const char *procname);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLINITIALIZEPROC) (EGLDisplay dpy, EGLint *major, EGLint *minor);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLMAKECURRENTPROC) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
typedef const char *(EGLAPIENTRYP PFNEGLQUERYSTRINGPROC) (EGLDisplay dpy, EGLint name);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLTERMINATEPROC) (EGLDisplay dpy);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITGLPROC) (void);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITNATIVEPROC) (EGLint engine);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
...@@ -620,6 +675,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface ...@@ -620,6 +675,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine);
#endif
#endif /* EGL_VERSION_1_0 */ #endif /* EGL_VERSION_1_0 */
#ifndef EGL_VERSION_1_1 #ifndef EGL_VERSION_1_1
...@@ -638,10 +694,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); ...@@ -638,10 +694,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine);
#define EGL_TEXTURE_RGB 0x305D #define EGL_TEXTURE_RGB 0x305D
#define EGL_TEXTURE_RGBA 0x305E #define EGL_TEXTURE_RGBA 0x305E
#define EGL_TEXTURE_TARGET 0x3081 #define EGL_TEXTURE_TARGET 0x3081
typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDTEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSURFACEATTRIBPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPINTERVALPROC) (EGLDisplay dpy, EGLint interval);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval);
#endif
#endif /* EGL_VERSION_1_1 */ #endif /* EGL_VERSION_1_1 */
#ifndef EGL_VERSION_1_2 #ifndef EGL_VERSION_1_2
...@@ -675,13 +737,20 @@ typedef void *EGLClientBuffer; ...@@ -675,13 +737,20 @@ typedef void *EGLClientBuffer;
#define EGL_RGB_BUFFER 0x308E #define EGL_RGB_BUFFER 0x308E
#define EGL_SINGLE_BUFFER 0x3085 #define EGL_SINGLE_BUFFER 0x3085
#define EGL_SWAP_BEHAVIOR 0x3093 #define EGL_SWAP_BEHAVIOR 0x3093
#define EGL_UNKNOWN ((EGLint)-1) #define EGL_UNKNOWN EGL_CAST(EGLint,-1)
#define EGL_VERTICAL_RESOLUTION 0x3091 #define EGL_VERTICAL_RESOLUTION 0x3091
typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDAPIPROC) (EGLenum api);
typedef EGLenum (EGLAPIENTRYP PFNEGLQUERYAPIPROC) (void);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERFROMCLIENTBUFFERPROC) (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETHREADPROC) (void);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITCLIENTPROC) (void);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api);
EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void);
#endif
#endif /* EGL_VERSION_1_2 */ #endif /* EGL_VERSION_1_2 */
#ifndef EGL_VERSION_1_3 #ifndef EGL_VERSION_1_3
...@@ -702,7 +771,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); ...@@ -702,7 +771,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void);
#ifndef EGL_VERSION_1_4 #ifndef EGL_VERSION_1_4
#define EGL_VERSION_1_4 1 #define EGL_VERSION_1_4 1
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) #define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0)
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 #define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200
#define EGL_MULTISAMPLE_RESOLVE 0x3099 #define EGL_MULTISAMPLE_RESOLVE 0x3099
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A #define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A
...@@ -710,7 +779,10 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); ...@@ -710,7 +779,10 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void);
#define EGL_OPENGL_API 0x30A2 #define EGL_OPENGL_API 0x30A2
#define EGL_OPENGL_BIT 0x0008 #define EGL_OPENGL_BIT 0x0008
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 #define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400
typedef EGLContext (EGLAPIENTRYP PFNEGLGETCURRENTCONTEXTPROC) (void);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void);
#endif
#endif /* EGL_VERSION_1_4 */ #endif /* EGL_VERSION_1_4 */
#ifndef EGL_VERSION_1_5 #ifndef EGL_VERSION_1_5
...@@ -744,7 +816,7 @@ typedef void *EGLImage; ...@@ -744,7 +816,7 @@ typedef void *EGLImage;
#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull #define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull
#define EGL_TIMEOUT_EXPIRED 0x30F5 #define EGL_TIMEOUT_EXPIRED 0x30F5
#define EGL_CONDITION_SATISFIED 0x30F6 #define EGL_CONDITION_SATISFIED 0x30F6
#define EGL_NO_SYNC ((EGLSync)0) #define EGL_NO_SYNC EGL_CAST(EGLSync,0)
#define EGL_SYNC_FENCE 0x30F9 #define EGL_SYNC_FENCE 0x30F9
#define EGL_GL_COLORSPACE 0x309D #define EGL_GL_COLORSPACE 0x309D
#define EGL_GL_COLORSPACE_SRGB 0x3089 #define EGL_GL_COLORSPACE_SRGB 0x3089
...@@ -761,7 +833,18 @@ typedef void *EGLImage; ...@@ -761,7 +833,18 @@ typedef void *EGLImage;
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 #define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 #define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8
#define EGL_IMAGE_PRESERVED 0x30D2 #define EGL_IMAGE_PRESERVED 0x30D2
#define EGL_NO_IMAGE ((EGLImage)0) #define EGL_NO_IMAGE EGL_CAST(EGLImage,0)
typedef EGLSync (EGLAPIENTRYP PFNEGLCREATESYNCPROC) (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCPROC) (EGLDisplay dpy, EGLSync sync);
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBPROC) (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value);
typedef EGLImage (EGLAPIENTRYP PFNEGLCREATEIMAGEPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEPROC) (EGLDisplay dpy, EGLImage image);
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYPROC) (EGLenum platform, void *native_display, const EGLAttrib *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags);
#if EGL_EGL_PROTOTYPES
EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync);
EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
...@@ -772,6 +855,7 @@ EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *nat ...@@ -772,6 +855,7 @@ EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *nat
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags);
#endif
#endif /* EGL_VERSION_1_5 */ #endif /* EGL_VERSION_1_5 */
#ifdef __cplusplus #ifdef __cplusplus
...@@ -781,7 +865,6 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint ...@@ -781,7 +865,6 @@ EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint
#endif /* __egl_h_ */ #endif /* __egl_h_ */
#ifndef __eglext_h_ #ifndef __eglext_h_
#define __eglext_h_ 1 #define __eglext_h_ 1
...@@ -790,39 +873,20 @@ extern "C" { ...@@ -790,39 +873,20 @@ extern "C" {
#endif #endif
/* /*
** Copyright (c) 2013-2015 The Khronos Group Inc. ** Copyright 2013-2020 The Khronos Group Inc.
** ** SPDX-License-Identifier: Apache-2.0
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
** **
** The above copyright notice and this permission notice shall be included ** This header is generated from the Khronos EGL XML API Registry.
** in all copies or substantial portions of the Materials. ** The current version of the Registry, generator scripts
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/*
** This header is generated from the Khronos OpenGL / OpenGL ES XML
** API Registry. The current version of the Registry, generator scripts
** used to make the header, and the header can be found at ** used to make the header, and the header can be found at
** http://www.opengl.org/registry/ ** http://www.khronos.org/registry/egl
** **
** Khronos $Revision: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun 2015) $ ** Khronos $Git commit SHA1: 6fb1daea15 $ on $Git commit date: 2022-05-25 09:41:13 -0600 $
*/ */
/*#include <EGL/eglplatform.h>*/ /*#include <EGL/eglplatform.h>*/
#define EGL_EGLEXT_VERSION 20150623 #define EGL_EGLEXT_VERSION 20220525
/* Generated C header for: /* Generated C header for:
* API: egl * API: egl
...@@ -861,6 +925,13 @@ EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, ...@@ -861,6 +925,13 @@ EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type,
#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 #define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040
#endif /* EGL_KHR_config_attribs */ #endif /* EGL_KHR_config_attribs */
#ifndef EGL_KHR_context_flush_control
#define EGL_KHR_context_flush_control 1
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
#endif /* EGL_KHR_context_flush_control */
#ifndef EGL_KHR_create_context #ifndef EGL_KHR_create_context
#define EGL_KHR_create_context 1 #define EGL_KHR_create_context 1
#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 #define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
...@@ -883,6 +954,42 @@ EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, ...@@ -883,6 +954,42 @@ EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type,
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 #define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3
#endif /* EGL_KHR_create_context_no_error */ #endif /* EGL_KHR_create_context_no_error */
#ifndef EGL_KHR_debug
#define EGL_KHR_debug 1
typedef void *EGLLabelKHR;
typedef void *EGLObjectKHR;
typedef void (EGLAPIENTRY *EGLDEBUGPROCKHR)(EGLenum error,const char *command,EGLint messageType,EGLLabelKHR threadLabel,EGLLabelKHR objectLabel,const char* message);
#define EGL_OBJECT_THREAD_KHR 0x33B0
#define EGL_OBJECT_DISPLAY_KHR 0x33B1
#define EGL_OBJECT_CONTEXT_KHR 0x33B2
#define EGL_OBJECT_SURFACE_KHR 0x33B3
#define EGL_OBJECT_IMAGE_KHR 0x33B4
#define EGL_OBJECT_SYNC_KHR 0x33B5
#define EGL_OBJECT_STREAM_KHR 0x33B6
#define EGL_DEBUG_MSG_CRITICAL_KHR 0x33B9
#define EGL_DEBUG_MSG_ERROR_KHR 0x33BA
#define EGL_DEBUG_MSG_WARN_KHR 0x33BB
#define EGL_DEBUG_MSG_INFO_KHR 0x33BC
#define EGL_DEBUG_CALLBACK_KHR 0x33B8
typedef EGLint (EGLAPIENTRYP PFNEGLDEBUGMESSAGECONTROLKHRPROC) (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEBUGKHRPROC) (EGLint attribute, EGLAttrib *value);
typedef EGLint (EGLAPIENTRYP PFNEGLLABELOBJECTKHRPROC) (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLint EGLAPIENTRY eglDebugMessageControlKHR (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDebugKHR (EGLint attribute, EGLAttrib *value);
EGLAPI EGLint EGLAPIENTRY eglLabelObjectKHR (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label);
#endif
#endif /* EGL_KHR_debug */
#ifndef EGL_KHR_display_reference
#define EGL_KHR_display_reference 1
#define EGL_TRACK_REFERENCES_KHR 0x3352
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBKHRPROC) (EGLDisplay dpy, EGLint name, EGLAttrib *value);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribKHR (EGLDisplay dpy, EGLint name, EGLAttrib *value);
#endif
#endif /* EGL_KHR_display_reference */
#ifndef EGL_KHR_fence_sync #ifndef EGL_KHR_fence_sync
#define EGL_KHR_fence_sync 1 #define EGL_KHR_fence_sync 1
typedef khronos_utime_nanoseconds_t EGLTimeKHR; typedef khronos_utime_nanoseconds_t EGLTimeKHR;
...@@ -945,7 +1052,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sy ...@@ -945,7 +1052,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sy
#define EGL_KHR_image 1 #define EGL_KHR_image 1
typedef void *EGLImageKHR; typedef void *EGLImageKHR;
#define EGL_NATIVE_PIXMAP_KHR 0x30B0 #define EGL_NATIVE_PIXMAP_KHR 0x30B0
#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) #define EGL_NO_IMAGE_KHR EGL_CAST(EGLImageKHR,0)
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
#ifdef EGL_EGLEXT_PROTOTYPES #ifdef EGL_EGLEXT_PROTOTYPES
...@@ -1007,6 +1114,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface s ...@@ -1007,6 +1114,16 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface s
#endif #endif
#endif /* EGL_KHR_lock_surface3 */ #endif /* EGL_KHR_lock_surface3 */
#ifndef EGL_KHR_mutable_render_buffer
#define EGL_KHR_mutable_render_buffer 1
#define EGL_MUTABLE_RENDER_BUFFER_BIT_KHR 0x1000
#endif /* EGL_KHR_mutable_render_buffer */
#ifndef EGL_KHR_no_config_context
#define EGL_KHR_no_config_context 1
#define EGL_NO_CONFIG_KHR EGL_CAST(EGLConfig,0)
#endif /* EGL_KHR_no_config_context */
#ifndef EGL_KHR_partial_update #ifndef EGL_KHR_partial_update
#define EGL_KHR_partial_update 1 #define EGL_KHR_partial_update 1
#define EGL_BUFFER_AGE_KHR 0x313D #define EGL_BUFFER_AGE_KHR 0x313D
...@@ -1049,7 +1166,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface ...@@ -1049,7 +1166,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface
#define EGL_SYNC_REUSABLE_KHR 0x30FA #define EGL_SYNC_REUSABLE_KHR 0x30FA
#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 #define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001
#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull #define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) #define EGL_NO_SYNC_KHR EGL_CAST(EGLSyncKHR,0)
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
#ifdef EGL_EGLEXT_PROTOTYPES #ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
...@@ -1062,7 +1179,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, ...@@ -1062,7 +1179,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync,
typedef void *EGLStreamKHR; typedef void *EGLStreamKHR;
typedef khronos_uint64_t EGLuint64KHR; typedef khronos_uint64_t EGLuint64KHR;
#ifdef KHRONOS_SUPPORT_INT64 #ifdef KHRONOS_SUPPORT_INT64
#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) #define EGL_NO_STREAM_KHR EGL_CAST(EGLStreamKHR,0)
#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 #define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210
#define EGL_PRODUCER_FRAME_KHR 0x3212 #define EGL_PRODUCER_FRAME_KHR 0x3212
#define EGL_CONSUMER_FRAME_KHR 0x3213 #define EGL_CONSUMER_FRAME_KHR 0x3213
...@@ -1090,6 +1207,24 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR ...@@ -1090,6 +1207,24 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR
#endif /* KHRONOS_SUPPORT_INT64 */ #endif /* KHRONOS_SUPPORT_INT64 */
#endif /* EGL_KHR_stream */ #endif /* EGL_KHR_stream */
#ifndef EGL_KHR_stream_attrib
#define EGL_KHR_stream_attrib 1
#ifdef KHRONOS_SUPPORT_INT64
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMATTRIBKHRPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamAttribKHR (EGLDisplay dpy, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
#endif
#endif /* KHRONOS_SUPPORT_INT64 */
#endif /* EGL_KHR_stream_attrib */
#ifndef EGL_KHR_stream_consumer_gltexture #ifndef EGL_KHR_stream_consumer_gltexture
#define EGL_KHR_stream_consumer_gltexture 1 #define EGL_KHR_stream_consumer_gltexture 1
#ifdef EGL_KHR_stream #ifdef EGL_KHR_stream
...@@ -1109,7 +1244,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLSt ...@@ -1109,7 +1244,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLSt
#define EGL_KHR_stream_cross_process_fd 1 #define EGL_KHR_stream_cross_process_fd 1
typedef int EGLNativeFileDescriptorKHR; typedef int EGLNativeFileDescriptorKHR;
#ifdef EGL_KHR_stream #ifdef EGL_KHR_stream
#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) #define EGL_NO_FILE_DESCRIPTOR_KHR EGL_CAST(EGLNativeFileDescriptorKHR,-1)
typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
#ifdef EGL_EGLEXT_PROTOTYPES #ifdef EGL_EGLEXT_PROTOTYPES
...@@ -1156,9 +1291,9 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, ...@@ -1156,9 +1291,9 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy,
#ifndef EGL_KHR_swap_buffers_with_damage #ifndef EGL_KHR_swap_buffers_with_damage
#define EGL_KHR_swap_buffers_with_damage 1 #define EGL_KHR_swap_buffers_with_damage 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects);
#ifdef EGL_EGLEXT_PROTOTYPES #ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects);
#endif #endif
#endif /* EGL_KHR_swap_buffers_with_damage */ #endif /* EGL_KHR_swap_buffers_with_damage */
...@@ -1175,6 +1310,10 @@ EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLin ...@@ -1175,6 +1310,10 @@ EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLin
#endif #endif
#endif /* EGL_KHR_wait_sync */ #endif /* EGL_KHR_wait_sync */
#ifndef EGL_ANDROID_GLES_layers
#define EGL_ANDROID_GLES_layers 1
#endif /* EGL_ANDROID_GLES_layers */
#ifndef EGL_ANDROID_blob_cache #ifndef EGL_ANDROID_blob_cache
#define EGL_ANDROID_blob_cache 1 #define EGL_ANDROID_blob_cache 1
typedef khronos_ssize_t EGLsizeiANDROID; typedef khronos_ssize_t EGLsizeiANDROID;
...@@ -1186,11 +1325,69 @@ EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobF ...@@ -1186,11 +1325,69 @@ EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobF
#endif #endif
#endif /* EGL_ANDROID_blob_cache */ #endif /* EGL_ANDROID_blob_cache */
#ifndef EGL_ANDROID_create_native_client_buffer
#define EGL_ANDROID_create_native_client_buffer 1
#define EGL_NATIVE_BUFFER_USAGE_ANDROID 0x3143
#define EGL_NATIVE_BUFFER_USAGE_PROTECTED_BIT_ANDROID 0x00000001
#define EGL_NATIVE_BUFFER_USAGE_RENDERBUFFER_BIT_ANDROID 0x00000002
#define EGL_NATIVE_BUFFER_USAGE_TEXTURE_BIT_ANDROID 0x00000004
typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLCREATENATIVECLIENTBUFFERANDROIDPROC) (const EGLint *attrib_list);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLClientBuffer EGLAPIENTRY eglCreateNativeClientBufferANDROID (const EGLint *attrib_list);
#endif
#endif /* EGL_ANDROID_create_native_client_buffer */
#ifndef EGL_ANDROID_framebuffer_target #ifndef EGL_ANDROID_framebuffer_target
#define EGL_ANDROID_framebuffer_target 1 #define EGL_ANDROID_framebuffer_target 1
#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 #define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147
#endif /* EGL_ANDROID_framebuffer_target */ #endif /* EGL_ANDROID_framebuffer_target */
#ifndef EGL_ANDROID_front_buffer_auto_refresh
#define EGL_ANDROID_front_buffer_auto_refresh 1
#define EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID 0x314C
#endif /* EGL_ANDROID_front_buffer_auto_refresh */
#ifndef EGL_ANDROID_get_frame_timestamps
#define EGL_ANDROID_get_frame_timestamps 1
typedef khronos_stime_nanoseconds_t EGLnsecsANDROID;
#define EGL_TIMESTAMP_PENDING_ANDROID EGL_CAST(EGLnsecsANDROID,-2)
#define EGL_TIMESTAMP_INVALID_ANDROID EGL_CAST(EGLnsecsANDROID,-1)
#define EGL_TIMESTAMPS_ANDROID 0x3430
#define EGL_COMPOSITE_DEADLINE_ANDROID 0x3431
#define EGL_COMPOSITE_INTERVAL_ANDROID 0x3432
#define EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID 0x3433
#define EGL_REQUESTED_PRESENT_TIME_ANDROID 0x3434
#define EGL_RENDERING_COMPLETE_TIME_ANDROID 0x3435
#define EGL_COMPOSITION_LATCH_TIME_ANDROID 0x3436
#define EGL_FIRST_COMPOSITION_START_TIME_ANDROID 0x3437
#define EGL_LAST_COMPOSITION_START_TIME_ANDROID 0x3438
#define EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID 0x3439
#define EGL_DISPLAY_PRESENT_TIME_ANDROID 0x343A
#define EGL_DEQUEUE_READY_TIME_ANDROID 0x343B
#define EGL_READS_DONE_TIME_ANDROID 0x343C
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint name);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETNEXTFRAMEIDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint timestamp);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint name);
EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingANDROID (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values);
EGLAPI EGLBoolean EGLAPIENTRY eglGetNextFrameIdANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId);
EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint timestamp);
EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampsANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values);
#endif
#endif /* EGL_ANDROID_get_frame_timestamps */
#ifndef EGL_ANDROID_get_native_client_buffer
#define EGL_ANDROID_get_native_client_buffer 1
struct AHardwareBuffer;
typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLGETNATIVECLIENTBUFFERANDROIDPROC) (const struct AHardwareBuffer *buffer);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLClientBuffer EGLAPIENTRY eglGetNativeClientBufferANDROID (const struct AHardwareBuffer *buffer);
#endif
#endif /* EGL_ANDROID_get_native_client_buffer */
#ifndef EGL_ANDROID_image_native_buffer #ifndef EGL_ANDROID_image_native_buffer
#define EGL_ANDROID_image_native_buffer 1 #define EGL_ANDROID_image_native_buffer 1
#define EGL_NATIVE_BUFFER_ANDROID 0x3140 #define EGL_NATIVE_BUFFER_ANDROID 0x3140
...@@ -1208,6 +1405,14 @@ EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR ...@@ -1208,6 +1405,14 @@ EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR
#endif #endif
#endif /* EGL_ANDROID_native_fence_sync */ #endif /* EGL_ANDROID_native_fence_sync */
#ifndef EGL_ANDROID_presentation_time
#define EGL_ANDROID_presentation_time 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLPRESENTATIONTIMEANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglPresentationTimeANDROID (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time);
#endif
#endif /* EGL_ANDROID_presentation_time */
#ifndef EGL_ANDROID_recordable #ifndef EGL_ANDROID_recordable
#define EGL_ANDROID_recordable 1 #define EGL_ANDROID_recordable 1
#define EGL_RECORDABLE_ANDROID 0x3142 #define EGL_RECORDABLE_ANDROID 0x3142
...@@ -1236,16 +1441,40 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu ...@@ -1236,16 +1441,40 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu
#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 #define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ #endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */
#ifndef EGL_ANGLE_sync_control_rate
#define EGL_ANGLE_sync_control_rate 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETMSCRATEANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglGetMscRateANGLE (EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator);
#endif
#endif /* EGL_ANGLE_sync_control_rate */
#ifndef EGL_ANGLE_window_fixed_size #ifndef EGL_ANGLE_window_fixed_size
#define EGL_ANGLE_window_fixed_size 1 #define EGL_ANGLE_window_fixed_size 1
#define EGL_FIXED_SIZE_ANGLE 0x3201 #define EGL_FIXED_SIZE_ANGLE 0x3201
#endif /* EGL_ANGLE_window_fixed_size */ #endif /* EGL_ANGLE_window_fixed_size */
#ifndef EGL_ARM_image_format
#define EGL_ARM_image_format 1
#define EGL_COLOR_COMPONENT_TYPE_UNSIGNED_INTEGER_ARM 0x3287
#define EGL_COLOR_COMPONENT_TYPE_INTEGER_ARM 0x3288
#endif /* EGL_ARM_image_format */
#ifndef EGL_ARM_implicit_external_sync
#define EGL_ARM_implicit_external_sync 1
#define EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM 0x328A
#endif /* EGL_ARM_implicit_external_sync */
#ifndef EGL_ARM_pixmap_multisample_discard #ifndef EGL_ARM_pixmap_multisample_discard
#define EGL_ARM_pixmap_multisample_discard 1 #define EGL_ARM_pixmap_multisample_discard 1
#define EGL_DISCARD_SAMPLES_ARM 0x3286 #define EGL_DISCARD_SAMPLES_ARM 0x3286
#endif /* EGL_ARM_pixmap_multisample_discard */ #endif /* EGL_ARM_pixmap_multisample_discard */
#ifndef EGL_EXT_bind_to_front
#define EGL_EXT_bind_to_front 1
#define EGL_FRONT_BUFFER_EXT 0x3464
#endif /* EGL_EXT_bind_to_front */
#ifndef EGL_EXT_buffer_age #ifndef EGL_EXT_buffer_age
#define EGL_EXT_buffer_age 1 #define EGL_EXT_buffer_age 1
#define EGL_BUFFER_AGE_EXT 0x313D #define EGL_BUFFER_AGE_EXT 0x313D
...@@ -1255,6 +1484,45 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu ...@@ -1255,6 +1484,45 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu
#define EGL_EXT_client_extensions 1 #define EGL_EXT_client_extensions 1
#endif /* EGL_EXT_client_extensions */ #endif /* EGL_EXT_client_extensions */
#ifndef EGL_EXT_client_sync
#define EGL_EXT_client_sync 1
#define EGL_SYNC_CLIENT_EXT 0x3364
#define EGL_SYNC_CLIENT_SIGNAL_EXT 0x3365
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCLIENTSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglClientSignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list);
#endif
#endif /* EGL_EXT_client_sync */
#ifndef EGL_EXT_compositor
#define EGL_EXT_compositor 1
#define EGL_PRIMARY_COMPOSITOR_CONTEXT_EXT 0x3460
#define EGL_EXTERNAL_REF_ID_EXT 0x3461
#define EGL_COMPOSITOR_DROP_NEWEST_FRAME_EXT 0x3462
#define EGL_COMPOSITOR_KEEP_NEWEST_FRAME_EXT 0x3463
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTLISTEXTPROC) (const EGLint *external_ref_ids, EGLint num_entries);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTATTRIBUTESEXTPROC) (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWLISTEXTPROC) (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWATTRIBUTESEXTPROC) (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORBINDTEXWINDOWEXTPROC) (EGLint external_win_id);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETSIZEEXTPROC) (EGLint external_win_id, EGLint width, EGLint height);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSWAPPOLICYEXTPROC) (EGLint external_win_id, EGLint policy);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextListEXT (const EGLint *external_ref_ids, EGLint num_entries);
EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextAttributesEXT (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries);
EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowListEXT (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries);
EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowAttributesEXT (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries);
EGLAPI EGLBoolean EGLAPIENTRY eglCompositorBindTexWindowEXT (EGLint external_win_id);
EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetSizeEXT (EGLint external_win_id, EGLint width, EGLint height);
EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSwapPolicyEXT (EGLint external_win_id, EGLint policy);
#endif
#endif /* EGL_EXT_compositor */
#ifndef EGL_EXT_config_select_group
#define EGL_EXT_config_select_group 1
#define EGL_CONFIG_SELECT_GROUP_EXT 0x34C0
#endif /* EGL_EXT_config_select_group */
#ifndef EGL_EXT_create_context_robustness #ifndef EGL_EXT_create_context_robustness
#define EGL_EXT_create_context_robustness 1 #define EGL_EXT_create_context_robustness 1
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF
...@@ -1266,7 +1534,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu ...@@ -1266,7 +1534,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSu
#ifndef EGL_EXT_device_base #ifndef EGL_EXT_device_base
#define EGL_EXT_device_base 1 #define EGL_EXT_device_base 1
typedef void *EGLDeviceEXT; typedef void *EGLDeviceEXT;
#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0)) #define EGL_NO_DEVICE_EXT EGL_CAST(EGLDeviceEXT,0)
#define EGL_BAD_DEVICE_EXT 0x322B #define EGL_BAD_DEVICE_EXT 0x322B
#define EGL_DEVICE_EXT 0x322C #define EGL_DEVICE_EXT 0x322C
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value);
...@@ -1284,8 +1552,14 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a ...@@ -1284,8 +1552,14 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a
#ifndef EGL_EXT_device_drm #ifndef EGL_EXT_device_drm
#define EGL_EXT_device_drm 1 #define EGL_EXT_device_drm 1
#define EGL_DRM_DEVICE_FILE_EXT 0x3233 #define EGL_DRM_DEVICE_FILE_EXT 0x3233
#define EGL_DRM_MASTER_FD_EXT 0x333C
#endif /* EGL_EXT_device_drm */ #endif /* EGL_EXT_device_drm */
#ifndef EGL_EXT_device_drm_render_node
#define EGL_EXT_device_drm_render_node 1
#define EGL_DRM_RENDER_NODE_FILE_EXT 0x3377
#endif /* EGL_EXT_device_drm_render_node */
#ifndef EGL_EXT_device_enumeration #ifndef EGL_EXT_device_enumeration
#define EGL_EXT_device_enumeration 1 #define EGL_EXT_device_enumeration 1
#endif /* EGL_EXT_device_enumeration */ #endif /* EGL_EXT_device_enumeration */
...@@ -1293,12 +1567,68 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a ...@@ -1293,12 +1567,68 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a
#ifndef EGL_EXT_device_openwf #ifndef EGL_EXT_device_openwf
#define EGL_EXT_device_openwf 1 #define EGL_EXT_device_openwf 1
#define EGL_OPENWF_DEVICE_ID_EXT 0x3237 #define EGL_OPENWF_DEVICE_ID_EXT 0x3237
#define EGL_OPENWF_DEVICE_EXT 0x333D
#endif /* EGL_EXT_device_openwf */ #endif /* EGL_EXT_device_openwf */
#ifndef EGL_EXT_device_persistent_id
#define EGL_EXT_device_persistent_id 1
#define EGL_DEVICE_UUID_EXT 0x335C
#define EGL_DRIVER_UUID_EXT 0x335D
#define EGL_DRIVER_NAME_EXT 0x335E
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEBINARYEXTPROC) (EGLDeviceEXT device, EGLint name, EGLint max_size, void *value, EGLint *size);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceBinaryEXT (EGLDeviceEXT device, EGLint name, EGLint max_size, void *value, EGLint *size);
#endif
#endif /* EGL_EXT_device_persistent_id */
#ifndef EGL_EXT_device_query #ifndef EGL_EXT_device_query
#define EGL_EXT_device_query 1 #define EGL_EXT_device_query 1
#endif /* EGL_EXT_device_query */ #endif /* EGL_EXT_device_query */
#ifndef EGL_EXT_device_query_name
#define EGL_EXT_device_query_name 1
#define EGL_RENDERER_EXT 0x335F
#endif /* EGL_EXT_device_query_name */
#ifndef EGL_EXT_explicit_device
#define EGL_EXT_explicit_device 1
#endif /* EGL_EXT_explicit_device */
#ifndef EGL_EXT_gl_colorspace_bt2020_linear
#define EGL_EXT_gl_colorspace_bt2020_linear 1
#define EGL_GL_COLORSPACE_BT2020_LINEAR_EXT 0x333F
#endif /* EGL_EXT_gl_colorspace_bt2020_linear */
#ifndef EGL_EXT_gl_colorspace_bt2020_pq
#define EGL_EXT_gl_colorspace_bt2020_pq 1
#define EGL_GL_COLORSPACE_BT2020_PQ_EXT 0x3340
#endif /* EGL_EXT_gl_colorspace_bt2020_pq */
#ifndef EGL_EXT_gl_colorspace_display_p3
#define EGL_EXT_gl_colorspace_display_p3 1
#define EGL_GL_COLORSPACE_DISPLAY_P3_EXT 0x3363
#endif /* EGL_EXT_gl_colorspace_display_p3 */
#ifndef EGL_EXT_gl_colorspace_display_p3_linear
#define EGL_EXT_gl_colorspace_display_p3_linear 1
#define EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT 0x3362
#endif /* EGL_EXT_gl_colorspace_display_p3_linear */
#ifndef EGL_EXT_gl_colorspace_display_p3_passthrough
#define EGL_EXT_gl_colorspace_display_p3_passthrough 1
#define EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT 0x3490
#endif /* EGL_EXT_gl_colorspace_display_p3_passthrough */
#ifndef EGL_EXT_gl_colorspace_scrgb
#define EGL_EXT_gl_colorspace_scrgb 1
#define EGL_GL_COLORSPACE_SCRGB_EXT 0x3351
#endif /* EGL_EXT_gl_colorspace_scrgb */
#ifndef EGL_EXT_gl_colorspace_scrgb_linear
#define EGL_EXT_gl_colorspace_scrgb_linear 1
#define EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT 0x3350
#endif /* EGL_EXT_gl_colorspace_scrgb_linear */
#ifndef EGL_EXT_image_dma_buf_import #ifndef EGL_EXT_image_dma_buf_import
#define EGL_EXT_image_dma_buf_import 1 #define EGL_EXT_image_dma_buf_import 1
#define EGL_LINUX_DMA_BUF_EXT 0x3270 #define EGL_LINUX_DMA_BUF_EXT 0x3270
...@@ -1325,6 +1655,39 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a ...@@ -1325,6 +1655,39 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a
#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 #define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285
#endif /* EGL_EXT_image_dma_buf_import */ #endif /* EGL_EXT_image_dma_buf_import */
#ifndef EGL_EXT_image_dma_buf_import_modifiers
#define EGL_EXT_image_dma_buf_import_modifiers 1
#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440
#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441
#define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442
#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443
#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444
#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445
#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446
#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447
#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448
#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449
#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufFormatsEXT (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufModifiersEXT (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers);
#endif
#endif /* EGL_EXT_image_dma_buf_import_modifiers */
#ifndef EGL_EXT_image_gl_colorspace
#define EGL_EXT_image_gl_colorspace 1
#define EGL_GL_COLORSPACE_DEFAULT_EXT 0x314D
#endif /* EGL_EXT_image_gl_colorspace */
#ifndef EGL_EXT_image_implicit_sync_control
#define EGL_EXT_image_implicit_sync_control 1
#define EGL_IMPORT_SYNC_TYPE_EXT 0x3470
#define EGL_IMPORT_IMPLICIT_SYNC_EXT 0x3471
#define EGL_IMPORT_EXPLICIT_SYNC_EXT 0x3472
#endif /* EGL_EXT_image_implicit_sync_control */
#ifndef EGL_EXT_multiview_window #ifndef EGL_EXT_multiview_window
#define EGL_EXT_multiview_window 1 #define EGL_EXT_multiview_window 1
#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 #define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134
...@@ -1334,8 +1697,8 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a ...@@ -1334,8 +1697,8 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint a
#define EGL_EXT_output_base 1 #define EGL_EXT_output_base 1
typedef void *EGLOutputLayerEXT; typedef void *EGLOutputLayerEXT;
typedef void *EGLOutputPortEXT; typedef void *EGLOutputPortEXT;
#define EGL_NO_OUTPUT_LAYER_EXT ((EGLOutputLayerEXT)0) #define EGL_NO_OUTPUT_LAYER_EXT EGL_CAST(EGLOutputLayerEXT,0)
#define EGL_NO_OUTPUT_PORT_EXT ((EGLOutputPortEXT)0) #define EGL_NO_OUTPUT_PORT_EXT EGL_CAST(EGLOutputPortEXT,0)
#define EGL_BAD_OUTPUT_LAYER_EXT 0x322D #define EGL_BAD_OUTPUT_LAYER_EXT 0x322D
#define EGL_BAD_OUTPUT_PORT_EXT 0x322E #define EGL_BAD_OUTPUT_PORT_EXT 0x322E
#define EGL_SWAP_INTERVAL_EXT 0x322F #define EGL_SWAP_INTERVAL_EXT 0x322F
...@@ -1372,6 +1735,13 @@ EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLO ...@@ -1372,6 +1735,13 @@ EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLO
#define EGL_OPENWF_PORT_ID_EXT 0x3239 #define EGL_OPENWF_PORT_ID_EXT 0x3239
#endif /* EGL_EXT_output_openwf */ #endif /* EGL_EXT_output_openwf */
#ifndef EGL_EXT_pixel_format_float
#define EGL_EXT_pixel_format_float 1
#define EGL_COLOR_COMPONENT_TYPE_EXT 0x3339
#define EGL_COLOR_COMPONENT_TYPE_FIXED_EXT 0x333A
#define EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT 0x333B
#endif /* EGL_EXT_pixel_format_float */
#ifndef EGL_EXT_platform_base #ifndef EGL_EXT_platform_base
#define EGL_EXT_platform_base 1 #define EGL_EXT_platform_base 1
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
...@@ -1400,9 +1770,24 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, ...@@ -1400,9 +1770,24 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy,
#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 #define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6
#endif /* EGL_EXT_platform_x11 */ #endif /* EGL_EXT_platform_x11 */
#ifndef EGL_EXT_platform_xcb
#define EGL_EXT_platform_xcb 1
#define EGL_PLATFORM_XCB_EXT 0x31DC
#define EGL_PLATFORM_XCB_SCREEN_EXT 0x31DE
#endif /* EGL_EXT_platform_xcb */
#ifndef EGL_EXT_present_opaque
#define EGL_EXT_present_opaque 1
#define EGL_PRESENT_OPAQUE_EXT 0x31DF
#endif /* EGL_EXT_present_opaque */
#ifndef EGL_EXT_protected_content
#define EGL_EXT_protected_content 1
#define EGL_PROTECTED_CONTENT_EXT 0x32C0
#endif /* EGL_EXT_protected_content */
#ifndef EGL_EXT_protected_surface #ifndef EGL_EXT_protected_surface
#define EGL_EXT_protected_surface 1 #define EGL_EXT_protected_surface 1
#define EGL_PROTECTED_CONTENT_EXT 0x32C0
#endif /* EGL_EXT_protected_surface */ #endif /* EGL_EXT_protected_surface */
#ifndef EGL_EXT_stream_consumer_egloutput #ifndef EGL_EXT_stream_consumer_egloutput
...@@ -1413,14 +1798,68 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStr ...@@ -1413,14 +1798,68 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStr
#endif #endif
#endif /* EGL_EXT_stream_consumer_egloutput */ #endif /* EGL_EXT_stream_consumer_egloutput */
#ifndef EGL_EXT_surface_CTA861_3_metadata
#define EGL_EXT_surface_CTA861_3_metadata 1
#define EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT 0x3360
#define EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT 0x3361
#endif /* EGL_EXT_surface_CTA861_3_metadata */
#ifndef EGL_EXT_surface_SMPTE2086_metadata
#define EGL_EXT_surface_SMPTE2086_metadata 1
#define EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT 0x3341
#define EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT 0x3342
#define EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT 0x3343
#define EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT 0x3344
#define EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT 0x3345
#define EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT 0x3346
#define EGL_SMPTE2086_WHITE_POINT_X_EXT 0x3347
#define EGL_SMPTE2086_WHITE_POINT_Y_EXT 0x3348
#define EGL_SMPTE2086_MAX_LUMINANCE_EXT 0x3349
#define EGL_SMPTE2086_MIN_LUMINANCE_EXT 0x334A
#define EGL_METADATA_SCALING_EXT 50000
#endif /* EGL_EXT_surface_SMPTE2086_metadata */
#ifndef EGL_EXT_surface_compression
#define EGL_EXT_surface_compression 1
#define EGL_SURFACE_COMPRESSION_EXT 0x34B0
#define EGL_SURFACE_COMPRESSION_PLANE1_EXT 0x328E
#define EGL_SURFACE_COMPRESSION_PLANE2_EXT 0x328F
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x34B1
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x34B2
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x34B4
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x34B5
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x34B6
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x34B7
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x34B8
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x34B9
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x34BA
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x34BB
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x34BC
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x34BD
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x34BE
#define EGL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x34BF
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSUPPORTEDCOMPRESSIONRATESEXTPROC) (EGLDisplay dpy, EGLConfig config, const EGLAttrib *attrib_list, EGLint *rates, EGLint rate_size, EGLint *num_rates);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySupportedCompressionRatesEXT (EGLDisplay dpy, EGLConfig config, const EGLAttrib *attrib_list, EGLint *rates, EGLint rate_size, EGLint *num_rates);
#endif
#endif /* EGL_EXT_surface_compression */
#ifndef EGL_EXT_swap_buffers_with_damage #ifndef EGL_EXT_swap_buffers_with_damage
#define EGL_EXT_swap_buffers_with_damage 1 #define EGL_EXT_swap_buffers_with_damage 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects);
#ifdef EGL_EGLEXT_PROTOTYPES #ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects);
#endif #endif
#endif /* EGL_EXT_swap_buffers_with_damage */ #endif /* EGL_EXT_swap_buffers_with_damage */
#ifndef EGL_EXT_sync_reuse
#define EGL_EXT_sync_reuse 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglUnsignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list);
#endif
#endif /* EGL_EXT_sync_reuse */
#ifndef EGL_EXT_yuv_surface #ifndef EGL_EXT_yuv_surface
#define EGL_EXT_yuv_surface 1 #define EGL_EXT_yuv_surface 1
#define EGL_YUV_ORDER_EXT 0x3301 #define EGL_YUV_ORDER_EXT 0x3301
...@@ -1481,6 +1920,12 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfi ...@@ -1481,6 +1920,12 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfi
#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 #define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
#endif /* EGL_IMG_context_priority */ #endif /* EGL_IMG_context_priority */
#ifndef EGL_IMG_image_plane_attribs
#define EGL_IMG_image_plane_attribs 1
#define EGL_NATIVE_BUFFER_MULTIPLANE_SEPARATE_IMG 0x3105
#define EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG 0x3106
#endif /* EGL_IMG_image_plane_attribs */
#ifndef EGL_MESA_drm_image #ifndef EGL_MESA_drm_image
#define EGL_MESA_drm_image 1 #define EGL_MESA_drm_image 1
#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 #define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0
...@@ -1490,6 +1935,7 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfi ...@@ -1490,6 +1935,7 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfi
#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 #define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4
#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 #define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001
#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 #define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002
#define EGL_DRM_BUFFER_USE_CURSOR_MESA 0x00000004
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
#ifdef EGL_EGLEXT_PROTOTYPES #ifdef EGL_EGLEXT_PROTOTYPES
...@@ -1513,6 +1959,21 @@ EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImage ...@@ -1513,6 +1959,21 @@ EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImage
#define EGL_PLATFORM_GBM_MESA 0x31D7 #define EGL_PLATFORM_GBM_MESA 0x31D7
#endif /* EGL_MESA_platform_gbm */ #endif /* EGL_MESA_platform_gbm */
#ifndef EGL_MESA_platform_surfaceless
#define EGL_MESA_platform_surfaceless 1
#define EGL_PLATFORM_SURFACELESS_MESA 0x31DD
#endif /* EGL_MESA_platform_surfaceless */
#ifndef EGL_MESA_query_driver
#define EGL_MESA_query_driver 1
typedef char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERCONFIGPROC) (EGLDisplay dpy);
typedef const char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERNAMEPROC) (EGLDisplay dpy);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI char *EGLAPIENTRY eglGetDisplayDriverConfig (EGLDisplay dpy);
EGLAPI const char *EGLAPIENTRY eglGetDisplayDriverName (EGLDisplay dpy);
#endif
#endif /* EGL_MESA_query_driver */
#ifndef EGL_NOK_swap_region #ifndef EGL_NOK_swap_region
#define EGL_NOK_swap_region 1 #define EGL_NOK_swap_region 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects);
...@@ -1539,6 +2000,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurfa ...@@ -1539,6 +2000,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurfa
#define EGL_AUTO_STEREO_NV 0x3136 #define EGL_AUTO_STEREO_NV 0x3136
#endif /* EGL_NV_3dvision_surface */ #endif /* EGL_NV_3dvision_surface */
#ifndef EGL_NV_context_priority_realtime
#define EGL_NV_context_priority_realtime 1
#define EGL_CONTEXT_PRIORITY_REALTIME_NV 0x3357
#endif /* EGL_NV_context_priority_realtime */
#ifndef EGL_NV_coverage_sample #ifndef EGL_NV_coverage_sample
#define EGL_NV_coverage_sample 1 #define EGL_NV_coverage_sample 1
#define EGL_COVERAGE_BUFFERS_NV 0x30E0 #define EGL_COVERAGE_BUFFERS_NV 0x30E0
...@@ -1596,6 +2062,181 @@ EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface sur ...@@ -1596,6 +2062,181 @@ EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface sur
#endif #endif
#endif /* EGL_NV_post_sub_buffer */ #endif /* EGL_NV_post_sub_buffer */
#ifndef EGL_NV_quadruple_buffer
#define EGL_NV_quadruple_buffer 1
#define EGL_QUADRUPLE_BUFFER_NV 0x3231
#endif /* EGL_NV_quadruple_buffer */
#ifndef EGL_NV_robustness_video_memory_purge
#define EGL_NV_robustness_video_memory_purge 1
#define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C
#endif /* EGL_NV_robustness_video_memory_purge */
#ifndef EGL_NV_stream_consumer_eglimage
#define EGL_NV_stream_consumer_eglimage 1
#define EGL_STREAM_CONSUMER_IMAGE_NV 0x3373
#define EGL_STREAM_IMAGE_ADD_NV 0x3374
#define EGL_STREAM_IMAGE_REMOVE_NV 0x3375
#define EGL_STREAM_IMAGE_AVAILABLE_NV 0x3376
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMIMAGECONSUMERCONNECTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, const EGLuint64KHR *modifiers, const EGLAttrib *attrib_list);
typedef EGLint (EGLAPIENTRYP PFNEGLQUERYSTREAMCONSUMEREVENTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMACQUIREIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMRELEASEIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglStreamImageConsumerConnectNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, const EGLuint64KHR *modifiers, const EGLAttrib *attrib_list);
EGLAPI EGLint EGLAPIENTRY eglQueryStreamConsumerEventNV (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamAcquireImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamReleaseImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync);
#endif
#endif /* EGL_NV_stream_consumer_eglimage */
#ifndef EGL_NV_stream_consumer_gltexture_yuv
#define EGL_NV_stream_consumer_gltexture_yuv 1
#define EGL_YUV_PLANE0_TEXTURE_UNIT_NV 0x332C
#define EGL_YUV_PLANE1_TEXTURE_UNIT_NV 0x332D
#define EGL_YUV_PLANE2_TEXTURE_UNIT_NV 0x332E
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALATTRIBSNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
#endif
#endif /* EGL_NV_stream_consumer_gltexture_yuv */
#ifndef EGL_NV_stream_cross_display
#define EGL_NV_stream_cross_display 1
#define EGL_STREAM_CROSS_DISPLAY_NV 0x334E
#endif /* EGL_NV_stream_cross_display */
#ifndef EGL_NV_stream_cross_object
#define EGL_NV_stream_cross_object 1
#define EGL_STREAM_CROSS_OBJECT_NV 0x334D
#endif /* EGL_NV_stream_cross_object */
#ifndef EGL_NV_stream_cross_partition
#define EGL_NV_stream_cross_partition 1
#define EGL_STREAM_CROSS_PARTITION_NV 0x323F
#endif /* EGL_NV_stream_cross_partition */
#ifndef EGL_NV_stream_cross_process
#define EGL_NV_stream_cross_process 1
#define EGL_STREAM_CROSS_PROCESS_NV 0x3245
#endif /* EGL_NV_stream_cross_process */
#ifndef EGL_NV_stream_cross_system
#define EGL_NV_stream_cross_system 1
#define EGL_STREAM_CROSS_SYSTEM_NV 0x334F
#endif /* EGL_NV_stream_cross_system */
#ifndef EGL_NV_stream_dma
#define EGL_NV_stream_dma 1
#define EGL_STREAM_DMA_NV 0x3371
#define EGL_STREAM_DMA_SERVER_NV 0x3372
#endif /* EGL_NV_stream_dma */
#ifndef EGL_NV_stream_fifo_next
#define EGL_NV_stream_fifo_next 1
#define EGL_PENDING_FRAME_NV 0x3329
#define EGL_STREAM_TIME_PENDING_NV 0x332A
#endif /* EGL_NV_stream_fifo_next */
#ifndef EGL_NV_stream_fifo_synchronous
#define EGL_NV_stream_fifo_synchronous 1
#define EGL_STREAM_FIFO_SYNCHRONOUS_NV 0x3336
#endif /* EGL_NV_stream_fifo_synchronous */
#ifndef EGL_NV_stream_flush
#define EGL_NV_stream_flush 1
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMFLUSHNVPROC) (EGLDisplay dpy, EGLStreamKHR stream);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglStreamFlushNV (EGLDisplay dpy, EGLStreamKHR stream);
#endif
#endif /* EGL_NV_stream_flush */
#ifndef EGL_NV_stream_frame_limits
#define EGL_NV_stream_frame_limits 1
#define EGL_PRODUCER_MAX_FRAME_HINT_NV 0x3337
#define EGL_CONSUMER_MAX_FRAME_HINT_NV 0x3338
#endif /* EGL_NV_stream_frame_limits */
#ifndef EGL_NV_stream_metadata
#define EGL_NV_stream_metadata 1
#define EGL_MAX_STREAM_METADATA_BLOCKS_NV 0x3250
#define EGL_MAX_STREAM_METADATA_BLOCK_SIZE_NV 0x3251
#define EGL_MAX_STREAM_METADATA_TOTAL_SIZE_NV 0x3252
#define EGL_PRODUCER_METADATA_NV 0x3253
#define EGL_CONSUMER_METADATA_NV 0x3254
#define EGL_PENDING_METADATA_NV 0x3328
#define EGL_METADATA0_SIZE_NV 0x3255
#define EGL_METADATA1_SIZE_NV 0x3256
#define EGL_METADATA2_SIZE_NV 0x3257
#define EGL_METADATA3_SIZE_NV 0x3258
#define EGL_METADATA0_TYPE_NV 0x3259
#define EGL_METADATA1_TYPE_NV 0x325A
#define EGL_METADATA2_TYPE_NV 0x325B
#define EGL_METADATA3_TYPE_NV 0x325C
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBNVPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribNV (EGLDisplay dpy, EGLint attribute, EGLAttrib *value);
EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data);
#endif
#endif /* EGL_NV_stream_metadata */
#ifndef EGL_NV_stream_origin
#define EGL_NV_stream_origin 1
#define EGL_STREAM_FRAME_ORIGIN_X_NV 0x3366
#define EGL_STREAM_FRAME_ORIGIN_Y_NV 0x3367
#define EGL_STREAM_FRAME_MAJOR_AXIS_NV 0x3368
#define EGL_CONSUMER_AUTO_ORIENTATION_NV 0x3369
#define EGL_PRODUCER_AUTO_ORIENTATION_NV 0x336A
#define EGL_LEFT_NV 0x336B
#define EGL_RIGHT_NV 0x336C
#define EGL_TOP_NV 0x336D
#define EGL_BOTTOM_NV 0x336E
#define EGL_X_AXIS_NV 0x336F
#define EGL_Y_AXIS_NV 0x3370
#endif /* EGL_NV_stream_origin */
#ifndef EGL_NV_stream_remote
#define EGL_NV_stream_remote 1
#define EGL_STREAM_STATE_INITIALIZING_NV 0x3240
#define EGL_STREAM_TYPE_NV 0x3241
#define EGL_STREAM_PROTOCOL_NV 0x3242
#define EGL_STREAM_ENDPOINT_NV 0x3243
#define EGL_STREAM_LOCAL_NV 0x3244
#define EGL_STREAM_PRODUCER_NV 0x3247
#define EGL_STREAM_CONSUMER_NV 0x3248
#define EGL_STREAM_PROTOCOL_FD_NV 0x3246
#endif /* EGL_NV_stream_remote */
#ifndef EGL_NV_stream_reset
#define EGL_NV_stream_reset 1
#define EGL_SUPPORT_RESET_NV 0x3334
#define EGL_SUPPORT_REUSE_NV 0x3335
typedef EGLBoolean (EGLAPIENTRYP PFNEGLRESETSTREAMNVPROC) (EGLDisplay dpy, EGLStreamKHR stream);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglResetStreamNV (EGLDisplay dpy, EGLStreamKHR stream);
#endif
#endif /* EGL_NV_stream_reset */
#ifndef EGL_NV_stream_socket
#define EGL_NV_stream_socket 1
#define EGL_STREAM_PROTOCOL_SOCKET_NV 0x324B
#define EGL_SOCKET_HANDLE_NV 0x324C
#define EGL_SOCKET_TYPE_NV 0x324D
#endif /* EGL_NV_stream_socket */
#ifndef EGL_NV_stream_socket_inet
#define EGL_NV_stream_socket_inet 1
#define EGL_SOCKET_TYPE_INET_NV 0x324F
#endif /* EGL_NV_stream_socket_inet */
#ifndef EGL_NV_stream_socket_unix
#define EGL_NV_stream_socket_unix 1
#define EGL_SOCKET_TYPE_UNIX_NV 0x324E
#endif /* EGL_NV_stream_socket_unix */
#ifndef EGL_NV_stream_sync #ifndef EGL_NV_stream_sync
#define EGL_NV_stream_sync 1 #define EGL_NV_stream_sync 1
#define EGL_SYNC_NEW_FRAME_NV 0x321F #define EGL_SYNC_NEW_FRAME_NV 0x321F
...@@ -1622,7 +2263,7 @@ typedef khronos_utime_nanoseconds_t EGLTimeNV; ...@@ -1622,7 +2263,7 @@ typedef khronos_utime_nanoseconds_t EGLTimeNV;
#define EGL_SYNC_TYPE_NV 0x30ED #define EGL_SYNC_TYPE_NV 0x30ED
#define EGL_SYNC_CONDITION_NV 0x30EE #define EGL_SYNC_CONDITION_NV 0x30EE
#define EGL_SYNC_FENCE_NV 0x30EF #define EGL_SYNC_FENCE_NV 0x30EF
#define EGL_NO_SYNC_NV ((EGLSyncNV)0) #define EGL_NO_SYNC_NV EGL_CAST(EGLSyncNV,0)
typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);
...@@ -1653,6 +2294,11 @@ EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); ...@@ -1653,6 +2294,11 @@ EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void);
#endif /* KHRONOS_SUPPORT_INT64 */ #endif /* KHRONOS_SUPPORT_INT64 */
#endif /* EGL_NV_system_time */ #endif /* EGL_NV_system_time */
#ifndef EGL_NV_triple_buffer
#define EGL_NV_triple_buffer 1
#define EGL_TRIPLE_BUFFER_NV 0x3230
#endif /* EGL_NV_triple_buffer */
#ifndef EGL_TIZEN_image_native_buffer #ifndef EGL_TIZEN_image_native_buffer
#define EGL_TIZEN_image_native_buffer 1 #define EGL_TIZEN_image_native_buffer 1
#define EGL_NATIVE_BUFFER_TIZEN 0x32A0 #define EGL_NATIVE_BUFFER_TIZEN 0x32A0
...@@ -1663,11 +2309,44 @@ EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); ...@@ -1663,11 +2309,44 @@ EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void);
#define EGL_NATIVE_SURFACE_TIZEN 0x32A1 #define EGL_NATIVE_SURFACE_TIZEN 0x32A1
#endif /* EGL_TIZEN_image_native_surface */ #endif /* EGL_TIZEN_image_native_surface */
#ifndef EGL_WL_bind_wayland_display
#define EGL_WL_bind_wayland_display 1
#define PFNEGLBINDWAYLANDDISPLAYWL PFNEGLBINDWAYLANDDISPLAYWLPROC
#define PFNEGLUNBINDWAYLANDDISPLAYWL PFNEGLUNBINDWAYLANDDISPLAYWLPROC
#define PFNEGLQUERYWAYLANDBUFFERWL PFNEGLQUERYWAYLANDBUFFERWLPROC
struct wl_display;
struct wl_resource;
#define EGL_WAYLAND_BUFFER_WL 0x31D5
#define EGL_WAYLAND_PLANE_WL 0x31D6
#define EGL_TEXTURE_Y_U_V_WL 0x31D7
#define EGL_TEXTURE_Y_UV_WL 0x31D8
#define EGL_TEXTURE_Y_XUXV_WL 0x31D9
#define EGL_TEXTURE_EXTERNAL_WL 0x31DA
#define EGL_WAYLAND_Y_INVERTED_WL 0x31DB
typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWLPROC) (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display);
EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value);
#endif
#endif /* EGL_WL_bind_wayland_display */
#ifndef EGL_WL_create_wayland_buffer_from_image
#define EGL_WL_create_wayland_buffer_from_image 1
#define PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC
struct wl_buffer;
typedef struct wl_buffer *(EGLAPIENTRYP PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC) (EGLDisplay dpy, EGLImageKHR image);
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI struct wl_buffer *EGLAPIENTRY eglCreateWaylandBufferFromImageWL (EGLDisplay dpy, EGLImageKHR image);
#endif
#endif /* EGL_WL_create_wayland_buffer_from_image */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __eglext_h_ */ #endif /* __eglext_h_ */
#endif /* _MSC_VER */ #endif /* _MSC_VER */
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -30,6 +30,23 @@ ...@@ -30,6 +30,23 @@
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
#ifdef __clang__
#ifndef __PRFCHWINTRIN_H
#define __PRFCHWINTRIN_H
static __inline__ void __attribute__((__always_inline__, __nodebug__))
_m_prefetch(void *__P)
{
__builtin_prefetch(__P, 0, 3 /* _MM_HINT_T0 */);
}
#endif /* __PRFCHWINTRIN_H */
#endif /* __clang__ */
#include <intrin.h>
#endif
/** /**
* \name The two types of endianness * \name The two types of endianness
*/ */
...@@ -42,11 +59,26 @@ ...@@ -42,11 +59,26 @@
#ifdef __linux__ #ifdef __linux__
#include <endian.h> #include <endian.h>
#define SDL_BYTEORDER __BYTE_ORDER #define SDL_BYTEORDER __BYTE_ORDER
#else /* __linux__ */ #elif defined(__OpenBSD__) || defined(__DragonFly__)
#include <endian.h>
#define SDL_BYTEORDER BYTE_ORDER
#elif defined(__FreeBSD__) || defined(__NetBSD__)
#include <sys/endian.h>
#define SDL_BYTEORDER BYTE_ORDER
/* predefs from newer gcc and clang versions: */
#elif defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__BYTE_ORDER__)
#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#define SDL_BYTEORDER SDL_LIL_ENDIAN
#elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
#define SDL_BYTEORDER SDL_BIG_ENDIAN
#else
#error Unsupported endianness
#endif /**/
#else
#if defined(__hppa__) || \ #if defined(__hppa__) || \
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
(defined(__MIPS__) && defined(__MISPEB__)) || \ (defined(__MIPS__) && defined(__MIPSEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ defined(__ppc__) || defined(__POWERPC__) || defined(__powerpc__) || defined(__PPC__) || \
defined(__sparc__) defined(__sparc__)
#define SDL_BYTEORDER SDL_BIG_ENDIAN #define SDL_BYTEORDER SDL_BIG_ENDIAN
#else #else
...@@ -55,6 +87,28 @@ ...@@ -55,6 +87,28 @@
#endif /* __linux__ */ #endif /* __linux__ */
#endif /* !SDL_BYTEORDER */ #endif /* !SDL_BYTEORDER */
#ifndef SDL_FLOATWORDORDER /* Not defined in SDL_config.h? */
/* predefs from newer gcc versions: */
#if defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__FLOAT_WORD_ORDER__)
#if (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#define SDL_FLOATWORDORDER SDL_LIL_ENDIAN
#elif (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)
#define SDL_FLOATWORDORDER SDL_BIG_ENDIAN
#else
#error Unsupported endianness
#endif /**/
#elif defined(__MAVERICK__)
/* For Maverick, float words are always little-endian. */
#define SDL_FLOATWORDORDER SDL_LIL_ENDIAN
#elif (defined(__arm__) || defined(__thumb__)) && !defined(__VFP_FP__) && !defined(__ARM_EABI__)
/* For FPA, float words are always big-endian. */
#define SDL_FLOATWORDORDER SDL_BIG_ENDIAN
#else
/* By default, assume that floats words follow the memory system mode. */
#define SDL_FLOATWORDORDER SDL_BYTEORDER
#endif /* __FLOAT_WORD_ORDER__ */
#endif /* !SDL_FLOATWORDORDER */
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
...@@ -65,22 +119,45 @@ extern "C" { ...@@ -65,22 +119,45 @@ extern "C" {
/** /**
* \file SDL_endian.h * \file SDL_endian.h
*/ */
#if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) /* various modern compilers may have builtin swap */
#if defined(__GNUC__) || defined(__clang__)
# define HAS_BUILTIN_BSWAP16 (_SDL_HAS_BUILTIN(__builtin_bswap16)) || \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
# define HAS_BUILTIN_BSWAP32 (_SDL_HAS_BUILTIN(__builtin_bswap32)) || \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define HAS_BUILTIN_BSWAP64 (_SDL_HAS_BUILTIN(__builtin_bswap64)) || \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
/* this one is broken */
# define HAS_BROKEN_BSWAP (__GNUC__ == 2 && __GNUC_MINOR__ <= 95)
#else
# define HAS_BUILTIN_BSWAP16 0
# define HAS_BUILTIN_BSWAP32 0
# define HAS_BUILTIN_BSWAP64 0
# define HAS_BROKEN_BSWAP 0
#endif
#if HAS_BUILTIN_BSWAP16
#define SDL_Swap16(x) __builtin_bswap16(x)
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
#pragma intrinsic(_byteswap_ushort)
#define SDL_Swap16(x) _byteswap_ushort(x)
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
__asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); __asm__("xchgb %b0,%h0": "=q"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__x86_64__)
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
__asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) #elif (defined(__powerpc__) || defined(__ppc__))
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
...@@ -89,7 +166,7 @@ SDL_Swap16(Uint16 x) ...@@ -89,7 +166,7 @@ SDL_Swap16(Uint16 x)
__asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
return (Uint16)result; return (Uint16)result;
} }
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) #elif (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
...@@ -97,7 +174,7 @@ SDL_Swap16(Uint16 x) ...@@ -97,7 +174,7 @@ SDL_Swap16(Uint16 x)
return x; return x;
} }
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
extern _inline Uint16 SDL_Swap16(Uint16); extern __inline Uint16 SDL_Swap16(Uint16);
#pragma aux SDL_Swap16 = \ #pragma aux SDL_Swap16 = \
"xchg al, ah" \ "xchg al, ah" \
parm [ax] \ parm [ax] \
...@@ -110,32 +187,37 @@ SDL_Swap16(Uint16 x) ...@@ -110,32 +187,37 @@ SDL_Swap16(Uint16 x)
} }
#endif #endif
#if defined(__GNUC__) && defined(__i386__) #if HAS_BUILTIN_BSWAP32
#define SDL_Swap32(x) __builtin_bswap32(x)
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
#pragma intrinsic(_byteswap_ulong)
#define SDL_Swap32(x) _byteswap_ulong(x)
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
__asm__("bswap %0": "=r"(x):"0"(x)); __asm__("bswap %0": "=r"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__x86_64__)
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
__asm__("bswapl %0": "=r"(x):"0"(x)); __asm__("bswapl %0": "=r"(x):"0"(x));
return x; return x;
} }
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) #elif (defined(__powerpc__) || defined(__ppc__))
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
Uint32 result; Uint32 result;
__asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); __asm__("rlwimi %0,%2,24,16,23": "=&r"(result): "0" (x>>24), "r"(x));
__asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); __asm__("rlwimi %0,%2,8,8,15" : "=&r"(result): "0" (result), "r"(x));
__asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); __asm__("rlwimi %0,%2,24,0,7" : "=&r"(result): "0" (result), "r"(x));
return result; return result;
} }
#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) #elif (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
...@@ -143,20 +225,11 @@ SDL_Swap32(Uint32 x) ...@@ -143,20 +225,11 @@ SDL_Swap32(Uint32 x)
return x; return x;
} }
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
extern _inline Uint32 SDL_Swap32(Uint32); extern __inline Uint32 SDL_Swap32(Uint32);
#ifndef __SW_3 /* 486+ */
#pragma aux SDL_Swap32 = \ #pragma aux SDL_Swap32 = \
"bswap eax" \ "bswap eax" \
parm [eax] \ parm [eax] \
modify [eax]; modify [eax];
#else /* 386-only */
#pragma aux SDL_Swap32 = \
"xchg al, ah" \
"ror eax, 16" \
"xchg al, ah" \
parm [eax] \
modify [eax];
#endif
#else #else
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
...@@ -166,31 +239,42 @@ SDL_Swap32(Uint32 x) ...@@ -166,31 +239,42 @@ SDL_Swap32(Uint32 x)
} }
#endif #endif
#if defined(__GNUC__) && defined(__i386__) #if HAS_BUILTIN_BSWAP64
#define SDL_Swap64(x) __builtin_bswap64(x)
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
#pragma intrinsic(_byteswap_uint64)
#define SDL_Swap64(x) _byteswap_uint64(x)
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
{ {
union union {
{ struct {
struct
{
Uint32 a, b; Uint32 a, b;
} s; } s;
Uint64 u; Uint64 u;
} v; } v;
v.u = x; v.u = x;
__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
"1"(v.s. : "=r"(v.s.a), "=r"(v.s.b)
b)); : "0" (v.s.a), "1"(v.s.b));
return v.u; return v.u;
} }
#elif defined(__GNUC__) && defined(__x86_64__) #elif defined(__x86_64__)
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
{ {
__asm__("bswapq %0": "=r"(x):"0"(x)); __asm__("bswapq %0": "=r"(x):"0"(x));
return x; return x;
} }
#elif defined(__WATCOMC__) && defined(__386__)
extern __inline Uint64 SDL_Swap64(Uint64);
#pragma aux SDL_Swap64 = \
"bswap eax" \
"bswap edx" \
"xchg eax,edx" \
parm [eax edx] \
modify [eax edx];
#else #else
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
...@@ -212,8 +296,7 @@ SDL_Swap64(Uint64 x) ...@@ -212,8 +296,7 @@ SDL_Swap64(Uint64 x)
SDL_FORCE_INLINE float SDL_FORCE_INLINE float
SDL_SwapFloat(float x) SDL_SwapFloat(float x)
{ {
union union {
{
float f; float f;
Uint32 ui32; Uint32 ui32;
} swapper; } swapper;
...@@ -222,6 +305,11 @@ SDL_SwapFloat(float x) ...@@ -222,6 +305,11 @@ SDL_SwapFloat(float x)
return swapper.f; return swapper.f;
} }
/* remove extra macros */
#undef HAS_BROKEN_BSWAP
#undef HAS_BUILTIN_BSWAP16
#undef HAS_BUILTIN_BSWAP32
#undef HAS_BUILTIN_BSWAP64
/** /**
* \name Swap to native * \name Swap to native
...@@ -229,22 +317,22 @@ SDL_SwapFloat(float x) ...@@ -229,22 +317,22 @@ SDL_SwapFloat(float x)
*/ */
/* @{ */ /* @{ */
#if SDL_BYTEORDER == SDL_LIL_ENDIAN #if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define SDL_SwapLE16(X) (X) #define SDL_SwapLE16(X) (X)
#define SDL_SwapLE32(X) (X) #define SDL_SwapLE32(X) (X)
#define SDL_SwapLE64(X) (X) #define SDL_SwapLE64(X) (X)
#define SDL_SwapFloatLE(X) (X) #define SDL_SwapFloatLE(X) (X)
#define SDL_SwapBE16(X) SDL_Swap16(X) #define SDL_SwapBE16(X) SDL_Swap16(X)
#define SDL_SwapBE32(X) SDL_Swap32(X) #define SDL_SwapBE32(X) SDL_Swap32(X)
#define SDL_SwapBE64(X) SDL_Swap64(X) #define SDL_SwapBE64(X) SDL_Swap64(X)
#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) #define SDL_SwapFloatBE(X) SDL_SwapFloat(X)
#else #else
#define SDL_SwapLE16(X) SDL_Swap16(X) #define SDL_SwapLE16(X) SDL_Swap16(X)
#define SDL_SwapLE32(X) SDL_Swap32(X) #define SDL_SwapLE32(X) SDL_Swap32(X)
#define SDL_SwapLE64(X) SDL_Swap64(X) #define SDL_SwapLE64(X) SDL_Swap64(X)
#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) #define SDL_SwapFloatLE(X) SDL_SwapFloat(X)
#define SDL_SwapBE16(X) (X) #define SDL_SwapBE16(X) (X)
#define SDL_SwapBE32(X) (X) #define SDL_SwapBE32(X) (X)
#define SDL_SwapBE64(X) (X) #define SDL_SwapBE64(X) (X)
#define SDL_SwapFloatBE(X) (X) #define SDL_SwapFloatBE(X) (X)
#endif #endif
/* @} *//* Swap to native */ /* @} *//* Swap to native */
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -37,9 +37,96 @@ extern "C" { ...@@ -37,9 +37,96 @@ extern "C" {
#endif #endif
/* Public functions */ /* Public functions */
/* SDL_SetError() unconditionally returns -1. */
/**
* Set the SDL error message for the current thread.
*
* Calling this function will replace any previous error message that was set.
*
* This function always returns -1, since SDL frequently uses -1 to signify an
* failing result, leading to this idiom:
*
* ```c
* if (error_code) {
* return SDL_SetError("This operation has failed: %d", error_code);
* }
* ```
*
* \param fmt a printf()-style message format string
* \param ... additional parameters matching % tokens in the `fmt` string, if
* any
* \returns always -1.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ClearError
* \sa SDL_GetError
*/
extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
/**
* Retrieve a message about the last error that occurred on the current
* thread.
*
* It is possible for multiple errors to occur before calling SDL_GetError().
* Only the last error is returned.
*
* The message is only applicable when an SDL function has signaled an error.
* You must check the return values of SDL function calls to determine when to
* appropriately call SDL_GetError(). You should *not* use the results of
* SDL_GetError() to decide if an error has occurred! Sometimes SDL will set
* an error string even when reporting success.
*
* SDL will *not* clear the error string for successful API calls. You *must*
* check return values for failure cases before you can assume the error
* string applies.
*
* Error strings are set per-thread, so an error set in a different thread
* will not interfere with the current thread's operation.
*
* The returned string is internally allocated and must not be freed by the
* application.
*
* \returns a message with information about the specific error that occurred,
* or an empty string if there hasn't been an error message set since
* the last call to SDL_ClearError(). The message is only applicable
* when an SDL function has signaled an error. You must check the
* return values of SDL function calls to determine when to
* appropriately call SDL_GetError().
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_ClearError
* \sa SDL_SetError
*/
extern DECLSPEC const char *SDLCALL SDL_GetError(void); extern DECLSPEC const char *SDLCALL SDL_GetError(void);
/**
* Get the last error message that was set for the current thread.
*
* This allows the caller to copy the error string into a provided buffer, but
* otherwise operates exactly the same as SDL_GetError().
*
* \param errstr A buffer to fill with the last error message that was set for
* the current thread
* \param maxlen The size of the buffer pointed to by the errstr parameter
* \returns the pointer passed in as the `errstr` parameter.
*
* \since This function is available since SDL 2.0.14.
*
* \sa SDL_GetError
*/
extern DECLSPEC char * SDLCALL SDL_GetErrorMsg(char *errstr, int maxlen);
/**
* Clear any previous error message for this thread.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetError
* \sa SDL_SetError
*/
extern DECLSPEC void SDLCALL SDL_ClearError(void); extern DECLSPEC void SDLCALL SDL_ClearError(void);
/** /**
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -50,7 +50,7 @@ extern "C" { ...@@ -50,7 +50,7 @@ extern "C" {
#define SDL_PRESSED 1 #define SDL_PRESSED 1
/** /**
* \brief The types of events that can be delivered. * The types of events that can be delivered.
*/ */
typedef enum typedef enum
{ {
...@@ -85,6 +85,8 @@ typedef enum ...@@ -85,6 +85,8 @@ typedef enum
Called on Android in onResume() Called on Android in onResume()
*/ */
SDL_LOCALECHANGED, /**< The user's locale preferences have changed. */
/* Display events */ /* Display events */
SDL_DISPLAYEVENT = 0x150, /**< Display state change */ SDL_DISPLAYEVENT = 0x150, /**< Display state change */
...@@ -100,6 +102,7 @@ typedef enum ...@@ -100,6 +102,7 @@ typedef enum
SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an
input language or keyboard layout change. input language or keyboard layout change.
*/ */
SDL_TEXTEDITING_EXT, /**< Extended keyboard text editing (composition) */
/* Mouse events */ /* Mouse events */
SDL_MOUSEMOTION = 0x400, /**< Mouse moved */ SDL_MOUSEMOTION = 0x400, /**< Mouse moved */
...@@ -115,6 +118,7 @@ typedef enum ...@@ -115,6 +118,7 @@ typedef enum
SDL_JOYBUTTONUP, /**< Joystick button released */ SDL_JOYBUTTONUP, /**< Joystick button released */
SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */ SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */
SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */ SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */
SDL_JOYBATTERYUPDATED, /**< Joystick battery level change */
/* Game controller events */ /* Game controller events */
SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */
...@@ -123,6 +127,10 @@ typedef enum ...@@ -123,6 +127,10 @@ typedef enum
SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */ SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */
SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */ SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */
SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */ SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */
SDL_CONTROLLERTOUCHPADDOWN, /**< Game controller touchpad was touched */
SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */
SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */
SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */
/* Touch events */ /* Touch events */
SDL_FINGERDOWN = 0x700, SDL_FINGERDOWN = 0x700,
...@@ -135,7 +143,7 @@ typedef enum ...@@ -135,7 +143,7 @@ typedef enum
SDL_MULTIGESTURE, SDL_MULTIGESTURE,
/* Clipboard events */ /* Clipboard events */
SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */ SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard or primary selection changed */
/* Drag and drop events */ /* Drag and drop events */
SDL_DROPFILE = 0x1000, /**< The system requests a file open */ SDL_DROPFILE = 0x1000, /**< The system requests a file open */
...@@ -154,6 +162,9 @@ typedef enum ...@@ -154,6 +162,9 @@ typedef enum
SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */ SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */ SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
/* Internal events */
SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
* and should be allocated with SDL_RegisterEvents() * and should be allocated with SDL_RegisterEvents()
*/ */
...@@ -234,6 +245,19 @@ typedef struct SDL_TextEditingEvent ...@@ -234,6 +245,19 @@ typedef struct SDL_TextEditingEvent
Sint32 length; /**< The length of selected editing text */ Sint32 length; /**< The length of selected editing text */
} SDL_TextEditingEvent; } SDL_TextEditingEvent;
/**
* \brief Extended keyboard text editing event structure (event.editExt.*) when text would be
* truncated if stored in the text buffer SDL_TextEditingEvent
*/
typedef struct SDL_TextEditingExtEvent
{
Uint32 type; /**< ::SDL_TEXTEDITING_EXT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with keyboard focus, if any */
char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
Sint32 start; /**< The start cursor of selected editing text */
Sint32 length; /**< The length of selected editing text */
} SDL_TextEditingExtEvent;
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32) #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
/** /**
...@@ -292,6 +316,10 @@ typedef struct SDL_MouseWheelEvent ...@@ -292,6 +316,10 @@ typedef struct SDL_MouseWheelEvent
Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */
Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */
Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */ Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */
float preciseX; /**< The amount scrolled horizontally, positive to the right and negative to the left, with float precision (added in 2.0.18) */
float preciseY; /**< The amount scrolled vertically, positive away from the user and negative toward the user, with float precision (added in 2.0.18) */
Sint32 mouseX; /**< X coordinate, relative to window (added in 2.26.0) */
Sint32 mouseY; /**< Y coordinate, relative to window (added in 2.26.0) */
} SDL_MouseWheelEvent; } SDL_MouseWheelEvent;
/** /**
...@@ -370,6 +398,16 @@ typedef struct SDL_JoyDeviceEvent ...@@ -370,6 +398,16 @@ typedef struct SDL_JoyDeviceEvent
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
} SDL_JoyDeviceEvent; } SDL_JoyDeviceEvent;
/**
* \brief Joysick battery level change event structure (event.jbattery.*)
*/
typedef struct SDL_JoyBatteryEvent
{
Uint32 type; /**< ::SDL_JOYBATTERYUPDATED */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */
SDL_JoystickPowerLevel level; /**< The joystick battery level */
} SDL_JoyBatteryEvent;
/** /**
* \brief Game controller axis motion event structure (event.caxis.*) * \brief Game controller axis motion event structure (event.caxis.*)
...@@ -413,6 +451,34 @@ typedef struct SDL_ControllerDeviceEvent ...@@ -413,6 +451,34 @@ typedef struct SDL_ControllerDeviceEvent
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
} SDL_ControllerDeviceEvent; } SDL_ControllerDeviceEvent;
/**
* \brief Game controller touchpad event structure (event.ctouchpad.*)
*/
typedef struct SDL_ControllerTouchpadEvent
{
Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */
Sint32 touchpad; /**< The index of the touchpad */
Sint32 finger; /**< The index of the finger on the touchpad */
float x; /**< Normalized in the range 0...1 with 0 being on the left */
float y; /**< Normalized in the range 0...1 with 0 being at the top */
float pressure; /**< Normalized in the range 0...1 */
} SDL_ControllerTouchpadEvent;
/**
* \brief Game controller sensor event structure (event.csensor.*)
*/
typedef struct SDL_ControllerSensorEvent
{
Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */
Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
} SDL_ControllerSensorEvent;
/** /**
* \brief Audio device event structure (event.adevice.*) * \brief Audio device event structure (event.adevice.*)
*/ */
...@@ -442,6 +508,7 @@ typedef struct SDL_TouchFingerEvent ...@@ -442,6 +508,7 @@ typedef struct SDL_TouchFingerEvent
float dx; /**< Normalized in the range -1...1 */ float dx; /**< Normalized in the range -1...1 */
float dy; /**< Normalized in the range -1...1 */ float dy; /**< Normalized in the range -1...1 */
float pressure; /**< Normalized in the range 0...1 */ float pressure; /**< Normalized in the range 0...1 */
Uint32 windowID; /**< The window underneath the finger, if any */
} SDL_TouchFingerEvent; } SDL_TouchFingerEvent;
...@@ -501,6 +568,7 @@ typedef struct SDL_SensorEvent ...@@ -501,6 +568,7 @@ typedef struct SDL_SensorEvent
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Sint32 which; /**< The instance ID of the sensor */ Sint32 which; /**< The instance ID of the sensor */
float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */ float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
} SDL_SensorEvent; } SDL_SensorEvent;
/** /**
...@@ -556,56 +624,81 @@ typedef struct SDL_SysWMEvent ...@@ -556,56 +624,81 @@ typedef struct SDL_SysWMEvent
*/ */
typedef union SDL_Event typedef union SDL_Event
{ {
Uint32 type; /**< Event type, shared with all events */ Uint32 type; /**< Event type, shared with all events */
SDL_CommonEvent common; /**< Common event data */ SDL_CommonEvent common; /**< Common event data */
SDL_DisplayEvent display; /**< Window event data */ SDL_DisplayEvent display; /**< Display event data */
SDL_WindowEvent window; /**< Window event data */ SDL_WindowEvent window; /**< Window event data */
SDL_KeyboardEvent key; /**< Keyboard event data */ SDL_KeyboardEvent key; /**< Keyboard event data */
SDL_TextEditingEvent edit; /**< Text editing event data */ SDL_TextEditingEvent edit; /**< Text editing event data */
SDL_TextInputEvent text; /**< Text input event data */ SDL_TextEditingExtEvent editExt; /**< Extended text editing event data */
SDL_MouseMotionEvent motion; /**< Mouse motion event data */ SDL_TextInputEvent text; /**< Text input event data */
SDL_MouseButtonEvent button; /**< Mouse button event data */ SDL_MouseMotionEvent motion; /**< Mouse motion event data */
SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ SDL_MouseButtonEvent button; /**< Mouse button event data */
SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
SDL_JoyBallEvent jball; /**< Joystick ball event data */ SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
SDL_JoyHatEvent jhat; /**< Joystick hat event data */ SDL_JoyBallEvent jball; /**< Joystick ball event data */
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ SDL_JoyHatEvent jhat; /**< Joystick hat event data */
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ SDL_JoyBatteryEvent jbattery; /**< Joystick battery event data */
SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */
SDL_AudioDeviceEvent adevice; /**< Audio device event data */ SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
SDL_SensorEvent sensor; /**< Sensor event data */ SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
SDL_QuitEvent quit; /**< Quit request event data */ SDL_ControllerTouchpadEvent ctouchpad; /**< Game Controller touchpad event data */
SDL_UserEvent user; /**< Custom event data */ SDL_ControllerSensorEvent csensor; /**< Game Controller sensor event data */
SDL_SysWMEvent syswm; /**< System dependent window event data */ SDL_AudioDeviceEvent adevice; /**< Audio device event data */
SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ SDL_SensorEvent sensor; /**< Sensor event data */
SDL_MultiGestureEvent mgesture; /**< Gesture event data */ SDL_QuitEvent quit; /**< Quit request event data */
SDL_DollarGestureEvent dgesture; /**< Gesture event data */ SDL_UserEvent user; /**< Custom event data */
SDL_DropEvent drop; /**< Drag and drop event data */ SDL_SysWMEvent syswm; /**< System dependent window event data */
SDL_TouchFingerEvent tfinger; /**< Touch finger event data */
/* This is necessary for ABI compatibility between Visual C++ and GCC SDL_MultiGestureEvent mgesture; /**< Gesture event data */
Visual C++ will respect the push pack pragma and use 52 bytes for SDL_DollarGestureEvent dgesture; /**< Gesture event data */
this structure, and GCC will use the alignment of the largest datatype SDL_DropEvent drop; /**< Drag and drop event data */
within the union, which is 8 bytes.
/* This is necessary for ABI compatibility between Visual C++ and GCC.
Visual C++ will respect the push pack pragma and use 52 bytes (size of
SDL_TextEditingEvent, the largest structure for 32-bit and 64-bit
architectures) for this union, and GCC will use the alignment of the
largest datatype within the union, which is 8 bytes on 64-bit
architectures.
So... we'll add padding to force the size to be 56 bytes for both. So... we'll add padding to force the size to be 56 bytes for both.
On architectures where pointers are 16 bytes, this needs rounding up to
the next multiple of 16, 64, and on architectures where pointers are
even larger the size of SDL_UserEvent will dominate as being 3 pointers.
*/ */
Uint8 padding[56]; Uint8 padding[sizeof(void *) <= 8 ? 56 : sizeof(void *) == 16 ? 64 : 3 * sizeof(void *)];
} SDL_Event; } SDL_Event;
/* Make sure we haven't broken binary compatibility */ /* Make sure we haven't broken binary compatibility */
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56); SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding));
/* Function prototypes */ /* Function prototypes */
/** /**
* Pumps the event loop, gathering events from the input devices. * Pump the event loop, gathering events from the input devices.
*
* This function updates the event queue and internal input device state.
*
* **WARNING**: This should only be run in the thread that initialized the
* video subsystem, and for extra safety, you should consider only doing those
* things on the main thread in any case.
* *
* This function updates the event queue and internal input device state. * SDL_PumpEvents() gathers all the pending input information from devices and
* places it in the event queue. Without calls to SDL_PumpEvents() no events
* would ever be placed on the queue. Often the need for calls to
* SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and
* SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not
* polling or waiting for events (e.g. you are filtering them), then you must
* call SDL_PumpEvents() to force an event queue update.
* *
* This should only be run in the thread that sets the video mode. * \since This function is available since SDL 2.0.0.
*
* \sa SDL_PollEvent
* \sa SDL_WaitEvent
*/ */
extern DECLSPEC void SDLCALL SDL_PumpEvents(void); extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
...@@ -618,22 +711,42 @@ typedef enum ...@@ -618,22 +711,42 @@ typedef enum
} SDL_eventaction; } SDL_eventaction;
/** /**
* Checks the event queue for messages and optionally returns them. * Check the event queue for messages and optionally return them.
*
* `action` may be any of the following:
* *
* If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to * - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of the
* the back of the event queue. * event queue.
* - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue,
* within the specified minimum and maximum type, will be returned to the
* caller and will _not_ be removed from the queue.
* - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue,
* within the specified minimum and maximum type, will be returned to the
* caller and will be removed from the queue.
* *
* If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front * You may have to call SDL_PumpEvents() before calling this function.
* of the event queue, within the specified minimum and maximum type, * Otherwise, the events may not be ready to be filtered when you call
* will be returned and will not be removed from the queue. * SDL_PeepEvents().
* *
* If \c action is ::SDL_GETEVENT, up to \c numevents events at the front * This function is thread-safe.
* of the event queue, within the specified minimum and maximum type,
* will be returned and will be removed from the queue.
* *
* \return The number of events actually stored, or -1 if there was an error. * \param events destination buffer for the retrieved events
* \param numevents if action is SDL_ADDEVENT, the number of events to add
* back to the event queue; if action is SDL_PEEKEVENT or
* SDL_GETEVENT, the maximum number of events to retrieve
* \param action action to take; see [[#action|Remarks]] for details
* \param minType minimum value of the event type to be considered;
* SDL_FIRSTEVENT is a safe choice
* \param maxType maximum value of the event type to be considered;
* SDL_LASTEVENT is a safe choice
* \returns the number of events actually stored or a negative error code on
* failure; call SDL_GetError() for more information.
* *
* This function is thread-safe. * \since This function is available since SDL 2.0.0.
*
* \sa SDL_PollEvent
* \sa SDL_PumpEvents
* \sa SDL_PushEvent
*/ */
extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
SDL_eventaction action, SDL_eventaction action,
...@@ -641,113 +754,354 @@ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, ...@@ -641,113 +754,354 @@ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
/* @} */ /* @} */
/** /**
* Checks to see if certain event types are in the event queue. * Check for the existence of a certain event type in the event queue.
*
* If you need to check for a range of event types, use SDL_HasEvents()
* instead.
*
* \param type the type of event to be queried; see SDL_EventType for details
* \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if
* events matching `type` are not present.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HasEvents
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type); extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
/**
* Check for the existence of certain event types in the event queue.
*
* If you need to check for a single event type, use SDL_HasEvent() instead.
*
* \param minType the low end of event type to be queried, inclusive; see
* SDL_EventType for details
* \param maxType the high end of event type to be queried, inclusive; see
* SDL_EventType for details
* \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are
* present, or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_HasEvents
*/
extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
/** /**
* This function clears events from the event queue * Clear events of a specific type from the event queue.
* This function only affects currently queued events. If you want to make *
* sure that all pending OS events are flushed, you can call SDL_PumpEvents() * This will unconditionally remove any events from the queue that match
* on the main thread immediately before the flush call. * `type`. If you need to remove a range of event types, use SDL_FlushEvents()
* instead.
*
* It's also normal to just ignore events you don't care about in your event
* loop without calling this function.
*
* This function only affects currently queued events. If you want to make
* sure that all pending OS events are flushed, you can call SDL_PumpEvents()
* on the main thread immediately before the flush call.
*
* \param type the type of event to be cleared; see SDL_EventType for details
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FlushEvents
*/ */
extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
/**
* Clear events of a range of types from the event queue.
*
* This will unconditionally remove any events from the queue that are in the
* range of `minType` to `maxType`, inclusive. If you need to remove a single
* event type, use SDL_FlushEvent() instead.
*
* It's also normal to just ignore events you don't care about in your event
* loop without calling this function.
*
* This function only affects currently queued events. If you want to make
* sure that all pending OS events are flushed, you can call SDL_PumpEvents()
* on the main thread immediately before the flush call.
*
* \param minType the low end of event type to be cleared, inclusive; see
* SDL_EventType for details
* \param maxType the high end of event type to be cleared, inclusive; see
* SDL_EventType for details
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_FlushEvent
*/
extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
/** /**
* \brief Polls for currently pending events. * Poll for currently pending events.
*
* If `event` is not NULL, the next event is removed from the queue and stored
* in the SDL_Event structure pointed to by `event`. The 1 returned refers to
* this event, immediately stored in the SDL Event structure -- not an event
* to follow.
*
* If `event` is NULL, it simply returns 1 if there is an event in the queue,
* but will not remove it from the queue.
*
* As this function may implicitly call SDL_PumpEvents(), you can only call
* this function in the thread that set the video mode.
*
* SDL_PollEvent() is the favored way of receiving system events since it can
* be done from the main loop and does not suspend the main loop while waiting
* on an event to be posted.
*
* The common practice is to fully process the event queue once every frame,
* usually as a first step before updating the game's state:
*
* ```c
* while (game_is_still_running) {
* SDL_Event event;
* while (SDL_PollEvent(&event)) { // poll until all events are handled!
* // decide what to do with this event.
* }
*
* // update game state, draw the current frame
* }
* ```
* *
* \return 1 if there are any pending events, or 0 if there are none available. * \param event the SDL_Event structure to be filled with the next event from
* the queue, or NULL
* \returns 1 if there is a pending event or 0 if there are none available.
* *
* \param event If not NULL, the next event is removed from the queue and * \since This function is available since SDL 2.0.0.
* stored in that area. *
* \sa SDL_GetEventFilter
* \sa SDL_PeepEvents
* \sa SDL_PushEvent
* \sa SDL_SetEventFilter
* \sa SDL_WaitEvent
* \sa SDL_WaitEventTimeout
*/ */
extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event); extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
/** /**
* \brief Waits indefinitely for the next available event. * Wait indefinitely for the next available event.
*
* If `event` is not NULL, the next event is removed from the queue and stored
* in the SDL_Event structure pointed to by `event`.
*
* As this function may implicitly call SDL_PumpEvents(), you can only call
* this function in the thread that initialized the video subsystem.
*
* \param event the SDL_Event structure to be filled in with the next event
* from the queue, or NULL
* \returns 1 on success or 0 if there was an error while waiting for events;
* call SDL_GetError() for more information.
* *
* \return 1, or 0 if there was an error while waiting for events. * \since This function is available since SDL 2.0.0.
* *
* \param event If not NULL, the next event is removed from the queue and * \sa SDL_PollEvent
* stored in that area. * \sa SDL_PumpEvents
* \sa SDL_WaitEventTimeout
*/ */
extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event); extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
/** /**
* \brief Waits until the specified timeout (in milliseconds) for the next * Wait until the specified timeout (in milliseconds) for the next available
* available event. * event.
*
* If `event` is not NULL, the next event is removed from the queue and stored
* in the SDL_Event structure pointed to by `event`.
*
* As this function may implicitly call SDL_PumpEvents(), you can only call
* this function in the thread that initialized the video subsystem.
*
* \param event the SDL_Event structure to be filled in with the next event
* from the queue, or NULL
* \param timeout the maximum number of milliseconds to wait for the next
* available event
* \returns 1 on success or 0 if there was an error while waiting for events;
* call SDL_GetError() for more information. This also returns 0 if
* the timeout elapsed without an event arriving.
* *
* \return 1, or 0 if there was an error while waiting for events. * \since This function is available since SDL 2.0.0.
* *
* \param event If not NULL, the next event is removed from the queue and * \sa SDL_PollEvent
* stored in that area. * \sa SDL_PumpEvents
* \param timeout The timeout (in milliseconds) to wait for next event. * \sa SDL_WaitEvent
*/ */
extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event, extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
int timeout); int timeout);
/** /**
* \brief Add an event to the event queue. * Add an event to the event queue.
* *
* \return 1 on success, 0 if the event was filtered, or -1 if the event queue * The event queue can actually be used as a two way communication channel.
* was full or there was some other error. * Not only can events be read from the queue, but the user can also push
* their own events onto it. `event` is a pointer to the event structure you
* wish to push onto the queue. The event is copied into the queue, and the
* caller may dispose of the memory pointed to after SDL_PushEvent() returns.
*
* Note: Pushing device input events onto the queue doesn't modify the state
* of the device within SDL.
*
* This function is thread-safe, and can be called from other threads safely.
*
* Note: Events pushed onto the queue with SDL_PushEvent() get passed through
* the event filter but events added with SDL_PeepEvents() do not.
*
* For pushing application-specific events, please use SDL_RegisterEvents() to
* get an event type that does not conflict with other code that also wants
* its own custom event types.
*
* \param event the SDL_Event to be added to the queue
* \returns 1 on success, 0 if the event was filtered, or a negative error
* code on failure; call SDL_GetError() for more information. A
* common reason for error is the event queue being full.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_PeepEvents
* \sa SDL_PollEvent
* \sa SDL_RegisterEvents
*/ */
extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event); extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
/**
* A function pointer used for callbacks that watch the event queue.
*
* \param userdata what was passed as `userdata` to SDL_SetEventFilter()
* or SDL_AddEventWatch, etc
* \param event the event that triggered the callback
* \returns 1 to permit event to be added to the queue, and 0 to disallow
* it. When used with SDL_AddEventWatch, the return value is ignored.
*
* \sa SDL_SetEventFilter
* \sa SDL_AddEventWatch
*/
typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event); typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
/** /**
* Sets up a filter to process all events before they change internal state and * Set up a filter to process all events before they change internal state and
* are posted to the internal event queue. * are posted to the internal event queue.
*
* If the filter function returns 1 when called, then the event will be added
* to the internal queue. If it returns 0, then the event will be dropped from
* the queue, but the internal state will still be updated. This allows
* selective filtering of dynamically arriving events.
*
* **WARNING**: Be very careful of what you do in the event filter function,
* as it may run in a different thread!
*
* On platforms that support it, if the quit event is generated by an
* interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
* application at the next event poll.
*
* There is one caveat when dealing with the ::SDL_QuitEvent event type. The
* event filter is only called when the window manager desires to close the
* application window. If the event filter returns 1, then the window will be
* closed, otherwise the window will remain open if possible.
* *
* The filter is prototyped as: * Note: Disabled events never make it to the event filter function; see
* \code * SDL_EventState().
* int SDL_EventFilter(void *userdata, SDL_Event * event);
* \endcode
* *
* If the filter returns 1, then the event will be added to the internal queue. * Note: If you just want to inspect events without filtering, you should use
* If it returns 0, then the event will be dropped from the queue, but the * SDL_AddEventWatch() instead.
* internal state will still be updated. This allows selective filtering of
* dynamically arriving events.
* *
* \warning Be very careful of what you do in the event filter function, as * Note: Events pushed onto the queue with SDL_PushEvent() get passed through
* it may run in a different thread! * the event filter, but events pushed onto the queue with SDL_PeepEvents() do
* not.
* *
* There is one caveat when dealing with the ::SDL_QuitEvent event type. The * \param filter An SDL_EventFilter function to call when an event happens
* event filter is only called when the window manager desires to close the * \param userdata a pointer that is passed to `filter`
* application window. If the event filter returns 1, then the window will
* be closed, otherwise the window will remain open if possible.
* *
* If the quit event is generated by an interrupt signal, it will bypass the * \since This function is available since SDL 2.0.0.
* internal queue and be delivered to the application at the next event poll. *
* \sa SDL_AddEventWatch
* \sa SDL_EventState
* \sa SDL_GetEventFilter
* \sa SDL_PeepEvents
* \sa SDL_PushEvent
*/ */
extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
void *userdata); void *userdata);
/** /**
* Return the current event filter - can be used to "chain" filters. * Query the current event filter.
* If there is no event filter set, this function returns SDL_FALSE. *
* This function can be used to "chain" filters, by saving the existing filter
* before replacing it with a function that will call that saved filter.
*
* \param filter the current callback function will be stored here
* \param userdata the pointer that is passed to the current event filter will
* be stored here
* \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_SetEventFilter
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter, extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
void **userdata); void **userdata);
/** /**
* Add a function which is called when an event is added to the queue. * Add a callback to be triggered when an event is added to the event queue.
*
* `filter` will be called when an event happens, and its return value is
* ignored.
*
* **WARNING**: Be very careful of what you do in the event filter function,
* as it may run in a different thread!
*
* If the quit event is generated by a signal (e.g. SIGINT), it will bypass
* the internal queue and be delivered to the watch callback immediately, and
* arrive at the next event poll.
*
* Note: the callback is called for events posted by the user through
* SDL_PushEvent(), but not for disabled events, nor for events by a filter
* callback set with SDL_SetEventFilter(), nor for events posted by the user
* through SDL_PeepEvents().
*
* \param filter an SDL_EventFilter function to call when an event happens.
* \param userdata a pointer that is passed to `filter`
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_DelEventWatch
* \sa SDL_SetEventFilter
*/ */
extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
void *userdata); void *userdata);
/** /**
* Remove an event watch function added with SDL_AddEventWatch() * Remove an event watch callback added with SDL_AddEventWatch().
*
* This function takes the same input as SDL_AddEventWatch() to identify and
* delete the corresponding callback.
*
* \param filter the function originally passed to SDL_AddEventWatch()
* \param userdata the pointer originally passed to SDL_AddEventWatch()
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_AddEventWatch
*/ */
extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
void *userdata); void *userdata);
/** /**
* Run the filter function on the current event queue, removing any * Run a specific filter function on the current event queue, removing any
* events for which the filter returns 0. * events for which the filter returns 0.
*
* See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(),
* this function does not change the filter permanently, it only uses the
* supplied filter until this function returns.
*
* \param filter the SDL_EventFilter function to call when an event happens
* \param userdata a pointer that is passed to `filter`
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetEventFilter
* \sa SDL_SetEventFilter
*/ */
extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
void *userdata); void *userdata);
...@@ -759,24 +1113,45 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, ...@@ -759,24 +1113,45 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
#define SDL_ENABLE 1 #define SDL_ENABLE 1
/** /**
* This function allows you to set the state of processing certain events. * Set the state of processing events by type.
* - If \c state is set to ::SDL_IGNORE, that event will be automatically *
* dropped from the event queue and will not be filtered. * `state` may be any of the following:
* - If \c state is set to ::SDL_ENABLE, that event will be processed *
* normally. * - `SDL_QUERY`: returns the current processing state of the specified event
* - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the * - `SDL_IGNORE` (aka `SDL_DISABLE`): the event will automatically be dropped
* current processing state of the specified event. * from the event queue and will not be filtered
* - `SDL_ENABLE`: the event will be processed normally
*
* \param type the type of event; see SDL_EventType for details
* \param state how to process the event
* \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
* of the event before this function makes any changes to it.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetEventState
*/ */
extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
/* @} */ /* @} */
#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
/** /**
* This function allocates a set of user-defined events, and returns * Allocate a set of user-defined events, and return the beginning event
* the beginning event number for that set of events. * number for that set of events.
*
* Calling this function with `numevents` <= 0 is an error and will return
* (Uint32)-1.
*
* Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or
* 0xFFFFFFFF), but is clearer to write.
*
* \param numevents the number of events to be allocated
* \returns the beginning event number, or (Uint32)-1 if there are not enough
* user-defined events left.
*
* \since This function is available since SDL 2.0.0.
* *
* If there aren't enough user-defined events left, this function * \sa SDL_PushEvent
* returns (Uint32)-1
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -38,88 +38,101 @@ extern "C" { ...@@ -38,88 +38,101 @@ extern "C" {
#endif #endif
/** /**
* \brief Get the path where the application resides. * Get the directory where the application was run from.
* *
* Get the "base path". This is the directory where the application was run * This is not necessarily a fast call, so you should call this once near
* from, which is probably the installation directory, and may or may not * startup and save the string if you need it.
* be the process's current working directory.
* *
* This returns an absolute path in UTF-8 encoding, and is guaranteed to * **Mac OS X and iOS Specific Functionality**: If the application is in a
* end with a path separator ('\\' on Windows, '/' most other places). * ".app" bundle, this function returns the Resource directory (e.g.
* MyApp.app/Contents/Resources/). This behaviour can be overridden by adding
* a property to the Info.plist file. Adding a string key with the name
* SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the
* behaviour.
* *
* The pointer returned by this function is owned by you. Please call * Supported values for the SDL_FILESYSTEM_BASE_DIR_TYPE property (Given an
* SDL_free() on the pointer when you are done with it, or it will be a * application in /Applications/SDLApp/MyApp.app):
* memory leak. This is not necessarily a fast call, though, so you should
* call this once near startup and save the string if you need it.
* *
* Some platforms can't determine the application's path, and on other * - `resource`: bundle resource directory (the default). For example:
* platforms, this might be meaningless. In such cases, this function will * `/Applications/SDLApp/MyApp.app/Contents/Resources`
* return NULL. * - `bundle`: the Bundle directory. For example:
* `/Applications/SDLApp/MyApp.app/`
* - `parent`: the containing directory of the bundle. For example:
* `/Applications/SDLApp/`
* *
* \return String of base dir in UTF-8 encoding, or NULL on error. * **Nintendo 3DS Specific Functionality**: This function returns "romfs"
* directory of the application as it is uncommon to store resources outside
* the executable. As such it is not a writable directory.
*
* The returned path is guaranteed to end with a path separator ('\' on
* Windows, '/' on most other platforms).
*
* The pointer returned is owned by the caller. Please call SDL_free() on the
* pointer when done with it.
*
* \returns an absolute path in UTF-8 encoding to the application data
* directory. NULL will be returned on error or when the platform
* doesn't implement this functionality, call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 2.0.1.
* *
* \sa SDL_GetPrefPath * \sa SDL_GetPrefPath
*/ */
extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); extern DECLSPEC char *SDLCALL SDL_GetBasePath(void);
/** /**
* \brief Get the user-and-app-specific path where files can be written. * Get the user-and-app-specific path where files can be written.
* *
* Get the "pref dir". This is meant to be where users can write personal * Get the "pref dir". This is meant to be where users can write personal
* files (preferences and save games, etc) that are specific to your * files (preferences and save games, etc) that are specific to your
* application. This directory is unique per user, per application. * application. This directory is unique per user, per application.
* *
* This function will decide the appropriate location in the native filesystem, * This function will decide the appropriate location in the native
* create the directory if necessary, and return a string of the absolute * filesystem, create the directory if necessary, and return a string of the
* path to the directory in UTF-8 encoding. * absolute path to the directory in UTF-8 encoding.
* *
* On Windows, the string might look like: * On Windows, the string might look like:
* "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" *
* `C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\`
* *
* On Linux, the string might look like: * On Linux, the string might look like:
* "/home/bob/.local/share/My Program Name/" *
* `/home/bob/.local/share/My Program Name/`
* *
* On Mac OS X, the string might look like: * On Mac OS X, the string might look like:
* "/Users/bob/Library/Application Support/My Program Name/" *
* * `/Users/bob/Library/Application Support/My Program Name/`
* (etc.) *
* * You should assume the path returned by this function is the only safe place
* You specify the name of your organization (if it's not a real organization, * to write files (and that SDL_GetBasePath(), while it might be writable, or
* your name or an Internet domain you own might do) and the name of your * even the parent of the returned path, isn't where you should be writing
* application. These should be untranslated proper names. * things).
* *
* Both the org and app strings may become part of a directory name, so * Both the org and app strings may become part of a directory name, so please
* please follow these rules: * follow these rules:
* *
* - Try to use the same org string (including case-sensitivity) for * - Try to use the same org string (_including case-sensitivity_) for all
* all your applications that use this function. * your applications that use this function.
* - Always use a unique app string for each one, and make sure it never * - Always use a unique app string for each one, and make sure it never
* changes for an app once you've decided on it. * changes for an app once you've decided on it.
* - Unicode characters are legal, as long as it's UTF-8 encoded, but... * - Unicode characters are legal, as long as it's UTF-8 encoded, but...
* - ...only use letters, numbers, and spaces. Avoid punctuation like * - ...only use letters, numbers, and spaces. Avoid punctuation like "Game
* "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. * Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
* *
* This returns an absolute path in UTF-8 encoding, and is guaranteed to * The returned path is guaranteed to end with a path separator ('\' on
* end with a path separator ('\\' on Windows, '/' most other places). * Windows, '/' on most other platforms).
* *
* The pointer returned by this function is owned by you. Please call * The pointer returned is owned by the caller. Please call SDL_free() on the
* SDL_free() on the pointer when you are done with it, or it will be a * pointer when done with it.
* memory leak. This is not necessarily a fast call, though, so you should *
* call this once near startup and save the string if you need it. * \param org the name of your organization
* * \param app the name of your application
* You should assume the path returned by this function is the only safe * \returns a UTF-8 string of the user directory in platform-dependent
* place to write files (and that SDL_GetBasePath(), while it might be * notation. NULL if there's a problem (creating directory failed,
* writable, or even the parent of the returned path, aren't where you * etc.).
* should be writing things). *
* * \since This function is available since SDL 2.0.1.
* Some platforms can't determine the pref path, and on other
* platforms, this might be meaningless. In such cases, this function will
* return NULL.
*
* \param org The name of your organization.
* \param app The name of your application.
* \return UTF-8 string of user dir in platform-dependent notation. NULL
* if there's a problem (creating directory failed, etc).
* *
* \sa SDL_GetBasePath * \sa SDL_GetBasePath
*/ */
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_rwops.h" #include "SDL_rwops.h"
#include "SDL_sensor.h"
#include "SDL_joystick.h" #include "SDL_joystick.h"
#include "begin_code.h" #include "begin_code.h"
...@@ -57,6 +58,23 @@ extern "C" { ...@@ -57,6 +58,23 @@ extern "C" {
struct _SDL_GameController; struct _SDL_GameController;
typedef struct _SDL_GameController SDL_GameController; typedef struct _SDL_GameController SDL_GameController;
typedef enum
{
SDL_CONTROLLER_TYPE_UNKNOWN = 0,
SDL_CONTROLLER_TYPE_XBOX360,
SDL_CONTROLLER_TYPE_XBOXONE,
SDL_CONTROLLER_TYPE_PS3,
SDL_CONTROLLER_TYPE_PS4,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO,
SDL_CONTROLLER_TYPE_VIRTUAL,
SDL_CONTROLLER_TYPE_PS5,
SDL_CONTROLLER_TYPE_AMAZON_LUNA,
SDL_CONTROLLER_TYPE_GOOGLE_STADIA,
SDL_CONTROLLER_TYPE_NVIDIA_SHIELD,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
} SDL_GameControllerType;
typedef enum typedef enum
{ {
...@@ -87,6 +105,8 @@ typedef struct SDL_GameControllerButtonBind ...@@ -87,6 +105,8 @@ typedef struct SDL_GameControllerButtonBind
/** /**
* To count the number of game controllers in the system for the following: * To count the number of game controllers in the system for the following:
*
* ```c
* int nJoysticks = SDL_NumJoysticks(); * int nJoysticks = SDL_NumJoysticks();
* int nGameControllers = 0; * int nGameControllers = 0;
* for (int i = 0; i < nJoysticks; i++) { * for (int i = 0; i < nJoysticks; i++) {
...@@ -94,6 +114,7 @@ typedef struct SDL_GameControllerButtonBind ...@@ -94,6 +114,7 @@ typedef struct SDL_GameControllerButtonBind
* nGameControllers++; * nGameControllers++;
* } * }
* } * }
* ```
* *
* Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is:
* guid,name,mappings * guid,name,mappings
...@@ -107,17 +128,39 @@ typedef struct SDL_GameControllerButtonBind ...@@ -107,17 +128,39 @@ typedef struct SDL_GameControllerButtonBind
* Buttons can be used as a controller axis and vice versa. * Buttons can be used as a controller axis and vice versa.
* *
* This string shows an example of a valid mapping for a controller * This string shows an example of a valid mapping for a controller
* "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
* *
* ```c
* "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
* ```
*/ */
/** /**
* Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform() * Load a set of Game Controller mappings from a seekable SDL data stream.
* A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt *
* You can call this function several times, if needed, to load different
* database files.
*
* If a new mapping is loaded for an already known controller GUID, the later
* version will overwrite the one currently loaded.
*
* Mappings not belonging to the current platform or with no platform field
* specified will be ignored (i.e. mappings for Linux will be ignored in
* Windows, etc).
*
* This function will load the text database entirely in memory before
* processing it, so take this into consideration if you are in a memory
* constrained environment.
*
* \param rw the data stream for the mappings to be added
* \param freerw non-zero to close the stream after being read
* \returns the number of mappings added or -1 on error; call SDL_GetError()
* for more information.
* *
* If \c freerw is non-zero, the stream will be closed after being read. * \since This function is available since SDL 2.0.2.
* *
* \return number of mappings added, -1 on error * \sa SDL_GameControllerAddMapping
* \sa SDL_GameControllerAddMappingsFromFile
* \sa SDL_GameControllerMappingForGUID
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw); extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
...@@ -129,133 +172,421 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, ...@@ -129,133 +172,421 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) #define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
/** /**
* Add or update an existing mapping configuration * Add support for controllers that SDL is unaware of or to cause an existing
* controller to have a different binding.
*
* The mapping string has the format "GUID,name,mapping", where GUID is the
* string value from SDL_JoystickGetGUIDString(), name is the human readable
* string for the device and mappings are controller mappings to joystick
* ones. Under Windows there is a reserved GUID of "xinput" that covers all
* XInput devices. The mapping format for joystick is: {| |bX |a joystick
* button, index X |- |hX.Y |hat X with value Y |- |aX |axis X of the joystick
* |} Buttons can be used as a controller axes and vice versa.
*
* This string shows an example of a valid mapping for a controller:
*
* ```c
* "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"
* ```
* *
* \return 1 if mapping is added, 0 if updated, -1 on error * \param mappingString the mapping string
* \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
* -1 on error; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerMapping
* \sa SDL_GameControllerMappingForGUID
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString); extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
/** /**
* Get the number of mappings installed * Get the number of mappings installed.
* *
* \return the number of mappings * \returns the number of mappings.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void); extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void);
/** /**
* Get the mapping at a particular index. * Get the mapping at a particular index.
*
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
* the index is out of range.
* *
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if the index is out of range. * \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index); extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index);
/** /**
* Get a mapping string for a GUID * Get the game controller mapping string for a given GUID.
* *
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available * The returned string must be freed with SDL_free().
*
* \param guid a structure containing the GUID for which a mapping is desired
* \returns a mapping string or NULL on error; call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickGetDeviceGUID
* \sa SDL_JoystickGetGUID
*/ */
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid); extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid);
/** /**
* Get a mapping string for an open GameController * Get the current mapping of a Game Controller.
*
* The returned string must be freed with SDL_free().
* *
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available * Details about mappings are discussed with SDL_GameControllerAddMapping().
*
* \param gamecontroller the game controller you want to get the current
* mapping for
* \returns a string that has the controller's mapping or NULL if no mapping
* is available; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerAddMapping
* \sa SDL_GameControllerMappingForGUID
*/ */
extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController * gamecontroller); extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller);
/** /**
* Is the joystick on this index supported by the game controller interface? * Check if the given joystick is supported by the game controller interface.
*
* `joystick_index` is the same as the `device_index` passed to
* SDL_JoystickOpen().
*
* \param joystick_index the device_index of a device, up to
* SDL_NumJoysticks()
* \returns SDL_TRUE if the given joystick is supported by the game controller
* interface, SDL_FALSE if it isn't or it's an invalid index.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerNameForIndex
* \sa SDL_GameControllerOpen
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index); extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
/** /**
* Get the implementation dependent name of a game controller. * Get the implementation dependent name for the game controller.
* This can be called before any controllers are opened. *
* If no name can be found, this function returns NULL. * This function can be called before any controllers are opened.
*
* `joystick_index` is the same as the `device_index` passed to
* SDL_JoystickOpen().
*
* \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1
* \returns the implementation-dependent name for the game controller, or NULL
* if there is no name or the index is invalid.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerName
* \sa SDL_GameControllerOpen
* \sa SDL_IsGameController
*/ */
extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
/** /**
* Get the mapping of a game controller. * Get the implementation dependent path for the game controller.
* This can be called before any controllers are opened.
* *
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available * This function can be called before any controllers are opened.
*
* `joystick_index` is the same as the `device_index` passed to
* SDL_JoystickOpen().
*
* \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1
* \returns the implementation-dependent path for the game controller, or NULL
* if there is no path or the index is invalid.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GameControllerPath
*/
extern DECLSPEC const char *SDLCALL SDL_GameControllerPathForIndex(int joystick_index);
/**
* Get the type of a game controller.
*
* This can be called before any controllers are opened.
*
* \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1
* \returns the controller type.
*
* \since This function is available since SDL 2.0.12.
*/
extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index);
/**
* Get the mapping of a game controller.
*
* This can be called before any controllers are opened.
*
* \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
* no mapping is available.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index); extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index);
/** /**
* Open a game controller for use. * Open a game controller for use.
* The index passed as an argument refers to the N'th game controller on the system.
* This index is not the value which will identify this controller in future
* controller events. The joystick's instance id (::SDL_JoystickID) will be
* used there instead.
* *
* \return A controller identifier, or NULL if an error occurred. * `joystick_index` is the same as the `device_index` passed to
* SDL_JoystickOpen().
*
* The index passed as an argument refers to the N'th game controller on the
* system. This index is not the value which will identify this controller in
* future controller events. The joystick's instance id (SDL_JoystickID) will
* be used there instead.
*
* \param joystick_index the device_index of a device, up to
* SDL_NumJoysticks()
* \returns a gamecontroller identifier or NULL if an error occurred; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerClose
* \sa SDL_GameControllerNameForIndex
* \sa SDL_IsGameController
*/ */
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
/** /**
* Return the SDL_GameController associated with an instance id. * Get the SDL_GameController associated with an instance id.
*
* \param joyid the instance id to get the SDL_GameController for
* \returns an SDL_GameController on success or NULL on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.4.
*/ */
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid); extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid);
/** /**
* Return the name for this currently opened controller * Get the SDL_GameController associated with a player index.
*
* Please note that the player index is _not_ the device index, nor is it the
* instance id!
*
* \param player_index the player index, which is not the device index or the
* instance id!
* \returns the SDL_GameController associated with a player index.
*
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_GameControllerGetPlayerIndex
* \sa SDL_GameControllerSetPlayerIndex
*/
extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index);
/**
* Get the implementation-dependent name for an opened game controller.
*
* This is the same name as returned by SDL_GameControllerNameForIndex(), but
* it takes a controller identifier instead of the (unstable) device index.
*
* \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen()
* \returns the implementation dependent name for the game controller, or NULL
* if there is no name or the identifier passed is invalid.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerNameForIndex
* \sa SDL_GameControllerOpen
*/ */
extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
/** /**
* Get the player index of an opened game controller, or -1 if it's not available * Get the implementation-dependent path for an opened game controller.
*
* This is the same path as returned by SDL_GameControllerNameForIndex(), but
* it takes a controller identifier instead of the (unstable) device index.
*
* \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen()
* \returns the implementation dependent path for the game controller, or NULL
* if there is no path or the identifier passed is invalid.
*
* \since This function is available since SDL 2.24.0.
*
* \sa SDL_GameControllerPathForIndex
*/
extern DECLSPEC const char *SDLCALL SDL_GameControllerPath(SDL_GameController *gamecontroller);
/**
* Get the type of this currently opened controller
*
* This is the same name as returned by SDL_GameControllerTypeForIndex(), but
* it takes a controller identifier instead of the (unstable) device index.
*
* \param gamecontroller the game controller object to query.
* \returns the controller type.
*
* \since This function is available since SDL 2.0.12.
*/
extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller);
/**
* Get the player index of an opened game controller.
*
* For XInput controllers this returns the XInput user index.
* *
* For XInput controllers this returns the XInput user index. * \param gamecontroller the game controller object to query.
* \returns the player index for controller, or -1 if it's not available.
*
* \since This function is available since SDL 2.0.9.
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller); extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller);
/** /**
* Get the USB vendor ID of an opened controller, if available. * Set the player index of an opened game controller.
* If the vendor ID isn't available this function returns 0. *
* \param gamecontroller the game controller object to adjust.
* \param player_index Player index to assign to this controller, or -1 to
* clear the player index and turn off player LEDs.
*
* \since This function is available since SDL 2.0.12.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller); extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index);
/** /**
* Get the USB product ID of an opened controller, if available. * Get the USB vendor ID of an opened controller, if available.
* If the product ID isn't available this function returns 0. *
* If the vendor ID isn't available this function returns 0.
*
* \param gamecontroller the game controller object to query.
* \return the USB vendor ID, or zero if unavailable.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller); extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller);
/** /**
* Get the product version of an opened controller, if available. * Get the USB product ID of an opened controller, if available.
* If the product version isn't available this function returns 0. *
* If the product ID isn't available this function returns 0.
*
* \param gamecontroller the game controller object to query.
* \return the USB product ID, or zero if unavailable.
*
* \since This function is available since SDL 2.0.6.
*/ */
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller); extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller);
/** /**
* Returns SDL_TRUE if the controller has been opened and currently connected, * Get the product version of an opened controller, if available.
* or SDL_FALSE if it has not. *
* If the product version isn't available this function returns 0.
*
* \param gamecontroller the game controller object to query.
* \return the USB product version, or zero if unavailable.
*
* \since This function is available since SDL 2.0.6.
*/
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller);
/**
* Get the firmware version of an opened controller, if available.
*
* If the firmware version isn't available this function returns 0.
*
* \param gamecontroller the game controller object to query.
* \return the controller firmware version, or zero if unavailable.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetFirmwareVersion(SDL_GameController *gamecontroller);
/**
* Get the serial number of an opened controller, if available.
*
* Returns the serial number of the controller, or NULL if it is not
* available.
*
* \param gamecontroller the game controller object to query.
* \return the serial number, or NULL if unavailable.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
/**
* Check if a controller has been opened and is currently connected.
*
* \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen()
* \returns SDL_TRUE if the controller has been opened and is currently
* connected, or SDL_FALSE if not.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerClose
* \sa SDL_GameControllerOpen
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
/** /**
* Get the underlying joystick object used by a controller * Get the Joystick ID from a Game Controller.
*
* This function will give you a SDL_Joystick object, which allows you to use
* the SDL_Joystick functions with a SDL_GameController object. This would be
* useful for getting a joystick's position at any given time, even if it
* hasn't moved (moving it would produce an event, which would have the axis'
* value).
*
* The pointer returned is owned by the SDL_GameController. You should not
* call SDL_JoystickClose() on it, for example, since doing so will likely
* cause SDL to crash.
*
* \param gamecontroller the game controller object that you want to get a
* joystick from
* \returns a SDL_Joystick object; call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
/** /**
* Enable/disable controller event polling. * Query or change current state of Game Controller events.
*
* If controller events are disabled, you must call SDL_GameControllerUpdate()
* yourself and check the state of the controller when you want controller
* information.
*
* Any number can be passed to SDL_GameControllerEventState(), but only -1, 0,
* and 1 will have any effect. Other numbers will just be returned.
* *
* If controller events are disabled, you must call SDL_GameControllerUpdate() * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
* yourself and check the state of the controller when you want controller * \returns the same value passed to the function, with exception to -1
* information. * (SDL_QUERY), which will return the current state.
* *
* The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. * \since This function is available since SDL 2.0.0.
*
* \sa SDL_JoystickEventState
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
/** /**
* Update the current state of the open game controllers. * Manually pump game controller updates if not using the loop.
*
* This function is called automatically by the event loop if events are
* enabled. Under such circumstances, it will not be necessary to call this
* function.
* *
* This is called automatically by the event loop if any game controller * \since This function is available since SDL 2.0.0.
* events are enabled.
*/ */
extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
...@@ -282,33 +613,94 @@ typedef enum ...@@ -282,33 +613,94 @@ typedef enum
} SDL_GameControllerAxis; } SDL_GameControllerAxis;
/** /**
* turn this string into a axis mapping * Convert a string into SDL_GameControllerAxis enum.
*
* This function is called internally to translate SDL_GameController mapping
* strings for the underlying joystick device into the consistent
* SDL_GameController mapping. You do not normally need to call this function
* unless you are parsing SDL_GameController mappings in your own code.
*
* Note specially that "righttrigger" and "lefttrigger" map to
* `SDL_CONTROLLER_AXIS_TRIGGERRIGHT` and `SDL_CONTROLLER_AXIS_TRIGGERLEFT`,
* respectively.
*
* \param str string representing a SDL_GameController axis
* \returns the SDL_GameControllerAxis enum corresponding to the input string,
* or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerGetStringForAxis
*/ */
extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString); extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *str);
/** /**
* turn this axis enum into a string mapping * Convert from an SDL_GameControllerAxis enum to a string.
*
* The caller should not SDL_free() the returned string.
*
* \param axis an enum value for a given SDL_GameControllerAxis
* \returns a string for the given axis, or NULL if an invalid axis is
* specified. The string returned is of the format used by
* SDL_GameController mapping strings.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerGetAxisFromString
*/ */
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis); extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
/** /**
* Get the SDL joystick layer binding for this controller button mapping * Get the SDL joystick layer binding for a controller axis mapping.
*
* \param gamecontroller a game controller
* \param axis an axis enum value (one of the SDL_GameControllerAxis values)
* \returns a SDL_GameControllerButtonBind describing the bind. On failure
* (like the given Controller axis doesn't exist on the device), its
* `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerGetBindForButton
*/ */
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
SDL_GameControllerAxis axis); SDL_GameControllerAxis axis);
/** /**
* Get the current state of an axis control on a game controller. * Query whether a game controller has a given axis.
*
* This merely reports whether the controller's mapping defined this axis, as
* that is all the information SDL has about the physical device.
*
* \param gamecontroller a game controller
* \param axis an axis enum value (an SDL_GameControllerAxis value)
* \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC SDL_bool SDLCALL
SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
/**
* Get the current state of an axis control on a game controller.
*
* The axis indices start at index 0.
*
* The state is a value ranging from -32768 to 32767. Triggers, however, range
* from 0 to 32767 (they never return a negative value).
*
* \param gamecontroller a game controller
* \param axis an axis index (one of the SDL_GameControllerAxis values)
* \returns axis state (including 0) on success or 0 (also) on failure; call
* SDL_GetError() for more information.
* *
* The state is a value ranging from -32768 to 32767 (except for the triggers, * \since This function is available since SDL 2.0.0.
* which range from 0 to 32767).
* *
* The axis indices start at index 0. * \sa SDL_GameControllerGetButton
*/ */
extern DECLSPEC Sint16 SDLCALL extern DECLSPEC Sint16 SDLCALL
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
SDL_GameControllerAxis axis);
/** /**
* The list of buttons available from a controller * The list of buttons available from a controller
...@@ -331,53 +723,345 @@ typedef enum ...@@ -331,53 +723,345 @@ typedef enum
SDL_CONTROLLER_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN,
SDL_CONTROLLER_BUTTON_DPAD_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT,
SDL_CONTROLLER_BUTTON_DPAD_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 (upper left, facing the back) */
SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 (upper right, facing the back) */
SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 (lower left, facing the back) */
SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 (lower right, facing the back) */
SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
SDL_CONTROLLER_BUTTON_MAX SDL_CONTROLLER_BUTTON_MAX
} SDL_GameControllerButton; } SDL_GameControllerButton;
/** /**
* turn this string into a button mapping * Convert a string into an SDL_GameControllerButton enum.
*
* This function is called internally to translate SDL_GameController mapping
* strings for the underlying joystick device into the consistent
* SDL_GameController mapping. You do not normally need to call this function
* unless you are parsing SDL_GameController mappings in your own code.
*
* \param str string representing a SDL_GameController axis
* \returns the SDL_GameControllerButton enum corresponding to the input
* string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
*
* \since This function is available since SDL 2.0.0.
*/ */
extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString); extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *str);
/** /**
* turn this button enum into a string mapping * Convert from an SDL_GameControllerButton enum to a string.
*
* The caller should not SDL_free() the returned string.
*
* \param button an enum value for a given SDL_GameControllerButton
* \returns a string for the given button, or NULL if an invalid button is
* specified. The string returned is of the format used by
* SDL_GameController mapping strings.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerGetButtonFromString
*/ */
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button); extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
/** /**
* Get the SDL joystick layer binding for this controller button mapping * Get the SDL joystick layer binding for a controller button mapping.
*
* \param gamecontroller a game controller
* \param button an button enum value (an SDL_GameControllerButton value)
* \returns a SDL_GameControllerButtonBind describing the bind. On failure
* (like the given Controller button doesn't exist on the device),
* its `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerGetBindForAxis
*/ */
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
SDL_GameControllerButton button); SDL_GameControllerButton button);
/**
* Query whether a game controller has a given button.
*
* This merely reports whether the controller's mapping defined this button,
* as that is all the information SDL has about the physical device.
*
* \param gamecontroller a game controller
* \param button a button enum value (an SDL_GameControllerButton value)
* \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller,
SDL_GameControllerButton button);
/** /**
* Get the current state of a button on a game controller. * Get the current state of a button on a game controller.
*
* \param gamecontroller a game controller
* \param button a button index (one of the SDL_GameControllerButton values)
* \returns 1 for pressed state or 0 for not pressed state or error; call
* SDL_GetError() for more information.
* *
* The button indices start at index 0. * \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerGetAxis
*/ */
extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
SDL_GameControllerButton button); SDL_GameControllerButton button);
/** /**
* Trigger a rumble effect * Get the number of touchpads on a game controller.
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
* *
* \param gamecontroller The controller to vibrate * \since This function is available since SDL 2.0.14.
* \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF */
* \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller);
* \param duration_ms The duration of the rumble effect, in milliseconds
/**
* Get the number of supported simultaneous fingers on a touchpad on a game
* controller.
* *
* \return 0, or -1 if rumble isn't supported on this joystick * \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad);
/**
* Get the current state of a finger on a touchpad on a game controller.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
/**
* Return whether a game controller has a particular sensor.
*
* \param gamecontroller The controller to query
* \param type The type of sensor to query
* \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type);
/**
* Set whether data reporting for a game controller sensor is enabled.
*
* \param gamecontroller The controller to update
* \param type The type of sensor to enable/disable
* \param enabled Whether data reporting should be enabled
* \returns 0 or -1 if an error occurred.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled);
/**
* Query whether sensor data reporting is enabled for a game controller.
*
* \param gamecontroller The controller to query
* \param type The type of sensor to query
* \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type);
/**
* Get the data rate (number of events per second) of a game controller
* sensor.
*
* \param gamecontroller The controller to query
* \param type The type of sensor to query
* \return the data rate, or 0.0f if the data rate is not available.
*
* \since This function is available since SDL 2.0.16.
*/
extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type);
/**
* Get the current state of a game controller sensor.
*
* The number of values and interpretation of the data is sensor dependent.
* See SDL_sensor.h for the details for each type of sensor.
*
* \param gamecontroller The controller to query
* \param type The type of sensor to query
* \param data A pointer filled with the current sensor state
* \param num_values The number of values to write to data
* \return 0 or -1 if an error occurred.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values);
/**
* Get the current state of a game controller sensor with the timestamp of the
* last update.
*
* The number of values and interpretation of the data is sensor dependent.
* See SDL_sensor.h for the details for each type of sensor.
*
* \param gamecontroller The controller to query
* \param type The type of sensor to query
* \param timestamp A pointer filled with the timestamp in microseconds of the
* current sensor reading if available, or 0 if not
* \param data A pointer filled with the current sensor state
* \param num_values The number of values to write to data
* \return 0 or -1 if an error occurred.
*
* \since This function is available since SDL 2.26.0.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller, SDL_SensorType type, Uint64 *timestamp, float *data, int num_values);
/**
* Start a rumble effect on a game controller.
*
* Each call to this function cancels any previous rumble effect, and calling
* it with 0 intensity stops any rumbling.
*
* \param gamecontroller The controller to vibrate
* \param low_frequency_rumble The intensity of the low frequency (left)
* rumble motor, from 0 to 0xFFFF
* \param high_frequency_rumble The intensity of the high frequency (right)
* rumble motor, from 0 to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds
* \returns 0, or -1 if rumble isn't supported on this controller
*
* \since This function is available since SDL 2.0.9.
*
* \sa SDL_GameControllerHasRumble
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
/** /**
* Close a controller previously opened with SDL_GameControllerOpen(). * Start a rumble effect in the game controller's triggers.
*
* Each call to this function cancels any previous trigger rumble effect, and
* calling it with 0 intensity stops any rumbling.
*
* Note that this is rumbling of the _triggers_ and not the game controller as
* a whole. This is currently only supported on Xbox One controllers. If you
* want the (more common) whole-controller rumble, use
* SDL_GameControllerRumble() instead.
*
* \param gamecontroller The controller to vibrate
* \param left_rumble The intensity of the left trigger rumble motor, from 0
* to 0xFFFF
* \param right_rumble The intensity of the right trigger rumble motor, from 0
* to 0xFFFF
* \param duration_ms The duration of the rumble effect, in milliseconds
* \returns 0, or -1 if trigger rumble isn't supported on this controller
*
* \since This function is available since SDL 2.0.14.
*
* \sa SDL_GameControllerHasRumbleTriggers
*/
extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
/**
* Query whether a game controller has an LED.
*
* \param gamecontroller The controller to query
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have a
* modifiable LED
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller);
/**
* Query whether a game controller has rumble support.
*
* \param gamecontroller The controller to query
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have rumble
* support
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GameControllerRumble
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumble(SDL_GameController *gamecontroller);
/**
* Query whether a game controller has rumble support on triggers.
*
* \param gamecontroller The controller to query
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have trigger
* rumble support
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GameControllerRumbleTriggers
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller);
/**
* Update a game controller's LED color.
*
* \param gamecontroller The controller to update
* \param red The intensity of the red LED
* \param green The intensity of the green LED
* \param blue The intensity of the blue LED
* \returns 0, or -1 if this controller does not have a modifiable LED
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue);
/**
* Send a controller specific effect packet
*
* \param gamecontroller The controller to affect
* \param data The data to send to the controller
* \param size The size of the data to send to the controller
* \returns 0, or -1 if this controller or driver doesn't support effect
* packets
*
* \since This function is available since SDL 2.0.16.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size);
/**
* Close a game controller previously opened with SDL_GameControllerOpen().
*
* \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen()
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GameControllerOpen
*/ */
extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
/**
* Return the sfSymbolsName for a given button on a game controller on Apple
* platforms.
*
* \param gamecontroller the controller to query
* \param button a button on the game controller
* \returns the sfSymbolsName or NULL if the name can't be found
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GameControllerGetAppleSFSymbolsNameForAxis
*/
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button);
/**
* Return the sfSymbolsName for a given axis on a game controller on Apple
* platforms.
*
* \param gamecontroller the controller to query
* \param axis an axis on the game controller
* \returns the sfSymbolsName or NULL if the name can't be found
*
* \since This function is available since SDL 2.0.18.
*
* \sa SDL_GameControllerGetAppleSFSymbolsNameForButton
*/
extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
......
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
...@@ -46,36 +46,66 @@ typedef Sint64 SDL_GestureID; ...@@ -46,36 +46,66 @@ typedef Sint64 SDL_GestureID;
/* Function prototypes */ /* Function prototypes */
/** /**
* \brief Begin Recording a gesture on the specified touch, or all touches (-1) * Begin recording a gesture on a specified touch device or all touch devices.
* *
* If the parameter `touchId` is -1 (i.e., all devices), this function will
* always return 1, regardless of whether there actually are any devices.
* *
* \param touchId the touch device id, or -1 for all touch devices
* \returns 1 on success or 0 if the specified device could not be found.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetTouchDevice
*/ */
extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
/** /**
* \brief Save all currently loaded Dollar Gesture templates * Save all currently loaded Dollar Gesture templates.
*
* \param dst a SDL_RWops to save to
* \returns the number of saved templates on success or 0 on failure; call
* SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
* *
* \sa SDL_LoadDollarTemplates
* \sa SDL_SaveDollarTemplate
*/ */
extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst);
/** /**
* \brief Save a currently loaded Dollar Gesture template * Save a currently loaded Dollar Gesture template.
* *
* \param gestureId a gesture id
* \param dst a SDL_RWops to save to
* \returns 1 on success or 0 on failure; call SDL_GetError() for more
* information.
* *
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_LoadDollarTemplates
* \sa SDL_SaveAllDollarTemplates
*/ */
extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst);
/** /**
* \brief Load Dollar Gesture templates from a file * Load Dollar Gesture templates from a file.
*
* \param touchId a touch id
* \param src a SDL_RWops to load from
* \returns the number of loaded templates on success or a negative error code
* (or 0) on failure; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0.
* *
* \sa SDL_SaveAllDollarTemplates
* \sa SDL_SaveDollarTemplate
*/ */
extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
} }
......