package main import gpu "../.." import app "../../app" main :: proc() { state, ok := app.init_window(800, 600, "GPU - Frame Offscreen Sample") if !ok { return } defer app.shutdown(&state) for !app.window_should_close(&state) { ctx := gpu.context_from_runtime() frame := app.begin_frame(&state, begin_present = false) offscreen := gpu.begin_target(&frame, gpu.offscreen_target(ctx, { name = "generated-offscreen", width = 256, height = 256, color_format = .R8G8B8A8_UNORM, depth_format = .D32_SFLOAT, clear_color = {0.02, 0.03, 0.08, 1}, clear_depth = 1, })) _ = gpu.push_layer(&frame, {name = "offscreen"}) _ = gpu.draw_rect(&frame, {x = 24, y = 24, width = 208, height = 208, color = {0.05, 0.18, 0.7, 1}}) _ = gpu.draw_circle_frame(&frame, {cx = 128, cy = 128, radius = 72, color = {1.0, 0.45, 0.08, 1}}) _ = gpu.draw_line_frame(&frame, {x0 = 16, y0 = 224, x1 = 240, y1 = 32, thickness = 6, color = gpu.WHITE}) present_desc := gpu.present_target(ctx) present_desc.clear_color = gpu.BLACK _ = gpu.begin_target(&frame, present_desc) _ = gpu.push_layer(&frame, {name = "present"}) _ = gpu.draw_offscreen_texture_quad(&frame, { target = offscreen, x = 160, y = 100, width = 480, height = 360, color = gpu.WHITE, }) _ = gpu.draw_rect(&frame, {x = 24, y = 24, width = 160, height = 48, color = {0, 0, 0, 0.6}}) gpu.draw_text_frame(&frame, {text = "offscreen -> sampled present", x = 32, y = 38, color = gpu.WHITE, scale = 2}) if !app.submit_frame(&state, &frame) { break } if app.is_key_pressed(&state, .Escape) { break } } }