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§

pub use crate::error::Result;

Modules§

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

Macros§

impl_ser_component
world_serializer

Structs§

Despero
Main engine struct