sdl3-sample-简明教程,指导如何在包括移动和 Web 在内的各种平台上构建和使用 SDL3

sdl3-sample-简明教程,指导如何在包括移动和 Web 在内的各种平台上构建和使用 SDL3

sdl3-sample源代码地址为:https://github.com/Ravbug/sdl3-sample

sdl3-example是SDL3的简明教程,指导如何在包括移动和 Web 在内的各种平台上构建和使用 SDL3。还包含 SDL_mixer、SDL_Image 和 SDL_ttf!

在线网站运行示例为:https://www.ravbug.com/sdl3-sample/

https://www.ravbug.com/sdl3-sample/官网在线运行结果:

SDL3 App From Source Minimal Example

This is a minimal example for building and using SDL3, SDL_Mixer, SDL_Image, and SDL_ttf_ from source

using C++ and CMake. It also demonstrates setting up things like macOS/iOS

bundles.

See <src/main.cpp> for the code.

Building And Running

Are you a complete beginner? If so, read this!

Otherwise, install CMake and your favorite compiler, and follow the commands below:

sh 复制代码
# You need to clone with submodules, otherwise SDL will not download.
git clone https://github.com/Ravbug/sdl3-sample --depth=1 --recurse-submodules
cd sdl3-sample
cmake -S . -B build

You can also use an init script inside config/. Then open the IDE project inside build/

(If you had CMake generate one) and run!

Supported Platforms

I have tested the following:

Platform Architecture Generator
macOS x86_64, arm64 Xcode
iOS x86_64, arm64 Xcode
tvOS x86_64, arm64 Xcode
visionOS* arm64 Xcode
Windows x86_64, arm64 Visual Studio
Linux x86_64, arm64 Ninja, Make
Web* wasm Ninja, Make
Android* x86, x64, arm, arm64 Ninja via Android Studio

*See further instructions in config/

Note: UWP support was removed from SDL3 during its development. For historical reasons, you can get a working UWP sample via this commit: df270da

Updating SDL

Just update the submodule:

sh 复制代码
cd SDL
git pull
cd ..

cd SDL_ttf
git pull

You don't need to use a submodule, you can also copy the source in directly. This

repository uses a submodule to keep its size to a minimum.

Reporting issues

Is something not working? Create an Issue or send a Pull Request on this repository!

当在自己的MacOS、Windows、Ubuntu等Linux系统中安装了CMake安装包后,可以按照官网说的如下命令执行:

bash 复制代码
# You need to clone with submodules, otherwise SDL will not download.
git clone https://github.com/Ravbug/sdl3-sample --depth=1 --recurse-submodules
cd sdl3-sample
cmake -S . -B build
cmake --build build
make

在MacOS中运行结果

在Windows11中运行结果

参考资料

相关推荐
咸鱼不用加盐12 小时前
HC32F460 USB CDC通信异常:非对齐访问异常排查
单片机·arm·c·cm4
shandianchengzi12 小时前
【记录】Copilot|Github Copilot重新学生认证通过方法(2025年7月,包括2FA和认证材料、Why are you not on campus)
github·copilot
K1ne_12 小时前
2026 最新版|学生认证白嫖 GitHub Copilot Pro 保姆级教程
github·copilot
cs.shunzhang12 小时前
GitHub 教育认证通过后如何领取 Copilot Pro
github·copilot
程序员柒叔12 小时前
OpenCode 踩坑记:GitHub Copilot 按次计费?我的账单为何暴涨 3 倍!
github·copilot·claude code·opencode
刚刚觉醒的小菜鸡12 小时前
copilot学生认证2026-github copilot学生认证(手把手教会)
github·copilot
徐小夕13 小时前
我花一天时间Vibe Coding的开源AI工具,一键检测你的电脑能跑哪些AI大模型
前端·javascript·github
一乐小哥19 小时前
如何写一个好的 Pull Request
github
Hommy8820 小时前
【开源剪映小助手】云渲染环境搭建
python·开源·github·剪映小助手
Robot_Nav21 小时前
Git 项目维护命令指南相关讲解
git·机器人·github