[][src]Crate duku

This Rust crate makes it easy to render 2D and 3D graphics.

Example

This example is not tested
use duku::Color;
use duku::Camera;
use duku::Duku;
use duku::Result;

fn main() -> Result<()> {
    // initialize duku and OS window with a size of 500x500
    let (mut duku, window) = Duku::builder().build_window(500, 500).build()?;

    // create a 3D perspective camera with an FOV of 90
    let mut camera = Camera::perspective_autosized(90);

    // move the camera to some location
    // and make it look at the center of the world
    camera.transform.move_by([2.0, 1.5, -2.0]);
    camera.transform.look_at([0.0, 0.0, 0.0]);

    // start up the main event loop
    window.main_loop(move |_| {
      // start drawing on the window using our camera
      duku.draw_on_window(Some(&camera), |target| {
            // set the background color to sky blue
            target.clear = Color::SKY_BLUE;

            // draw a cube at the center of the world
            target.draw_cube();
        });
    });

    Ok(())
}

More usage examples can be found here.

Structs

Camera

The view into a scene.

Color

Color bytes in RGBA.

Cubemap

Texture representation of an environment.

CubemapSides

6 square sides of the cubemap.

Duku

The renderer context.

DukuBuilder

The render context builder.

Framebuffer

Texture that can be rendered to.

Handle

A handle to a rendering resource.

Light

Light used in shadowing calculations.

Material

Material parameters to use in a shader.

Matrix4

4x4 Matrix.

Mesh

Shape collection for rendering

Model

Collection of meshes and materials.

ModelNode

One node of the model.

Quaternion

Compact 3D rotation representation.

Shader

Program that runs on the GPU.

Stats

The stats of the current target's render.

Target

Active render target.

Texture

Image that can be sampled in a shader.

Transform

Represents transformation in separate components.

Vector2

2-component Vector.

Vector3

3-component Vector.

Vector4

4-component Vector.

WindowHandle

Handle to a OS window.

Enums

BorderMode

Border positioning mode.

ColorSpace

Color value representation mode.

Error

Crate's Error type.

Filter

Filtering mode for texture sampling.

Format

Image's pixel format.

LightType

Type of a light.

Mips

Texture mipmapping mode.

Msaa

Multi Sample Anti-Aliasing mode.

Pcf

Shadow softening used when sampling.

Projection

The projection type of a camera

ShapeMode

Shape positioning mode.

VSync

VSync setting for rendering.

Wrap

Wrapping mode for texture sampling.

Type Definitions

Result

Crate's Result type.