logo
pub struct Render { /* private fields */ }
Expand description

Gives access to rendering specific functionality like drawing 2D triangles.

Use the require_render_api macro’s render() function to get an instance of Render. See the module level documentation for an example.

A Render object can be cheaply cloned.

Implementations

Draw colored 2D triangles in screen space (physical pixel coordinates).

  • colors - Assumes premultiplied alpha.

Draw colored 2D textured triangles in screen space (physical pixel coordinates).

  • colors - Assumes premultiplied alpha.

Draws 3D debug lines.

These are simple but fast primitive lines that are meant to quickly get something up with little overhead, when you just need to visualize something for debugging. They will never deliver a polished look, so do not use for user-facing things.

Creates a mesh.

NOTE: Normals can be automatically generated by the engine. Simply set normals to None in mesh.data.

Creates a mesh with a material.

NOTE: Normals can be automatically generated by the engine. Simply set normals to None in mesh.data.

Creates a mesh with multiple materials split by sections.

The mesh can be split into multiple sections with different materials. If no sections are provided the entire mesh will be a single section. NOTE: Normals can be automatically generated by the engine. Simply set normals to None in mesh.data.

Loads a mesh from directly provided GLTF data.

Supports .gltf and .glb, and a single additional buffer file. buffer_name is not used directly, but might be used for validation.

Creates a mesh from a GLTF resource handle and additional buffer resource handle.

Draws a single mesh.

It is OK to drop the RenderMesh in the same frame after calling this, it will still be drawn.

When drawing multiple meshes, prefer to use Render::draw_meshes instead for improved performance.

If you are drawing the same mesh over multiple frames, pick a unique-enough instance_id and pass the same one every frame. Pass 0 if you can’t come up with one, but you’ll end up with rendering artifacts on quick movements.

Errors

Under normal safe circumstances, this function cannot error. However, errors through the underlying API can happen - for example, if the raw handle inside mesh has already been destroyed (via unsafe code).

Draws multiple meshes.

Use RenderMeshInstanceBuilder to create a RenderMeshInstance.

It is OK to drop the RenderMesh in the same frame after calling this, it will still be drawn.

Errors

Under normal safe circumstances, this function cannot error. However, errors through the underlying API can happen - for example, if the raw handle inside mesh has already been destroyed (via unsafe code).

If an error occurs drawing one or more of the meshes in the list, no meshes in the list will be drawn, and an error is returned.

Draws multiple meshes with a list of material overrides.

Use RenderMeshInstanceBuilder to create a RenderMeshInstance.

It is okay to drop the RenderMesh in the same frame after calling this, it will still be drawn.

The material ID inside the meshes will be used to index into the material_overrides list offsetted by RenderMeshInstance::materials_offset. If no override is provided for an index the meshes original material will be used.

Allocate a new texture.

Example
let data = [255, 0, 0, 255,
            0, 255, 0, 255];
let texture = render
    .create_texture()
    .name("my_texture")
    .dimension(2, 1)
    .format(TextureFormat::R8G8B8A8_SRGB) // can be omitted - this is the default
    .data(pixels)
    .build()?;

Creates a new SDF function from Saft opcodes and constants.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.