下载与安装
进入官网下载页面
找到对应平台的下载链接, 比如:
接口说明
基础接口
初始化与退出(SDL.h)
SDL_Init
- 接口定义:
1 | int SDL_Init(Uint32 flags); |
- 功能说明
初始化SDL的各个子系统
- 参数说明:
flags: 子系统初始化使能标志位, 可以使用如下表所示枚举值进行或操作
枚举值 | 子系统 |
---|---|
SDL_INIT_AUDIO | 音频子系统 |
SDL_INIT_EVENTS | 事件子系统 |
SDL_INIT_TIMER | 定时器子系统 |
SDL_INIT_VIDEO | 图形图像子系统 |
SDL_INIT_JOYSTICK | 游戏摇杆子系统 |
SDL_INIT_HAPTIC | 触觉子系统 |
SDL_INIT_CAMECONTROLLER | 游戏控制器子系统(包含摇杆子系统) |
SDL_INIT_EVERYTHING | 所有子系统 |
- 返回值说明:
0: 成功
< 0: 失败错误码, 可以通过
SDL_GetError()
获取错误信息
- 示例代码:
1 |
|
SDL_InitSubSystem
- 接口定义
1 | int SDL_InitSubSystem(Uint32 flags) |
1 | int main(int, char**) { |
SDL_Quit
- 接口定义
1 | void SDL_Quit(); |
- 功能说明
清理所有初始化的的子系统
- 示例代码
1 | int main(int,char**) { |
SDL_QuitSubSystem
- 接口定义
1 | void SDL_QuitSubSystem(Uint32 flags) |
- 功能说明
关闭指定子系统
- 参数说明
flags: 同SDL_Init
- 示例代码
1 | int main(int, char**) { |
SDL_SetMainReady
- 接口定义
1 | void SDL_SetMainReady(); |
- 功能说明
当不使用SDL_main函数作为入口函数时, 使用此函数来规避SDL_Init失败
- 示例代码
1 | int main(int, char**) { |
SDL_WasInit
- 接口定义
1 | Uint32 SDL_WasInit(Uint32 flags); |
- 功能说明
获取已初始化的子系统掩码
- 参数说明
flags: 同SDL_Init
- 返回值说明
flags为0的时候, 返回所有已初始化子系统的掩码。
否则返回指定子系统的初始化状态
SDL_WinRTRunApp
- 接口定义
1 | int SDL_WinRTRunApp(MainFunction main_func, void *reserved); |
- 功能说明
初始化和启动SDL/WinRT 应用程序
- 参数说明
main_func: C风格的main函数的函数类型
int MainFunction(int,char **)
- 返回值说明
0: 成功
-1: 失败, 可以通过SDL_GetError()获取错误信息
配置变量(SDL_hints.h)
错误处理(SDL_error.h)
SDL_GetError()
- 接口定义
1 | const char* SDL_GetError(); |
- 功能说明
获取错误消息
- 返回值说明
有错误时, 返回长度非零的字符串首地址, 否则对应的字符串长度为0
- 示例代码
1 | int main(int, char**) { |
SDL_ClearError()
- 接口定义
1 | void SDL_ClearError(); |
- 功能说明
清除已有错误
- 示例代码
1 | auto error = SDL_GetError(); |
SDL_SetError()
- 接口定义
1 | int SDL_SetError(const char*fmt, ...); |
- 功能说明
设置错误信息
- 参数说明
printf() 风格的格式化输入参数
- 返回值说明
只返回 -1
- 示例代码
1 | SDL_SetError("Invalid render mode: %d", mode); |
日志处理(SDL_log.h)
SDL_Log
SDL_LogCritical
SDL_LogDebug
SDL_LogError
SDL_LogGetOutputFunction
SDL_GetPriority
SDL_LogInfo
SDL_LogMessage
SDL_LogMessageV
SDL_LogResetPriorities
SDL_LogSetAllPriority
SDL_LogSetOutputFunciton
SDL_LogSetPriority
SDL_LogVerbose
SDL_Warn
断言(SDL_assert.h)
SDL_GetAssertionHandler
SDL_GetAssertionReport
SDL_GetDefaultAssertionHandler
SDL_ResetAssertionReport
SDL_SetAssertionHandler
SDL_TriggerBreakpoint
SDL_assert
SDL_assert_paranoid
SDL_assert_release
版本查询(SDL_version.h)
SDL_COMPILEDVERSION
SDL_GetRevision
SDL_GetRevisionNumber
SDL_GetVersion
SDL_REVISION
SDL_VERSION
SDL_VERSIONNUM
SDL_VERSION_ATLEAST
图形图像
显示与窗口管理(SDL_video.h)
SDL_CreateWindow
SDL_CreateWindowAndRenderer
SDL_CreateWindowFrom
SDL_DestroyWindow
SDL_DisableScreenSaver
SDL_EnableScreenSaver
SDL_GL_CreateContext
SDL_GL_DeleteContext
SDL_GL_ExtensionSupported
SDL_GL_GetAttribute
SDL_GL_GetCurrentContext
SDL_GL_GetCurrentWindow
SDL_GL_GetDrawableSize
SDL_GL_GetProcAddress
SDL_GL_GetSwapInterval
SDL_GL_LoadLibrary
SDL_GL_MakeCurrent
SDL_GL_ResetAttributes
SDL_GL_SetAttribute
SDL_GL_SetSwapInterval
SDL_GL_SwapWindow
SDL_GL_UnloadLibrary
SDL_GetClosestDisplayMode
SDL_GetCurrentDisplayMode
SDL_GetCurrentVideoDriver
SDL_GetDesktopDisplayMode
SDL_GetDisplayBounds
SDL_GetDisplayDPI
SDL_GetDisplayMode
SDL_GetDisplayName
SDL_GetDisplayUsableBounds
SDL_GetGrabbedWindow
SDL_GetNumDisplayModes
2D加速渲染(SDL_render.h)
SDL_ComposeCustomBlendMode
SDL_CreateRenderer
SDL_CreateSoftwareRenderer
SDL_CreateTexture
SDL_CreateTextureFromSurface
SDL_CreateWindowAndRenderer
SDL_DestroyRenderer
SDL_DestroyTexture
SDL_GL_BindTexture
SDL_GL_UnbindTexture
SDL_GetNumRenderDrivers
SDL_GetRenderDrawBlendMode
SDL_GetRenderDrawColor
SDL_GetRenderDriverInfo
SDL_GetRenderTarget
SDL_GetRenderer
SDL_GetRendererInfo
SDL_GetRendererOutputSize
SDL_GetTextureAlphaMod
SDL_GetTextureBlendMode
SDL_GetTextureColorMod
SDL_LockTexture
SDL_QueryTexture
SDL_RenderClear
SDL_RenderCopy
SDL_RenderCopyEx
SDL_RenderDrawLine
SDL_RenderDrawLines
SDL_RenderDrawPoint
SDL_RenderDrawPoints
SDL_RenderDrawRect
SDL_RenderDrawRects
SDL_RenderFillRect
SDL_RenderFillRects
SDL_RenderGetClipRect
SDL_RenderGetIntegerScale
SDL_RenderGetLogicalSize
SDL_RenderGetScale
SDL_RenderGetViewport
SDL_RenderIsClipEnabled
SDL_RenderPresent
SDL_RenderReadPixels
SDL_RenderSetClipRect
SDL_RenderSetIntegerScale
SDL_RenderSetLogicalSize
SDL_RenderSetScale
SDL_RenderSetViewport
SDL_RenderTargetSupported
SDL_SetRenderDrawBlendMode
SDL_SetRenderDrawColor
SDL_SetRenderTarget
SDL_SetTextureAlphaMod
SDL_SetTextureBlendMode
SDL_SetTextureColorMod
SDL_UnlockTexture
SDL_UpdateTexture
SDL_UpdateYUVTexture
像素格式与转换例程(SDL_pixels.h)
SDL_AllocFormat
SDL_AllocPalette
SDL_CalculateGammaRamp
SDL_FreeFormat
SDL_FreePalette
SDL_GetPixelFormatName
SDL_GetRGB
SDL_GetRGBA
SDL_MapRGB
SDL_MapRGBA
SDL_MasksToPixelFormatEnum
SDL_PixelFormatEnumToMasks
SDL_SetPaletteColors
SDL_SetPixelFormatPalette
矩形操作函数(SDL_rect.h)
SDL_EnclosePoints
SDL_HasIntersection
SDL_IntersectRect
SDL_IntersectRectAndLine
SDL_PointInRect
SDL_RectEmpty
SDL_RectEquals
SDL_UnionRect
表面创建于简单绘图(SDL_surface.h)
SDL_BlitScaled
SDL_BlitSurface
SDL_ConvertPixels
SDL_ConvertSurface
SDL_ConvertSurfaceFormat
SDL_CreateRGBSurface
SDL_CreateRGBSurfaceFrom
SDL_CreateRGBSurfaceWithFormat
SDL_CreateRGBSurfaceWithFormatFrom
SDL_FillRect
SDL_FillRects
SDL_FreeSurface
SDL_GetClipRect
SDL_GetColorKey
SDL_GetSurfaceAlphaMod
SDL_GetSurfaceBlendMode
SDL_GetSurfaceColorMod
SDL_LoadBMP
SDL_LoadBMP_RW
SDL_LockSurface
SDL_LowerBlit
SDL_LowerBlitScaled
SDL_MUSTLOCK
SDL_SaveBMP
SDL_SaveBMP_RW
SDL_SetClipRect
SDL_SetColorKey
SDL_SetSurfaceAlphaMod
SDL_SetSurfaceBlendMode
SDL_SetSurfaceColorMod
SDL_SetSurfacePalette
SDL_SetSurfaceRLE
SDL_UnlockSurface
平台相关的窗口管理(SDL_syswm.h)
SDL_GetWindowWMInfo
剪贴板处理(SDL_clipboard.h)
SDL_GetClipboardText
SDL_HasClipboardText
SDL_SetClipboardText
Vulkan支持(SDL_Vulkan.h)
SDL_Vulkan_CreateSurface
SDL_Vulkan_GetDrawableSize
SDL_Vulkan_GetInstanceExtensions
SDL_Vulkan_GetVkInstanceProcAddr
SDL_Vulkan_LoadLibrary
SDL_Vulkan_UnloadLibrary
音频
音频设备管理、音频播放与录音(SDL_audio.h)
SDL_AudioInit
SDL_AudioQuit
SDL_BuildAudioCVT
SDL_ClearQueuedAudio
SDL_CloseAudio
SDL_CloseAudioDevice
SDL_ConvertAudio
SDL_DequeueAudio
SDL_FreeWAV
SDL_GetAudioDeviceName
SDL_GetAudioDeviceStatus
SDL_GetAudioDriver
SDL_GetAudioStatus
SDL_GetCurrentAudioDriver
SDL_GetNumAudioDevices
SDL_GetNumAudioDrivers
SDL_GetQueuedAudioSize
SDL_LoadWAV
SDL_LoadWAV_RW
SDL_LockAudio
SDL_LockAudioDevice
SDL_MixAudio
SDL_MixAudioFormat
SDL_OpenAudio
SDL_OpenAudioDevice
SDL_PauseAudio
SDL_PauseAudioDevice
SDL_QueueAudio
SDL_UnlockAudio
SDL_UnlockAudioDevice
系统输入事件
事件处理(SDL_events.h)
SDL_AddEventWatch
SDL_DelEventWatch
SDL_EventState
SDL_FilterEvents
SDL_FlushEvent
SDL_FlushEvents
SDL_GetEventFilter
SDL_GetEventState
SDL_GetNumTouchDevices
SDL_GetNumTouchFingers
SDL_GetTouchDevice
SDL_GetTouchFinger
SDL_HasEvent
SDL_HasEvents
SDL_LoadDollarTemplates
SDL_PeepEvents
SDL_PollEvent
SDL_PumpEvents
SDL_PushEvent
SDL_QuitRequested
SDL_RecordGesture
SDL_RegisterEvents
SDL_SaveAllDollarTemplates
SDL_SaveDollarTemplate
SDL_SetEventFilter
SDL_WaitEvent
SDL_WaitEventTimeout
键盘支持(SDL_keyboard.h)
SDL_GetKeyFromName
SDL_GetKeyFromScancode
SDL_GetKeyName
SDL_GetKeyboardFocus
SDL_GetKeyboardState
SDL_GetModState
SDL_GetScancodeFromKey
SDL_GetScancodeFromName
SDL_GetScancodeName
SDL_HasScreenKeyboardSupport
SDL_IsScreenKeyboardShown
SDL_IsTextInputActive
SDL_SetModState
SDL_SetTextInputRect
SDL_StartTextInput
SDL_StopTextInput
鼠标支持(SDL_mouse.h)
SDL_CaptureMouse
SDL_CreateColorCursor
SDL_CreateCursor
SDL_CreateSystemCursor
SDL_FreeCursor
SDL_GetCursor
SDL_GetDefaultCursor
SDL_GetGlobalMouseState
SDL_GetMouseFocus
SDL_GetMouseState
SDL_GetRelativeMouseMode
SDL_GetRelativeMouseState
SDL_SetCursor
SDL_SetRelativeMouseMode
SDL_ShowCursor
SDL_WarpMouseGlobal
SDL_WarpMouseInWindow
游戏摇杆支持(SDL_joystick.h)
SDL_JoystickClose
SDL_JoystickCurrentPowerLevel
SDL_JoystickEventState
SDL_JoystickFromInstanceID
SDL_JoystickGetAttached
SDL_JoystickGetAxis
SDL_JoystickGetBall
SDL_JoystickGetButton
SDL_JoystickGetDeviceGUID
SDL_JoystickGetGUID
SDL_JoystickGetGUIDFromString
SDL_JoystickGetGUIDString
SDL_JoystickGetHat
SDL_JoystickInstanceID
SDL_JoystickName
SDL_JoystickNameForIndex
SDL_JoystickNumAxes
SDL_JoystickNumBalls
SDL_JoystickNumButtons
SDL_JoystickNumHats
SDL_JoystickOpen
SDL_JoystickUpdate
SDL_NumJoysticks
游戏控制器支持(SDL_gamecontroller.h)
SDL_GameControllerAddMapping
SDL_GameControllerAddMappingsFromFile
SDL_GameControllerAddMappingsFromRW
SDL_GameControllerClose
SDL_GameControllerEventState
SDL_GameControllerFromInstanceID
SDL_GameControllerGetAttached
SDL_GameControllerGetAxis
SDL_GameControllerGetAxisFromString
SDL_GameControllerGetBindForAxis
SDL_GameControllerGetBindForButton
SDL_GameControllerGetButton
SDL_GameControllerGetButtonFromString
SDL_GameControllerGetJoystick
SDL_GameControllerGetStringForAxis
SDL_GameControllerGetStringForButton
SDL_GameControllerMapping
SDL_GameControllerMappingForGUID
SDL_GameControllerName
SDL_GameControllerNameForIndex
SDL_GameControllerOpen
SDL_GameControllerUpdate
SDL_IsGameController
传感器(SDL_sensor.h)
SDL_NumSensors
SDL_SensorClose
SDL_SensorFromInstanceID
SDL_SensorGetData
SDL_SensorGetDeviceInstanceID
SDL_SensorGetDeviceName
SDL_SensorGetDeviceNonPortableType
SDL_SensorGetDeviceType
SDL_SensorGetInstanceID
SDL_SensorGetName
SDL_SensorGetNonPortableType
SDL_SensorGetType
SDL_SensorOpen
SDL_SensorType
SDL_SensorUpdate
力反馈
力反馈支持 (SDL_haptic.h)
SDL_HapticClose
SDL_HapticDestroyEffect
SDL_HapticEffectSupported
SDL_HapticGetEffectStatus
SDL_HapticIndex
SDL_HapticName
SDL_HapticNewEffect
SDL_HapticNumAxes
SDL_HapticNumEffects
SDL_HapticNumEffectsPlaying
SDL_HapticOpen
SDL_HapticOpenFromJoystick
SDL_HapticOpenFromMouse
SDL_HapticOpened
SDL_HapticPause
SDL_HapticQuery
SDL_HapticRumbleInit
SDL_HapticRumblePlay
SDL_HapticRumbleStop
SDL_HapticRumbleSupported
SDL_HapticRunEffect
SDL_HapticSetAutocenter
SDL_HapticSetGain
SDL_HapticStopAll
SDL_HapticStopEffect
SDL_HapticUnpause
SDL_HapticUpdateEffect
SDL_JoystickIsHaptic
SDL_MouseIsHaptic
SDL_NumHaptics
定时器
定时器支持(SDL_timer.h)
SDL_AddTimer
SDL_Delay
SDL_GetPerformanceCounter
SDL_GetPerformanceFrequency
SDL_GetTicks
SDL_RemoveTimer
SDL_TICKS_PASSED
多线程
线程管理(SDL_thread.h)
SDL_CreateThread
SDL_DetachThread
SDL_GetThreadID
SDL_GetThreadName
SDL_SetThreadPriority
SDL_TLSCreate
SDL_TLSGet
SDL_TLSSet
SDL_ThreadID
SDL_WaitThread
线程同步(SDL_mutex.h)
SDL_CondBroadcast
SDL_CondSignal
SDL_CondWait
SDL_CondWaitTimeout
SDL_CreateCond
SDL_CreateMutex
SDL_CreateSemaphore
SDL_DestroyCond
SDL_DestroyMutex
SDL_DestroySemaphore
SDL_LockMutex
SDL_SemPost
SDL_SemTryWait
SDL_SemValue
SDL_SemWait
SDL_SemWaitTimeout
SDL_TryLockMutex
SDL_UnlockMutex
原子操作(SDL_atomic.h)
SDL_AtomicAdd
SDL_AtomicCAS
SDL_AtomicCASPtr
SDL_AtomicDecRef
SDL_AtomicGet
SDL_AtomicGetPtr
SDL_AtomicIncRef
SDL_AtomicLock
SDL_AtomicSet
SDL_AtomicSetPtr
SDL_AtomicTryLock
SDL_AtomicUnlock
SDL_CompilerBarrier
文件系统
文件系统路径(SDL_filesystem.h)
SDL_GetBasePath
SDL_GetPrefPath
文件IO抽象(SDL_rwops.h)
SDL_AllocRW
SDL_FreeRW
SDL_RWFromConstMem
SDL_RWFromFP
SDL_RWFromFile
SDL_RWFromMem
SDL_RWclose
SDL_RWread
SDL_RWseek
SDL_RWsize
SDL_RWtell
SDL_RWwrite
SDL_ReadBE16
SDL_ReadBE32
SDL_ReadBE64
SDL_ReadLE16
SDL_ReadLE32
SDL_ReadLE64
SDL_ReadU8
SDL_WriteBE16
SDL_WriteBE32
SDL_WriteBE64
SDL_WriteLE16
SDL_WriteLE32
SDL_WriteLE64
SDL_WriteU8