| 1 | import gg |
| 2 | import rand |
| 3 | |
| 4 | // The flags here override the default limits for Sokol |
| 5 | #flag -D_SGL_DEFAULT_MAX_VERTICES=4194304 |
| 6 | #flag -D_SGL_DEFAULT_MAX_COMMANDS=65536 |
| 7 | |
| 8 | // Without the flags, `max_circles` > 5040, will just show a blue screen without |
| 9 | // *any circles* drawn. |
| 10 | // **Note** however, that increasing `_SGL_DEFAULT_MAX_VERTICES`, also increases |
| 11 | // the default RAM usage of your app. In this case, instead of using ~40MB on |
| 12 | // Ubuntu 20.04, the app instead uses ~140MB. |
| 13 | const max_circles = 10_000 |
| 14 | |
| 15 | fn main() { |
| 16 | gg.start( |
| 17 | window_title: 'Hello' |
| 18 | bg_color: gg.Color{50, 50, 150, 255} |
| 19 | width: 800 |
| 20 | height: 600 |
| 21 | frame_fn: fn (ctx &gg.Context) { |
| 22 | wsize := gg.window_size() |
| 23 | ctx.begin() |
| 24 | for _ in 0 .. max_circles { |
| 25 | rx := rand.int_in_range(0, wsize.width) or { 0 } |
| 26 | ry := rand.int_in_range(0, wsize.height) or { 0 } |
| 27 | cr := rand.u8() |
| 28 | cg := rand.u8() |
| 29 | cb := rand.u8() |
| 30 | ctx.draw_circle_filled(rx, ry, 10, gg.Color{cr, cg, cb, 255}) |
| 31 | } |
| 32 | ctx.show_fps() |
| 33 | ctx.end() |
| 34 | } |
| 35 | ) |
| 36 | } |
| 37 | |