package main import "core:math" import gpu "../.." import app "../../app" main :: proc() { state, ok := app.init_window(800, 600, "GPU - Spinning Cube") if !ok { return } defer app.shutdown(&state) camera := gpu.default_camera_3d() cube := gpu.gen_mesh_cube(1, 1, 1) defer gpu.unload_mesh(cube) rotation: f32 = 0 for !app.window_should_close(&state) { dt := app.get_frame_time(&state) rotation += dt * math.PI * 0.5 // quarter turn per second app.update_camera(&state, &camera, .ORBITAL) frame := app.begin_frame(&state, gpu.CORNFLOWER_BLUE) gpu.set_camera_3d(&frame, camera) // Spinning cube (custom transform via draw_mesh) transform := gpu.mat4_translate({0, 0.5, 0}) * gpu.mat4_rotate_y(rotation) _ = gpu.draw_mesh_instance_frame(&frame, {mesh = cube, transform = transform}) // Ground plane _ = gpu.draw_plane_frame(&frame, {center = {0, 0, 0}, size = {10, 10}}) // Grid _ = gpu.draw_grid_frame(&frame, {slices = 10, spacing = 1}) // Static shapes _ = gpu.draw_sphere_frame(&frame, {center = {-2, 0.5, 0}, radius = 0.5}) _ = gpu.draw_cube_frame(&frame, {center = {2, 0.25, 0}, size = {0.5, 0.5, 0.5}}) _ = app.submit_frame(&state, &frame) if app.is_key_pressed(&state, .Escape) { break } } }