SDL API reference
Here is the SDL 1.3 API function reference ordered by SDL subsystem. For an alphabetical ordered list of API functions, see SDL_API_by_name.
Contents
General
SDL_Init - Initializes SDL.
SDL_Quit - Shuts down SDL.
SDL_InitSubSystem - Initializes subsystems.
SDL_QuitSubSystem - Shuts down a subsystem.
SDL_WasInit - Checks which subsystems are initialized.
Error Handling
SDL_GetError - Retrieve a null-terminated string describing the last reported SDL error.
SDL_SetError - Set a string describing an error to be submitted to the SDL Error system.
SDL_Error - Set a SDL Error based on an error code.
SDL_ClearError - Clear the last reported error from the SDL Error system.
Object Loading
SDL_LoadObject - Load a shared object.
SDL_LoadFunction - Return the address of a function in a loaded shared object.
SDL_UnloadObject - Unload a shared object.
SDL_envvars - Setting/Retrieving SDL environment variables.
CPU/Power Info
CPU Feature Queries - A list of functions used to query the features offered by a CPU.
SDL_GetPowerInfo - Retrieve the seconds and percentage of remaining battery life.
Version
SDL_VERSION - Determine the compile-time version of SDL.
SDL_GetVersion - Determine the run-time version of SDL.
SDL_GetRevision - Determine the run-time revision number of SDL.
SDL_version - Defines an SDL version.
Video
SDL_GetNumVideoDrivers - Returns the number of video drivers compiled into SDL.
SDL_GetVideoDriver - Returns the name of a video driver compiled into SDL.
SDL_VideoInit - Initialize the video subsystem, optionally specifying a video driver.
SDL_VideoQuit - Shuts down the video subsystem.
SDL_GetCurrentVideoDriver - Returns the name of the currently initialized video driver.
Display Devices
SDL_GetNumVideoDisplays - Returns the number of available video displays.
SDL_SelectVideoDisplay - Set the current active video display.
SDL_GetCurrentVideoDisplay - Get the ID of the currently active video display.
Display Modes
SDL_GetNumDisplayModes - Returns the number of available display modes for the current display.
SDL_GetDisplayMode - Retrieve information about a specific display mode.
SDL_GetDesktopDisplayMode - Retrieve information about the current desktop display mode.
SDL_GetCurrentDisplayMode - Retrieve information about the current display mode.
SDL_GetClosestDisplayMode - Get the closest match to the requested display mode.
SDL_SetFullscreenDisplayMode - Set the display mode used when a fullscreen window is visible.
SDL_GetFullscreenDisplayMode - Retrieve information about the display mode used when a fullscreen window is visible.
SDL_SetDisplayPalette - Set the palette entries for indexed display modes.
SDL_GetDisplayPalette - Retrieve the palette entries from indexed display modes.
SDL_SetGamma - Set the gamma correction for each color channel on the current display.
SDL_SetGammaRamp - Set the gamma ramp for the current display.
SDL_GetGammaRamp - Retrieve the gamma ramp from the current display.
Windows
SDL_CreateWindow - Create a window.
SDL_DestroyWindow - Destroy a window.
SDL_GetWindowFlags - Retrieve the flag settings of a window.
SDL_SetWindowTitle - Set the title of a window, in UTF-8 format.
SDL_GetWindowTitle - Get the title of a window, in UTF-8 format.
SDL_SetWindowIcon - Set the icon of a window.
SDL_SetWindowData - Associate a pointer to user-data with a window.
SDL_GetWindowData - Retrieve a pointer to user-data from a window.
SDL_SetWindowPosition - Set the position of a window.
SDL_GetWindowPosition - Get the position of a window.
SDL_SetWindowSize - Set the size of a window's client area (ignores surrounding borders).
SDL_GetWindowSize - Get the size of a window's client area (ignores surrounding borders).
SDL_ShowWindow - Show a window.
SDL_HideWindow - Hide a window.
SDL_RaiseWindow - Bring a window to the front and make it current.
SDL_MaximizeWindow - Make a window as large as possible.
SDL_MinimizeWindow - Iconize a window (reduce to the taskbar).
SDL_RestoreWindow - Restore the size and position of a minimized or maximized window.
SDL_SetWindowFullscreen - Place a window in fullscreen mode.
SDL_SetWindowGrab - Set a window's input grab mode.
SDL_GetWindowGrab - Retrieve a window's input grab mode.
SDL_GetWindowWMInfo - Get driver specific information about a window.
Renderer
SDL_GetNumRenderDrivers - Returns the number of available render drivers for the current active display.
SDL_GetRenderDriverInfo - Retrieve information on a specified render driver for the current active display.
SDL_CreateRenderer - Create a render driver for the specified window and make it active.
SDL_DestroyRenderer - Destroy the rendering context for the specified window along with all associated textures.
SDL_SelectRenderer - Retrieve the rendering context of the specified window.
SDL_GetRendererInfo - Retrieve information on the currently active rendering context.
SDL_CreateTexture - Create a texture for the currently active rendering context.
SDL_CreateTextureFromSurface - Create a texture from an existing SDL_Surface for the currently active rendering context.
SDL_DestroyTexture - Destroy the specified texture.
SDL_QueryTexture - Query the attributes of the specified texture.
SDL_QueryTexturePixels - Query the pixel data of the specified texture.
SDL_SetTexturePalette - Set the color palette of the specified indexed texture.
SDL_GetTexturePalette - Retrieve the color palette of the specified indexed texture.
SDL_SetTextureColorMod - Set a color value to be used to modulate the color of the specified texture.
SDL_GetTextureColorMod - Retrieve the color value used to modulate the color of the specified texture.
SDL_SetTextureAlphaMod - Set an alpha value to be used to modulate the alpha of the specified texture.
SDL_GetTextureAlphaMod - Retrieve the alpha value to be used to modulate the alpha of the specified texture.
SDL_SetTextureBlendMode - Set the blend mode to be used for texture copy operations for the specified texture.
SDL_GetTextureBlendMode - Retrieve the blend mode used for texture copy operations for the specified texture.
SDL_SetTextureScaleMode - Set the scale mode to be used for texture copy operation for the specified texture.
SDL_GetTextureScaleMode - Retrieve the scale mode used for texture copy operation for the specified texture.
SDL_UpdateTexture - Update a rectangle of pixel data for the specified texture.
SDL_LockTexture - Lock a rectangle of pixel data for the specified texture for editing.
SDL_UnlockTexture - Unlock pixel data for the specified texture, uploading the changes to video memory if required.
SDL_DirtyTexture - Mark an array of rectangles of pixel data as 'dirty' for the specified texture.
SDL_SetRenderDrawColor - Set the color to be used in Fill and Line drawing operations.
SDL_GetRenderDrawColor - Retrieve the color used in Fill and Line drawing operations.
SDL_SetRenderDrawBlendMode - Set the blend mode to be used in Fill and Line drawing operations.
SDL_GetRenderDrawBlendMode - Retrieve the blend mode used in Fill and Line drawing operations.
SDL_RenderPoint - Draw a point on the currently active rendering context.
SDL_RenderLine - Draw a line on the currently active rendering context.
SDL_RenderFill - Fill a specified rectangle of pixels with the set color on the currently active rendering context.
SDL_RenderCopy - Copy a rectangle of pixels from the specified texture into a rectangle of pixels in the currently active rendering context (just like performing a BLIT).
SDL_RenderReadPixels - Retrieve a rectangle of pixel data from the currently active rendering context.
SDL_RenderWritePixels - Write a rectangle of pixel data to the currently active rendering context (warning: very slow).
SDL_RenderPresent - Update the screen with rendering actions performed since the last update (like SwapBuffers).
OpenGL
SDL_GL_LoadLibrary - Specify the OpenGL library to be used.
SDL_GL_UnloadLibrary - Unload the OpenGL library.
SDL_GL_ExtensionSupported - Confirm if an OpenGL extension is supported for the current context.
SDL_GL_GetProcAddress - Retrieve the address of an OpenGL function.
SDL_GL_GetAttribute - Retrieve the value of a special SDL/OpenGL attribute.
SDL_GL_SetAttribute - Set the value of a special SDL/OpenGL attribute.
SDL_GL_CreateContext - Create an OpenGL context for the specified window and make it current.
SDL_GL_DeleteContext - Delete the specified OpenGL context.
SDL_GL_MakeCurrent - Assign the specified OpenGL context to the specified window and make it current.
SDL_GL_SetSwapInterval - Set the swap interval for the current OpenGL context.
SDL_GL_GetSwapInterval - Retrieve the swap interval of the current OpenGL context.
SDL_GL_SwapWindow - Swap OpenGL framebuffers / update display for the specified window.
SDL_GLattr - SDL GL Attributes.
Screensaver
SDL_IsScreenSaverEnabled - Determine if the screen may be blanked by a screensaver.
SDL_EnableScreenSaver - Allow the screen to be blanked by a screensaver.
SDL_DisableScreenSaver - Prevent the screen from being blanked by a screensaver.
Events
SDLKey - Keysym definitions.
SDLMod - Modifier definitions.
SDL_PumpEvents - Pump the event loop, gathering events from input devices.
SDL_PeepEvents - Check the event queue for messages and optionally return them.
SDL_PollEvent - Poll for currently pending events.
SDL_HasEvent - Check to see if the specified events are present in the event queue.
SDL_WaitEvent - Wait indefinitely for the next available event.
SDL_WaitEventTimeout - Wait for the next available event, but only up to a specified maximum time.
SDL_PushEvent - Push an event onto the event queue.
SDL_SetEventFilter - Set up a filter to process all events.
SDL_GetEventFilter - Retrieve the current event filter (useful for chaining filters).
SDL_EventState - Set the processing state of certain events.
Device States
SDL_GetKeyboardState - Retrieve a snapshot of the current keyboard state of the currently active keyboard.
SDL_GetModState - Retrieve the state of modifier keys of the currently active keyboard.
SDL_SetModState - Set the state of modifier keys for the currently active keyboard.
SDL_GetKeyName - Retrieve the name of an SDL virtual keysym.
SDL_GetMouseState - Retrieve the current state of the currently active mouse.
SDL_GetRelativeMouseState - Retrieve the current relative state of the currently active mouse.
SDL_JoystickEventState - Enable/disable joystick event polling.
Mouse
SDL_GetNumMice - Retrieve the number of available mice.
SDL_GetMouseName - Retrieve the name of a specified mouse.
SDL_SelectMouse - Set the current active mouse.
SDL_GetMouseFocusWindow - Retrieve the ID of the window that currently has focus for a specified mouse.
SDL_WarpMouseInWindow - Set the position of the mouse cursor in the specified window.
SDL_CreateCursor - Creates a new mouse cursor for the currently active mouse.
SDL_FreeCursor - Free a mouse cursor.
SDL_SetCursor - Set the cursor for the currently active mouse.
SDL_GetCursor - Retrieve the cursor from the currently active mouse.
SDL_ShowCursor - Toggles whether or not the cursor is shown on the screen for the currently active mouse.
SDL_GetCursorsNumber - Retrieve the number of supported cursors (useful in Windows only).
SDL_GetCurrentCursor - Retrieve the ID of the current cursor of a specified mouse (useful in Windows only).
Joystick
SDL_NumJoysticks - Retrieve the number of available joysticks.
SDL_JoystickName - Retrieve the name of a joystick.
SDL_JoystickOpen - Open a joystick for use.
SDL_JoystickClose - Close a previously opened joystick.
SDL_JoystickOpened - Determine if a joystick has been opened.
SDL_JoystickIndex - Retrieve the ID of a joystick.
SDL_JoystickNumAxes - Retrieve the number of joystick axes.
SDL_JoystickNumBalls - Retrieve the number of joystick trackballs.
SDL_JoystickNumHats - Retrieve the number of joystick hats.
SDL_JoystickNumButtons - Retrieve the number of joystick buttons.
SDL_JoystickUpdate - Update the state of all joysticks.
SDL_JoystickGetAxis - Retrieve the current state of a joystick axis.
SDL_JoystickGetHat - Retrieve the current state of a joystick hat.
SDL_JoystickGetBall - Retrieve relative trackball motion.
SDL_JoystickGetButton - Retrieve the current state of a specified button on a joystick.
Haptic (Force Feedback)
SDL_NumHaptics - Retrieve the number of detected Haptic devices.
SDL_HapticName - Retrieve the name of the specified Haptic device.
SDL_HapticOpen - Initializes the specified Haptic device.
SDL_HapticClose - Uninitializes the specified Haptic device.
SDL_HapticOpened - Confirms if the specified Haptic device is currently initialized.
SDL_HapticIndex - Retrieve the index of the specified Haptic device.
SDL_MouseIsHaptic - Confirms if the currently active mouse is capable of Haptic functionality.
SDL_HapticOpenFromMouse - Initializes a Haptic Device from the currently active mouse.
SDL_JoystickIsHaptic - Confirms if the specified joystick is capable of Haptic functionality.
SDL_HapticOpenFromJoystick - Initializes a Haptic Device from the specified joystick.
SDL_HapticNumEffects - Retrieve the number of effects the specified Haptic device can store.
SDL_HapticNumEffectsPlaying - Retrieve the number of effects the specified Haptic device can play simulatniously.
SDL_HapticQuery - Retrieve a bitmask of available features on the specified Haptic device.
SDL_HapticNumAxes - Retrieve the number of axis available on the Haptic device.
SDL_HapticEffectSupported - Confirm if an effect is supported on the specified Haptic device.
SDL_HapticNewEffect - Create a new effect on the specified Haptic device.
SDL_HapticDestroyEffect - Stop and destroy the specified effect.
SDL_HapticUpdateEffect - Update the properties of an effect.
SDL_HapticRunEffect - Execute the specified effect on its associated Haptic device.
SDL_HapticStopEffect - Stop execution of the specified effect on its associated Haptic device.
SDL_HapticGetEffectStatus - Retrieve the execution status of the specified effect on its associated Haptic device.
SDL_HapticSetGain - Set the global gain of the specified Haptic device.
SDL_HapticSetAutocenters - Set the global autocenter of the specified Haptic device.
SDL_HapticPause - Pause the specified Haptic device.
SDL_HapticUnpause - Unpause the specified Haptic device.
SDL_HapticStopAll - Stop all currently executing effects on the specified Haptic device.
Audio
SDL_GetNumAudioDevices - Retrieve the number of audio devices exposed by the driver.
SDL_GetAudioDeviceName - Retrieve the name of an audio device.
SDL_OpenAudio - Open the audio device with the desired parameters.
SDL_OpenAudioDevice - Open a specified audio device with the desired parameters.
SDL_CloseAudio - Shut-down audio processing and close the audio device.
SDL_CloseAudioDevice - Shut-down audio processing and close the specified audio device.
SDL_PauseAudio - Pause and un-pause the audio.
SDL_PauseAudioDevice - Pause and un-pause the audio on a specified device.
SDL_GetAudioStatus - Retrieves the current audio status.
SDL_GetAudioDeviceStatus - Retrieves the current audio status of the specified device.
SDL_AudioDeviceConnected - Confirm if the specified device is still functioning.
SDL_LoadWAV - Load a WAVE file.
SDL_FreeWAV - Free the data of a previously opened WAVE file.
SDL_BuildAudioCVT - Initializes a SDL_AudioCVT structure for conversion.
SDL_ConvertAudio - Converts audio data to a specified audio format.
SDL_MixAudio - Mixes audio data.
SDL_MixAudioFormat - Mixes audio data in a specified audio format (allowing deviceless mixing).
SDL_LockAudio - Locks out the callback function.
SDL_LockAudioDevice - Locks out the callback function for a specified device.
SDL_UnlockAudio - Unlocks the callback function.
SDL_UnlockAudioDevice - Unlocks the callback function for a specified device.
SDL_AudioSpec - Audio Specification Structure.
SDL_AudioCVT - Audio Conversion Structure.
Multi-threaded programming
SDL_CreateThread - Create a new thread of execution that shares its parent's properties.
SDL_ThreadID - Retrieve the 32-bit thread ID of the current thread.
SDL_GetThreadID - Get the SDL thread ID of a SDL_Thread.
SDL_WaitThread - Wait for a thread to finish execution.
SDL_CreateMutex - Create a mutex.
SDL_DestroyMutex - Destroy a mutex.
SDL_mutexP - Lock a mutex.
SDL_mutexV - Unlock a mutex.
SDL_CreateSemaphore - Create a new semaphore.
SDL_DestroySemaphore - Destroy a semaphore.
SDL_SemWait - Lock a semaphore and suspend the thread if the semaphore value is zero.
SDL_SemTryWait - Attempt to lock a semaphore but do not suspend the thread.
SDL_SemWaitTimeout - Lock a semaphore, but only wait up to a specified maximum time.
SDL_SemPost - Unlock a semaphore.
SDL_SemValue - Retrieve the current value of a semaphore.
SDL_CreateCond - Create a condition variable.
SDL_DestroyCond - Destroy a condition variable.
SDL_CondSignal - Resume a thread waiting on a condition variable.
SDL_CondBroadcast - Resume all threads waiting on a condition variable.
SDL_CondWait - Wait on a condition variable.
SDL_CondWaitTimeout - Wait on a condition variable, but only up to a specified maximum time.
Time
SDL_GetTicks - Get the number of milliseconds since the SDL library initialization.
SDL_Delay - Wait a specified number of milliseconds before returning.
SDL_AddTimer - Add a timer which will call a callback function after the specified number of milliseconds has elapsed.
SDL_RemoveTimer - Remove a timer.
Files
SDL_RWFromFile - Opens a file.
SDL_RWFromFP - Opens a file from a stdio file pointer.
SDL_RWFromMem - Prepares access to a memory area.
SDL_RWFromConstMem - Prepares access to a constant memory area.
SDL_RWclose - Closes a data source.
SDL_RWseek - Seeks within a data source.
SDL_RWtell - Gets the current position within a data source.
SDL_RWread - Reads from a data source.
SDL_RWwrite - Writes to a data source.
SDL_AllocRW - Allocates an SDL_RWops structure.
SDL_FreeRW - Frees an SDL_RWops structure.
SDL_RWops - Read/write operation structure.
