SDL API

The sdl module exposes libSDL2’s C API with some Pythonic renaming.

See also https://wiki.libsdl.org/FrontPage

sdl.AudioCVT

alias of SDL_AudioCVT

sdl.AudioSpec

alias of SDL_AudioSpec

sdl.BITSPERPIXEL(X)
sdl.BYTESPERPIXEL(X)
sdl.Color

alias of SDL_Color

sdl.CommonEvent

alias of SDL_CommonEvent

sdl.ControllerAxisEvent

alias of SDL_ControllerAxisEvent

sdl.ControllerButtonEvent

alias of SDL_ControllerButtonEvent

sdl.ControllerDeviceEvent

alias of SDL_ControllerDeviceEvent

sdl.Cursor

alias of SDL_Cursor

sdl.DEFINE_PIXELFORMAT(type, order, layout, bits, bytes)
sdl.DEFINE_PIXELFOURCC(A, B, C, D)

Return a four-character code as a uint32.

sdl.DisplayMode

alias of SDL_DisplayMode

sdl.DollarGestureEvent

alias of SDL_DollarGestureEvent

sdl.DropEvent

alias of SDL_DropEvent

sdl.Event

alias of SDL_Event

sdl.FOURCC(A, B, C, D)

Return a four-character code as a uint32.

sdl.Finger

alias of SDL_Finger

sdl.GL_BindTexture(texture, texw=None, texh=None)

int SDL_GL_BindTexture(SDL_Texture *, float *, float *)

Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions.

Parameters:
  • texture – The SDL texture to bind
  • texw – A pointer to a float that will be filled with the texture width
  • texh – A pointer to a float that will be filled with the texture height
Returns:

0 on success, or -1 if the operation is not supported

sdl.GL_CreateContext(window)

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()

sdl.GL_DeleteContext(context)

void SDL_GL_DeleteContext(void *)

Delete an OpenGL context.

See also SDL_GL_CreateContext()

sdl.GL_ExtensionSupported(extension)

SDL_bool SDL_GL_ExtensionSupported(char const *)

Return true if an OpenGL extension is supported for the current context.

sdl.GL_GetAttribute(attr, value=None)

int SDL_GL_GetAttribute(SDL_GLattr, int *)

Get the actual value for an attribute from the current context.

sdl.GL_GetCurrentContext()

void * SDL_GL_GetCurrentContext(void)

Get the currently active OpenGL context.

sdl.GL_GetCurrentWindow()

SDL_Window * SDL_GL_GetCurrentWindow(void)

Get the currently active OpenGL window.

sdl.GL_GetProcAddress(proc)

void * SDL_GL_GetProcAddress(char const *)

Get the address of an OpenGL function.

sdl.GL_GetSwapInterval()

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()

sdl.GL_LoadLibrary(path)

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()

sdl.GL_MakeCurrent(window, context)

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.

sdl.GL_SetAttribute(attr, value)

int SDL_GL_SetAttribute(SDL_GLattr, int)

Set an OpenGL window attribute before window creation.

sdl.GL_SetSwapInterval(interval)

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()

sdl.GL_SwapWindow(window)

void SDL_GL_SwapWindow(SDL_Window *)

Swap the OpenGL buffers for a window, if double-buffering is supported.

sdl.GL_UnbindTexture(texture)

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
sdl.GL_UnloadLibrary()

void SDL_GL_UnloadLibrary(void)

Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().

See also SDL_GL_LoadLibrary()

sdl.GameController

alias of SDL_GameController

sdl.GameControllerButtonBind

alias of SDL_GameControllerButtonBind

sdl.Haptic

alias of SDL_Haptic

sdl.HapticCondition

alias of SDL_HapticCondition

sdl.HapticConstant

alias of SDL_HapticConstant

sdl.HapticCustom

alias of SDL_HapticCustom

sdl.HapticDirection

alias of SDL_HapticDirection

sdl.HapticEffect

alias of SDL_HapticEffect

sdl.HapticLeftRight

alias of SDL_HapticLeftRight

sdl.HapticPeriodic

alias of SDL_HapticPeriodic

sdl.HapticRamp

alias of SDL_HapticRamp

sdl.ISPIXELFORMAT_ALPHA(format)
sdl.ISPIXELFORMAT_FOURCC(format)
sdl.ISPIXELFORMAT_INDEXED(format)
sdl.JoyAxisEvent

alias of SDL_JoyAxisEvent

sdl.JoyBallEvent

alias of SDL_JoyBallEvent

sdl.JoyButtonEvent

alias of SDL_JoyButtonEvent

sdl.JoyDeviceEvent

alias of SDL_JoyDeviceEvent

sdl.JoyHatEvent

alias of SDL_JoyHatEvent

sdl.Joystick

alias of SDL_Joystick

sdl.JoystickGUID

alias of SDL_JoystickGUID

sdl.KeyboardEvent

alias of SDL_KeyboardEvent

sdl.Keysym

alias of SDL_Keysym

sdl.MessageBoxButtonData

alias of SDL_MessageBoxButtonData

sdl.MessageBoxColor

alias of SDL_MessageBoxColor

sdl.MessageBoxColorScheme

alias of SDL_MessageBoxColorScheme

sdl.MessageBoxData

alias of SDL_MessageBoxData

sdl.MouseButtonEvent

alias of SDL_MouseButtonEvent

sdl.MouseMotionEvent

alias of SDL_MouseMotionEvent

sdl.MouseWheelEvent

alias of SDL_MouseWheelEvent

sdl.MultiGestureEvent

alias of SDL_MultiGestureEvent

sdl.OSEvent

alias of SDL_OSEvent

sdl.PIXELFLAG(X)
sdl.PIXELLAYOUT(X)
sdl.PIXELORDER(X)
sdl.PIXELTYPE(X)
sdl.Palette

alias of SDL_Palette

sdl.PixelFormat

alias of SDL_PixelFormat

sdl.Point

alias of SDL_Point

sdl.QuitEvent

alias of SDL_QuitEvent

sdl.RWFromConstMem(mem, size)

SDL_RWops * SDL_RWFromConstMem(void const *, int)

sdl.RWFromFP(fp, autoclose)

SDL_RWops * SDL_RWFromFP(FILE *, SDL_bool)

sdl.RWFromFile(file, mode)

SDL_RWops * SDL_RWFromFile(char const *, char const *)

sdl.RWFromMem(mem, size)

SDL_RWops * SDL_RWFromMem(void *, int)

sdl.RWops

alias of SDL_RWops

sdl.Rect

alias of SDL_Rect

sdl.Renderer

alias of SDL_Renderer

sdl.RendererInfo

alias of SDL_RendererInfo

exception sdl.SDLError

Fetch and wrap the current SDL error message.

class sdl.Struct(data=None, ffi=<cffi.api.FFI object at 0x0000000004d3fd38>)

Wrap a cffi structure in a Python class, hiding allocation and dereferencing.

sdl.Surface

alias of SDL_Surface

sdl.SysWMEvent

alias of SDL_SysWMEvent

sdl.SysWMmsg

alias of SDL_SysWMmsg

sdl.TLSCreate()

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()

sdl.TLSGet(id)

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()

sdl.TLSSet(id, value, destructor)

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:
  • id – The thread local storage ID
  • value – The value to associate with the ID for the current thread
  • destructor – A function called when the thread exits, to free the value.
Returns:

0 on success, -1 on error

See also SDL_TLSCreate()

sdl.TextEditingEvent

alias of SDL_TextEditingEvent

sdl.TextInputEvent

alias of SDL_TextInputEvent

sdl.Texture

alias of SDL_Texture

sdl.Thread

alias of SDL_Thread

sdl.TouchFingerEvent

alias of SDL_TouchFingerEvent

sdl.UserEvent

alias of SDL_UserEvent

sdl.Window

alias of SDL_Window

sdl.WindowEvent

alias of SDL_WindowEvent

sdl.abs(x)

int SDL_abs(int)

sdl.addEventWatch(filter, userdata)

void SDL_AddEventWatch(int SDL_AddEventWatch(void *, SDL_Event *), void *)

Add a function which is called when an event is added to the queue.

sdl.addHintCallback(name, callback, userdata)

void SDL_AddHintCallback(char const *, void SDL_AddHintCallback(void *, char const *, char const *, char const *), void *)

sdl.addTimer(interval, callback, param)

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.allocFormat(pixel_format)

SDL_PixelFormat * SDL_AllocFormat(uint32_t)

Create an SDL_PixelFormat structure from a pixel format enum.

sdl.allocPalette(ncolors)

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.allocRW()

SDL_RWops * SDL_AllocRW(void)

sdl.assert_data

alias of SDL_assert_data

sdl.atan(x)

double SDL_atan(double)

sdl.atan2(x, y)

double SDL_atan2(double, double)

sdl.atof(str)

double SDL_atof(char const *)

sdl.atoi(str)

int SDL_atoi(char const *)

sdl.atomicLock(lock=None)

void SDL_AtomicLock(int *)

Lock a spin lock by setting it to a non-zero value.

Parameters:lock – Points to the lock.
sdl.atomicTryLock(lock=None)

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.
sdl.atomicUnlock(lock=None)

void SDL_AtomicUnlock(int *)

Unlock a spin lock by setting it to 0. Always returns immediately.

Parameters:lock – Points to the lock.
sdl.atomic_t

alias of SDL_atomic_t

sdl.audioInit(driver_name)

int SDL_AudioInit(char const *)

sdl.audioQuit()

void SDL_AudioQuit(void)

sdl.blitSurface(src, srcrect, dst, dstrect)

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()

sdl.buildAudioCVT(cvt, src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate)

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.
sdl.calculateGammaRamp(a0, a1=<cdata 'void *' NULL>)

void SDL_CalculateGammaRamp(float, uint16_t *)

Parameters:
  • gamma – a gamma value where 0.0 is black and 1.0 is identity
  • ramp – an array of 256 values filled in with the gamma ramp
Returns:

ramp

sdl.calloc(nmemb, size)

void * SDL_calloc(size_t, size_t)

sdl.ceil(x)

double SDL_ceil(double)

