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 中使用

MIT/Apache

150KB
3K SLoC

grr!

一个针对OpenGL 4.5+的裸机库

crates.io docs license-mit license-apache2 Build Status

[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
cargo run --example texture

(可能是)基于物理的渲染(IBL)

在运行之前,需要将资源(模型和HDRI)提取到examples/assets中!

cargo run --example pbr --release

依赖项

~210KB