Expand description
Bare metal OpenGL 4.5+ wrapper
§Overview
grr
aims at providing a modern and clean looking API with focus on
direct state access. The terminology used follows mostly Vulkan and OpenGL.
§Initialization
The main entry point for working with the library is a Device
.
A device wraps an OpenGL context which needs to be created and managed externally.
The documentation and examples will all use glutin
for window and context management.
extern crate glutin;
extern crate grr;
fn main() -> Result<(), Box<std::error::Error>> {
let mut events_loop = glutin::EventsLoop::new();
let wb = glutin::WindowBuilder::new()
.with_title("Hello grr!")
.with_dimensions((1024.0, 768.0).into());
let window = unsafe {
glutin::ContextBuilder::new()
.with_vsync(true)
.with_srgb(true)
.with_gl_debug_flag(true)
.build_windowed(wb, &events_loop)?
.make_current()
.unwrap()
};
let grr = unsafe {
grr::Device::new(
|symbol| window.get_proc_address(symbol) as *const _,
grr::Debug::Enable {
callback: |_, _, _, _, msg| {
println!("{:?}", msg);
},
flags: grr::DebugReport::all(),
},
)
};
Ok(())
}
§Modules
The API has multiple concepts which interplay with each other. The main of interacting with the library is via
function calls on a Device
object. The calls often translate directly to one GL call.
All other objects created are opaque handles!
- Resource: Objects with associated memory. Can be a
Buffer
(untyped) or anImage
. - Pipeline: There currently are two sort of pipelines supported: Graphics and Compute
- Framebuffer: Assembles the attachments (
ImageView
orRenderBuffer
) for draw calls - Sampler: Configures image filtering. An
Image
is bound together with aSampler
to a texture unit for access in a shader stage. - Vertex Array: Specifies the vertex attributes and bindings for the input assembler stage. Buffers are bound to a
VertexArray
to declare the memory region to fetch attribute data from.
Structs§
- Barrier
- Memory barrier.
- Blend
Channel - Buffer
- Buffer
Image Copy - Buffer
Range - Buffer Range.
- Color
Blend - Color
Blend Attachment - Debug
Report - Debug report flags.
- Depth
Stencil - Depth and stencil test and associated options.
- Device
- Logical device, representation one or multiple physical devices (hardware or software).
- Device
Features - Additional features supported by the device.
- Device
Limits - Dispatch
Indirect Cmd - Indirect dispatch command structure.
- Draw
Indexed Indirect Cmd - Indirect (indexed) draw command structure.
- Draw
Indirect Cmd - Indirect draw command structure.
- Extent
- Framebuffer
- Framebuffer handle.
- Graphics
Pipeline Desc - Graphics Pipeline Descriptor.
- Host
Image Copy - Image
- Image resource handle.
- Image
Copy - Image
View - Image view handle.
- Input
Assembly - Input Assembly Descriptor.
- Mapping
Flags - Memory mapping flags.
- Memory
Flags - Memory property flags.
- Memory
Layout - Specifies the layout of the host or buffer memory.
- Mesh
Pipeline Desc - Multisample
- Offset
- Starting location for copying from or to texture data.
- Pipeline
- Graphics or Compute pipeline.
- Pipeline
Flags - Pipeline link flags.
- Query
- Query
Result Flags - Rasterization
- Rasterizer Descriptor.
- Region
- Region
Barrier - Memory barrier for by-region dependencies.
- Renderbuffer
- Renderbuffer handle.
- Sampler
- Sampler handle.
- Sampler
Desc - Sampler Descriptor.
- Shader
- Shader.
- Shader
Flags - Shader compilation flags.
- Stencil
Face - Stencil operation settings, per-face.
- Subresource
Layers - Subresource
Range - Subresource of an image.
- Vertex
Array - Vertex array handle.
- Vertex
Attribute Desc - Vertex attribute format and binding.
- Vertex
Buffer View - Buffer representation for vertex attributes
- Vertex
Pipeline Desc - Viewport
- Viewport transformation.
Enums§
- Attachment
- Attachment reference.
- Attachment
View - Base
Format - Blend
Factor - BlendOp
- Clear
Attachment - Attachment clearing description.
- Compare
- Comparison operator.
- Conditional
Mode - Constant
- Uniform constant.
- Cull
Mode - Polygon culling mode.
- Debug
- Device debug control.
- Debug
Source - Debug message source.
- Debug
Type - Debug message type.
- Error
- Error return codes
- Filter
- Filter options for computing pixels when the texture maps to an area different from one texture element.
- Format
- The
Format
enum represents a sized internal format of texture storage. The naming convention closely follows that of Vulkan, but it has a close correspondence with OpenGL. - Format
Layout - Front
Face - Polygon front face.
- Image
Type - Image dimensionality type.
- Image
View Type - Image View type.
- IndexTy
- Index size.
- Input
Rate - Vertex attribute addresssing.
- MsgFilter
- Message filter.
- Object
Type - Polygon
Mode - Polygon rendering mode.
- Primitive
- Primitve topology.
- Query
Type - Sampler
Address - Sampler addressing mode.
- Shader
Stage - Shader Stages.
- Stencil
Op - Vertex
Format - Vertex attribute formats.
Traits§
Functions§
- as_
u8_ slice - View a slice as raw byte slice.
Type Aliases§
- Debug
Callback - Result
- A specialized Result type for
grr
operations.