sdl.clearError()

void SDL_ClearError(void)

sdl.clearHints()

void SDL_ClearHints(void)

Clear all hints.

This function is called during SDL_Quit() to free stored hints.

sdl.closeAudio()

void SDL_CloseAudio(void)

This function shuts down audio processing and closes the audio device.

sdl.closeAudioDevice(dev)

void SDL_CloseAudioDevice(uint32_t)

sdl.cond

alias of SDL_cond

sdl.condBroadcast(cond)

int SDL_CondBroadcast(SDL_cond *)

Restart all threads that are waiting on the condition variable.

Returns:0 or -1 on error.
sdl.condSignal(cond)

int SDL_CondSignal(SDL_cond *)

Restart one of the threads that are waiting on the condition variable.

Returns:0 or -1 on error.
sdl.condWait(cond, mutex)

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.
sdl.condWaitTimeout(cond, mutex, ms)

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.

sdl.convertAudio(cvt)

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.

sdl.convertPixels(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch)

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.convertSurface(src, fmt, flags)

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.convertSurfaceFormat(src, pixel_format, flags)

SDL_Surface * SDL_ConvertSurfaceFormat(SDL_Surface *, uint32_t, uint32_t)

sdl.copysign(x, y)

double SDL_copysign(double, double)

sdl.cos(x)

double SDL_cos(double)

sdl.cosf(x)

float SDL_cosf(float)

sdl.createColorCursor(surface, hot_x, hot_y)

SDL_Cursor * SDL_CreateColorCursor(SDL_Surface *, int, int)

Create a color cursor.

See also SDL_FreeCursor()

sdl.createCond()

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.createCursor(data, mask, w, h, hot_x, hot_y)

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.createMutex()

SDL_mutex * SDL_CreateMutex(void)

Create a mutex, initialized unlocked.

sdl.createRGBSurface(flags, width, height, depth, Rmask, Gmask, Bmask, Amask)

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:
  • flags – The flags are obsolete and should be set to 0.
  • width – The width in pixels of the surface to create.
  • height – The height in pixels of the surface to create.
  • depth – The depth in bits of the surface to create.
  • Rmask – The red mask of the surface to create.
  • Gmask – The green mask of the surface to create.
  • Bmask – The blue mask of the surface to create.
  • Amask – The alpha mask of the surface to create.
sdl.createRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask)

SDL_Surface * SDL_CreateRGBSurfaceFrom(void *, int, int, int, int, uint32_t, uint32_t, uint32_t, uint32_t)

sdl.createRenderer(window, index, flags)

SDL_Renderer * SDL_CreateRenderer(SDL_Window *, int, uint32_t)

Create a 2D rendering context for a window.

Parameters:
  • window – The window where rendering is displayed.
  • index – The index of the rendering driver to initialize, or -1 to initialize the first one supporting the requested flags.
  • flags – SDL_RendererFlags.
Returns:

A valid rendering context or NULL if there was an error.

See also SDL_CreateSoftwareRenderer()

sdl.createSemaphore(initial_value)

SDL_sem * SDL_CreateSemaphore(uint32_t)

Create a semaphore, initialized with value, returns NULL on failure.

sdl.createSoftwareRenderer(surface)

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.createSystemCursor(id)

SDL_Cursor * SDL_CreateSystemCursor(SDL_SystemCursor)

Create a system cursor.

See also SDL_FreeCursor()

sdl.createTexture(renderer, format, access, w, h)

SDL_Texture * SDL_CreateTexture(SDL_Renderer *, uint32_t, int, int, int)

Create a texture for a rendering context.

Parameters:
  • renderer – The renderer.
  • format – The format of the texture.
  • access – One of the enumerated values in SDL_TextureAccess.
  • w – The width of the texture in pixels.
  • h – The height of the texture in pixels.
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.createTextureFromSurface(renderer, surface)

SDL_Texture * SDL_CreateTextureFromSurface(SDL_Renderer *, SDL_Surface *)

Create a texture from an existing surface.

Parameters:
  • renderer – The renderer.
  • surface – The surface containing pixel data used to fill the texture.
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.createThread(fn, name, data)

SDL_Thread * SDL_CreateThread(int SDL_CreateThread(void *), char const *, void *)

Create a thread.

sdl.createWindow(title, x, y, w, h, flags)

SDL_Window * SDL_CreateWindow(char const *, int, int, int, int, uint32_t)

Create a window with the specified position, dimensions, and flags.

Parameters:
  • title – The title of the window, in UTF-8 encoding.
  • x – The x position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED.
  • y – The y position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED.
  • w – The width of the window.
  • h – The height of the window.
  • flags – The flags for the window, a mask of any of the following: SDL_WINDOW_FULLSCREEN, SDL_WINDOW_OPENGL, SDL_WINDOW_HIDDEN, SDL_WINDOW_BORDERLESS, SDL_WINDOW_RESIZABLE, SDL_WINDOW_MAXIMIZED, SDL_WINDOW_MINIMIZED, SDL_WINDOW_INPUT_GRABBED, SDL_WINDOW_ALLOW_HIGHDPI.
Returns:

The id of the window created, or zero if window creation failed.

See also SDL_DestroyWindow()

sdl.createWindowAndRenderer(width, height, window_flags, window, renderer)

int SDL_CreateWindowAndRenderer(int, int, uint32_t, SDL_Window * *, SDL_Renderer * *)

Create a window and default renderer.

Parameters:
  • width – The width of the window
  • height – The height of the window
  • window_flags – The flags used to create the window
  • window – A pointer filled with the window, or NULL on error
  • renderer – A pointer filled with the renderer, or NULL on error
Returns:

0 on success, or -1 on error

sdl.createWindowFrom(data)

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()

sdl.delEventWatch(filter, userdata)

void SDL_DelEventWatch(int SDL_DelEventWatch(void *, SDL_Event *), void *)

Remove an event watch function added with SDL_AddEventWatch()

sdl.delHintCallback(name, callback, userdata)

void SDL_DelHintCallback(char const *, void SDL_DelHintCallback(void *, char const *, char const *, char const *), void *)

Remove a function watching a particular hint.

Parameters:
  • name – The hint being watched
  • callback – The function being called when the hint value changes
  • userdata – A pointer being passed to the callback function
sdl.delay(ms)

void SDL_Delay(uint32_t)

Wait a specified number of milliseconds before returning.

sdl.destroyCond(cond)

void SDL_DestroyCond(SDL_cond *)

Destroy a condition variable.

sdl.destroyMutex(mutex)

void SDL_DestroyMutex(SDL_mutex *)

Destroy a mutex.

sdl.destroyRenderer(renderer)

void SDL_DestroyRenderer(SDL_Renderer *)

Destroy the rendering context for a window and free associated textures.

See also SDL_CreateRenderer()

sdl.destroySemaphore(sem)

void SDL_DestroySemaphore(SDL_sem *)

Destroy a semaphore.

sdl.destroyTexture(texture)

void SDL_DestroyTexture(SDL_Texture *)

Destroy the specified texture.

See also SDL_CreateTexture()

sdl.destroyWindow(window)

void SDL_DestroyWindow(SDL_Window *)

Destroy a window.

sdl.disableScreenSaver()

void SDL_DisableScreenSaver(void)

Prevent the screen from being blanked by a screensaver.

See also SDL_IsScreenSaverEnabled()

sdl.enableScreenSaver()

void SDL_EnableScreenSaver(void)

Allow the screen to be blanked by a screensaver.

See also SDL_IsScreenSaverEnabled()

sdl.enclosePoints(points, count, clip, result)

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
sdl.error(code)

int SDL_Error(SDL_errorcode)

sdl.eventState(type, state)

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.

sdl.fabs(x)

double SDL_fabs(double)

sdl.fillRect(dst, rect, color)

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.
sdl.fillRects(dst, rects, count, color)

int SDL_FillRects(SDL_Surface *, SDL_Rect const *, int, uint32_t)

sdl.filterEvents(filter, userdata)

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.

sdl.floor(x)

double SDL_floor(double)

sdl.flushEvent(type)

void SDL_FlushEvent(uint32_t)

This function clears events from the event queue

sdl.flushEvents(minType, maxType)

void SDL_FlushEvents(uint32_t, uint32_t)

sdl.free(mem)

void SDL_free(void *)

sdl.freeCursor(cursor)

void SDL_FreeCursor(SDL_Cursor *)

Frees a cursor created with SDL_CreateCursor().

See also SDL_CreateCursor()

sdl.freeFormat(format)

void SDL_FreeFormat(SDL_PixelFormat *)

Free an SDL_PixelFormat structure.

sdl.freePalette(palette)

void SDL_FreePalette(SDL_Palette *)

Free a palette created with SDL_AllocPalette().

See also SDL_AllocPalette()

sdl.freeRW(area)

void SDL_FreeRW(SDL_RWops *)

sdl.freeSurface(surface)

void SDL_FreeSurface(SDL_Surface *)

sdl.freeWAV(audio_buf=None)

void SDL_FreeWAV(uint8_t *)

This function frees data previously allocated with SDL_LoadWAV_RW()

sdl.gameControllerAddMapping(mappingString)

int SDL_GameControllerAddMapping(char const *)

Add or update an existing mapping configuration

Returns:1 if mapping is added, 0 if updated, -1 on error
sdl.gameControllerClose(gamecontroller)

void SDL_GameControllerClose(SDL_GameController *)

Close a controller previously opened with SDL_GameControllerOpen().

sdl.gameControllerEventState(state)

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.gameControllerGetAttached(gamecontroller)

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.

sdl.gameControllerGetAxis(gamecontroller, axis)

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.gameControllerGetAxisFromString(pchString)

SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(char const *)

turn this string into a axis mapping

sdl.gameControllerGetBindForAxis(gamecontroller, axis)

SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController *, SDL_GameControllerAxis)

Get the SDL joystick layer binding for this controller button mapping

sdl.gameControllerGetBindForButton(gamecontroller, button)

SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameController *, SDL_GameControllerButton)

Get the SDL joystick layer binding for this controller button mapping

