| 1 | // This example shows how to clear your window on each frame, with a different color, using a Sokol pass. |
| 2 | // It is ported from https://github.com/floooh/sokol-samples/blob/master/sapp/clear-sapp.c . |
| 3 | import sokol.gfx |
| 4 | import sokol.sapp |
| 5 | |
| 6 | fn frame(mut action gfx.PassAction) { |
| 7 | g := f32(action.colors[0].clear_value.g + 0.01) |
| 8 | action.colors[0].clear_value.g = if g > 1.0 { 0 } else { g } |
| 9 | gfx.begin_pass(sapp.create_default_pass(action)) |
| 10 | gfx.end_pass() |
| 11 | gfx.commit() |
| 12 | } |
| 13 | |
| 14 | fn main() { |
| 15 | action := gfx.create_clear_pass_action(1.0, 0, 0, 1.0) |
| 16 | sapp.run( |
| 17 | window_title: c'Clear (sokol app)' |
| 18 | width: 400 |
| 19 | height: 300 |
| 20 | init_cb: || gfx.setup(sapp.create_desc()) |
| 21 | cleanup_cb: || gfx.shutdown() |
| 22 | frame_userdata_cb: frame |
| 23 | user_data: &action |
| 24 | ) |
| 25 | } |
| 26 | |