Expand description
Bindings to the SDL2 C library.
By default the crate will dynamically link to the system installed version of SDL2. The crate provides bindings for most of the 2.0.16 APIs, but your system version of SDL2 might be older or newer than that. For example, Debian Bullseye is on 2.0.14, but Debian Bookworm has updated to 2.24.1 (note that in between SDL2 changed their version number policy, so new versions now update the middle value). On Windows MSVC the “system” version will be SDL2’s official pre-built development files that come bundled in the crate.
If you use the static_bundled_build
cargo feature then this will build
SDL2 using a bundled copy of the source and then statically link to that.
Building SDL2 can take a bit during that first build (usually 1 minute or
more).
§Crate Features
cargo_check
: This causes the entire build.rs to exit early. This is useful if you don’t need to make an executable, such ascargo check
orcargo doc
.
Modules§
- audio
- Audio playback.
- blendmode
- Support module for pixel blending.
- clipboard
- Interact with the system clipboard.
- cpuinfo
- Get some useful info about the current CPU.
- error
- SDL uses a thread-local buffer to store the current error string.
- events
- Module for event handling.
- filesystem
- Filesystem helper functions.
- gamecontroller
- The SDL “game controller” API lets you view any joystick as being (approximately) an XBox 360 controller.
- gesture
- Module for touch gestures.
- hints
- SDL configuration variables
- joystick
- Module for SDL joystick event handling.
- keyboard
- Interactions with the keyboard.
- keycode
- Logical key mappings (changes by locale).
- loadso
- Module for loading “shared objects” (aka dynamic libraries / DLLs).
- messagebox
- Allows the creation of message boxes, for short messages to the user.
- mouse
- Mouse control and interaction.
- pixels
- Module for pixel editing.
- platform
- Platform based functions.
- power
- Lets you get power info about the system.
- prelude
- This is a module that re-exports every sub-module of the crate.
- quit
- Quit stuff.
- rect
- Operations for SDL’s rectangle type.
- renderer
- SDL’s portable 2D rendering functions.
- rwops
- Allows for interaction with things you can read and write from.
- scancode
- Physical key mappings (ignores locale).
- sensor
- Lets SDL use various sensors (such as the accelerometer in a phone).
- stdinc
- The “standard include” which almost every other include tends to use.
- surface
- Module for SDL’s in-memory bitmap type.
- syswm
- SDL’s custom system window manager hooks.
- timer
- Timer related functionality.
- touch
- Module for touch interface interactions.
- version
- Lets you get info about the runtime SDL version.
- video
- Module for interacting with the video subsystem.
Structs§
- SDL_
Init Flags - SDL2’s initialization flags.
Enums§
Constants§
- SDL_
INIT_ AUDIO - SDL_
INIT_ EVENTS - SDL_
INIT_ EVERYTHING - SDL_
INIT_ GAMECONTROLLER SDL_INIT_GAMECONTROLLER
impliesSDL_INIT_JOYSTICK
- SDL_
INIT_ HAPTIC - SDL_
INIT_ JOYSTICK SDL_INIT_JOYSTICK
impliesSDL_INIT_EVENTS
- SDL_
INIT_ NOPARACHUTE - compatibility; this flag is ignored.
- SDL_
INIT_ SENSOR - SDL_
INIT_ TIMER - SDL_
INIT_ VIDEO SDL_INIT_VIDEO
impliesSDL_INIT_EVENTS
Functions§
- SDL_
Init ⚠ - This function initializes the subsystems specified by
flags
. - SDL_
Init ⚠SubSystem - This function initializes specific SDL subsystems
- SDL_
Quit ⚠ - This function cleans up all initialized subsystems.
- SDL_
Quit ⚠SubSystem - This function cleans up specific SDL subsystems.
- SDL_
WasInit ⚠ - This function returns a mask of the specified subsystems which have previously been initialized.
Type Aliases§
- c_char
- Equivalent to C’s
char
type. - c_
double - Equivalent to C’s
double
type. - c_float
- Equivalent to C’s
float
type. - c_int
- Equivalent to C’s
signed int
(int
) type. - c_long
- Equivalent to C’s
signed long
(long
) type. - c_
longlong - Equivalent to C’s
signed long long
(long long
) type. - c_schar
- Equivalent to C’s
signed char
type. - c_short
- Equivalent to C’s
signed short
(short
) type. - c_uchar
- Equivalent to C’s
unsigned char
type. - c_uint
- Equivalent to C’s
unsigned int
type. - c_ulong
- Equivalent to C’s
unsigned long
type. - c_
ulonglong - Equivalent to C’s
unsigned long long
type. - c_
ushort - Equivalent to C’s
unsigned short
type.