sdl.gameControllerGetButton(gamecontroller, button)

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.gameControllerGetButtonFromString(pchString)

SDL_GameControllerButton SDL_GameControllerGetButtonFromString(char const *)

turn this string into a button mapping

sdl.gameControllerGetJoystick(gamecontroller)

SDL_Joystick * SDL_GameControllerGetJoystick(SDL_GameController *)

Get the underlying joystick object used by a controller

sdl.gameControllerGetStringForAxis(axis)

char const * SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis)

turn this axis enum into a string mapping

sdl.gameControllerGetStringForButton(button)

char const * SDL_GameControllerGetStringForButton(SDL_GameControllerButton)

turn this button enum into a string mapping

sdl.gameControllerMapping(gamecontroller)

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
sdl.gameControllerMappingForGUID(guid)

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
sdl.gameControllerName(gamecontroller)

char const * SDL_GameControllerName(SDL_GameController *)

Return the name for this currently opened controller

sdl.gameControllerNameForIndex(joystick_index)

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.gameControllerOpen(joystick_index)

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.
sdl.gameControllerUpdate()

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.getAssertionReport()

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

sdl.getAudioDeviceName(index, iscapture)

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.getAudioDeviceStatus(dev)

SDL_AudioStatus SDL_GetAudioDeviceStatus(uint32_t)

sdl.getAudioDriver(index)

char const * SDL_GetAudioDriver(int)

sdl.getAudioStatus()

SDL_AudioStatus SDL_GetAudioStatus(void)

sdl.getCPUCacheLineSize()

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.

sdl.getCPUCount()

int SDL_GetCPUCount(void)

This function returns the number of CPU cores available.

sdl.getClipRect(surface, rect)

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.

sdl.getClipboardText()

char * SDL_GetClipboardText(void)

Get UTF-8 text from the clipboard, which must be freed with SDL_free()

See also SDL_SetClipboardText()

sdl.getClosestDisplayMode(displayIndex, mode, closest)

SDL_DisplayMode * SDL_GetClosestDisplayMode(int, SDL_DisplayMode const *, SDL_DisplayMode *)

Get the closest match to the requested display mode.

Parameters:
  • displayIndex – The index of display from which mode should be queried.
  • mode – The desired display mode
  • closest – A pointer to a display mode to be filled in with the closest match of the available display modes.
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()

sdl.getColorKey(surface, key=None)

int SDL_GetColorKey(SDL_Surface *, uint32_t *)

Gets the color key (transparent pixel) in a blittable surface.

Parameters:
  • surface – The surface to update
  • key – A pointer filled in with the transparent pixel in the native surface format
Returns:

0 on success, or -1 if the surface is not valid or colorkey is not enabled.

sdl.getCurrentAudioDriver()

char const * SDL_GetCurrentAudioDriver(void)

This function returns the name of the current audio driver, or NULL if no driver has been initialized.

sdl.getCurrentDisplayMode(displayIndex, mode)

int SDL_GetCurrentDisplayMode(int, SDL_DisplayMode *)

Fill in information about the current display mode.

sdl.getCurrentVideoDriver()

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.getCursor()

SDL_Cursor * SDL_GetCursor(void)

Return the active cursor.

sdl.getDefaultCursor()

SDL_Cursor * SDL_GetDefaultCursor(void)

Return the default cursor.

sdl.getDesktopDisplayMode(displayIndex, mode)

int SDL_GetDesktopDisplayMode(int, SDL_DisplayMode *)

Fill in information about the desktop display mode.

sdl.getDisplayBounds(displayIndex, rect)

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()

sdl.getDisplayMode(displayIndex, modeIndex, mode)

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()

sdl.getDisplayName(displayIndex)

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()

sdl.getError()

char const * SDL_GetError(void)

sdl.getEventFilter(filter, userdata)

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.

sdl.getHint(name)

char const * SDL_GetHint(char const *)

Get a hint.

Returns:The string value of a hint variable.
sdl.getKeyFromName(name)

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

sdl.getKeyFromScancode(scancode)

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()

sdl.getKeyName(key)

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.getKeyboardFocus()

SDL_Window * SDL_GetKeyboardFocus(void)

Get the window which currently has keyboard focus.

sdl.getKeyboardState(numkeys=None)

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.getModState()

SDL_Keymod SDL_GetModState(void)

Get the current key modifier state for the keyboard.

sdl.getMouseFocus()

SDL_Window * SDL_GetMouseFocus(void)

Get the window which currently has mouse focus.

sdl.getMouseState(x=None, y=None)

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.

sdl.getNumAudioDevices(iscapture)

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()).

sdl.getNumAudioDrivers()

int SDL_GetNumAudioDrivers(void)

sdl.getNumDisplayModes(displayIndex)

int SDL_GetNumDisplayModes(int)

Returns the number of available display modes.

See also SDL_GetDisplayMode()

sdl.getNumRenderDrivers()

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()

sdl.getNumTouchDevices()

int SDL_GetNumTouchDevices(void)

Get the number of registered touch devices.

sdl.getNumTouchFingers(touchID)

int SDL_GetNumTouchFingers(int64_t)

Get the number of active fingers for a given touch device.

sdl.getNumVideoDisplays()

int SDL_GetNumVideoDisplays(void)

Returns the number of available video displays.

See also SDL_GetDisplayBounds()

sdl.getNumVideoDrivers()

int SDL_GetNumVideoDrivers(void)

Get the number of video drivers compiled into SDL.

See also SDL_GetVideoDriver()

sdl.getPerformanceCounter()

uint64_t SDL_GetPerformanceCounter(void)

Get the current value of the high resolution counter.

sdl.getPerformanceFrequency()

uint64_t SDL_GetPerformanceFrequency(void)

Get the count per second of the high resolution counter.

sdl.getPixelFormatName(format)

char const * SDL_GetPixelFormatName(uint32_t)

Get the human readable name of a pixel format.

sdl.getPlatform()

char const * SDL_GetPlatform(void)

Gets the name of the platform.

sdl.getPowerInfo(secs=None, pct=None)

SDL_PowerState SDL_GetPowerInfo(int *, int *)

Get the current power supply details.

Parameters:
  • secs – Seconds of battery life left. You can pass a NULL here if you don’t care. Will return -1 if we can’t determine a value, or we’re not running on a battery.
  • pct – Percentage of battery life left, between 0 and 100. You can pass a NULL here if you don’t care. Will return -1 if we can’t determine a value, or we’re not running on a battery.
Returns:

The state of the battery (if any).

sdl.getRGB(pixel, format, r=None, g=None, b=None)

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

sdl.getRGBA(pixel, format, r=None, g=None, b=None, a=None)

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.getRelativeMouseMode()

SDL_bool SDL_GetRelativeMouseMode(void)

Query whether relative mouse mode is enabled.

See also SDL_SetRelativeMouseMode()

sdl.getRelativeMouseState(x=None, y=None)

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().

sdl.getRenderDrawBlendMode(renderer, blendMode)

int SDL_GetRenderDrawBlendMode(SDL_Renderer *, SDL_BlendMode *)

Get the blend mode used for drawing operations.

Parameters:
  • renderer – The renderer from which blend mode should be queried.
  • blendMode – A pointer filled in with the current blend mode.
Returns:

0 on success, or -1 on error

See also SDL_SetRenderDrawBlendMode()

sdl.getRenderDrawColor(renderer, r=None, g=None, b=None, a=None)

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:
  • renderer – The renderer from which drawing color should be queried.
  • r – A pointer to the red value used to draw on the rendering target.
  • g – A pointer to the green value used to draw on the rendering target.
  • b – A pointer to the blue value used to draw on the rendering target.
  • a – A pointer to the alpha value used to draw on the rendering target, usually SDL_ALPHA_OPAQUE (255).
Returns:

0 on success, or -1 on error

sdl.getRenderDriverInfo(index, info)

int SDL_GetRenderDriverInfo(int, SDL_RendererInfo *)

Get information about a specific 2D rendering driver for the current display.

Parameters:
  • index – The index of the driver to query information about.
  • info – A pointer to an SDL_RendererInfo struct to be filled with information on the rendering driver.
Returns:

0 on success, -1 if the index was out of range.

See also SDL_CreateRenderer()

sdl.getRenderTarget(renderer)

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.getRenderer(window)

SDL_Renderer * SDL_GetRenderer(SDL_Window *)

Get the renderer associated with a window.

sdl.getRendererInfo(renderer, info)

int SDL_GetRendererInfo(SDL_Renderer *, SDL_RendererInfo *)

Get information about a rendering context.

sdl.getRendererOutputSize(renderer, w=None, h=None)

int SDL_GetRendererOutputSize(SDL_Renderer *, int *, int *)

Get the output size of a rendering context.

sdl.getRevision()

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.

sdl.getRevisionNumber()

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.getScancodeFromKey(key)

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.getScancodeFromName(name)

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

