[][src]Crate grr

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;

use glutin::GlContext;

fn main() -> grr::Result<()> {
    let mut events_loop = glutin::EventsLoop::new();
    let window = glutin::WindowBuilder::new()
        .with_title("Hello grr!")
        .with_dimensions(1024, 768);
    let context = glutin::ContextBuilder::new()
        .with_vsync(true)
        .with_srgb(true)
        .with_gl_debug_flag(true);

    let window = glutin::GlWindow::new(window, context, &events_loop).unwrap();
    unsafe {
        window.make_current().unwrap();
    }

    let grr = 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 an Image.
  • Pipeline: There currently are two sort of pipelines suppoerted: Graphics and Compute
  • Framebuffer: Assembles the attachments (ImageView or RenderBuffer) for draw calls
  • Sampler: Configures image filtering. An Image is bound together with a Sampler 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.

BlendChannel
Buffer
BufferRange

Buffer Range.

ColorBlend
ColorBlendAttachment
DebugReport

Debug report flags.

DepthStencil
Device

Logical device, representation one or multiple physical devices (hardware or software).

DeviceFeatures

Additional features supported by the device.

DeviceLimits
DrawIndexedIndirectCmd

Indirect (indexed) draw command structure.

DrawIndirectCmd

Indirect draw command structure.

Extent
Framebuffer

Framebuffer handle.

GraphicsPipelineDesc

Graphics Pipeline Descriptor.

Image

Image resource handle.

ImageView

Image view handle.

InputAssembly

Input Assembly Descriptor.

MappingFlags

Memory mapping flags.

MemoryFlags

Memory property flags.

Multisample
Offset
Pipeline

Graphics or Compute pipeline.

Query
Rasterization

Rasteriyer Descriptor.

Region
RegionBarrier

Memory barrier for by-region dependencies.

Renderbuffer

Renderbuffer handle.

Sampler

Sampler handle.

SamplerDesc

Sampler Descriptor.

Shader

Shader.

StencilFace
SubresourceLayout
SubresourceLevel
SubresourceRange

Subresource of an image.

VertexArray

Vertex array handle.

VertexAttributeDesc
VertexBufferView

Buffer representation for vertex attributes

Viewport

Viewport transformation.

Enums

Attachment

Attachment reference.

AttachmentView
BaseFormat
BlendFactor
BlendOp
ClearAttachment

Attachment clearing description.

Compare

Comparison operator.

ConditionalMode
Constant

Uniform constant.

Debug

Device debug control.

DebugSource

Debug message source.

DebugType

Debug message type.

Error

Error return codes

Filter
Format
FormatLayout
ImageType

Image dimensionality type.

ImageViewType
IndexTy

Index size.

InputRate

Vertex attribute addresssing.

Primitive

Primitve topology.

QueryType
SamplerAddress

Sampler addressing mode.

ShaderStage

Shader Stages.

StencilOp
VertexFormat

Vertex attribute formats.

Functions

as_u8_slice

View a slice as raw byte slice.

Type Definitions

Result

A specialized Result type for grr operations.