1 个不稳定版本
0.1.0 | 2024年7月27日 |
---|
#67 在 渲染
每月下载量:139
15KB
111 行
Softbuffer 快速入门
一个包装器,使使用 Softbuffer 与使用 minifb 一样简单。
在 softbuffer-quickstart 中运行 Softbuffer 示例
use softbuffer_quickstart::{SoftbufferWindow, WindowProperties};
fn main() {
let mut window = SoftbufferWindow::new(
// This is the "loop closure" -- called on every update loop
|window, buffer| {
let (width, height) = {
let size = window.inner_size();
(size.width, size.height)
};
for index in 0..(width * height) {
let y = index / width;
let x = index % width;
let red = x % 255;
let green = y % 255;
let blue = (x * y) % 255;
buffer[index as usize] = blue | (green << 8) | (red << 16);
}
},
// This is how we can set properties for the window when it's initially created.
WindowProperties::default()
);
window.run().expect("window can't run :(");
}
贡献
欢迎提交 PR!就像我的其他项目一样,我可能需要一些时间来响应问题/PR。建议在提交 PR 之前不要压缩您的提交,因为这样做会使代码审查变得稍微困难一些。
我在寻找任何方法,在尽可能简化库的同时,尽可能提高性能。
想法
- 处理 Winit 事件(如调整大小)
- 使用缓冲区提高性能(通常循环很慢!必须有一种更快的方法来遍历缓冲区中的所有内容)
- 为 WindowProperties 添加图标(可能适合新贡献者)
依赖项
~3–16MB
~226K SLoC