The sdl module exposes libSDL2’s C API with some Pythonic renaming.
See also https://wiki.libsdl.org/FrontPage
alias of SDL_AudioCVT
alias of SDL_AudioSpec
alias of SDL_Color
alias of SDL_CommonEvent
alias of SDL_ControllerAxisEvent
alias of SDL_ControllerButtonEvent
alias of SDL_ControllerDeviceEvent
alias of SDL_Cursor
Return a four-character code as a uint32.
alias of SDL_DisplayMode
alias of SDL_DollarGestureEvent
alias of SDL_DropEvent
alias of SDL_Event
Return a four-character code as a uint32.
alias of SDL_Finger
int SDL_GL_BindTexture(SDL_Texture *, float *, float *)
Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the operation is not supported |
void * SDL_GL_CreateContext(SDL_Window *)
Create an OpenGL context for use with an OpenGL window, and make it current.
See also SDL_GL_DeleteContext()
void SDL_GL_DeleteContext(void *)
Delete an OpenGL context.
See also SDL_GL_CreateContext()
SDL_bool SDL_GL_ExtensionSupported(char const *)
Return true if an OpenGL extension is supported for the current context.
int SDL_GL_GetAttribute(SDL_GLattr, int *)
Get the actual value for an attribute from the current context.
void * SDL_GL_GetCurrentContext(void)
Get the currently active OpenGL context.
SDL_Window * SDL_GL_GetCurrentWindow(void)
Get the currently active OpenGL window.
void * SDL_GL_GetProcAddress(char const *)
Get the address of an OpenGL function.
int SDL_GL_GetSwapInterval(void)
Get the swap interval for the current OpenGL context.
Returns: | 0 if there is no vertical retrace synchronization, 1 if the buffer swap is synchronized with the vertical retrace, and -1 if late swaps happen immediately instead of waiting for the next retrace. If the system can’t determine the swap interval, or there isn’t a valid current context, this will return 0 as a safe default. |
---|
See also SDL_GL_SetSwapInterval()
int SDL_GL_LoadLibrary(char const *)
Dynamically load an OpenGL library.
Parameters: | path – The platform dependent OpenGL library name, or NULL to open the default OpenGL library. |
---|---|
Returns: | 0 on success, or -1 if the library couldn’t be loaded. |
This should be done after initializing the video driver, but before creating any OpenGL windows. If no OpenGL library is loaded, the default library will be loaded upon creation of the first OpenGL window.
If you do this, you need to retrieve all of the GL functions used in your program from the dynamic library using SDL_GL_GetProcAddress().
See also SDL_GL_GetProcAddress()
int SDL_GL_MakeCurrent(SDL_Window *, void *)
Set up an OpenGL context for rendering into an OpenGL window.
The context must have been created with a compatible window.
int SDL_GL_SetAttribute(SDL_GLattr, int)
Set an OpenGL window attribute before window creation.
int SDL_GL_SetSwapInterval(int)
Set the swap interval for the current OpenGL context.
Parameters: | interval – 0 for immediate updates, 1 for updates synchronized with the vertical retrace. If the system supports it, you may specify -1 to allow late swaps to happen immediately instead of waiting for the next retrace. |
---|---|
Returns: | 0 on success, or -1 if setting the swap interval is not supported. |
See also SDL_GL_GetSwapInterval()
void SDL_GL_SwapWindow(SDL_Window *)
Swap the OpenGL buffers for a window, if double-buffering is supported.
int SDL_GL_UnbindTexture(SDL_Texture *)
Unbind a texture from the current OpenGL/ES/ES2 context.
Parameters: | texture – The SDL texture to unbind |
---|---|
Returns: | 0 on success, or -1 if the operation is not supported |
void SDL_GL_UnloadLibrary(void)
Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
See also SDL_GL_LoadLibrary()
alias of SDL_GameController
alias of SDL_GameControllerButtonBind
alias of SDL_Haptic
alias of SDL_HapticCondition
alias of SDL_HapticConstant
alias of SDL_HapticCustom
alias of SDL_HapticDirection
alias of SDL_HapticEffect
alias of SDL_HapticLeftRight
alias of SDL_HapticPeriodic
alias of SDL_HapticRamp
alias of SDL_JoyAxisEvent
alias of SDL_JoyBallEvent
alias of SDL_JoyButtonEvent
alias of SDL_JoyDeviceEvent
alias of SDL_JoyHatEvent
alias of SDL_Joystick
alias of SDL_JoystickGUID
alias of SDL_KeyboardEvent
alias of SDL_Keysym
alias of SDL_MessageBoxButtonData
alias of SDL_MessageBoxColor
alias of SDL_MessageBoxColorScheme
alias of SDL_MessageBoxData
alias of SDL_MouseButtonEvent
alias of SDL_MouseMotionEvent
alias of SDL_MouseWheelEvent
alias of SDL_MultiGestureEvent
alias of SDL_OSEvent
alias of SDL_Palette
alias of SDL_PixelFormat
alias of SDL_Point
alias of SDL_QuitEvent
SDL_RWops * SDL_RWFromConstMem(void const *, int)
SDL_RWops * SDL_RWFromFP(FILE *, SDL_bool)
SDL_RWops * SDL_RWFromFile(char const *, char const *)
SDL_RWops * SDL_RWFromMem(void *, int)
alias of SDL_RWops
alias of SDL_Rect
alias of SDL_Renderer
alias of SDL_RendererInfo
Fetch and wrap the current SDL error message.
Wrap a cffi structure in a Python class, hiding allocation and dereferencing.
alias of SDL_Surface
alias of SDL_SysWMEvent
alias of SDL_SysWMmsg
unsigned int SDL_TLSCreate(void)
Create an identifier that is globally visible to all threads but refers to data that is thread-specific.
Returns: | The newly created thread local storage identifier, or 0 on error |
---|
static SDL_SpinLock tls_lock;
static SDL_TLSID thread_local_storage;
void SetMyThreadData(void *value)
{
if (!thread_local_storage) {
SDL_AtomicLock(&tls_lock);
if (!thread_local_storage) {
thread_local_storage = SDL_TLSCreate();
}
SDL_AtomicUnLock(&tls_lock);
}
SDL_TLSSet(thread_local_storage, value);
}
void *GetMyThreadData(void)
{
return SDL_TLSGet(thread_local_storage);
}
See also SDL_TLSGet()
void * SDL_TLSGet(unsigned int)
Get the value associated with a thread local storage ID for the current thread.
Parameters: | id – The thread local storage ID |
---|---|
Returns: | The value associated with the ID for the current thread, or NULL if no value has been set. |
See also SDL_TLSCreate()
int SDL_TLSSet(unsigned int, void const *, void SDL_TLSSet(void *))
Set the value associated with a thread local storage ID for the current thread.
Parameters: |
|
---|---|
Returns: | 0 on success, -1 on error |
See also SDL_TLSCreate()
alias of SDL_TextEditingEvent
alias of SDL_TextInputEvent
alias of SDL_Texture
alias of SDL_Thread
alias of SDL_TouchFingerEvent
alias of SDL_UserEvent
alias of SDL_Window
alias of SDL_WindowEvent
int SDL_abs(int)
void SDL_AddEventWatch(int SDL_AddEventWatch(void *, SDL_Event *), void *)
Add a function which is called when an event is added to the queue.
void SDL_AddHintCallback(char const *, void SDL_AddHintCallback(void *, char const *, char const *, char const *), void *)
int SDL_AddTimer(uint32_t, uint32_t SDL_AddTimer(uint32_t, void *), void *)
Add a new timer to the pool of timers already running.
Returns: | A timer ID, or NULL when an error occurs. |
---|
SDL_PixelFormat * SDL_AllocFormat(uint32_t)
Create an SDL_PixelFormat structure from a pixel format enum.
SDL_Palette * SDL_AllocPalette(int)
Create a palette structure with the specified number of color entries.
Returns: | A new palette, or NULL if there wasn’t enough memory. |
---|
The palette entries are initialized to white.
See also SDL_FreePalette()
SDL_RWops * SDL_AllocRW(void)
alias of SDL_assert_data
double SDL_atan(double)
double SDL_atan2(double, double)
double SDL_atof(char const *)
int SDL_atoi(char const *)
void SDL_AtomicLock(int *)
Lock a spin lock by setting it to a non-zero value.
Parameters: | lock – Points to the lock. |
---|
SDL_bool SDL_AtomicTryLock(int *)
Try to lock a spin lock by setting it to a non-zero value.
Parameters: | lock – Points to the lock. |
---|---|
Returns: | SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. |
void SDL_AtomicUnlock(int *)
Unlock a spin lock by setting it to 0. Always returns immediately.
Parameters: | lock – Points to the lock. |
---|
alias of SDL_atomic_t
int SDL_AudioInit(char const *)
void SDL_AudioQuit(void)
int SDL_UpperBlit(SDL_Surface *, SDL_Rect const *, SDL_Surface *, SDL_Rect *)
This is the public blit function, SDL_BlitSurface(), and it performs rectangle validation and clipping before passing it to SDL_LowerBlit()
int SDL_BuildAudioCVT(SDL_AudioCVT *, uint16_t, uint8_t, int, uint16_t, uint8_t, int)
This function takes a source format and rate and a destination format and rate, and initializes the cvt structure with information needed by SDL_ConvertAudio() to convert a buffer of audio data from one format to the other.
Returns: | -1 if the format conversion is not supported, 0 if there’s no conversion needed, or 1 if the audio filter is set up. |
---|
void SDL_CalculateGammaRamp(float, uint16_t *)
Parameters: |
|
---|---|
Returns: | ramp |
void * SDL_calloc(size_t, size_t)
double SDL_ceil(double)
void SDL_ClearError(void)
void SDL_ClearHints(void)
Clear all hints.
This function is called during SDL_Quit() to free stored hints.
void SDL_CloseAudio(void)
This function shuts down audio processing and closes the audio device.
void SDL_CloseAudioDevice(uint32_t)
alias of SDL_cond
int SDL_CondBroadcast(SDL_cond *)
Restart all threads that are waiting on the condition variable.
Returns: | 0 or -1 on error. |
---|
int SDL_CondSignal(SDL_cond *)
Restart one of the threads that are waiting on the condition variable.
Returns: | 0 or -1 on error. |
---|
int SDL_CondWait(SDL_cond *, SDL_mutex *)
Wait on the condition variable, unlocking the provided mutex.
The mutex must be locked before entering this function!
The mutex is re-locked once the condition variable is signaled.
Returns: | 0 when it is signaled, or -1 on error. |
---|
int SDL_CondWaitTimeout(SDL_cond *, SDL_mutex *, uint32_t)
Waits for at most ms milliseconds, and returns 0 if the condition variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not signaled in the allotted time, and -1 on error.
On some platforms this function is implemented by looping with a delay of 1 ms, and so should be avoided if possible.
int SDL_ConvertAudio(SDL_AudioCVT *)
Once you have initialized the cvt structure using SDL_BuildAudioCVT(), created an audio buffer cvt->buf, and filled it with cvt->len bytes of audio data in the source format, this function will convert it in- place to the desired format.
The data conversion may expand the size of the audio data, so the buffer cvt->buf should be allocated after the cvt structure is initialized by SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long.
int SDL_ConvertPixels(int, int, uint32_t, void const *, int, uint32_t, void *, int)
Copy a block of pixels of one format to another format.
Returns: | 0 on success, or -1 if there was an error |
---|
SDL_Surface * SDL_ConvertSurface(SDL_Surface *, SDL_PixelFormat *, uint32_t)
Creates a new surface of the specified format, and then copies and maps the given surface to it so the blit of the converted surface will be as fast as possible. If this function fails, it returns NULL.
The flags parameter is passed to SDL_CreateRGBSurface() and has those semantics. You can also pass SDL_RLEACCEL in the flags parameter and SDL will try to RLE accelerate colorkey and alpha blits in the resulting surface.
SDL_Surface * SDL_ConvertSurfaceFormat(SDL_Surface *, uint32_t, uint32_t)
double SDL_copysign(double, double)
double SDL_cos(double)
float SDL_cosf(float)
SDL_Cursor * SDL_CreateColorCursor(SDL_Surface *, int, int)
Create a color cursor.
See also SDL_FreeCursor()
SDL_cond * SDL_CreateCond(void)
Create a condition variable.
Typical use of condition variables:
Thread A: SDL_LockMutex(lock); while ( ! condition ) { SDL_CondWait(cond, lock); } SDL_UnlockMutex(lock);
Thread B: SDL_LockMutex(lock); ... condition = true; ... SDL_CondSignal(cond); SDL_UnlockMutex(lock);
There is some discussion whether to signal the condition variable with the mutex locked or not. There is some potential performance benefit to unlocking first on some platforms, but there are some potential race conditions depending on how your code is structured.
In general it’s safer to signal the condition variable while the mutex is locked.
SDL_Cursor * SDL_CreateCursor(uint8_t const *, uint8_t const *, int, int, int, int)
Create a cursor, using the specified bitmap data and mask (in MSB format).
The cursor width must be a multiple of 8 bits.
The cursor is created in black and white according to the following: data
mask
resulting pixel on screen
0
1
White
1
1
Black
0
0
Transparent
1
0
Inverted color if possible, black if not.
See also SDL_FreeCursor()
SDL_mutex * SDL_CreateMutex(void)
Create a mutex, initialized unlocked.
SDL_Surface * SDL_CreateRGBSurface(uint32_t, int, int, int, uint32_t, uint32_t, uint32_t, uint32_t)
Allocate and free an RGB surface.
If the depth is 4 or 8 bits, an empty palette is allocated for the surface. If the depth is greater than 8 bits, the pixel format is set using the flags ‘[RGB]mask’.
If the function runs out of memory, it will return NULL.
Parameters: |
|
---|
SDL_Surface * SDL_CreateRGBSurfaceFrom(void *, int, int, int, int, uint32_t, uint32_t, uint32_t, uint32_t)
SDL_Renderer * SDL_CreateRenderer(SDL_Window *, int, uint32_t)
Create a 2D rendering context for a window.
Parameters: |
|
---|---|
Returns: | A valid rendering context or NULL if there was an error. |
See also SDL_CreateSoftwareRenderer()
SDL_sem * SDL_CreateSemaphore(uint32_t)
Create a semaphore, initialized with value, returns NULL on failure.
SDL_Renderer * SDL_CreateSoftwareRenderer(SDL_Surface *)
Create a 2D software rendering context for a surface.
Parameters: | surface – The surface where rendering is done. |
---|---|
Returns: | A valid rendering context or NULL if there was an error. |
See also SDL_CreateRenderer()
SDL_Cursor * SDL_CreateSystemCursor(SDL_SystemCursor)
Create a system cursor.
See also SDL_FreeCursor()
SDL_Texture * SDL_CreateTexture(SDL_Renderer *, uint32_t, int, int, int)
Create a texture for a rendering context.
Parameters: |
|
---|---|
Returns: | The created texture is returned, or 0 if no rendering context was active, the format was unsupported, or the width or height were out of range. |
See also SDL_QueryTexture()
SDL_Texture * SDL_CreateTextureFromSurface(SDL_Renderer *, SDL_Surface *)
Create a texture from an existing surface.
Parameters: |
|
---|---|
Returns: | The created texture is returned, or 0 on error. |
The surface is not modified or freed by this function.
See also SDL_QueryTexture()
SDL_Thread * SDL_CreateThread(int SDL_CreateThread(void *), char const *, void *)
Create a thread.
SDL_Window * SDL_CreateWindow(char const *, int, int, int, int, uint32_t)
Create a window with the specified position, dimensions, and flags.
Parameters: |
|
---|---|
Returns: | The id of the window created, or zero if window creation failed. |
See also SDL_DestroyWindow()
int SDL_CreateWindowAndRenderer(int, int, uint32_t, SDL_Window * *, SDL_Renderer * *)
Create a window and default renderer.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
SDL_Window * SDL_CreateWindowFrom(void const *)
Create an SDL window from an existing native window.
Parameters: | data – A pointer to driver-dependent window creation data |
---|---|
Returns: | The id of the window created, or zero if window creation failed. |
See also SDL_DestroyWindow()
void SDL_DelEventWatch(int SDL_DelEventWatch(void *, SDL_Event *), void *)
Remove an event watch function added with SDL_AddEventWatch()
void SDL_DelHintCallback(char const *, void SDL_DelHintCallback(void *, char const *, char const *, char const *), void *)
Remove a function watching a particular hint.
Parameters: |
|
---|
void SDL_Delay(uint32_t)
Wait a specified number of milliseconds before returning.
void SDL_DestroyCond(SDL_cond *)
Destroy a condition variable.
void SDL_DestroyMutex(SDL_mutex *)
Destroy a mutex.
void SDL_DestroyRenderer(SDL_Renderer *)
Destroy the rendering context for a window and free associated textures.
See also SDL_CreateRenderer()
void SDL_DestroySemaphore(SDL_sem *)
Destroy a semaphore.
void SDL_DestroyTexture(SDL_Texture *)
Destroy the specified texture.
See also SDL_CreateTexture()
void SDL_DestroyWindow(SDL_Window *)
Destroy a window.
void SDL_DisableScreenSaver(void)
Prevent the screen from being blanked by a screensaver.
See also SDL_IsScreenSaverEnabled()
void SDL_EnableScreenSaver(void)
Allow the screen to be blanked by a screensaver.
See also SDL_IsScreenSaverEnabled()
SDL_bool SDL_EnclosePoints(SDL_Point const *, int, SDL_Rect const *, SDL_Rect *)
Calculate a minimal rectangle enclosing a set of points.
Returns: | SDL_TRUE if any points were within the clipping rect |
---|
int SDL_Error(SDL_errorcode)
uint8_t SDL_EventState(uint32_t, int)
This function allows you to set the state of processing certain events.If state is set to SDL_IGNORE, that event will be automatically dropped from the event queue and will not event be filtered.
If state is set to SDL_ENABLE, that event will be processed normally.
If state is set to SDL_QUERY, SDL_EventState() will return the current processing state of the specified event.
double SDL_fabs(double)
int SDL_FillRect(SDL_Surface *, SDL_Rect const *, uint32_t)
Performs a fast fill of the given rectangle with color.
If rect is NULL, the whole surface will be filled with color.
The color should be a pixel of the format used by the surface, and can be generated by the SDL_MapRGB() function.
Returns: | 0 on success, or -1 on error. |
---|
int SDL_FillRects(SDL_Surface *, SDL_Rect const *, int, uint32_t)
void SDL_FilterEvents(int SDL_FilterEvents(void *, SDL_Event *), void *)
Run the filter function on the current event queue, removing any events for which the filter returns 0.
double SDL_floor(double)
void SDL_FlushEvent(uint32_t)
This function clears events from the event queue
void SDL_FlushEvents(uint32_t, uint32_t)
void SDL_free(void *)
void SDL_FreeCursor(SDL_Cursor *)
Frees a cursor created with SDL_CreateCursor().
See also SDL_CreateCursor()
void SDL_FreeFormat(SDL_PixelFormat *)
Free an SDL_PixelFormat structure.
void SDL_FreePalette(SDL_Palette *)
Free a palette created with SDL_AllocPalette().
See also SDL_AllocPalette()
void SDL_FreeRW(SDL_RWops *)
void SDL_FreeSurface(SDL_Surface *)
void SDL_FreeWAV(uint8_t *)
This function frees data previously allocated with SDL_LoadWAV_RW()
int SDL_GameControllerAddMapping(char const *)
Add or update an existing mapping configuration
Returns: | 1 if mapping is added, 0 if updated, -1 on error |
---|
void SDL_GameControllerClose(SDL_GameController *)
Close a controller previously opened with SDL_GameControllerOpen().
int SDL_GameControllerEventState(int)
Enable/disable controller event polling.
If controller events are disabled, you must call SDL_GameControllerUpdate() yourself and check the state of the controller when you want controller information.
The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
SDL_bool SDL_GameControllerGetAttached(SDL_GameController *)
Returns SDL_TRUE if the controller has been opened and currently connected, or SDL_FALSE if it has not.
int16_t SDL_GameControllerGetAxis(SDL_GameController *, SDL_GameControllerAxis)
Get the current state of an axis control on a game controller.
The state is a value ranging from -32768 to 32767.
The axis indices start at index 0.
SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(char const *)
turn this string into a axis mapping
SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController *, SDL_GameControllerAxis)
Get the SDL joystick layer binding for this controller button mapping
SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameController *, SDL_GameControllerButton)
Get the SDL joystick layer binding for this controller button mapping
uint8_t SDL_GameControllerGetButton(SDL_GameController *, SDL_GameControllerButton)
Get the current state of a button on a game controller.
The button indices start at index 0.
SDL_GameControllerButton SDL_GameControllerGetButtonFromString(char const *)
turn this string into a button mapping
SDL_Joystick * SDL_GameControllerGetJoystick(SDL_GameController *)
Get the underlying joystick object used by a controller
char const * SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis)
turn this axis enum into a string mapping
char const * SDL_GameControllerGetStringForButton(SDL_GameControllerButton)
turn this button enum into a string mapping
char * SDL_GameControllerMapping(SDL_GameController *)
Get a mapping string for an open GameController
Returns: | the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available |
---|
char * SDL_GameControllerMappingForGUID(SDL_JoystickGUID)
Get a mapping string for a GUID
Returns: | the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available |
---|
char const * SDL_GameControllerName(SDL_GameController *)
Return the name for this currently opened controller
char const * SDL_GameControllerNameForIndex(int)
Get the implementation dependent name of a game controller. This can be called before any controllers are opened. If no name can be found, this function returns NULL.
SDL_GameController * SDL_GameControllerOpen(int)
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 the value which will identify this controller in future controller events.
Returns: | A controller identifier, or NULL if an error occurred. |
---|
void SDL_GameControllerUpdate(void)
Update the current state of the open game controllers.
This is called automatically by the event loop if any game controller events are enabled.
SDL_assert_data const * SDL_GetAssertionReport(void)
Get a list of all assertion failures.
Get all assertions triggered since last call to SDL_ResetAssertionReport(), or the start of the program.
The proper way to examine this data looks something like this:
const SDL_assert_data *item = SDL_GetAssertionReport(); while (item) { printf(“’%s’, %s (%s:%d), triggered %u times, always ignore: %s.
item->condition, item->function, item->filename, item->linenum, item->trigger_count, item->always_ignore ? “yes” : “no”); item = item->next; }
return: | List of all assertions. |
---|
See also SDL_ResetAssertionReport
char const * SDL_GetAudioDeviceName(int, int)
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. The values returned by this function reflect the latest call to SDL_GetNumAudioDevices(); recall that function to redetect available hardware.
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 string for any length of time, you should make your own copy of it, as it will be invalid next time any of several other SDL functions is called.
SDL_AudioStatus SDL_GetAudioDeviceStatus(uint32_t)
char const * SDL_GetAudioDriver(int)
SDL_AudioStatus SDL_GetAudioStatus(void)
int SDL_GetCPUCacheLineSize(void)
This function returns the L1 cache line size of the CPU
This is useful for determining multi-threaded structure padding or SIMD prefetch sizes.
int SDL_GetCPUCount(void)
This function returns the number of CPU cores available.
void SDL_GetClipRect(SDL_Surface *, SDL_Rect *)
Gets the clipping rectangle for the destination surface in a blit.
rect must be a pointer to a valid rectangle which will be filled with the correct values.
char * SDL_GetClipboardText(void)
Get UTF-8 text from the clipboard, which must be freed with SDL_free()
See also SDL_SetClipboardText()
SDL_DisplayMode * SDL_GetClosestDisplayMode(int, SDL_DisplayMode const *, SDL_DisplayMode *)
Get the closest match to the requested display mode.
Parameters: |
|
---|---|
Returns: | The passed in value |
The available display modes are scanned, and closest is filled in with the closest mode matching the requested mode and returned. The mode format and refresh_rate default to the desktop mode if they are 0. The modes are scanned with size being first priority, format being second priority, and finally checking the refresh_rate. If all the available modes are too small, then NULL is returned.
See also SDL_GetNumDisplayModes()
int SDL_GetColorKey(SDL_Surface *, uint32_t *)
Gets the color key (transparent pixel) in a blittable surface.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the surface is not valid or colorkey is not enabled. |
char const * SDL_GetCurrentAudioDriver(void)
This function returns the name of the current audio driver, or NULL if no driver has been initialized.
int SDL_GetCurrentDisplayMode(int, SDL_DisplayMode *)
Fill in information about the current display mode.
char const * SDL_GetCurrentVideoDriver(void)
Returns the name of the currently initialized video driver.
Returns: | The name of the current video driver or NULL if no driver has been initialized |
---|
See also SDL_GetNumVideoDrivers()
SDL_Cursor * SDL_GetCursor(void)
Return the active cursor.
SDL_Cursor * SDL_GetDefaultCursor(void)
Return the default cursor.
int SDL_GetDesktopDisplayMode(int, SDL_DisplayMode *)
Fill in information about the desktop display mode.
int SDL_GetDisplayBounds(int, SDL_Rect *)
Get the desktop area represented by a display, with the primary display located at 0,0.
Returns: | 0 on success, or -1 if the index is out of range. |
---|
See also SDL_GetNumVideoDisplays()
int SDL_GetDisplayMode(int, int, SDL_DisplayMode *)
Fill in information about a specific display mode.
The display modes are sorted in this priority: bits per pixel -> more colors to fewer colors
width -> largest to smallest
height -> largest to smallest
refresh rate -> highest to lowest
See also SDL_GetNumDisplayModes()
char const * SDL_GetDisplayName(int)
Get the name of a display in UTF-8 encoding.
Returns: | The name of a display, or NULL for an invalid display index. |
---|
See also SDL_GetNumVideoDisplays()
char const * SDL_GetError(void)
SDL_bool SDL_GetEventFilter(int(* *)(void *, SDL_Event *), void * *)
Return the current event filter - can be used to “chain” filters. If there is no event filter set, this function returns SDL_FALSE.
char const * SDL_GetHint(char const *)
Get a hint.
Returns: | The string value of a hint variable. |
---|
int32_t SDL_GetKeyFromName(char const *)
Get a key code from a human-readable name.
Returns: | key code, or SDLK_UNKNOWN if the name wasn’t recognized |
---|
See also SDL_Keycode
int32_t SDL_GetKeyFromScancode(SDL_Scancode)
Get the key code corresponding to the given scancode according to the current keyboard layout.
See SDL_Keycode for details.
See also SDL_GetKeyName()
char const * SDL_GetKeyName(int32_t)
Get a human-readable name for a key.
Returns: | A pointer to a UTF-8 string that stays valid at least until the next call to this function. If you need it around any longer, you must copy it. If the key doesn’t have a name, this function returns an empty string (“”). |
---|
See also SDL_Key
SDL_Window * SDL_GetKeyboardFocus(void)
Get the window which currently has keyboard focus.
uint8_t const * SDL_GetKeyboardState(int *)
Get a snapshot of the current state of the keyboard.
param numkeys: if non-NULL, receives the length of the returned array. return: An array of key states. Indexes into this array are obtained by using Example::
const Uint8 *state = SDL_GetKeyboardState(NULL); if ( state[SDL_SCANCODE_RETURN] ) { printf("<RETURN> is pressed.
SDL_Keymod SDL_GetModState(void)
Get the current key modifier state for the keyboard.
SDL_Window * SDL_GetMouseFocus(void)
Get the window which currently has mouse focus.
uint32_t SDL_GetMouseState(int *, int *)
Retrieve the current state of the mouse.
The current button state is returned as a button bitmask, which can be tested using the SDL_BUTTON(X) macros, and x and y are set to the mouse cursor position relative to the focus window for the currently selected mouse. You can pass NULL for either x or y.
int SDL_GetNumAudioDevices(int)
Get the number of available devices exposed by the current driver. Only valid after a successfully initializing the audio subsystem. Returns -1 if an explicit list of devices can’t be determined; this 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 to 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()).
int SDL_GetNumAudioDrivers(void)
int SDL_GetNumDisplayModes(int)
Returns the number of available display modes.
See also SDL_GetDisplayMode()
int SDL_GetNumRenderDrivers(void)
Get the number of 2D rendering drivers available for the current display.
A render driver is a set of code that handles rendering and texture management on a particular display. Normally there is only one, but some drivers may have several available with different capabilities.
See also SDL_GetRenderDriverInfo()
int SDL_GetNumTouchDevices(void)
Get the number of registered touch devices.
int SDL_GetNumTouchFingers(int64_t)
Get the number of active fingers for a given touch device.
int SDL_GetNumVideoDisplays(void)
Returns the number of available video displays.
See also SDL_GetDisplayBounds()
int SDL_GetNumVideoDrivers(void)
Get the number of video drivers compiled into SDL.
See also SDL_GetVideoDriver()
uint64_t SDL_GetPerformanceCounter(void)
Get the current value of the high resolution counter.
uint64_t SDL_GetPerformanceFrequency(void)
Get the count per second of the high resolution counter.
char const * SDL_GetPixelFormatName(uint32_t)
Get the human readable name of a pixel format.
char const * SDL_GetPlatform(void)
Gets the name of the platform.
SDL_PowerState SDL_GetPowerInfo(int *, int *)
Get the current power supply details.
Parameters: |
|
---|---|
Returns: | The state of the battery (if any). |
void SDL_GetRGB(uint32_t, SDL_PixelFormat const *, uint8_t *, uint8_t *, uint8_t *)
Get the RGB components from a pixel of the specified format.
See also SDL_GetRGBA
void SDL_GetRGBA(uint32_t, SDL_PixelFormat const *, uint8_t *, uint8_t *, uint8_t *, uint8_t *)
Get the RGBA components from a pixel of the specified format.
See also SDL_GetRGB
SDL_bool SDL_GetRelativeMouseMode(void)
Query whether relative mouse mode is enabled.
See also SDL_SetRelativeMouseMode()
uint32_t SDL_GetRelativeMouseState(int *, int *)
Retrieve the relative state of the mouse.
The current button state is returned as a button bitmask, which can be tested using the SDL_BUTTON(X) macros, and x and y are set to the mouse deltas since the last call to SDL_GetRelativeMouseState().
int SDL_GetRenderDrawBlendMode(SDL_Renderer *, SDL_BlendMode *)
Get the blend mode used for drawing operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
See also SDL_SetRenderDrawBlendMode()
int SDL_GetRenderDrawColor(SDL_Renderer *, uint8_t *, uint8_t *, uint8_t *, uint8_t *)
Get the color used for drawing operations (Rect, Line and Clear).
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_GetRenderDriverInfo(int, SDL_RendererInfo *)
Get information about a specific 2D rendering driver for the current display.
Parameters: |
|
---|---|
Returns: | 0 on success, -1 if the index was out of range. |
See also SDL_CreateRenderer()
SDL_Texture * SDL_GetRenderTarget(SDL_Renderer *)
Get the current render target or NULL for the default render target.
Returns: | The current render target |
---|
See also SDL_SetRenderTarget()
SDL_Renderer * SDL_GetRenderer(SDL_Window *)
Get the renderer associated with a window.
int SDL_GetRendererInfo(SDL_Renderer *, SDL_RendererInfo *)
Get information about a rendering context.
int SDL_GetRendererOutputSize(SDL_Renderer *, int *, int *)
Get the output size of a rendering context.
char const * SDL_GetRevision(void)
Get the code revision of SDL that is linked against your program.
Returns an arbitrary string (a hash value) uniquely identifying the exact revision of the SDL library in use, and is only useful in comparing against other revisions. It is NOT an incrementing number.
int SDL_GetRevisionNumber(void)
Get the revision number of SDL that is linked against your program.
Returns a number uniquely identifying the exact revision of the SDL library in use. It is an incrementing number based on commits to hg.libsdl.org.
SDL_Scancode SDL_GetScancodeFromKey(int32_t)
Get the scancode corresponding to the given key code according to the current keyboard layout.
See SDL_Scancode for details.
See also SDL_GetScancodeName()
SDL_Scancode SDL_GetScancodeFromName(char const *)
Get a scancode from a human-readable name.
Returns: | scancode, or SDL_SCANCODE_UNKNOWN if the name wasn’t recognized |
---|
See also SDL_Scancode
char const * SDL_GetScancodeName(SDL_Scancode)
Get a human-readable name for a scancode.
Returns: | A pointer to the name for the scancode. If the scancode doesn’t have a name, this function returns an empty string (“”). |
---|
See also SDL_Scancode
int SDL_GetSurfaceAlphaMod(SDL_Surface *, uint8_t *)
Get the additional alpha value used in blit operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the surface is not valid. |
See also SDL_SetSurfaceAlphaMod()
int SDL_GetSurfaceBlendMode(SDL_Surface *, SDL_BlendMode *)
Get the blend mode used for blit operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the surface is not valid. |
See also SDL_SetSurfaceBlendMode()
int SDL_GetSurfaceColorMod(SDL_Surface *, uint8_t *, uint8_t *, uint8_t *)
Get the additional color value used in blit operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the surface is not valid. |
See also SDL_SetSurfaceColorMod()
int SDL_GetTextureAlphaMod(SDL_Texture *, uint8_t *)
Get the additional alpha value used in render copy operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the texture is not valid. |
See also SDL_SetTextureAlphaMod()
int SDL_GetTextureBlendMode(SDL_Texture *, SDL_BlendMode *)
Get the blend mode used for texture copy operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the texture is not valid. |
See also SDL_SetTextureBlendMode()
int SDL_GetTextureColorMod(SDL_Texture *, uint8_t *, uint8_t *, uint8_t *)
Get the additional color value used in render copy operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the texture is not valid. |
See also SDL_SetTextureColorMod()
unsigned long SDL_GetThreadID(SDL_Thread *)
Get the thread identifier for the specified thread.
Equivalent to SDL_ThreadID() if the specified thread is NULL.
char const * SDL_GetThreadName(SDL_Thread *)
Get the thread name, as it was specified in SDL_CreateThread(). This function returns a pointer to a UTF-8 string that names the specified thread, or NULL if it doesn’t have a name. This is internal memory, not to be free()’d by the caller, and remains valid until the specified thread is cleaned up by SDL_WaitThread().
uint32_t SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
This value wraps if the program runs for more than ~49 days.
int64_t SDL_GetTouchDevice(int)
Get the touch ID with the given index, or 0 if the index is invalid.
SDL_Finger * SDL_GetTouchFinger(int64_t, int)
Get the finger object of the given touch, with the given index.
void SDL_GetVersion(SDL_version *)
Get the version of SDL that is linked against your program.
If you are linking to SDL dynamically, then it is possible that the current version will be different than the version you compiled against. This function returns the current version, while SDL_VERSION() is a macro that tells you what version you compiled with.
SDL_version compiled; SDL_version linked; SDL_VERSION(&compiled); SDL_GetVersion(&linked); printf("We compiled against SDL version %d.%d.%d ...
compiled.major, compiled.minor, compiled.patch);
printf(“But we linked against SDL version %d.%d.%d.
linked.major, linked.minor, linked.patch);
This function may be called safely at any time, even before SDL_Init().
See also SDL_VERSION
char const * SDL_GetVideoDriver(int)
Get the name of a built in video driver.
The video drivers are presented in the order in which they are normally checked during initialization.
See also SDL_GetNumVideoDrivers()
float SDL_GetWindowBrightness(SDL_Window *)
Get the brightness (gamma correction) for a window.
Returns: | The last brightness value passed to |
---|
See also SDL_SetWindowBrightness()
void * SDL_GetWindowData(SDL_Window *, char const *)
Retrieve the data pointer associated with a window.
Parameters: |
|
---|---|
Returns: | The value associated with ‘name’ |
See also SDL_SetWindowData()
int SDL_GetWindowDisplayIndex(SDL_Window *)
Get the display index associated with a window.
Returns: | the display index of the display containing the center of the window, or -1 on error. |
---|
int SDL_GetWindowDisplayMode(SDL_Window *, SDL_DisplayMode *)
Fill in information about the display mode used when a fullscreen window is visible.
See also SDL_SetWindowDisplayMode()
uint32_t SDL_GetWindowFlags(SDL_Window *)
Get the window flags.
SDL_Window * SDL_GetWindowFromID(uint32_t)
Get a window from a stored ID, or NULL if it doesn’t exist.
int SDL_GetWindowGammaRamp(SDL_Window *, uint16_t *, uint16_t *, uint16_t *)
Get the gamma ramp for a window.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if gamma ramps are unsupported. |
See also SDL_SetWindowGammaRamp()
SDL_bool SDL_GetWindowGrab(SDL_Window *)
Get a window’s input grab mode.
Returns: | This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise. |
---|
See also SDL_SetWindowGrab()
uint32_t SDL_GetWindowID(SDL_Window *)
Get the numeric ID of a window, for logging purposes.
void SDL_GetWindowMaximumSize(SDL_Window *, int *, int *)
Get the maximum size of a window’s client area.
Parameters: |
|
---|
See also SDL_GetWindowMinimumSize()
void SDL_GetWindowMinimumSize(SDL_Window *, int *, int *)
Get the minimum size of a window’s client area.
Parameters: |
|
---|
See also SDL_GetWindowMaximumSize()
uint32_t SDL_GetWindowPixelFormat(SDL_Window *)
Get the pixel format associated with the window.
void SDL_GetWindowPosition(SDL_Window *, int *, int *)
Get the position of a window.
Parameters: |
|
---|
See also SDL_SetWindowPosition()
void SDL_GetWindowSize(SDL_Window *, int *, int *)
Get the size of a window’s client area.
Parameters: |
|
---|
See also SDL_SetWindowSize()
SDL_Surface * SDL_GetWindowSurface(SDL_Window *)
Get the SDL surface associated with the window.
Returns: | The window’s framebuffer surface, or NULL on error. |
---|
A new surface will be created with the optimal format for the window, if necessary. This surface will be freed when the window is destroyed.
You may not combine this with 3D or the rendering API on this window.
See also SDL_UpdateWindowSurface()
char const * SDL_GetWindowTitle(SDL_Window *)
Get the title of a window, in UTF-8 format.
See also SDL_SetWindowTitle()
char * SDL_getenv(char const *)
void SDL_HapticClose(SDL_Haptic *)
Closes a Haptic device previously opened with SDL_HapticOpen().
Parameters: | haptic – Haptic device to close. |
---|
void SDL_HapticDestroyEffect(SDL_Haptic *, int)
Destroys a haptic effect on the device.
This will stop the effect if it’s running. Effects are automatically destroyed when the device is closed.
Parameters: |
|
---|
See also SDL_HapticNewEffect
int SDL_HapticEffectSupported(SDL_Haptic *, SDL_HapticEffect *)
Checks to see if effect is supported by haptic.
Parameters: |
|
---|---|
Returns: | SDL_TRUE if effect is supported, SDL_FALSE if it isn’t or -1 on error. |
See also SDL_HapticQuery
int SDL_HapticGetEffectStatus(SDL_Haptic *, int)
Gets the status of the current effect on the haptic device.
Device must support the SDL_HAPTIC_STATUS feature.
Parameters: |
|
---|---|
Returns: | 0 if it isn’t playing, 1 if it is playing or -1 on error. |
See also SDL_HapticRunEffect
int SDL_HapticIndex(SDL_Haptic *)
Gets the index of a haptic device.
Parameters: | haptic – Haptic device to get the index of. |
---|---|
Returns: | The index of the haptic device or -1 on error. |
See also SDL_HapticOpen
char const * SDL_HapticName(int)
Get the implementation dependent name of a Haptic device.
This can be called before any joysticks are opened. If no name can be found, this function returns NULL.
Parameters: | device_index – Index of the device to get its name. |
---|---|
Returns: | Name of the device or NULL on error. |
See also SDL_NumHaptics
int SDL_HapticNewEffect(SDL_Haptic *, SDL_HapticEffect *)
Creates a new haptic effect on the device.
Parameters: |
|
---|---|
Returns: | The id of the effect on success or -1 on error. |
See also SDL_HapticUpdateEffect
int SDL_HapticNumAxes(SDL_Haptic *)
Gets the number of haptic axes the device has.
See also SDL_HapticDirection
int SDL_HapticNumEffects(SDL_Haptic *)
Returns the number of effects a haptic device can store.
On some platforms this isn’t fully supported, and therefore is an approximation. Always check to see if your created effect was actually created and do not rely solely on SDL_HapticNumEffects().
Parameters: | haptic – The haptic device to query effect max. |
---|---|
Returns: | The number of effects the haptic device can store or -1 on error. |
See also SDL_HapticNumEffectsPlaying
int SDL_HapticNumEffectsPlaying(SDL_Haptic *)
Returns the number of effects a haptic device can play at the same time.
This is not supported on all platforms, but will always return a value. Added here for the sake of completeness.
Parameters: | haptic – The haptic device to query maximum playing effects. |
---|---|
Returns: | The number of effects the haptic device can play at the same time or -1 on error. |
See also SDL_HapticNumEffects
SDL_Haptic * SDL_HapticOpen(int)
Opens a Haptic device for usage.
The index passed as an argument refers to the N’th Haptic device on this system.
When opening a haptic device, its gain will be set to maximum and autocenter will be disabled. To modify these values use SDL_HapticSetGain() and SDL_HapticSetAutocenter().
Parameters: | device_index – Index of the device to open. |
---|---|
Returns: | Device identifier or NULL on error. |
See also SDL_HapticIndex
SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick *)
Opens a Haptic device for usage from a Joystick device.
You must still close the haptic device seperately. It will not be closed with the joystick.
When opening from a joystick you should first close the haptic device before closing the joystick device. If not, on some implementations the haptic device will also get unallocated and you’ll be unable to use force feedback on that device.
Parameters: | joystick – Joystick to create a haptic device from. |
---|---|
Returns: | A valid haptic device identifier on success or NULL on error. |
See also SDL_HapticOpen
SDL_Haptic * SDL_HapticOpenFromMouse(void)
Tries to open a haptic device from the current mouse.
Returns: | The haptic device identifier or NULL on error. |
---|
See also SDL_MouseIsHaptic
int SDL_HapticOpened(int)
Checks if the haptic device at index has been opened.
Parameters: | device_index – Index to check to see if it has been opened. |
---|---|
Returns: | 1 if it has been opened or 0 if it hasn’t. |
See also SDL_HapticOpen
int SDL_HapticPause(SDL_Haptic *)
Pauses a haptic device.
Device must support the SDL_HAPTIC_PAUSE feature. Call SDL_HapticUnpause() to resume playback.
Do not modify the effects nor add new ones while the device is paused. That can cause all sorts of weird errors.
Parameters: | haptic – Haptic device to pause. |
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticUnpause
unsigned int SDL_HapticQuery(SDL_Haptic *)
Gets the haptic devices supported features in bitwise matter.
Example:
if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) {
printf("We have constant haptic effect!");
}
Parameters: | haptic – The haptic device to query. |
---|---|
Returns: | Haptic features in bitwise manner (OR’d). |
See also SDL_HapticNumEffects
int SDL_HapticRumbleInit(SDL_Haptic *)
Initializes the haptic device for simple rumble playback.
Parameters: | haptic – Haptic device to initialize for simple rumble playback. |
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticOpen
int SDL_HapticRumblePlay(SDL_Haptic *, float, uint32_t)
Runs simple rumble on a haptic device.
Parameters: |
|
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticRumbleSupported
int SDL_HapticRumbleStop(SDL_Haptic *)
Stops the simple rumble on a haptic device.
Parameters: | haptic – Haptic to stop the rumble on. |
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticRumbleSupported
int SDL_HapticRumbleSupported(SDL_Haptic *)
Checks to see if rumble is supported on a haptic device.
Parameters: | haptic – Haptic device to check to see if it supports rumble. |
---|---|
Returns: | SDL_TRUE if effect is supported, SDL_FALSE if it isn’t or -1 on error. |
See also SDL_HapticRumbleInit
int SDL_HapticRunEffect(SDL_Haptic *, int, uint32_t)
Runs the haptic effect on its associated haptic device.
If iterations are SDL_HAPTIC_INFINITY, it’ll run the effect over and over repeating the envelope (attack and fade) every time. If you only want the effect to last forever, set SDL_HAPTIC_INFINITY in the effect’s length parameter.
Parameters: |
|
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticStopEffect
int SDL_HapticSetAutocenter(SDL_Haptic *, int)
Sets the global autocenter of the device.
Autocenter should be between 0 and 100. Setting it to 0 will disable autocentering.
Device must support the SDL_HAPTIC_AUTOCENTER feature.
Parameters: |
|
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticQuery
int SDL_HapticSetGain(SDL_Haptic *, int)
Sets the global gain of the device.
Device must support the SDL_HAPTIC_GAIN feature.
The user may specify the maximum gain by setting the environment variable SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the maximum.
Parameters: |
|
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticQuery
int SDL_HapticStopAll(SDL_Haptic *)
Stops all the currently playing effects on a haptic device.
Parameters: | haptic – Haptic device to stop. |
---|---|
Returns: | 0 on success or -1 on error. |
int SDL_HapticStopEffect(SDL_Haptic *, int)
Stops the haptic effect on its associated haptic device.
Parameters: |
|
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticRunEffect
int SDL_HapticUnpause(SDL_Haptic *)
Unpauses a haptic device.
Call to unpause after SDL_HapticPause().
Parameters: | haptic – Haptic device to pause. |
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticPause
int SDL_HapticUpdateEffect(SDL_Haptic *, int, SDL_HapticEffect *)
Updates the properties of an effect.
Can be used dynamically, although behaviour when dynamically changing direction may be strange. Specifically the effect may reupload itself and start playing from the start. You cannot change the type either when running SDL_HapticUpdateEffect().
Parameters: |
|
---|---|
Returns: | 0 on success or -1 on error. |
See also SDL_HapticNewEffect
SDL_bool SDL_Has3DNow(void)
This function returns true if the CPU has 3DNow! features.
SDL_bool SDL_HasAltiVec(void)
This function returns true if the CPU has AltiVec features.
SDL_bool SDL_HasClipboardText(void)
Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty.
See also SDL_GetClipboardText()
SDL_bool SDL_HasEvent(uint32_t)
Checks to see if certain event types are in the event queue.
SDL_bool SDL_HasEvents(uint32_t, uint32_t)
SDL_bool SDL_HasIntersection(SDL_Rect const *, SDL_Rect const *)
Determine whether two rectangles intersect.
Returns: | SDL_TRUE if there is an intersection, SDL_FALSE otherwise. |
---|
SDL_bool SDL_HasMMX(void)
This function returns true if the CPU has MMX features.
SDL_bool SDL_HasRDTSC(void)
This function returns true if the CPU has the RDTSC instruction.
SDL_bool SDL_HasSSE(void)
This function returns true if the CPU has SSE features.
SDL_bool SDL_HasSSE2(void)
This function returns true if the CPU has SSE2 features.
SDL_bool SDL_HasSSE3(void)
This function returns true if the CPU has SSE3 features.
SDL_bool SDL_HasSSE41(void)
This function returns true if the CPU has SSE4.1 features.
SDL_bool SDL_HasSSE42(void)
This function returns true if the CPU has SSE4.2 features.
SDL_bool SDL_HasScreenKeyboardSupport(void)
Returns whether the platform has some screen keyboard support.
Returns: | SDL_TRUE if some keyboard support is available else SDL_FALSE. |
---|
Not all screen keyboard functions are supported on all platforms.
See also SDL_IsScreenKeyboardShown()
void SDL_HideWindow(SDL_Window *)
Hide a window.
See also SDL_ShowWindow()
size_t SDL_iconv(struct _SDL_iconv_t *, char const * *, size_t *, char * *, size_t *)
int SDL_iconv_close(struct _SDL_iconv_t *)
struct _SDL_iconv_t * SDL_iconv_open(char const *, char const *)
char * SDL_iconv_string(char const *, char const *, char const *, size_t)
This function converts a string between encodings in one pass, returning a string that must be freed with SDL_free() or NULL on error.
int SDL_Init(uint32_t)
This function initializes the subsystems specified by flags Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup signal handlers for some commonly ignored fatal signals (like SIGSEGV).
int SDL_InitSubSystem(uint32_t)
This function initializes specific SDL subsystems
SDL_bool SDL_IntersectRect(SDL_Rect const *, SDL_Rect const *, SDL_Rect *)
Calculate the intersection of two rectangles.
Returns: | SDL_TRUE if there is an intersection, SDL_FALSE otherwise. |
---|
SDL_bool SDL_IntersectRectAndLine(SDL_Rect const *, int *, int *, int *, int *)
Calculate the intersection of a rectangle and line segment.
Returns: | SDL_TRUE if there is an intersection, SDL_FALSE otherwise. |
---|
SDL_bool SDL_IsGameController(int)
Is the joystick on this index supported by the game controller interface?
SDL_bool SDL_IsScreenKeyboardShown(SDL_Window *)
Returns whether the screen keyboard is shown for given window.
Parameters: | window – The window for which screen keyboard should be queried. |
---|---|
Returns: | SDL_TRUE if screen keyboard is shown else SDL_FALSE. |
See also SDL_HasScreenKeyboardSupport()
SDL_bool SDL_IsScreenSaverEnabled(void)
Returns whether the screensaver is currently enabled (default on).
See also SDL_EnableScreenSaver()
SDL_bool SDL_IsTextInputActive(void)
Return whether or not Unicode text input events are enabled.
See also SDL_StartTextInput()
int SDL_isdigit(int)
int SDL_isspace(int)
char * SDL_itoa(int, char *, int)
void SDL_JoystickClose(SDL_Joystick *)
Close a joystick previously opened with SDL_JoystickOpen().
int SDL_JoystickEventState(int)
Enable/disable joystick event polling.
If joystick events are disabled, you must call SDL_JoystickUpdate() yourself and check the state of the joystick when you want joystick information.
The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
SDL_bool SDL_JoystickGetAttached(SDL_Joystick *)
Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
int16_t SDL_JoystickGetAxis(SDL_Joystick *, int)
Get the current state of an axis control on a joystick.
The state is a value ranging from -32768 to 32767.
The axis indices start at index 0.
int SDL_JoystickGetBall(SDL_Joystick *, int, int *, int *)
Get the ball axis change since the last poll.
Returns: | 0, or -1 if you passed it invalid parameters. |
---|
The ball indices start at index 0.
uint8_t SDL_JoystickGetButton(SDL_Joystick *, int)
Get the current state of a button on a joystick.
The button indices start at index 0.
SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int)
Return the GUID for the joystick at this index
SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick *)
Return the GUID for this opened joystick
SDL_JoystickGUID SDL_JoystickGetGUIDFromString(char const *)
convert a string into a joystick formatted guid
void SDL_JoystickGetGUIDString(SDL_JoystickGUID, char *, int)
Return a string representation for this guid. pszGUID must point to at least 33 bytes (32 for the string plus a NULL terminator).
uint8_t SDL_JoystickGetHat(SDL_Joystick *, int)
Get the current state of a POV hat on a joystick.
The hat indices start at index 0.
Returns: | The return value is one of the following positions: |
---|
int32_t SDL_JoystickInstanceID(SDL_Joystick *)
Get the instance ID of an opened joystick or -1 if the joystick is invalid.
int SDL_JoystickIsHaptic(SDL_Joystick *)
Checks to see if a joystick has haptic features.
Parameters: | joystick – Joystick to test for haptic capabilities. |
---|---|
Returns: | 1 if the joystick is haptic, 0 if it isn’t or -1 if an error ocurred. |
See also SDL_HapticOpenFromJoystick
char const * SDL_JoystickName(SDL_Joystick *)
Return the name for this currently opened joystick. If no name can be found, this function returns NULL.
char const * SDL_JoystickNameForIndex(int)
Get the implementation dependent name of a joystick. This can be called before any joysticks are opened. If no name can be found, this function returns NULL.
int SDL_JoystickNumAxes(SDL_Joystick *)
Get the number of general axis controls on a joystick.
int SDL_JoystickNumBalls(SDL_Joystick *)
Get the number of trackballs on a joystick.
Joystick trackballs have only relative motion events associated with them and their state cannot be polled.
int SDL_JoystickNumButtons(SDL_Joystick *)
Get the number of buttons on a joystick.
int SDL_JoystickNumHats(SDL_Joystick *)
Get the number of POV hats on a joystick.
SDL_Joystick * SDL_JoystickOpen(int)
Open a joystick for use. The index passed as an argument refers tothe N’th joystick on the system. This index is the value which will identify this joystick in future joystick events.
Returns: | A joystick identifier, or NULL if an error occurred. |
---|
void SDL_JoystickUpdate(void)
Update the current state of the open joysticks.
This is called automatically by the event loop if any joystick events are enabled.
char * SDL_lltoa(int64_t, char *, int)
SDL_Surface * SDL_LoadBMP_RW(SDL_RWops *, int)
Load a surface from a seekable SDL data stream (memory or file).
If freesrc is non-zero, the stream will be closed after being read.
The new surface should be freed with SDL_FreeSurface().
Returns: | the new surface, or NULL if there was an error. |
---|
int SDL_LoadDollarTemplates(int64_t, SDL_RWops *)
Load Dollar Gesture templates from a file.
void * SDL_LoadFunction(void *, char const *)
Given an object handle, this function looks up the address of the named function in the shared object and returns it. This address is no longer valid after calling SDL_UnloadObject().
void * SDL_LoadObject(char const *)
This function dynamically loads a shared object and returns a pointer to the object handle (or NULL if there was an error). The ‘sofile’ parameter is a system dependent name of the object file.
SDL_AudioSpec * SDL_LoadWAV_RW(SDL_RWops *, int, SDL_AudioSpec *, uint8_t * *, uint32_t *)
This function loads a WAVE from the data source, automatically freeing that source if freesrc is non-zero. For example, to load a WAVE file, you could do:
SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
If this function succeeds, it returns the given SDL_AudioSpec, filled with the audio data format of the wave data, and sets *audio_buf to a malloc()’d buffer containing the audio data, and sets *audio_len to the length of that audio buffer, in bytes. You need to free the audio buffer with SDL_FreeWAV() when you are done with it.
This function returns NULL and sets the SDL error message if the wave file cannot be opened, uses an unknown data format, or is corrupt. Currently raw and MS-ADPCM WAVE files are supported.
void SDL_LockAudio(void)
void SDL_LockAudioDevice(uint32_t)
int SDL_LockMutex(SDL_mutex *)
int SDL_LockSurface(SDL_Surface *)
Sets up a surface for directly accessing the pixels.
Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to and read from surface->pixels, using the pixel format stored in surface->format. Once you are done accessing the surface, you should use SDL_UnlockSurface() to release it.
Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates to 0, then you can read and write to the surface at any time, and the pixel format of the surface will not change.
No operating system or library calls should be made between lock/unlock pairs, as critical system locks may be held during this time.
SDL_LockSurface() returns 0, or -1 if the surface couldn’t be locked.
See also SDL_UnlockSurface()
int SDL_LockTexture(SDL_Texture *, SDL_Rect const *, void * *, int *)
Lock a portion of the texture for write-only pixel access.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the texture is not valid or was not created with |
See also SDL_UnlockTexture()
void SDL_Log(char const *, ...)
Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
void SDL_LogCritical(int, char const *, ...)
Log a message with SDL_LOG_PRIORITY_CRITICAL.
void SDL_LogDebug(int, char const *, ...)
Log a message with SDL_LOG_PRIORITY_DEBUG.
void SDL_LogError(int, char const *, ...)
Log a message with SDL_LOG_PRIORITY_ERROR.
void SDL_LogGetOutputFunction(void(* *)(void *, int, SDL_LogPriority, char const *), void * *)
Get the current log output function.
SDL_LogPriority SDL_LogGetPriority(int)
Get the priority of a particular log category.
void SDL_LogInfo(int, char const *, ...)
Log a message with SDL_LOG_PRIORITY_INFO.
void SDL_LogMessage(int, SDL_LogPriority, char const *, ...)
Log a message with the specified category and priority.
void SDL_LogMessageV(int, SDL_LogPriority, char const *, int32_t)
Log a message with the specified category and priority.
void SDL_LogResetPriorities(void)
Reset all priorities to default.
This is called in SDL_Quit().
void SDL_LogSetAllPriority(SDL_LogPriority)
Set the priority of all log categories.
void SDL_LogSetOutputFunction(void SDL_LogSetOutputFunction(void *, int, SDL_LogPriority, char const *), void *)
This function allows you to replace the default log output function with one of your own.
void SDL_LogSetPriority(int, SDL_LogPriority)
Set the priority of a particular log category.
void SDL_LogVerbose(int, char const *, ...)
Log a message with SDL_LOG_PRIORITY_VERBOSE.
void SDL_LogWarn(int, char const *, ...)
Log a message with SDL_LOG_PRIORITY_WARN.
int SDL_LowerBlit(SDL_Surface *, SDL_Rect *, SDL_Surface *, SDL_Rect *)
This is a semi-private blit function and it performs low-level surface blitting only.
int SDL_LowerBlitScaled(SDL_Surface *, SDL_Rect *, SDL_Surface *, SDL_Rect *)
This is a semi-private blit function and it performs low-level surface scaled blitting only.
char * SDL_ltoa(long, char *, int)
int SDL_main(int, char * *)
The prototype for the application’s main() function
void * SDL_malloc(size_t)
uint32_t SDL_MapRGB(SDL_PixelFormat const *, uint8_t, uint8_t, uint8_t)
Maps an RGB triple to an opaque pixel value for a given pixel format.
See also SDL_MapRGBA
uint32_t SDL_MapRGBA(SDL_PixelFormat const *, uint8_t, uint8_t, uint8_t, uint8_t)
Maps an RGBA quadruple to a pixel value for a given pixel format.
See also SDL_MapRGB
uint32_t SDL_MasksToPixelFormatEnum(int, uint32_t, uint32_t, uint32_t, uint32_t)
Convert a bpp and RGBA masks to an enumerated pixel format.
Returns: | The pixel format, or |
---|
See also SDL_PixelFormatEnumToMasks()
void SDL_MaximizeWindow(SDL_Window *)
Make a window as large as possible.
See also SDL_RestoreWindow()
int SDL_memcmp(void const *, void const *, size_t)
void * SDL_memcpy(void *, void const *, size_t)
void * SDL_memmove(void *, void const *, size_t)
void * SDL_memset(void *, int, size_t)
void SDL_MinimizeWindow(SDL_Window *)
Minimize a window to an iconic representation.
See also SDL_RestoreWindow()
void SDL_MixAudio(uint8_t *, uint8_t const *, uint32_t, int)
This takes two audio buffers of the playing audio format and mixes them, performing addition, volume adjustment, and overflow clipping. The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME for full audio volume. Note this does not change hardware volume. This is provided for convenience you can mix your own audio data.
void SDL_MixAudioFormat(uint8_t *, uint8_t const *, uint16_t, uint32_t, int)
This works like SDL_MixAudio(), but you specify the audio format instead of using the format of audio device 1. Thus it can be used when no audio device is open at all.
int SDL_MouseIsHaptic(void)
Gets whether or not the current mouse has haptic capabilities.
Returns: | SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn’t. |
---|
See also SDL_HapticOpenFromMouse
alias of SDL_mutex
int SDL_NumHaptics(void)
Count the number of haptic devices attached to the system.
Returns: | Number of haptic devices detected on the system. |
---|
int SDL_NumJoysticks(void)
Count the number of joysticks attached to the system right now
int SDL_OpenAudio(SDL_AudioSpec *, SDL_AudioSpec *)
This function opens the audio device with the desired parameters, and returns 0 if successful, placing the actual hardware parameters in the structure pointed to by obtained. If obtained is NULL, the audio data passed to the callback function will be guaranteed to be in the requested format, and will be automatically converted to the hardware audio format if necessary. This function returns -1 if it failed to open the audio device, or couldn’t set up the audio thread.
When filling in the desired audio spec structure,desired->freq should be the desired audio frequency in samples-per- second.
desired->format should be the desired audio format.
desired->samples is the desired size of the audio buffer, in 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 seem to range between 512 and 8096 inclusive, depending on the application and CPU speed. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio buffer in time. A stereo sample consists of both right and left channels in LR ordering. Note that the number of samples is directly related to time by the following formula::
ms = (samples*1000)/freq
desired->size is the size in bytes of the audio buffer, and is calculated by SDL_OpenAudio().
desired->silence is the value used to set the buffer to silence, and is calculated by SDL_OpenAudio().
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_LockAudio() and SDL_UnlockAudio() in your code.
desired->userdata is passed as the first parameter to your callback function.
The audio device starts out playing silence when it’s opened, and should be enabled for playing by calling SDL_PauseAudio(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.
uint32_t SDL_OpenAudioDevice(char const *, int, SDL_AudioSpec const *, SDL_AudioSpec *, int)
Open a specific audio device. Passing in a device name of NULL requests the most reasonable default (and is equivalent to calling SDL_OpenAudio()).
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.
Returns: | 0 on error, a valid device ID that is >= 2 on success. |
---|
SDL_OpenAudio(), unlike this function, always acts on device ID 1.
void SDL_PauseAudio(int)
void SDL_PauseAudioDevice(uint32_t, int)
int SDL_PeepEvents(SDL_Event *, int, SDL_eventaction, uint32_t, uint32_t)
Checks the event queue for messages and optionally returns them.
If action is SDL_ADDEVENT, up to numevents events will be added to the back of the event queue.
If action is SDL_PEEKEVENT, up to numevents events at the front of the event queue, within the specified minimum and maximum type, will be returned and will not be removed from the queue.
If action is SDL_GETEVENT, up to numevents events at the front of the event queue, within the specified minimum and maximum type, will be returned and will be removed from the queue.
Returns: | The number of events actually stored, or -1 if there was an error. |
---|
This function is thread-safe.
SDL_bool SDL_PixelFormatEnumToMasks(uint32_t, int *, uint32_t *, uint32_t *, uint32_t *, uint32_t *)
Convert one of the enumerated pixel formats to a bpp and RGBA masks.
Returns: | SDL_TRUE, or SDL_FALSE if the conversion wasn’t possible. |
---|
See also SDL_MasksToPixelFormatEnum()
int SDL_PollEvent(SDL_Event *)
Polls for currently pending events.
Returns: | 1 if there are any pending events, or 0 if there are none available. |
---|---|
Parameters: | event – If not NULL, the next event is removed from the queue and stored in that area. |
double SDL_pow(double, double)
void SDL_PumpEvents(void)
Pumps the event loop, gathering events from the input devices.
This function updates the event queue and internal input device state.
This should only be run in the thread that sets the video mode.
int SDL_PushEvent(SDL_Event *)
Add an event to the event queue.
Returns: | 1 on success, 0 if the event was filtered, or -1 if the event queue was full or there was some other error. |
---|
void SDL_qsort(void *, size_t, size_t, int SDL_qsort(void const *, void const *))
int SDL_QueryTexture(SDL_Texture *, uint32_t *, int *, int *, int *)
Query the attributes of a texture.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the texture is not valid. |
void SDL_Quit(void)
This function cleans up all initialized subsystems. You should call it upon all exit conditions.
void SDL_QuitSubSystem(uint32_t)
This function cleans up specific SDL subsystems
void SDL_RaiseWindow(SDL_Window *)
Raise a window above other windows and set the input focus.
uint16_t SDL_ReadBE16(SDL_RWops *)
uint32_t SDL_ReadBE32(SDL_RWops *)
uint64_t SDL_ReadBE64(SDL_RWops *)
uint16_t SDL_ReadLE16(SDL_RWops *)
uint32_t SDL_ReadLE32(SDL_RWops *)
uint64_t SDL_ReadLE64(SDL_RWops *)
uint8_t SDL_ReadU8(SDL_RWops *)
void * SDL_realloc(void *, size_t)
int SDL_RecordGesture(int64_t)
Begin Recording a gesture on the specified touch, or all touches (-1)
uint32_t SDL_RegisterEvents(int)
This function allocates a set of user-defined events, and returns the beginning event number for that set of events.
If there aren’t enough user-defined events left, this function returns (Uint32)-1
SDL_bool SDL_RemoveTimer(int)
Remove a timer knowing its ID.
Returns: | A boolean value indicating success or failure. |
---|
It is not safe to remove a timer multiple times.
int SDL_RenderClear(SDL_Renderer *)
Clear the current rendering target with the drawing color.
This function clears the entire rendering target, ignoring the viewport.
Returns: | 0 on success, or -1 on error |
---|
int SDL_RenderCopy(SDL_Renderer *, SDL_Texture *, SDL_Rect const *, SDL_Rect const *)
Copy a portion of the texture to the current rendering target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_RenderCopyEx(SDL_Renderer *, SDL_Texture *, SDL_Rect const *, SDL_Rect const *, double, SDL_Point const *, SDL_RendererFlip)
Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_RenderDrawLine(SDL_Renderer *, int, int, int, int)
Draw a line on the current rendering target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_RenderDrawLines(SDL_Renderer *, SDL_Point const *, int)
Draw a series of connected lines on the current rendering target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_RenderDrawPoint(SDL_Renderer *, int, int)
Draw a point on the current rendering target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_RenderDrawPoints(SDL_Renderer *, SDL_Point const *, int)
Draw multiple points on the current rendering target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_RenderDrawRect(SDL_Renderer *, SDL_Rect const *)
Draw a rectangle on the current rendering target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_RenderDrawRects(SDL_Renderer *, SDL_Rect const *, int)
Draw some number of rectangles on the current rendering target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_RenderFillRect(SDL_Renderer *, SDL_Rect const *)
Fill a rectangle on the current rendering target with the drawing color.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_RenderFillRects(SDL_Renderer *, SDL_Rect const *, int)
Fill some number of rectangles on the current rendering target with the drawing color.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
void SDL_RenderGetClipRect(SDL_Renderer *, SDL_Rect *)
Get the clip rectangle for the current target.
Parameters: |
|
---|
See also SDL_RenderSetClipRect()
void SDL_RenderGetLogicalSize(SDL_Renderer *, int *, int *)
Get device independent resolution for rendering.
Parameters: |
|
---|
See also SDL_RenderSetLogicalSize()
void SDL_RenderGetScale(SDL_Renderer *, float *, float *)
Get the drawing scale for the current target.
Parameters: |
|
---|
See also SDL_RenderSetScale()
void SDL_RenderGetViewport(SDL_Renderer *, SDL_Rect *)
Get the drawing area for the current target.
See also SDL_RenderSetViewport()
void SDL_RenderPresent(SDL_Renderer *)
Update the screen with rendering performed.
int SDL_RenderReadPixels(SDL_Renderer *, SDL_Rect const *, uint32_t, void *, int)
Read pixels from the current rendering target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if pixel reading is not supported. |
This is a very slow operation, and should not be used frequently.
int SDL_RenderSetClipRect(SDL_Renderer *, SDL_Rect const *)
Set the clip rectangle for the current target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
See also SDL_RenderGetClipRect()
int SDL_RenderSetLogicalSize(SDL_Renderer *, int, int)
Set device independent resolution for rendering.
Parameters: |
|
---|
This function uses the viewport and scaling functionality to allow a fixed logical resolution for rendering, regardless of the actual output resolution. If the actual output resolution doesn’t have the same aspect ratio the output rendering will be centered within the output display.
If the output display is a window, mouse events in the window will be filtered and scaled so they seem to arrive within the logical resolution.
If this function results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints.
See also SDL_RenderGetLogicalSize()
int SDL_RenderSetScale(SDL_Renderer *, float, float)
Set the drawing scale for rendering on the current target.
Parameters: |
|
---|
The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer. This allows resolution independent drawing with a single coordinate system.
If this results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints. For best results use integer scaling factors.
See also SDL_RenderGetScale()
int SDL_RenderSetViewport(SDL_Renderer *, SDL_Rect const *)
Set the drawing area for rendering on the current target.
Parameters: |
|
---|
The x,y of the viewport rect represents the origin for rendering.
Returns: | 0 on success, or -1 on error |
---|
If the window associated with the renderer is resized, the viewport is automatically reset.
See also SDL_RenderGetViewport()
SDL_bool SDL_RenderTargetSupported(SDL_Renderer *)
Determines whether a window supports the use of render targets.
Parameters: | renderer – The renderer that will be checked |
---|---|
Returns: | SDL_TRUE if supported, SDL_FALSE if not. |
SDL_assert_state SDL_ReportAssertion(SDL_assert_data *, char const *, char const *, int)
void SDL_ResetAssertionReport(void)
Reset the list of all assertion failures.
Reset list of all assertions triggered.
See also SDL_GetAssertionReport
void SDL_RestoreWindow(SDL_Window *)
Restore the size and position of a minimized or maximized window.
See also SDL_MaximizeWindow()
int SDL_SaveAllDollarTemplates(SDL_RWops *)
Save all currently loaded Dollar Gesture templates.
int SDL_SaveBMP_RW(SDL_Surface *, SDL_RWops *, int)
Save a surface to a seekable SDL data stream (memory or file).
If freedst is non-zero, the stream will be closed after being written.
Returns: | 0 if successful or -1 if there was an error. |
---|
int SDL_SaveDollarTemplate(int64_t, SDL_RWops *)
Save a currently loaded Dollar Gesture template.
double SDL_scalbn(double, int)
alias of SDL_sem
int SDL_SemPost(SDL_sem *)
Atomically increases the semaphore’s count (not blocking).
Returns: | 0, or -1 on error. |
---|
int SDL_SemTryWait(SDL_sem *)
Non-blocking variant of SDL_SemWait().
Returns: | 0 if the wait succeeds, |
---|
uint32_t SDL_SemValue(SDL_sem *)
Returns the current count of the semaphore.
int SDL_SemWait(SDL_sem *)
This function suspends the calling thread until the semaphore pointed to by sem has a positive count. It then atomically decreases the semaphore count.
int SDL_SemWaitTimeout(SDL_sem *, uint32_t)
Variant of SDL_SemWait() with a timeout in milliseconds.
Returns: | 0 if the wait succeeds, |
---|
On some platforms this function is implemented by looping with a delay of 1 ms, and so should be avoided if possible.
void SDL_SetAssertionHandler(SDL_assert_state SDL_SetAssertionHandler(SDL_assert_data const *, void *), void *)
Set an application-defined assertion handler.
This allows an app to show its own assertion UI and/or force the response to an assertion failure. If the app doesn’t provide this, SDL will try to do the right thing, popping up a 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 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()!
Returns: | SDL_assert_state value of how to handle the assertion failure. |
---|---|
Parameters: |
|
SDL_bool SDL_SetClipRect(SDL_Surface *, SDL_Rect const *)
Sets the clipping rectangle for the destination surface in a blit.
If the clip rectangle is NULL, clipping will be disabled.
If the clip rectangle doesn’t intersect the surface, the function will return SDL_FALSE and blits will be completely clipped. Otherwise the function returns SDL_TRUE and blits to the surface will be clipped to the intersection of the surface area and the clipping rectangle.
Note that blits are automatically clipped to the edges of the source and destination surfaces.
int SDL_SetClipboardText(char const *)
Put UTF-8 text into the clipboard.
See also SDL_GetClipboardText()
int SDL_SetColorKey(SDL_Surface *, int, uint32_t)
Sets the color key (transparent pixel) in a blittable surface.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the surface is not valid |
You can pass SDL_RLEACCEL to enable RLE accelerated blits.
void SDL_SetCursor(SDL_Cursor *)
Set the active cursor.
int SDL_SetError(char const *, ...)
void SDL_SetEventFilter(int SDL_SetEventFilter(void *, SDL_Event *), void *)
Sets up a filter to process all events before they change internal state and are posted to the internal event queue.
The filter is prototyped as:
int SDL_EventFilter(void *userdata, SDL_Event * event);
If the filter returns 1, 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.
Be very careful of what you do in the event filter function, as it may run in a different thread!
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.
If the quit event is generated by an interrupt signal, it will bypass the internal queue and be delivered to the application at the next event poll.
SDL_bool SDL_SetHint(char const *, char const *)
Set a hint with normal priority.
Returns: | SDL_TRUE if the hint was set, SDL_FALSE otherwise |
---|
SDL_bool SDL_SetHintWithPriority(char const *, char const *, SDL_HintPriority)
Set a hint with a specific priority.
The priority controls the behavior when setting a hint that already has a value. Hints will replace existing hints of their priority and lower. Environment variables are considered to have override priority.
Returns: | SDL_TRUE if the hint was set, SDL_FALSE otherwise |
---|
void SDL_SetMainReady(void)
This is called by the real SDL main function to let the rest of the library know that initialization was done properly.
Calling this yourself without knowing what you’re doing can cause crashes and hard to diagnose problems with your application.
void SDL_SetModState(SDL_Keymod)
Set the current key modifier state for the keyboard.
This does not change the keyboard state, only the key modifier flags.
int SDL_SetPaletteColors(SDL_Palette *, SDL_Color const *, int, int)
Set a range of colors in a palette.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if not all of the colors could be set. |
int SDL_SetPixelFormatPalette(SDL_PixelFormat *, SDL_Palette *)
Set the palette for a pixel format structure.
int SDL_SetRelativeMouseMode(SDL_bool)
Set relative mouse mode.
Parameters: | enabled – Whether or not to enable relative mode |
---|---|
Returns: | 0 on success, or -1 if relative mode is not supported. |
While the mouse is in relative mode, the cursor is hidden, and the driver will try to report continuous motion in the current window. Only relative motion events will be delivered, the mouse position will not change.
This function will flush any pending mouse motion.
See also SDL_GetRelativeMouseMode()
int SDL_SetRenderDrawBlendMode(SDL_Renderer *, SDL_BlendMode)
Set the blend mode used for drawing operations (Fill and Line).
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
If the blend mode is not supported, the closest supported mode is chosen.
See also SDL_GetRenderDrawBlendMode()
int SDL_SetRenderDrawColor(SDL_Renderer *, uint8_t, uint8_t, uint8_t, uint8_t)
Set the color used for drawing operations (Rect, Line and Clear).
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
int SDL_SetRenderTarget(SDL_Renderer *, SDL_Texture *)
Set a texture as the current rendering target.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 on error |
See also SDL_GetRenderTarget()
int SDL_SetSurfaceAlphaMod(SDL_Surface *, uint8_t)
Set an additional alpha value used in blit operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the surface is not valid. |
See also SDL_GetSurfaceAlphaMod()
int SDL_SetSurfaceBlendMode(SDL_Surface *, SDL_BlendMode)
Set the blend mode used for blit operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the parameters are not valid. |
See also SDL_GetSurfaceBlendMode()
int SDL_SetSurfaceColorMod(SDL_Surface *, uint8_t, uint8_t, uint8_t)
Set an additional color value used in blit operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the surface is not valid. |
See also SDL_GetSurfaceColorMod()
int SDL_SetSurfacePalette(SDL_Surface *, SDL_Palette *)
Set the palette used by a surface.
Returns: | 0, or -1 if the surface format doesn’t use a palette. |
---|
A single palette can be shared with many surfaces.
int SDL_SetSurfaceRLE(SDL_Surface *, int)
Sets the RLE acceleration hint for a surface.
Returns: | 0 on success, or -1 if the surface is not valid |
---|
If RLE is enabled, colorkey and alpha blending blits are much faster, but the surface must be locked before directly accessing the pixels.
void SDL_SetTextInputRect(SDL_Rect *)
Set the rectangle used to type Unicode text inputs. This is used as a hint for IME and on-screen keyboard placement.
See also SDL_StartTextInput()
int SDL_SetTextureAlphaMod(SDL_Texture *, uint8_t)
Set an additional alpha value used in render copy operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the texture is not valid or alpha modulation is not supported. |
See also SDL_GetTextureAlphaMod()
int SDL_SetTextureBlendMode(SDL_Texture *, SDL_BlendMode)
Set the blend mode used for texture copy operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the texture is not valid or the blend mode is not supported. |
If the blend mode is not supported, the closest supported mode is chosen.
See also SDL_GetTextureBlendMode()
int SDL_SetTextureColorMod(SDL_Texture *, uint8_t, uint8_t, uint8_t)
Set an additional color value used in render copy operations.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the texture is not valid or color modulation is not supported. |
See also SDL_GetTextureColorMod()
int SDL_SetThreadPriority(SDL_ThreadPriority)
Set the priority for the current thread
void SDL_SetWindowBordered(SDL_Window *, SDL_bool)
Set the border state of a window.
This will add or remove the window’s SDL_WINDOW_BORDERLESS flag and add or remove the border from the actual window. This is a no-op if the window’s border already matches the requested state.
Parameters: |
|
---|
You can’t change the border state of a fullscreen window.
See also SDL_GetWindowFlags()
int SDL_SetWindowBrightness(SDL_Window *, float)
Set the brightness (gamma correction) for a window.
Returns: | 0 on success, or -1 if setting the brightness isn’t supported. |
---|
See also SDL_GetWindowBrightness()
void * SDL_SetWindowData(SDL_Window *, char const *, void *)
Associate an arbitrary named pointer with a window.
Parameters: |
|
---|---|
Returns: | The previous value associated with ‘name’ |
The name is case-sensitive.
See also SDL_GetWindowData()
int SDL_SetWindowDisplayMode(SDL_Window *, SDL_DisplayMode const *)
Set the display mode used when a fullscreen window is visible.
By default the window’s dimensions and the desktop format and refresh rate are used.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if setting the display mode failed. |
See also SDL_GetWindowDisplayMode()
int SDL_SetWindowFullscreen(SDL_Window *, uint32_t)
Set a window’s fullscreen state.
Returns: | 0 on success, or -1 if setting the display mode failed. |
---|
See also SDL_SetWindowDisplayMode()
int SDL_SetWindowGammaRamp(SDL_Window *, uint16_t const *, uint16_t const *, uint16_t const *)
Set the gamma ramp for a window.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if gamma ramps are unsupported. |
Set the gamma translation table for the red, green, and blue channels of the video hardware. Each table is an array of 256 16-bit quantities, representing a mapping between the input and output for that channel. The input is the index into the array, and the output is the 16-bit gamma value at that index, scaled to the output color precision.
See also SDL_GetWindowGammaRamp()
void SDL_SetWindowGrab(SDL_Window *, SDL_bool)
Set a window’s input grab mode.
Parameters: |
|
---|
See also SDL_GetWindowGrab()
void SDL_SetWindowIcon(SDL_Window *, SDL_Surface *)
Set the icon for a window.
Parameters: |
|
---|
void SDL_SetWindowMaximumSize(SDL_Window *, int, int)
Set the maximum size of a window’s client area.
Parameters: |
|
---|
You can’t change the maximum size of a fullscreen window, it automatically matches the size of the display mode.
See also SDL_GetWindowMaximumSize()
void SDL_SetWindowMinimumSize(SDL_Window *, int, int)
Set the minimum size of a window’s client area.
Parameters: |
|
---|
You can’t change the minimum size of a fullscreen window, it automatically matches the size of the display mode.
See also SDL_GetWindowMinimumSize()
void SDL_SetWindowPosition(SDL_Window *, int, int)
Set the position of a window.
Parameters: |
|
---|
The window coordinate origin is the upper left of the display.
See also SDL_GetWindowPosition()
void SDL_SetWindowSize(SDL_Window *, int, int)
Set the size of a window’s client area.
Parameters: |
|
---|
You can’t change the size of a fullscreen window, it automatically matches the size of the display mode.
See also SDL_GetWindowSize()
void SDL_SetWindowTitle(SDL_Window *, char const *)
Set the title of a window, in UTF-8 format.
See also SDL_GetWindowTitle()
int SDL_setenv(char const *, char const *, int)
int SDL_ShowCursor(int)
Toggle whether or not the cursor is shown.
Parameters: | toggle – 1 to show the cursor, 0 to hide it, -1 to query the current state. |
---|---|
Returns: | 1 if the cursor is shown, or 0 if the cursor is hidden. |
int SDL_ShowMessageBox(SDL_MessageBoxData const *, int *)
Create a modal message box.
Parameters: |
|
---|---|
Returns: | -1 on error, otherwise 0 and buttonid contains user id of button hit or -1 if dialog was closed. |
This function should be called on the thread that created the parent window, or on the main thread if the messagebox has no parent. It will block execution of that thread until the user clicks a button or closes the messagebox.
int SDL_ShowSimpleMessageBox(uint32_t, char const *, char const *, SDL_Window *)
Create a simple modal message box.
Parameters: |
|
---|---|
Returns: | 0 on success, -1 on error |
See also SDL_ShowMessageBox
void SDL_ShowWindow(SDL_Window *)
Show a window.
See also SDL_HideWindow()
double SDL_sin(double)
float SDL_sinf(float)
int SDL_snprintf(char *, size_t, char const *, ...)
int SDL_SoftStretch(SDL_Surface *, SDL_Rect const *, SDL_Surface *, SDL_Rect const *)
Perform a fast, low quality, stretch blit between two surfaces of the same pixel format.
This function uses a static buffer, and is not thread-safe.
double SDL_sqrt(double)
int SDL_sscanf(char const *, char const *, ...)
void SDL_StartTextInput(void)
Start accepting Unicode text input events. This function will show the on-screen keyboard if supported.
See also SDL_StopTextInput()
void SDL_StopTextInput(void)
Stop receiving any text input events. This function will hide the on- screen keyboard if supported.
See also SDL_StartTextInput()
int SDL_strcasecmp(char const *, char const *)
char * SDL_strchr(char const *, int)
int SDL_strcmp(char const *, char const *)
char * SDL_strdup(char const *)
size_t SDL_strlcat(char *, char const *, size_t)
size_t SDL_strlcpy(char *, char const *, size_t)
size_t SDL_strlen(char const *)
char * SDL_strlwr(char *)
int SDL_strncasecmp(char const *, char const *, size_t)
int SDL_strncmp(char const *, char const *, size_t)
char * SDL_strrchr(char const *, int)
char * SDL_strrev(char *)
char * SDL_strstr(char const *, char const *)
double SDL_strtod(char const *, char * *)
long SDL_strtol(char const *, char * *, int)
int64_t SDL_strtoll(char const *, char * *, int)
unsigned long SDL_strtoul(char const *, char * *, int)
uint64_t SDL_strtoull(char const *, char * *, int)
char * SDL_strupr(char *)
unsigned long SDL_ThreadID(void)
Get the thread identifier for the current thread.
int SDL_tolower(int)
int SDL_toupper(int)
int SDL_TryLockMutex(SDL_mutex *)
Try to lock the mutex
Returns: | 0, SDL_MUTEX_TIMEDOUT, or -1 on error |
---|
char * SDL_uitoa(unsigned int, char *, int)
char * SDL_ulltoa(uint64_t, char *, int)
char * SDL_ultoa(unsigned long, char *, int)
void SDL_UnionRect(SDL_Rect const *, SDL_Rect const *, SDL_Rect *)
Calculate the union of two rectangles.
void SDL_UnloadObject(void *)
Unload a shared object from memory.
void SDL_UnlockAudio(void)
void SDL_UnlockAudioDevice(uint32_t)
int SDL_UnlockMutex(SDL_mutex *)
void SDL_UnlockSurface(SDL_Surface *)
See also SDL_LockSurface()
void SDL_UnlockTexture(SDL_Texture *)
Unlock a texture, uploading the changes to video memory, if needed.
See also SDL_LockTexture()
int SDL_UpdateTexture(SDL_Texture *, SDL_Rect const *, void const *, int)
Update the given texture rectangle with new pixel data.
Parameters: |
|
---|---|
Returns: | 0 on success, or -1 if the texture is not valid. |
This is a fairly slow function.
int SDL_UpdateWindowSurface(SDL_Window *)
Copy the window surface to the screen.
Returns: | 0 on success, or -1 on error. |
---|
See also SDL_GetWindowSurface()
int SDL_UpdateWindowSurfaceRects(SDL_Window *, SDL_Rect const *, int)
Copy a number of rectangles on the window surface to the screen.
Returns: | 0 on success, or -1 on error. |
---|
See also SDL_GetWindowSurface()
int SDL_UpperBlit(SDL_Surface *, SDL_Rect const *, SDL_Surface *, SDL_Rect *)
This is the public blit function, SDL_BlitSurface(), and it performs rectangle validation and clipping before passing it to SDL_LowerBlit()
int SDL_UpperBlitScaled(SDL_Surface *, SDL_Rect const *, SDL_Surface *, SDL_Rect *)
This is the public scaled blit function, SDL_BlitScaled(), and it performs rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
size_t SDL_utf8strlcpy(char *, char const *, size_t)
alias of SDL_version
int SDL_VideoInit(char const *)
Initialize the video subsystem, optionally specifying a video driver.
Parameters: | driver_name – Initialize a specific driver by name, or NULL for the default video driver. |
---|---|
Returns: | 0 on success, -1 on error |
This function initializes the video subsystem; setting up a connection to the window manager, etc, and determines the available display modes and pixel formats, but does not initialize a window or graphics mode.
See also SDL_VideoQuit()
void SDL_VideoQuit(void)
Shuts down the video subsystem.
This function closes all windows, and restores the original video mode.
See also SDL_VideoInit()
int SDL_vsnprintf(char *, size_t, char const *, int32_t)
int SDL_WaitEvent(SDL_Event *)
Waits indefinitely for the next available event.
Returns: | 1, or 0 if there was an error while waiting for events. |
---|---|
Parameters: | event – If not NULL, the next event is removed from the queue and stored in that area. |
int SDL_WaitEventTimeout(SDL_Event *, int)
Waits until the specified timeout (in milliseconds) for the next available event.
Returns: | 1, or 0 if there was an error while waiting for events. |
---|---|
Parameters: |
|
void SDL_WaitThread(SDL_Thread *, int *)
Wait for a thread to finish. Threads that haven’t been detached will remain (as a “zombie”) until this function cleans them up. Not doing so is a resource leak.
Once a thread has been cleaned up through this function, the SDL_Thread that references it becomes invalid and should not be referenced again. As such, only one thread may call SDL_WaitThread() on another.
The return code for the thread function is placed in the area pointed to by status, if status is not NULL.
You may not wait on a thread that has been used in a call to SDL_DetachThread(). Use either that function or this one, but not both, or behavior is undefined.
It is safe to pass NULL to this function; it is a no-op.
void SDL_WarpMouseInWindow(SDL_Window *, int, int)
Moves the mouse to the given position within the window.
Parameters: |
|
---|
This function generates a mouse motion event
uint32_t SDL_WasInit(uint32_t)
This function returns a mask of the specified subsystems which have previously been initialized.
If flags is 0, it returns a mask of all initialized subsystems.
size_t SDL_wcslcat(wchar_t *, wchar_t const *, size_t)
size_t SDL_wcslcpy(wchar_t *, wchar_t const *, size_t)
size_t SDL_wcslen(wchar_t const *)
size_t SDL_WriteBE16(SDL_RWops *, uint16_t)
size_t SDL_WriteBE32(SDL_RWops *, uint32_t)
size_t SDL_WriteBE64(SDL_RWops *, uint64_t)
size_t SDL_WriteLE16(SDL_RWops *, uint16_t)
size_t SDL_WriteLE32(SDL_RWops *, uint32_t)
size_t SDL_WriteLE64(SDL_RWops *, uint64_t)
size_t SDL_WriteU8(SDL_RWops *, uint8_t)