sdl.getScancodeName(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

sdl.getSurfaceAlphaMod(surface, alpha=None)

int SDL_GetSurfaceAlphaMod(SDL_Surface *, uint8_t *)

Get the additional alpha value used in blit operations.

Parameters:
  • surface – The surface to query.
  • alpha – A pointer filled in with the current alpha value.
Returns:

0 on success, or -1 if the surface is not valid.

See also SDL_SetSurfaceAlphaMod()

sdl.getSurfaceBlendMode(surface, blendMode)

int SDL_GetSurfaceBlendMode(SDL_Surface *, SDL_BlendMode *)

Get the blend mode used for blit operations.

Parameters:
  • surface – The surface to query.
  • blendMode – A pointer filled in with the current blend mode.
Returns:

0 on success, or -1 if the surface is not valid.

See also SDL_SetSurfaceBlendMode()

sdl.getSurfaceColorMod(surface, r=None, g=None, b=None)

int SDL_GetSurfaceColorMod(SDL_Surface *, uint8_t *, uint8_t *, uint8_t *)

Get the additional color value used in blit operations.

Parameters:
  • surface – The surface to query.
  • r – A pointer filled in with the current red color value.
  • g – A pointer filled in with the current green color value.
  • b – A pointer filled in with the current blue color value.
Returns:

0 on success, or -1 if the surface is not valid.

See also SDL_SetSurfaceColorMod()

sdl.getTextureAlphaMod(texture, alpha=None)

int SDL_GetTextureAlphaMod(SDL_Texture *, uint8_t *)

Get the additional alpha value used in render copy operations.

Parameters:
  • texture – The texture to query.
  • alpha – A pointer filled in with the current alpha value.
Returns:

0 on success, or -1 if the texture is not valid.

See also SDL_SetTextureAlphaMod()

sdl.getTextureBlendMode(texture, blendMode)

int SDL_GetTextureBlendMode(SDL_Texture *, SDL_BlendMode *)

Get the blend mode used for texture copy operations.

Parameters:
  • texture – The texture to query.
  • blendMode – A pointer filled in with the current blend mode.
Returns:

0 on success, or -1 if the texture is not valid.

See also SDL_SetTextureBlendMode()

sdl.getTextureColorMod(texture, r=None, g=None, b=None)

int SDL_GetTextureColorMod(SDL_Texture *, uint8_t *, uint8_t *, uint8_t *)

Get the additional color value used in render copy operations.

Parameters:
  • texture – The texture to query.
  • r – A pointer filled in with the current red color value.
  • g – A pointer filled in with the current green color value.
  • b – A pointer filled in with the current blue color value.
Returns:

0 on success, or -1 if the texture is not valid.

See also SDL_SetTextureColorMod()

sdl.getThreadID(thread)

unsigned long SDL_GetThreadID(SDL_Thread *)

Get the thread identifier for the specified thread.

Equivalent to SDL_ThreadID() if the specified thread is NULL.

sdl.getThreadName(thread)

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().

sdl.getTicks()

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.

sdl.getTouchDevice(index)

int64_t SDL_GetTouchDevice(int)

Get the touch ID with the given index, or 0 if the index is invalid.

sdl.getTouchFinger(touchID, index)

SDL_Finger * SDL_GetTouchFinger(int64_t, int)

Get the finger object of the given touch, with the given index.

sdl.getVersion(ver)

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

sdl.getVideoDriver(index)

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()

sdl.getWindowBrightness(window)

float SDL_GetWindowBrightness(SDL_Window *)

Get the brightness (gamma correction) for a window.

Returns:The last brightness value passed to

See also SDL_SetWindowBrightness()

sdl.getWindowData(window, name)

void * SDL_GetWindowData(SDL_Window *, char const *)

Retrieve the data pointer associated with a window.

Parameters:
  • window – The window to query.
  • name – The name of the pointer.
Returns:

The value associated with ‘name’

See also SDL_SetWindowData()

sdl.getWindowDisplayIndex(window)

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.
sdl.getWindowDisplayMode(window, mode)

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()

sdl.getWindowFlags(window)

uint32_t SDL_GetWindowFlags(SDL_Window *)

Get the window flags.

sdl.getWindowFromID(id)

SDL_Window * SDL_GetWindowFromID(uint32_t)

Get a window from a stored ID, or NULL if it doesn’t exist.

sdl.getWindowGammaRamp(window, red=None, green=None, blue=None)

int SDL_GetWindowGammaRamp(SDL_Window *, uint16_t *, uint16_t *, uint16_t *)

Get the gamma ramp for a window.

Parameters:
  • window – The window from which the gamma ramp should be queried.
  • red – A pointer to a 256 element array of 16-bit quantities to hold the translation table for the red channel, or NULL.
  • green – A pointer to a 256 element array of 16-bit quantities to hold the translation table for the green channel, or NULL.
  • blue – A pointer to a 256 element array of 16-bit quantities to hold the translation table for the blue channel, or NULL.
Returns:

0 on success, or -1 if gamma ramps are unsupported.

See also SDL_SetWindowGammaRamp()

sdl.getWindowGrab(window)

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()

sdl.getWindowID(window)

uint32_t SDL_GetWindowID(SDL_Window *)

Get the numeric ID of a window, for logging purposes.

sdl.getWindowMaximumSize(window, w=None, h=None)

void SDL_GetWindowMaximumSize(SDL_Window *, int *, int *)

Get the maximum size of a window’s client area.

Parameters:
  • window – The window to query.
  • w – Pointer to variable for storing the maximum width, may be NULL
  • h – Pointer to variable for storing the maximum height, may be NULL

See also SDL_GetWindowMinimumSize()

sdl.getWindowMinimumSize(window, w=None, h=None)

void SDL_GetWindowMinimumSize(SDL_Window *, int *, int *)

Get the minimum size of a window’s client area.

Parameters:
  • window – The window to query.
  • w – Pointer to variable for storing the minimum width, may be NULL
  • h – Pointer to variable for storing the minimum height, may be NULL

See also SDL_GetWindowMaximumSize()

sdl.getWindowPixelFormat(window)

uint32_t SDL_GetWindowPixelFormat(SDL_Window *)

Get the pixel format associated with the window.

sdl.getWindowPosition(window, x=None, y=None)

void SDL_GetWindowPosition(SDL_Window *, int *, int *)

Get the position of a window.

Parameters:
  • window – The window to query.
  • x – Pointer to variable for storing the x position, may be NULL
  • y – Pointer to variable for storing the y position, may be NULL

See also SDL_SetWindowPosition()

sdl.getWindowSize(window, w=None, h=None)

void SDL_GetWindowSize(SDL_Window *, int *, int *)

Get the size of a window’s client area.

Parameters:
  • window – The window to query.
  • w – Pointer to variable for storing the width, may be NULL
  • h – Pointer to variable for storing the height, may be NULL

See also SDL_SetWindowSize()

sdl.getWindowSurface(window)

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()

sdl.getWindowTitle(window)

char const * SDL_GetWindowTitle(SDL_Window *)

Get the title of a window, in UTF-8 format.

See also SDL_SetWindowTitle()

sdl.getenv(name)

char * SDL_getenv(char const *)

sdl.hapticClose(haptic)

void SDL_HapticClose(SDL_Haptic *)

Closes a Haptic device previously opened with SDL_HapticOpen().

Parameters:haptic – Haptic device to close.
sdl.hapticDestroyEffect(haptic, effect)

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:
  • haptic – Device to destroy the effect on.
  • effect – Identifier of the effect to destroy.

See also SDL_HapticNewEffect

sdl.hapticEffectSupported(haptic, effect)

int SDL_HapticEffectSupported(SDL_Haptic *, SDL_HapticEffect *)

Checks to see if effect is supported by haptic.

Parameters:
  • haptic – Haptic device to check on.
  • effect – Effect to check to see if it is supported.
Returns:

SDL_TRUE if effect is supported, SDL_FALSE if it isn’t or -1 on error.

See also SDL_HapticQuery

sdl.hapticGetEffectStatus(haptic, effect)

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:
  • haptic – Haptic device to query the effect status on.
  • effect – Identifier of the effect to query its status.
Returns:

0 if it isn’t playing, 1 if it is playing or -1 on error.

See also SDL_HapticRunEffect

sdl.hapticIndex(haptic)

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

sdl.hapticName(device_index)

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

sdl.hapticNewEffect(haptic, effect)

int SDL_HapticNewEffect(SDL_Haptic *, SDL_HapticEffect *)

Creates a new haptic effect on the device.

Parameters:
  • haptic – Haptic device to create the effect on.
  • effect – Properties of the effect to create.
Returns:

The id of the effect on success or -1 on error.

See also SDL_HapticUpdateEffect

sdl.hapticNumAxes(haptic)

int SDL_HapticNumAxes(SDL_Haptic *)

Gets the number of haptic axes the device has.

See also SDL_HapticDirection

sdl.hapticNumEffects(haptic)

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

sdl.hapticNumEffectsPlaying(haptic)

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.hapticOpen(device_index)

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.hapticOpenFromJoystick(joystick)

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.hapticOpenFromMouse()

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

sdl.hapticOpened(device_index)

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

sdl.hapticPause(haptic)

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

sdl.hapticQuery(haptic)

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

sdl.hapticRumbleInit(haptic)

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

sdl.hapticRumblePlay(haptic, strength, length)

int SDL_HapticRumblePlay(SDL_Haptic *, float, uint32_t)

Runs simple rumble on a haptic device.

Parameters:
  • haptic – Haptic device to play rumble effect on.
  • strength – Strength of the rumble to play as a 0-1 float value.
  • length – Length of the rumble to play in milliseconds.
Returns:

0 on success or -1 on error.

See also SDL_HapticRumbleSupported

sdl.hapticRumbleStop(haptic)

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

sdl.hapticRumbleSupported(haptic)

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

sdl.hapticRunEffect(haptic, effect, iterations)

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:
  • haptic – Haptic device to run the effect on.
  • effect – Identifier of the haptic effect to run.
  • iterations – Number of iterations to run the effect. Use SDL_HAPTIC_INFINITY for infinity.
Returns:

0 on success or -1 on error.

See also SDL_HapticStopEffect

sdl.hapticSetAutocenter(haptic, autocenter)

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:
  • haptic – Haptic device to set autocentering on.
  • autocenter – Value to set autocenter to, 0 disables autocentering.
Returns:

0 on success or -1 on error.

See also SDL_HapticQuery

sdl.hapticSetGain(haptic, gain)

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:
  • haptic – Haptic device to set the gain on.
  • gain – Value to set the gain to, should be between 0 and 100.
Returns:

0 on success or -1 on error.

See also SDL_HapticQuery

sdl.hapticStopAll(haptic)

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.
sdl.hapticStopEffect(haptic, effect)

int SDL_HapticStopEffect(SDL_Haptic *, int)

Stops the haptic effect on its associated haptic device.

Parameters:
  • haptic – Haptic device to stop the effect on.
  • effect – Identifier of the effect to stop.
Returns:

0 on success or -1 on error.

See also SDL_HapticRunEffect

sdl.hapticUnpause(haptic)

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

sdl.hapticUpdateEffect(haptic, effect, data)

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:
  • haptic – Haptic device that has the effect.
  • effect – Effect to update.
  • data – New effect properties to use.
Returns:

0 on success or -1 on error.

See also SDL_HapticNewEffect

sdl.has3DNow()

SDL_bool SDL_Has3DNow(void)

This function returns true if the CPU has 3DNow! features.

sdl.hasAltiVec()

SDL_bool SDL_HasAltiVec(void)

This function returns true if the CPU has AltiVec features.

sdl.hasClipboardText()

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.hasEvent(type)

SDL_bool SDL_HasEvent(uint32_t)

Checks to see if certain event types are in the event queue.

sdl.hasEvents(minType, maxType)

SDL_bool SDL_HasEvents(uint32_t, uint32_t)

sdl.hasIntersection(A, B)

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.hasMMX()

SDL_bool SDL_HasMMX(void)

This function returns true if the CPU has MMX features.

sdl.hasRDTSC()

SDL_bool SDL_HasRDTSC(void)

This function returns true if the CPU has the RDTSC instruction.

sdl.hasSSE()

SDL_bool SDL_HasSSE(void)

This function returns true if the CPU has SSE features.

sdl.hasSSE2()

SDL_bool SDL_HasSSE2(void)

This function returns true if the CPU has SSE2 features.

sdl.hasSSE3()

SDL_bool SDL_HasSSE3(void)

This function returns true if the CPU has SSE3 features.

sdl.hasSSE41()

SDL_bool SDL_HasSSE41(void)

This function returns true if the CPU has SSE4.1 features.

sdl.hasSSE42()

SDL_bool SDL_HasSSE42(void)

This function returns true if the CPU has SSE4.2 features.

sdl.hasScreenKeyboardSupport()

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()

sdl.hideWindow(window)

void SDL_HideWindow(SDL_Window *)

Hide a window.

See also SDL_ShowWindow()

sdl.iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft=None)

