8个版本 (重大更新)
0.8.0 | 2020年7月24日 |
---|---|
0.7.0 | 2019年7月29日 |
0.6.0 | 2019年3月24日 |
0.5.0 | 2019年1月9日 |
0.1.0 | 2017年12月31日 |
#370 in 图形API
在 2 crate 中使用
150KB
3K SLoC

grr!
一个针对OpenGL 4.5+的裸机库
[dependencies]
grr = "0.8"
grr
旨在在OpenGL 4.5+之上提供一个薄层,暴露一个以Vulkan为导向的现代API。该库的唯一目的是提供一个清洁的API,以便于快速原型设计。
特性
- API围绕直接状态访问构建
- 遵循Vulkan术语和函数名称
- 仅提供最新的GL功能
- 强制执行sRGB帧缓冲区处理
入门指南
查看我们的Hello Triangle示例,以了解库的用法!
示例
// Bind graphics pipeline (shaders)
grr.bind_pipeline(&pipeline);
// Configure vertex attributes
grr.bind_vertex_array(&vertex_array);
// Bind vertex buffers for fetching attribute data
grr.bind_vertex_buffers(
&vertex_array,
0,
&[grr::VertexBufferView {
buffer: &triangle_data,
offset: 0,
stride: (std::mem::size_of::<f32>() * 5) as _,
input_rate: grr::InputRate::Vertex,
}]
);
// Clear default framebuffer
grr.clear_attachment(grr::Framebuffer::DEFAULT, grr::ClearAttachment::ColorFloat(0, [0.5, 0.5, 0.5, 1.0]));
// Draw triangles
grr.draw(grr::Primitive::Triangles, 0..3, 0..1);
// Present on screen!
window.swap_buffers().unwrap();
示例
Hello Triangle
cargo run --example triangle
设备信息
cargo run --example device
纹理(Logo)
cargo run --example texture
(可能是)基于物理的渲染(IBL)
在运行之前,需要将资源(模型和HDRI)提取到examples/assets
中!
cargo run --example pbr --release
- 从https://learnopengl.com/的PBR教程移植或基于该教程(CC BY-NC 4.0)。
Cerberus
模型由Andrew Maximov创作(https://artisaverb.info/Cerberus.html)Popcorn Lobby
HDRI来自sIBL档案(http://www.hdrlabs.com/sibl/archive.html)
依赖项
~210KB