raysan5/raylib
GitHub: raysan5/raylib
一个轻量级、零依赖的跨平台 C 语言游戏开发库,专注于让图形编程变得简单有趣。
Stars: 31306 | Forks: 2945
**raylib 是一个简单、易用的库,旨在享受电子游戏编程的乐趣。**
raylib 深受 Borland BGI 图形库和 XNA 框架的启发,特别适合原型开发、工具构建、图形应用程序、嵌入式系统和教育用途。
*给探险者的提示:raylib 是一个用于享受电子游戏编程的库;没有花哨的界面,没有视觉辅助工具,没有调试按钮……只有最纯粹的斯巴达式程序员编码方式。*
准备好学习了吗?跳转到[代码示例!](https://www.raylib.com/examples.html)
[](https://github.com/raysan5/raylib/releases) [](https://github.com/raysan5/raylib/stargazers) [](https://github.com/raysan5/raylib/commits/master) [](https://github.com/sponsors/raysan5) [](https://repology.org/project/raylib/versions) [](LICENSE) [](https://discord.gg/raylib) [](https://www.reddit.com/r/raylib/) [](https://www.youtube.com/c/raylib) [](https://www.twitch.tv/raysan5) [](https://github.com/raysan5/raylib/actions/workflows/build_windows.yml) [](https://github.com/raysan5/raylib/actions/workflows/build_linux.yml) [](https://github.com/raysan5/raylib/actions/workflows/build_macos.yml) [](https://github.com/raysan5/raylib/actions/workflows/build_webassembly.yml) [](https://github.com/raysan5/raylib/actions/workflows/build_cmake.yml) [](https://github.com/raysan5/raylib/actions/workflows/build_examples_windows.yml) [](https://github.com/raysan5/raylib/actions/workflows/build_examples_linux.yml) ## 特性 - **无外部依赖**,所有必需的库都[已包含在 raylib 中](https://github.com/raysan5/raylib/tree/master/src/external) - 支持多种平台:**Windows, Linux, MacOS, RPI, Android, HTML5... 以及更多!** - 使用 PascalCase/camelCase 符号风格,用纯 C99 代码编写 - 支持 OpenGL 硬件加速:**1.1, 2.1, 3.3, 4.3, ES 2.0, ES 3.0** - **独特的 OpenGL 抽象层**(可用作独立模块):[rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) - 支持多种**字体**格式(TTF, OTF, FNT, BDF, 精灵字体) - 支持多种纹理格式,包括**压缩格式**(DXT, ETC, ASTC) - **完整的 3D 支持**,包括 3D 形状、模型、广告牌、高度图等! - 灵活的材质系统,支持经典贴图和 **PBR 贴图** - 支持**动画 3D 模型**(骨骼动画)(IQM, M3D, glTF) - 支持 Shader,包括模型 Shader 和**后处理** Shader - 用于向量、矩阵和四元数运算的**强大数学模块**:[raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) - 音频加载和播放,支持流式传输(WAV, QOA, OGG, MP3, FLAC, XM, MOD) - 支持 **VR 立体渲染**,带有可配置的 HMD 设备参数 - 拥有包含 [超过 140 个代码示例](https://github.com/raysan5/raylib/tree/master/examples) 的庞大示例库! - 绑定到 [超过 70 种编程语言](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)! - **免费且开源** ## 基本示例 这是一个基本的 raylib 示例,它创建一个窗口并在屏幕中间绘制文本 `"Congrats! You created your first window!"`。在[此处查看在线运行的示例](https://www.raylib.com/examples/core/loader.html?name=core_basic_window)。 ``` #include "raylib.h" int main(void) { InitWindow(800, 450, "raylib [core] example - basic window"); while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(RAYWHITE); DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); EndDrawing(); } CloseWindow(); return 0; } ``` ## 构建与安装 raylib 的 Windows, Linux, macOS, Android 和 HTML5 二进制版本可在 [Github 发布页面](https://github.com/raysan5/raylib/releases) 获取。 raylib 也可通过多种操作系统发行版上的多个包管理器获取。 #### 在多个平台上安装和构建 raylib [raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) 包含有关在多个平台上构建和使用的详细说明。 - [在 Windows 上工作](https://github.com/raysan5/raylib/wiki/Working-on-Windows) - [在 macOS 上工作](https://github.com/raysan5/raylib/wiki/Working-on-macOS) - [在 GNU Linux 上工作](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux) - [在 Chrome OS 上工作](https://github.com/raysan5/raylib/wiki/Working-on-Chrome-OS) - [在 FreeBSD 上工作](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD) - [在 Raspberry Pi 上工作](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi) - [为 Android 开发](https://github.com/raysan5/raylib/wiki/Working-for-Android) - [为 Web (HTML5) 开发](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5)) - [使用 CMake 在任何地方工作](https://github.com/raysan5/raylib/wiki/Working-with-CMake) *请注意,Wiki 是开放编辑的,如果您在为目标平台构建 raylib 时发现任何问题,请随时编辑 Wiki 或提交相关问题。* #### 使用多种 IDE 设置 raylib raylib 是在 Windows 平台上使用 [Notepad++](https://notepad-plus-plus.org/) 和 [MinGW GCC](https://www.mingw-w64.org/) 编译器开发的,但也可以在其他平台上的其他 IDE 中使用。 [Projects 目录](https://github.com/raysan5/raylib/tree/master/projects) 包含多个即插即用的**项目模板**,用于使用多种 IDE 构建 raylib 和代码示例。 *请注意,支持的 IDE 很多,某些提供的模板可能需要审查,因此,如果您发现模板有问题或认为可以改进,请随时发送 PR 或提交相关问题。* ## 学习与文档 raylib 旨在通过以[示例](https://github.com/raysan5/raylib/tree/master/examples)作为主要参考来学习。虽然没有标准的 API 文档,但有一个 [**速查表**](https://www.raylib.com/cheatsheet/cheatsheet.html),其中包含库中可用的所有函数及每个函数的简短描述,输入参数和结果值名称应该足够直观,以理解每个函数的工作原理。 关于 raylib 设计的一些额外文档可以在 [raylib GitHub Wiki](https://github.com/raysan5/raylib/wiki) 中找到。以下是相关链接: - [raylib 速查表](https://www.raylib.com/cheatsheet/cheatsheet.html) - [raylib 架构](https://github.com/raysan5/raylib/wiki/raylib-architecture) - [raylib 库设计](https://github.com/raysan5/raylib/wiki) - [raylib 示例集合](https://github.com/raysan5/raylib/tree/master/examples) - [raylib 游戏集合](https://github.com/raysan5/raylib-games) ## 联系与社交网络 raylib 存在于多个网络中,并且 raylib 社区每天都在壮大。如果您正在使用 raylib 并乐在其中,请随时加入我们的任何网络。最活跃的网络是我们的 [Discord 服务器](https://discord.gg/raylib)! :) - 网页:[https://www.raylib.com](https://www.raylib.com) - Discord:[https://discord.gg/raylib](https://discord.gg/raylib) - X:[https://x.com/raysan5](https://x.com/raysan5) - BlueSky:[https://bsky.app/profile/raysan5](https://bsky.app/profile/raysan5.bsky.social) - Twitch: [https://www.twitch.tv/raysan5](https://www.twitch.tv/raysan5) - Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib) - Patreon:[https://www.patreon.com/raylib](https://www.patreon.com/raylib) - YouTube:[https://www.youtube.com/channel/raylib](https://www.youtube.com/c/raylib) ## 贡献者
标签:2D图形, 3D图形, AI工具, Bash脚本, LangChain, OpenGL, raylib, Vulkan, zlib许可证, 云安全, 原型开发, 图形库, 图形渲染, 多媒体, 客户端加密, 客户端加密, 嵌入式系统, 工具开发, 开源, 教育编程, 游戏开发, 游戏引擎, 游戏编程, 简单易用, 编程库, 轻量级