size_t SDL_iconv(struct _SDL_iconv_t *, char const * *, size_t *, char * *, size_t *)

sdl.iconv_close(cd)

int SDL_iconv_close(struct _SDL_iconv_t *)

sdl.iconv_open(tocode, fromcode)

struct _SDL_iconv_t * SDL_iconv_open(char const *, char const *)

sdl.iconv_string(tocode, fromcode, inbuf, inbytesleft)

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.

sdl.init(flags)

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).

sdl.initSubSystem(flags)

int SDL_InitSubSystem(uint32_t)

This function initializes specific SDL subsystems

sdl.intersectRect(A, B, result)

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.intersectRectAndLine(rect, X1=None, Y1=None, X2=None, Y2=None)

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.isGameController(joystick_index)

SDL_bool SDL_IsGameController(int)

Is the joystick on this index supported by the game controller interface?

sdl.isScreenKeyboardShown(window)

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.isScreenSaverEnabled()

SDL_bool SDL_IsScreenSaverEnabled(void)

Returns whether the screensaver is currently enabled (default on).

See also SDL_EnableScreenSaver()

sdl.isTextInputActive()

SDL_bool SDL_IsTextInputActive(void)

Return whether or not Unicode text input events are enabled.

See also SDL_StartTextInput()

sdl.isdigit(x)

int SDL_isdigit(int)

sdl.isspace(x)

int SDL_isspace(int)

sdl.itoa(value, str, radix)

char * SDL_itoa(int, char *, int)

sdl.joystickClose(joystick)

void SDL_JoystickClose(SDL_Joystick *)

Close a joystick previously opened with SDL_JoystickOpen().

sdl.joystickEventState(state)

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.joystickGetAttached(joystick)

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.

sdl.joystickGetAxis(joystick, axis)

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.

sdl.joystickGetBall(joystick, ball, dx=None, dy=None)

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.

sdl.joystickGetButton(joystick, button)

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.joystickGetDeviceGUID(device_index)

SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int)

Return the GUID for the joystick at this index

sdl.joystickGetGUID(joystick)

SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick *)

Return the GUID for this opened joystick

sdl.joystickGetGUIDFromString(pchGUID)

SDL_JoystickGUID SDL_JoystickGetGUIDFromString(char const *)

convert a string into a joystick formatted guid

sdl.joystickGetGUIDString(a0)

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).

sdl.joystickGetHat(joystick, hat)

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:
sdl.joystickInstanceID(joystick)

int32_t SDL_JoystickInstanceID(SDL_Joystick *)

Get the instance ID of an opened joystick or -1 if the joystick is invalid.

sdl.joystickIsHaptic(joystick)

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

sdl.joystickName(joystick)

char const * SDL_JoystickName(SDL_Joystick *)

Return the name for this currently opened joystick. If no name can be found, this function returns NULL.

sdl.joystickNameForIndex(device_index)

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.

sdl.joystickNumAxes(joystick)

int SDL_JoystickNumAxes(SDL_Joystick *)

Get the number of general axis controls on a joystick.

sdl.joystickNumBalls(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.

sdl.joystickNumButtons(joystick)

int SDL_JoystickNumButtons(SDL_Joystick *)

Get the number of buttons on a joystick.

sdl.joystickNumHats(joystick)

int SDL_JoystickNumHats(SDL_Joystick *)

Get the number of POV hats on a joystick.

sdl.joystickOpen(device_index)

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.
sdl.joystickUpdate()

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.

sdl.lltoa(value, str, radix)

char * SDL_lltoa(int64_t, char *, int)

sdl.loadBMP_RW(src, freesrc)

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.
sdl.loadDollarTemplates(touchId, src)

int SDL_LoadDollarTemplates(int64_t, SDL_RWops *)

Load Dollar Gesture templates from a file.

sdl.loadFunction(handle, name)

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().

sdl.loadObject(sofile)

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.loadWAV_RW(src, freesrc, spec, audio_buf, audio_len=None)

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.

sdl.lockAudio()

void SDL_LockAudio(void)

sdl.lockAudioDevice(dev)

void SDL_LockAudioDevice(uint32_t)

sdl.lockMutex(mutex)

int SDL_LockMutex(SDL_mutex *)

sdl.lockSurface(surface)

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()

sdl.lockTexture(texture, rect, pixels, pitch=None)

int SDL_LockTexture(SDL_Texture *, SDL_Rect const *, void * *, int *)

Lock a portion of the texture for write-only pixel access.

Parameters:
  • texture – The texture to lock for access, which was created with SDL_TEXTUREACCESS_STREAMING.
  • rect – A pointer to the rectangle to lock for access. If the rect is NULL, the entire texture will be locked.
  • pixels – This is filled in with a pointer to the locked pixels, appropriately offset by the locked area.
  • pitch – This is filled in with the pitch of the locked pixels.
Returns:

0 on success, or -1 if the texture is not valid or was not created with

See also SDL_UnlockTexture()

sdl.log(fmt)

void SDL_Log(char const *, ...)

Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.

sdl.logCritical(category, fmt)

void SDL_LogCritical(int, char const *, ...)

Log a message with SDL_LOG_PRIORITY_CRITICAL.

sdl.logDebug(category, fmt)

void SDL_LogDebug(int, char const *, ...)

Log a message with SDL_LOG_PRIORITY_DEBUG.

sdl.logError(category, fmt)

void SDL_LogError(int, char const *, ...)

Log a message with SDL_LOG_PRIORITY_ERROR.

sdl.logGetOutputFunction(callback, userdata)

void SDL_LogGetOutputFunction(void(* *)(void *, int, SDL_LogPriority, char const *), void * *)

Get the current log output function.

sdl.logGetPriority(category)

SDL_LogPriority SDL_LogGetPriority(int)

Get the priority of a particular log category.

sdl.logInfo(category, fmt)

void SDL_LogInfo(int, char const *, ...)

Log a message with SDL_LOG_PRIORITY_INFO.

sdl.logMessage(category, priority, fmt)

void SDL_LogMessage(int, SDL_LogPriority, char const *, ...)

Log a message with the specified category and priority.

sdl.logMessageV(category, priority, fmt, ap)

void SDL_LogMessageV(int, SDL_LogPriority, char const *, int32_t)

Log a message with the specified category and priority.

sdl.logResetPriorities()

void SDL_LogResetPriorities(void)

Reset all priorities to default.

This is called in SDL_Quit().

sdl.logSetAllPriority(priority)

void SDL_LogSetAllPriority(SDL_LogPriority)

Set the priority of all log categories.

sdl.logSetOutputFunction(callback, userdata)

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.

sdl.logSetPriority(category, priority)

void SDL_LogSetPriority(int, SDL_LogPriority)

Set the priority of a particular log category.

sdl.logVerbose(category, fmt)

void SDL_LogVerbose(int, char const *, ...)

Log a message with SDL_LOG_PRIORITY_VERBOSE.

sdl.logWarn(category, fmt)

void SDL_LogWarn(int, char const *, ...)

Log a message with SDL_LOG_PRIORITY_WARN.

sdl.lowerBlit(src, srcrect, dst, dstrect)

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.

sdl.lowerBlitScaled(src, srcrect, dst, dstrect)

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.

sdl.ltoa(value, str, radix)

char * SDL_ltoa(long, char *, int)

sdl.main(argc, argv)

int SDL_main(int, char * *)

The prototype for the application’s main() function

sdl.malloc(size)

void * SDL_malloc(size_t)

sdl.mapRGB(format, r, g, b)

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

sdl.mapRGBA(format, r, g, b, a)

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

sdl.masksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask)

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()

sdl.maximizeWindow(window)

void SDL_MaximizeWindow(SDL_Window *)

Make a window as large as possible.

See also SDL_RestoreWindow()

sdl.memcmp(s1, s2, len)

int SDL_memcmp(void const *, void const *, size_t)

sdl.memcpy(dst, src, len)

void * SDL_memcpy(void *, void const *, size_t)

sdl.memmove(dst, src, len)

void * SDL_memmove(void *, void const *, size_t)

sdl.memset(dst, c, len)

void * SDL_memset(void *, int, size_t)

sdl.minimizeWindow(window)

void SDL_MinimizeWindow(SDL_Window *)

Minimize a window to an iconic representation.

See also SDL_RestoreWindow()

sdl.mixAudio(dst, src, len, volume)

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.

sdl.mixAudioFormat(dst, src, format, len, volume)

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.

