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中运行结果

参考资料

相关推荐
passerby60617 分钟前
如何自己造一个时间处理库
前端·javascript·github
小弥儿5 小时前
GitHub今日热榜 | 2026-09-04:Agent省 token 成今日主线
学习·开源·github
辻弋2016 小时前
自动检测硬件生成驱动清单、实时监控FPS、120秒性能记录——30+项优化模块化开关,所有改动可精确复原
服务器·windows·游戏引擎·电脑·开源软件
苏灿烤鱼8 小时前
给 AI Agent 装一个「会进化的大脑」:OpenViking 深度拆解
开源·github·agent
逛逛GitHub8 小时前
清华开源的 Agent 交互学习神器,又登上 GitHub 热榜了。
github
其实防守也摸鱼8 小时前
OpenClaw Windows 踩坑实战指南
运维·服务器·数据库·windows·github·copilot
小马92610 小时前
从单模型到多模型编排:GitHub HydraFusion 如何让编程 Agent 降本 36%-67%
人工智能·github
C++ 老炮儿的技术栈10 小时前
MFC CPtrArray的用法
开发语言·数据结构·c++·算法·mfc·c
小弥儿11 小时前
GitHub今日热榜 | 2026-09-08:微软 markitdown 冲进前三
学习·microsoft·开源·github
蜡台12 小时前
超详细 GitHub Actions 自动发布部署教程
github·github page·github action