Skip to main content

Crate optic_render

Crate optic_render 

Source
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

LayerModuleRole
ContextRenderContextEGL display, surfaces, vsync
BackendGLThin wrappers around raw OpenGL calls
DeviceGPUStateful renderer with fallback assets
AssetsassetLoad/save/cache meshes, textures, shaders from disk
Handles[handles]Runtime GPU handles: MeshHandle, Shader, Texture2D, Canvas, InstanceBuffer
CameraCameraPerspective/orthographic camera with fly-through controls
TransformsTransform2D, Transform3D, CamTransformPosition / 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.
CanvasDesc
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.
InstanceBuffer
A GPU buffer of interleaved per-instance attributes with a CPU-side mirror for random access.
InstanceDesc2D
Descriptor for preparing 2D instance data before uploading it to the GPU.
InstanceDesc3D
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.
MeshHandle
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.
RenderContext
EGL + OpenGL 4.6 context with support for multiple window surfaces.
Shader
A handle to an OpenGL shader program.
StorageBuffer
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.
WindowSurface
An EGL window surface and its dimensions.
Workers
Work-group dimensions for compute shader dispatch.

Enums§

RenderTarget
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.