sdl.mouseIsHaptic()

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

sdl.mutex

alias of SDL_mutex

sdl.numHaptics()

int SDL_NumHaptics(void)

Count the number of haptic devices attached to the system.

Returns:Number of haptic devices detected on the system.
sdl.numJoysticks()

int SDL_NumJoysticks(void)

Count the number of joysticks attached to the system right now

sdl.openAudio(desired, obtained)

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.

sdl.openAudioDevice(device, iscapture, desired, obtained, allowed_changes)

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.

sdl.pauseAudio(pause_on)

void SDL_PauseAudio(int)

sdl.pauseAudioDevice(dev, pause_on)

void SDL_PauseAudioDevice(uint32_t, int)

sdl.peepEvents(events, numevents, action, minType, maxType)

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.pixelFormatEnumToMasks(format, bpp=None, Rmask=None, Gmask=None, Bmask=None, Amask=None)

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()

sdl.pollEvent(event)

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.
sdl.pow(x, y)

double SDL_pow(double, double)

sdl.pumpEvents()

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.

sdl.pushEvent(event)

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.
sdl.qsort(base, nmemb, size, compare)

void SDL_qsort(void *, size_t, size_t, int SDL_qsort(void const *, void const *))

sdl.queryTexture(texture, format=None, access=None, w=None, h=None)

int SDL_QueryTexture(SDL_Texture *, uint32_t *, int *, int *, int *)

Query the attributes of a texture.

Parameters:
  • texture – A texture to be queried.
  • format – A pointer filled in with the raw format of the texture. The actual format may differ, but pixel transfers will use this format.
  • access – A pointer filled in with the actual access to the texture.
  • w – A pointer filled in with the width of the texture in pixels.
  • h – A pointer filled in with the height of the texture in pixels.
Returns:

0 on success, or -1 if the texture is not valid.

sdl.quit()

void SDL_Quit(void)

This function cleans up all initialized subsystems. You should call it upon all exit conditions.

sdl.quitSubSystem(flags)

void SDL_QuitSubSystem(uint32_t)

This function cleans up specific SDL subsystems

sdl.raiseWindow(window)

void SDL_RaiseWindow(SDL_Window *)

Raise a window above other windows and set the input focus.

sdl.readBE16(src)

uint16_t SDL_ReadBE16(SDL_RWops *)

sdl.readBE32(src)

uint32_t SDL_ReadBE32(SDL_RWops *)

sdl.readBE64(src)

uint64_t SDL_ReadBE64(SDL_RWops *)

sdl.readLE16(src)

uint16_t SDL_ReadLE16(SDL_RWops *)

sdl.readLE32(src)

uint32_t SDL_ReadLE32(SDL_RWops *)

sdl.readLE64(src)

uint64_t SDL_ReadLE64(SDL_RWops *)

sdl.readU8(src)

uint8_t SDL_ReadU8(SDL_RWops *)

sdl.realloc(mem, size)

void * SDL_realloc(void *, size_t)

sdl.recordGesture(touchId)

int SDL_RecordGesture(int64_t)

Begin Recording a gesture on the specified touch, or all touches (-1)

sdl.registerEvents(numevents)

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.removeTimer(id)

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.

sdl.renderClear(renderer)

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
sdl.renderCopy(renderer, texture, srcrect, dstrect)

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:
  • renderer – The renderer which should copy parts of a texture.
  • texture – The source texture.
  • srcrect – A pointer to the source rectangle, or NULL for the entire texture.
  • dstrect – A pointer to the destination rectangle, or NULL for the entire rendering target.
Returns:

0 on success, or -1 on error

sdl.renderCopyEx(renderer, texture, srcrect, dstrect, angle, center, flip)

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:
  • renderer – The renderer which should copy parts of a texture.
  • texture – The source texture.
  • srcrect – A pointer to the source rectangle, or NULL for the entire texture.
  • dstrect – A pointer to the destination rectangle, or NULL for the entire rendering target.
  • angle – An angle in degrees that indicates the rotation that will be applied to dstrect
  • center – A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2)
  • flip – An SDL_RendererFlip value stating which flipping actions should be performed on the texture
Returns:

0 on success, or -1 on error

sdl.renderDrawLine(renderer, x1, y1, x2, y2)

int SDL_RenderDrawLine(SDL_Renderer *, int, int, int, int)

Draw a line on the current rendering target.

Parameters:
  • renderer – The renderer which should draw a line.
  • x1 – The x coordinate of the start point.
  • y1 – The y coordinate of the start point.
  • x2 – The x coordinate of the end point.
  • y2 – The y coordinate of the end point.
Returns:

0 on success, or -1 on error

sdl.renderDrawLines(renderer, points, count)

int SDL_RenderDrawLines(SDL_Renderer *, SDL_Point const *, int)

Draw a series of connected lines on the current rendering target.

Parameters:
  • renderer – The renderer which should draw multiple lines.
  • points – The points along the lines
  • count – The number of points, drawing count-1 lines
Returns:

0 on success, or -1 on error

sdl.renderDrawPoint(renderer, x, y)

int SDL_RenderDrawPoint(SDL_Renderer *, int, int)

Draw a point on the current rendering target.

Parameters:
  • renderer – The renderer which should draw a point.
  • x – The x coordinate of the point.
  • y – The y coordinate of the point.
Returns:

0 on success, or -1 on error

sdl.renderDrawPoints(renderer, points, count)

int SDL_RenderDrawPoints(SDL_Renderer *, SDL_Point const *, int)

Draw multiple points on the current rendering target.

Parameters:
  • renderer – The renderer which should draw multiple points.
  • points – The points to draw
  • count – The number of points to draw
Returns:

0 on success, or -1 on error

sdl.renderDrawRect(renderer, rect)

int SDL_RenderDrawRect(SDL_Renderer *, SDL_Rect const *)

Draw a rectangle on the current rendering target.

Parameters:
  • renderer – The renderer which should draw a rectangle.
  • rect – A pointer to the destination rectangle, or NULL to outline the entire rendering target.
Returns:

0 on success, or -1 on error

sdl.renderDrawRects(renderer, rects, count)

int SDL_RenderDrawRects(SDL_Renderer *, SDL_Rect const *, int)

Draw some number of rectangles on the current rendering target.

Parameters:
  • renderer – The renderer which should draw multiple rectangles.
  • rects – A pointer to an array of destination rectangles.
  • count – The number of rectangles.
Returns:

0 on success, or -1 on error

sdl.renderFillRect(renderer, rect)

int SDL_RenderFillRect(SDL_Renderer *, SDL_Rect const *)

Fill a rectangle on the current rendering target with the drawing color.

Parameters:
  • renderer – The renderer which should fill a rectangle.
  • rect – A pointer to the destination rectangle, or NULL for the entire rendering target.
Returns:

0 on success, or -1 on error

sdl.renderFillRects(renderer, rects, count)

int SDL_RenderFillRects(SDL_Renderer *, SDL_Rect const *, int)

Fill some number of rectangles on the current rendering target with the drawing color.

Parameters:
  • renderer – The renderer which should fill multiple rectangles.
  • rects – A pointer to an array of destination rectangles.
  • count – The number of rectangles.
Returns:

0 on success, or -1 on error

sdl.renderGetClipRect(renderer, rect)

void SDL_RenderGetClipRect(SDL_Renderer *, SDL_Rect *)

Get the clip rectangle for the current target.

Parameters:
  • renderer – The renderer from which clip rectangle should be queried.
  • rect – A pointer filled in with the current clip rectangle, or an empty rectangle if clipping is disabled.

See also SDL_RenderSetClipRect()

sdl.renderGetLogicalSize(renderer, w=None, h=None)

void SDL_RenderGetLogicalSize(SDL_Renderer *, int *, int *)

Get device independent resolution for rendering.

Parameters:
  • renderer – The renderer from which resolution should be queried.
  • w – A pointer filled with the width of the logical resolution
  • h – A pointer filled with the height of the logical resolution

See also SDL_RenderSetLogicalSize()

sdl.renderGetScale(renderer, scaleX=None, scaleY=None)

void SDL_RenderGetScale(SDL_Renderer *, float *, float *)

Get the drawing scale for the current target.

Parameters:
  • renderer – The renderer from which drawing scale should be queried.
  • scaleX – A pointer filled in with the horizontal scaling factor
  • scaleY – A pointer filled in with the vertical scaling factor

See also SDL_RenderSetScale()

sdl.renderGetViewport(renderer, rect)

void SDL_RenderGetViewport(SDL_Renderer *, SDL_Rect *)

Get the drawing area for the current target.

See also SDL_RenderSetViewport()

sdl.renderPresent(renderer)

void SDL_RenderPresent(SDL_Renderer *)

Update the screen with rendering performed.

sdl.renderReadPixels(renderer, rect, format, pixels, pitch)

int SDL_RenderReadPixels(SDL_Renderer *, SDL_Rect const *, uint32_t, void *, int)

Read pixels from the current rendering target.

Parameters:
  • renderer – The renderer from which pixels should be read.
  • rect – A pointer to the rectangle to read, or NULL for the entire render target.
  • format – The desired format of the pixel data, or 0 to use the format of the rendering target
  • pixels – A pointer to be filled in with the pixel data
  • pitch – The pitch of the pixels parameter.
Returns:

0 on success, or -1 if pixel reading is not supported.

This is a very slow operation, and should not be used frequently.

sdl.renderSetClipRect(renderer, rect)

int SDL_RenderSetClipRect(SDL_Renderer *, SDL_Rect const *)

Set the clip rectangle for the current target.

Parameters:
  • renderer – The renderer for which clip rectangle should be set.
  • rect – A pointer to the rectangle to set as the clip rectangle, or NULL to disable clipping.
Returns:

0 on success, or -1 on error

See also SDL_RenderGetClipRect()

sdl.renderSetLogicalSize(renderer, w, h)

int SDL_RenderSetLogicalSize(SDL_Renderer *, int, int)

Set device independent resolution for rendering.

Parameters:
  • renderer – The renderer for which resolution should be set.
  • w – The width of the logical resolution
  • h – The height of the logical resolution

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()

