| 1 | module main |
| 2 | |
| 3 | import gg |
| 4 | |
| 5 | const win_width = 100 |
| 6 | const win_height = 100 |
| 7 | |
| 8 | struct App { |
| 9 | mut: |
| 10 | gg &gg.Context = unsafe { nil } |
| 11 | image int |
| 12 | } |
| 13 | |
| 14 | fn main() { |
| 15 | mut app := &App{} |
| 16 | app.gg = gg.new_context( |
| 17 | width: win_width |
| 18 | height: win_height |
| 19 | window_title: 'issue 10989' |
| 20 | frame_fn: frame |
| 21 | user_data: app |
| 22 | init_fn: initialize |
| 23 | ) |
| 24 | app.gg.run() |
| 25 | } |
| 26 | |
| 27 | fn initialize(mut app App) { |
| 28 | buffer := []u8{len: 10 * 10} |
| 29 | app.image = app.gg.new_streaming_image(10, 10, 1, pixel_format: .r8) |
| 30 | app.gg.update_pixel_data(app.image, buffer.data) |
| 31 | } |
| 32 | |
| 33 | fn frame(mut app App) { |
| 34 | app.gg.begin() |
| 35 | app.gg.draw_image_by_id(0, 0, 10, 10, app.image) |
| 36 | app.gg.end() |
| 37 | } |
| 38 | |