Skip to main content

Drawable

Trait Drawable 

Source
pub trait Drawable {
    // Required methods
    fn prepare(&self, context: &mut RenderContext<'_>) -> Result<(), Error>;
    fn draw(&self, context: &mut RenderContext<'_>);
    fn cleanup(&self, context: &mut RenderContext<'_>);
}
Expand description

Trait for objects that can be rendered.

Required Methods§

Source

fn prepare(&self, context: &mut RenderContext<'_>) -> Result<(), Error>

Prepares the object for rendering.

This method should set up all necessary OpenGL state, bind shaders, textures, and vertex data required for rendering.

§Errors

May return an error if GPU resource preparation fails (e.g., dynamic atlas glyph upload).

Source

fn draw(&self, context: &mut RenderContext<'_>)

Performs the actual rendering.

This method should issue draw calls to render the object. All necessary state should already be set up from the prepare() call.

Source

fn cleanup(&self, context: &mut RenderContext<'_>)

Cleans up after rendering.

This method should restore OpenGL state and unbind any resources that were bound during prepare(). This ensures proper cleanup for subsequent rendering operations.

Implementors§