sdl.renderSetScale(renderer, scaleX, scaleY)

int SDL_RenderSetScale(SDL_Renderer *, float, float)

Set the drawing scale for rendering on the current target.

Parameters:
  • renderer – The renderer for which the drawing scale should be set.
  • scaleX – The horizontal scaling factor
  • scaleY – The vertical scaling factor

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()

sdl.renderSetViewport(renderer, rect)

int SDL_RenderSetViewport(SDL_Renderer *, SDL_Rect const *)

Set the drawing area for rendering on the current target.

Parameters:
  • renderer – The renderer for which the drawing area should be set.
  • rect – The rectangle representing the drawing area, or NULL to set the viewport to the entire target.

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.renderTargetSupported(renderer)

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.reportAssertion()

SDL_assert_state SDL_ReportAssertion(SDL_assert_data *, char const *, char const *, int)

sdl.resetAssertionReport()

void SDL_ResetAssertionReport(void)

Reset the list of all assertion failures.

Reset list of all assertions triggered.

See also SDL_GetAssertionReport

sdl.restoreWindow(window)

void SDL_RestoreWindow(SDL_Window *)

Restore the size and position of a minimized or maximized window.

See also SDL_MaximizeWindow()

sdl.saveAllDollarTemplates(src)

int SDL_SaveAllDollarTemplates(SDL_RWops *)

Save all currently loaded Dollar Gesture templates.

sdl.saveBMP_RW(surface, dst, freedst)

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.
sdl.saveDollarTemplate(gestureId, src)

int SDL_SaveDollarTemplate(int64_t, SDL_RWops *)

Save a currently loaded Dollar Gesture template.

sdl.scalbn(x, n)

double SDL_scalbn(double, int)

sdl.sem

alias of SDL_sem

sdl.semPost(sem)

int SDL_SemPost(SDL_sem *)

Atomically increases the semaphore’s count (not blocking).

Returns:0, or -1 on error.
sdl.semTryWait(sem)

int SDL_SemTryWait(SDL_sem *)

Non-blocking variant of SDL_SemWait().

Returns:0 if the wait succeeds,
sdl.semValue(sem)

uint32_t SDL_SemValue(SDL_sem *)

Returns the current count of the semaphore.

sdl.semWait(sem)

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.

sdl.semWaitTimeout(sem, ms)

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.

sdl.setAssertionHandler(handler, userdata)

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:
  • handler – Callback function, called when an assertion fails.
  • userdata – A pointer passed to the callback as-is.
sdl.setClipRect(surface, rect)

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.

sdl.setClipboardText(text)

int SDL_SetClipboardText(char const *)

Put UTF-8 text into the clipboard.

See also SDL_GetClipboardText()

sdl.setColorKey(surface, flag, key)

int SDL_SetColorKey(SDL_Surface *, int, uint32_t)

Sets the color key (transparent pixel) in a blittable surface.

Parameters:
  • surface – The surface to update
  • flag – Non-zero to enable colorkey and 0 to disable colorkey
  • key – The transparent pixel in the native surface format
Returns:

0 on success, or -1 if the surface is not valid

You can pass SDL_RLEACCEL to enable RLE accelerated blits.

sdl.setCursor(cursor)

void SDL_SetCursor(SDL_Cursor *)

Set the active cursor.

sdl.setError(fmt)

int SDL_SetError(char const *, ...)

sdl.setEventFilter(filter, userdata)

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.setHint(name, value)

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.setHintWithPriority(name, value, priority)

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
sdl.setMainReady()

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.

sdl.setModState(modstate)

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.

sdl.setPaletteColors(palette, colors, firstcolor, ncolors)

int SDL_SetPaletteColors(SDL_Palette *, SDL_Color const *, int, int)

Set a range of colors in a palette.

Parameters:
  • palette – The palette to modify.
  • colors – An array of colors to copy into the palette.
  • firstcolor – The index of the first palette entry to modify.
  • ncolors – The number of entries to modify.
Returns:

0 on success, or -1 if not all of the colors could be set.

sdl.setPixelFormatPalette(format, palette)

int SDL_SetPixelFormatPalette(SDL_PixelFormat *, SDL_Palette *)

Set the palette for a pixel format structure.

sdl.setRelativeMouseMode(enabled)

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()

sdl.setRenderDrawBlendMode(renderer, blendMode)

int SDL_SetRenderDrawBlendMode(SDL_Renderer *, SDL_BlendMode)

Set the blend mode used for drawing operations (Fill and Line).

Parameters:
  • renderer – The renderer for which blend mode should be set.
  • blendMode – SDL_BlendMode to use for blending.
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()

sdl.setRenderDrawColor(renderer, r, g, b, a)

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:
  • renderer – The renderer for which drawing color should be set.
  • r – The red value used to draw on the rendering target.
  • g – The green value used to draw on the rendering target.
  • b – The blue value used to draw on the rendering target.
  • a – The alpha value used to draw on the rendering target, usually SDL_ALPHA_OPAQUE (255).
Returns:

0 on success, or -1 on error

sdl.setRenderTarget(renderer, texture)

int SDL_SetRenderTarget(SDL_Renderer *, SDL_Texture *)

Set a texture as the current rendering target.

Parameters:
  • renderer – The renderer.
  • texture – The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
Returns:

0 on success, or -1 on error

See also SDL_GetRenderTarget()

sdl.setSurfaceAlphaMod(surface, alpha)

int SDL_SetSurfaceAlphaMod(SDL_Surface *, uint8_t)

Set an additional alpha value used in blit operations.

Parameters:
  • surface – The surface to update.
  • alpha – The alpha value multiplied into blit operations.
Returns:

0 on success, or -1 if the surface is not valid.

See also SDL_GetSurfaceAlphaMod()

sdl.setSurfaceBlendMode(surface, blendMode)

int SDL_SetSurfaceBlendMode(SDL_Surface *, SDL_BlendMode)

Set the blend mode used for blit operations.

Parameters:
  • surface – The surface to update.
  • blendMode – SDL_BlendMode to use for blit blending.
Returns:

0 on success, or -1 if the parameters are not valid.

See also SDL_GetSurfaceBlendMode()

sdl.setSurfaceColorMod(surface, r, g, b)

int SDL_SetSurfaceColorMod(SDL_Surface *, uint8_t, uint8_t, uint8_t)

Set an additional color value used in blit operations.

Parameters:
  • surface – The surface to update.
  • r – The red color value multiplied into blit operations.
  • g – The green color value multiplied into blit operations.
  • b – The blue color value multiplied into blit operations.
Returns:

0 on success, or -1 if the surface is not valid.

See also SDL_GetSurfaceColorMod()

sdl.setSurfacePalette(surface, palette)

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.

sdl.setSurfaceRLE(surface, flag)

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.

sdl.setTextInputRect(rect)

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()

sdl.setTextureAlphaMod(texture, alpha)

int SDL_SetTextureAlphaMod(SDL_Texture *, uint8_t)

Set an additional alpha value used in render copy operations.

Parameters:
  • texture – The texture to update.
  • alpha – The alpha value multiplied into copy operations.
Returns:

0 on success, or -1 if the texture is not valid or alpha modulation is not supported.

See also SDL_GetTextureAlphaMod()

sdl.setTextureBlendMode(texture, blendMode)

int SDL_SetTextureBlendMode(SDL_Texture *, SDL_BlendMode)

Set the blend mode used for texture copy operations.

Parameters:
  • texture – The texture to update.
  • blendMode – SDL_BlendMode to use for texture blending.
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()

sdl.setTextureColorMod(texture, r, g, b)

int SDL_SetTextureColorMod(SDL_Texture *, uint8_t, uint8_t, uint8_t)

Set an additional color value used in render copy operations.

Parameters:
  • texture – The texture to update.
  • r – The red color value multiplied into copy operations.
  • g – The green color value multiplied into copy operations.
  • b – The blue color value multiplied into copy operations.
Returns:

0 on success, or -1 if the texture is not valid or color modulation is not supported.

See also SDL_GetTextureColorMod()

sdl.setThreadPriority(priority)

int SDL_SetThreadPriority(SDL_ThreadPriority)

Set the priority for the current thread

sdl.setWindowBordered(window, bordered)

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:
  • window – The window of which to change the border state.
  • bordered – SDL_FALSE to remove border, SDL_TRUE to add border.

You can’t change the border state of a fullscreen window.

See also SDL_GetWindowFlags()

sdl.setWindowBrightness(window, brightness)

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()

sdl.setWindowData(window, name, userdata)

void * SDL_SetWindowData(SDL_Window *, char const *, void *)

Associate an arbitrary named pointer with a window.

Parameters:
  • window – The window to associate with the pointer.
  • name – The name of the pointer.
  • userdata – The associated pointer.
Returns:

The previous value associated with ‘name’

The name is case-sensitive.

See also SDL_GetWindowData()

sdl.setWindowDisplayMode(window, mode)

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:
  • window – The window for which the display mode should be set.
  • mode – The mode to use, or NULL for the default mode.
Returns:

0 on success, or -1 if setting the display mode failed.

See also SDL_GetWindowDisplayMode()

sdl.setWindowFullscreen(window, flags)

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()

sdl.setWindowGammaRamp(window, red=None, green=None, blue=None)

int SDL_SetWindowGammaRamp(SDL_Window *, uint16_t const *, uint16_t const *, uint16_t const *)

Set the gamma ramp for a window.

Parameters:
  • window – The window for which the gamma ramp should be set.
  • red – The translation table for the red channel, or NULL.
  • green – The translation table for the green channel, or NULL.
  • blue – The translation table for the blue channel, or NULL.
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()

sdl.setWindowGrab(window, grabbed)

void SDL_SetWindowGrab(SDL_Window *, SDL_bool)

Set a window’s input grab mode.

Parameters:
  • window – The window for which the input grab mode should be set.
  • grabbed – This is SDL_TRUE to grab input, and SDL_FALSE to release input.

See also SDL_GetWindowGrab()

sdl.setWindowIcon(window, icon)

void SDL_SetWindowIcon(SDL_Window *, SDL_Surface *)

