summaryrefslogtreecommitdiff
path: root/bindgen/rust/examples/main_loop.rs
blob: 8da3e9afbbe010060bbec8d4a35ae25bfadf5b96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use celeritas::*;

unsafe fn run_game() {
    // init
    Core_Bringup();

    let camera_pos = Vec3 {
        x: 0.0,
        y: 2.0,
        z: -3.0,
    };
    let camera = Camera_Create(
        camera_pos,
        vec3_normalise(vec3_negate(camera_pos)),
        VEC3_Y,
        45.0,
    );
    SetCamera(camera);

    let whatever = Vec3 {
        x: 1.0,
        y: 1.0,
        z: 1.0,
    };
    let sun = DirectionalLight {
        direction: whatever,
        ambient: whatever,
        diffuse: whatever,
        specular: whatever,
    };
    SetMainLight(sun);

    let skybox = Skybox_Create(face_paths, 6);

    // main loop
    while !ShouldExit() {
        Frame_Begin();

        Skybox_Draw(&mut skybox, camera);

        Frame_End();
    }
}

fn main() {
    println!("Running from Rust!");

    unsafe {
        run_game();
    }
}