Crate despero

source ·
Expand description

Despero (esp. despair) is rusty data-driven 3D game engine, which implements paradigm of ECS and provides developers with appropriate toolkit to develop PBR games with advanced technologies

Simple example

use despero::prelude::*;
 
fn main(){
    Despero::init(WindowBuilder {
        title: Some("My Game"),
        ..Default::default()
    })
        
        .default_systems()

        .add_setup_system(create_model)
        .add_setup_system(create_camera)
        .add_system(rotate_model)
        .run();
}
 
fn create_model(
    mut cmd: Write<CommandBuffer>,
    mut renderer: Write<Renderer>,
){
    let texture = renderer.create_texture("assets/texture.jpg", Filter::LINEAR) as u32;
        
    cmd.spawn(ModelBundle {
        mesh: Mesh::load_obj("assets/model.obj").swap_remove(0),
        material: renderer.create_material(
            DefaultMat::builder()
                .texture_id(texture)
                .metallic(0.0)
                .roughness(1.0)
                .build(),
        ),
        transform: Transform::from_translation(Vector3::new(0.0, 0.0, 0.0)),
    });

    info!("I run only once!");
}
 
fn rotate_model(
    world: SubWorld<&mut Transform>,
){
    for (_, mut t) in &mut world.query::<&mut Transform>() {
        t.rotation *= UnitQuaternion::from_axis_angle(&Unit::new_normalize(Vector3::new(0.0, 1.0, 0.0)), 0.05);
    }

    info!("I run in loop!");
}
  
fn create_camera(
    mut cmd: Write<CommandBuffer>,
){
    cmd.spawn(CameraBundle{
        camera: 
            Camera::builder()
                .is_active(true)
                .build(),
        transform: Transform::default(),
    });
}

Re-exports

Modules

  • Assets and scenes handling
  • ECS components and re-exports
  • Module of the main engine’s error handler Result
  • Structures implementing mathematics
  • Rapier3D implementations
  • Bundle of all essential components of the engine
  • Submodules and structures to work with graphics
  • Mlua scripting implementations
  • Component connected with time

Macros

Structs