Set the icon for a window.

Parameters:
  • window – The window for which the icon should be set.
  • icon – The icon for the window.
sdl.setWindowMaximumSize(window, max_w, max_h)

void SDL_SetWindowMaximumSize(SDL_Window *, int, int)

Set the maximum size of a window’s client area.

Parameters:
  • window – The window to set a new maximum size.
  • max_w – The maximum width of the window, must be >0
  • max_h – The maximum height of the window, must be >0

You can’t change the maximum size of a fullscreen window, it automatically matches the size of the display mode.

See also SDL_GetWindowMaximumSize()

sdl.setWindowMinimumSize(window, min_w, min_h)

void SDL_SetWindowMinimumSize(SDL_Window *, int, int)

Set the minimum size of a window’s client area.

Parameters:
  • window – The window to set a new minimum size.
  • min_w – The minimum width of the window, must be >0
  • min_h – The minimum height of the window, must be >0

You can’t change the minimum size of a fullscreen window, it automatically matches the size of the display mode.

See also SDL_GetWindowMinimumSize()

sdl.setWindowPosition(window, x, y)

void SDL_SetWindowPosition(SDL_Window *, int, int)

Set the position of a window.

Parameters:
  • window – The window to reposition.
  • x – The x coordinate of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED.
  • y – The y coordinate of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED.

The window coordinate origin is the upper left of the display.

See also SDL_GetWindowPosition()

sdl.setWindowSize(window, w, h)

void SDL_SetWindowSize(SDL_Window *, int, int)

Set the size of a window’s client area.

Parameters:
  • window – The window to resize.
  • w – The width of the window, must be >0
  • h – The height of the window, must be >0

You can’t change the size of a fullscreen window, it automatically matches the size of the display mode.

See also SDL_GetWindowSize()

sdl.setWindowTitle(window, title)

void SDL_SetWindowTitle(SDL_Window *, char const *)

Set the title of a window, in UTF-8 format.

See also SDL_GetWindowTitle()

sdl.setenv(name, value, overwrite)

int SDL_setenv(char const *, char const *, int)

sdl.showCursor(toggle)

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.
sdl.showMessageBox(messageboxdata, buttonid=None)

int SDL_ShowMessageBox(SDL_MessageBoxData const *, int *)

Create a modal message box.

Parameters:
  • messageboxdata – The SDL_MessageBoxData structure with title, text, etc.
  • buttonid – The pointer to which user id of hit button should be copied.
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.

sdl.showSimpleMessageBox(flags, title, message, window)

int SDL_ShowSimpleMessageBox(uint32_t, char const *, char const *, SDL_Window *)

Create a simple modal message box.

Parameters:
  • flags – SDL_MessageBoxFlags
  • title – UTF-8 title text
  • message – UTF-8 message text
  • window – The parent window, or NULL for no parent
Returns:

0 on success, -1 on error

See also SDL_ShowMessageBox

sdl.showWindow(window)

void SDL_ShowWindow(SDL_Window *)

Show a window.

See also SDL_HideWindow()

sdl.sin(x)

double SDL_sin(double)

sdl.sinf(x)

float SDL_sinf(float)

sdl.snprintf(text, maxlen, fmt)

int SDL_snprintf(char *, size_t, char const *, ...)

sdl.softStretch(src, srcrect, dst, dstrect)

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.

sdl.sqrt(x)

double SDL_sqrt(double)

sdl.sscanf(text, fmt)

int SDL_sscanf(char const *, char const *, ...)

sdl.startTextInput()

void SDL_StartTextInput(void)

Start accepting Unicode text input events. This function will show the on-screen keyboard if supported.

See also SDL_StopTextInput()

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()

sdl.strcasecmp(str1, str2)

int SDL_strcasecmp(char const *, char const *)

sdl.strchr(str, c)

char * SDL_strchr(char const *, int)

sdl.strcmp(str1, str2)

int SDL_strcmp(char const *, char const *)

sdl.strdup(str)

char * SDL_strdup(char const *)

sdl.strlcat(dst, src, maxlen)

size_t SDL_strlcat(char *, char const *, size_t)

sdl.strlcpy(dst, src, maxlen)

size_t SDL_strlcpy(char *, char const *, size_t)

sdl.strlen(str)

size_t SDL_strlen(char const *)

sdl.strlwr(str)

char * SDL_strlwr(char *)

sdl.strncasecmp(str1, str2, len)

int SDL_strncasecmp(char const *, char const *, size_t)

sdl.strncmp(str1, str2, maxlen)

int SDL_strncmp(char const *, char const *, size_t)

sdl.strrchr(str, c)

char * SDL_strrchr(char const *, int)

sdl.strrev(str)

char * SDL_strrev(char *)

sdl.strstr(haystack, needle)

char * SDL_strstr(char const *, char const *)

sdl.strtod(str, endp)

double SDL_strtod(char const *, char * *)

sdl.strtol(str, endp, base)

long SDL_strtol(char const *, char * *, int)

sdl.strtoll(str, endp, base)

int64_t SDL_strtoll(char const *, char * *, int)

sdl.strtoul(str, endp, base)

unsigned long SDL_strtoul(char const *, char * *, int)

sdl.strtoull(str, endp, base)

uint64_t SDL_strtoull(char const *, char * *, int)

sdl.strupr(str)

char * SDL_strupr(char *)

sdl.threadID()

unsigned long SDL_ThreadID(void)

Get the thread identifier for the current thread.

sdl.tolower(x)

int SDL_tolower(int)

sdl.toupper(x)

int SDL_toupper(int)

sdl.tryLockMutex(mutex)

int SDL_TryLockMutex(SDL_mutex *)

Try to lock the mutex

Returns:0, SDL_MUTEX_TIMEDOUT, or -1 on error
sdl.uitoa(value, str, radix)

char * SDL_uitoa(unsigned int, char *, int)

sdl.ulltoa(value, str, radix)

char * SDL_ulltoa(uint64_t, char *, int)

sdl.ultoa(value, str, radix)

char * SDL_ultoa(unsigned long, char *, int)

sdl.unionRect(A, B, result)

void SDL_UnionRect(SDL_Rect const *, SDL_Rect const *, SDL_Rect *)

Calculate the union of two rectangles.

sdl.unloadObject(handle)

void SDL_UnloadObject(void *)

Unload a shared object from memory.

sdl.unlockAudio()

void SDL_UnlockAudio(void)

sdl.unlockAudioDevice(dev)

void SDL_UnlockAudioDevice(uint32_t)

sdl.unlockMutex(mutex)

int SDL_UnlockMutex(SDL_mutex *)

sdl.unlockSurface(surface)

void SDL_UnlockSurface(SDL_Surface *)

See also SDL_LockSurface()

sdl.unlockTexture(texture)

void SDL_UnlockTexture(SDL_Texture *)

Unlock a texture, uploading the changes to video memory, if needed.

See also SDL_LockTexture()

sdl.updateTexture(texture, rect, pixels, pitch)

int SDL_UpdateTexture(SDL_Texture *, SDL_Rect const *, void const *, int)

Update the given texture rectangle with new pixel data.

Parameters:
  • texture – The texture to update
  • rect – A pointer to the rectangle of pixels to update, or NULL to update the entire texture.
  • pixels – The raw pixel data.
  • pitch – The number of bytes between rows of pixel data.
Returns:

0 on success, or -1 if the texture is not valid.

This is a fairly slow function.

sdl.updateWindowSurface(window)

int SDL_UpdateWindowSurface(SDL_Window *)

Copy the window surface to the screen.

Returns:0 on success, or -1 on error.

See also SDL_GetWindowSurface()

sdl.updateWindowSurfaceRects(window, rects, numrects)

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()

sdl.upperBlit(src, srcrect, dst, dstrect)

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()

sdl.upperBlitScaled(src, srcrect, dst, dstrect)

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()

sdl.utf8strlcpy(dst, src, dst_bytes)

size_t SDL_utf8strlcpy(char *, char const *, size_t)

sdl.version

alias of SDL_version

sdl.videoInit(driver_name)

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()

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()

sdl.vsnprintf(text, maxlen, fmt, ap)

int SDL_vsnprintf(char *, size_t, char const *, int32_t)

sdl.waitEvent(event)

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.
sdl.waitEventTimeout(event, timeout)

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:
  • event – If not NULL, the next event is removed from the queue and stored in that area.
  • timeout – The timeout (in milliseconds) to wait for next event.
sdl.waitThread(thread, status=None)

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.

sdl.warpMouseInWindow(window, x, y)

void SDL_WarpMouseInWindow(SDL_Window *, int, int)

Moves the mouse to the given position within the window.

Parameters:
  • window – The window to move the mouse into, or NULL for the current mouse focus
  • x – The x coordinate within the window
  • y – The y coordinate within the window

This function generates a mouse motion event

sdl.wasInit(flags)

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.

sdl.wcslcat(dst, src, maxlen)

size_t SDL_wcslcat(wchar_t *, wchar_t const *, size_t)

sdl.wcslcpy(dst, src, maxlen)

size_t SDL_wcslcpy(wchar_t *, wchar_t const *, size_t)

sdl.wcslen(wstr=None)

size_t SDL_wcslen(wchar_t const *)

sdl.writeBE16(dst, value)

size_t SDL_WriteBE16(SDL_RWops *, uint16_t)

sdl.writeBE32(dst, value)

size_t SDL_WriteBE32(SDL_RWops *, uint32_t)

sdl.writeBE64(dst, value)

size_t SDL_WriteBE64(SDL_RWops *, uint64_t)

sdl.writeLE16(dst, value)

size_t SDL_WriteLE16(SDL_RWops *, uint16_t)

sdl.writeLE32(dst, value)

size_t SDL_WriteLE32(SDL_RWops *, uint32_t)

sdl.writeLE64(dst, value)

size_t SDL_WriteLE64(SDL_RWops *, uint64_t)

sdl.writeU8(dst, value)

size_t SDL_WriteU8(SDL_RWops *, uint8_t)

Previous topic

pysdl2-cffi

Next topic

SDL_image API

This Page