Expand description
GPU-accelerated rendering with EGL/OpenGL 4.6.
optic-render manages the full graphics pipeline: context creation (headless or
windowed), asset loading (meshes, textures, shaders), instanced drawing, off-screen
canvas (framebuffer objects), and 2D/3D camera transforms.
§Architecture
| Layer | Module | Role |
|---|---|---|
| Context | RenderContext | EGL display, surfaces, vsync |
| Backend | GL | Thin wrappers around raw OpenGL calls |
| Device | GPU | Stateful renderer with fallback assets |
| Assets | asset | Load/save/cache meshes, textures, shaders from disk |
| Handles | [handles] | Runtime GPU handles: MeshHandle, Shader, Texture2D, Canvas, InstanceBuffer … |
| Camera | Camera | Perspective/orthographic camera with fly-through controls |
| Transforms | Transform2D, Transform3D, CamTransform | Position / rotation / scale helpers |
§Getting started
ⓘ
use optic_render::GPU;
let gpu = GPU::new_headless()?;
println!("{}", gpu.version());§Feature flags
This crate is always compiled with all features. The parent optic crate controls
which sub-crates are included via its own feature flags.
Modules§
- asset
- Asset loading, caching, and GPU upload.
- canvas
- instance
- mesh
- shader
- texture
- transform
- 2D, 3D, and camera transforms.
Structs§
- CamTransform
- Camera transform state with pre-computed view and projection matrices.
- Camera
- A 3D camera with perspective or orthographic projection.
- Canvas
- An off-screen render target (framebuffer object) with optional MSAA.
- Canvas
Desc - Describes the format and structure of an off-screen framebuffer (canvas).
- GL
- Low-level, stateless OpenGL 4.6 wrappers.
- GPU
- The primary renderer — owns the GL context, fallback assets, and global pipeline state.
- Instance
Buffer - A GPU buffer of interleaved per-instance attributes with a CPU-side mirror for random access.
- Instance
Desc2D - Descriptor for preparing 2D instance data before uploading it to the GPU.
- Instance
Desc3D - Descriptor for preparing 3D instance data before uploading it to the GPU.
- Mesh2D
- High-level mesh with visibility, shader, transform, and draw mode.
- Mesh3D
- High-level mesh with visibility, shader, transform, and draw mode.
- Mesh
Handle - Low-level OpenGL mesh handle wrapping VAO, VBO, IBO, and instance state.
- RGB
- RGB color with three 0..1 float channels.
- RGBA
- RGBA color with four 0..1 float channels.
- Render
Context - EGL + OpenGL 4.6 context with support for multiple window surfaces.
- Shader
- A handle to an OpenGL shader program.
- Storage
Buffer - A GPU-side shader storage buffer (SSBO) for compute or vertex pulling.
- Texture2D
- A handle to an OpenGL 2D texture object.
- Transform2D
- A 2D transform with position, rotation, scale, layer, and aspect ratio.
- Transform3D
- A 3D transform with position, rotation (Euler angles in degrees), and scale.
- Window
Surface - An EGL window surface and its dimensions.
- Workers
- Work-group dimensions for compute shader dispatch.
Enums§
- Render
Target - Either the screen (default framebuffer) or a canvas (FBO).
- Slot
- A texture or storage-buffer binding slot (0–15).
Functions§
- compile_
shader - Compiles a single GLSL shader stage.
- create_
index_ buffer - Creates an IBO (element array buffer) and returns its ID.
- create_
mesh_ buffer - Creates a VAO + VBO pair and returns their IDs.
- create_
texture - Creates a new OpenGL 2D texture from raw pixel data.
- delete_
program - Deletes a GL program object.
- delete_
texture - Deletes an OpenGL 2D texture by its ID.
- fill_
buffer - Uploads data to a VBO (full buffer replace).
- fill_
index_ buffer - Uploads index data to an IBO.
- link_
compute_ program - Links a compute shader source into a GL program.
- link_
program - Links a vertex + fragment shader pair into a GL program.
- resize_
buffer - Resizes a VBO without uploading data (contents become undefined).
- set_
attr_ layout - Configures a vertex attribute pointer for the given layout.
- subfill_
buffer - Uploads data to a sub-range of a VBO.