v2 / vlib / gg / testdata / streaming_r8_zero_buffer_issue_10989.vv
37 lines · 31 sloc · 655 bytes · ecb38f349349ab369383c51a22f430909a7d2ebd
Raw
1module main
2
3import gg
4
5const win_width = 100
6const win_height = 100
7
8struct App {
9mut:
10 gg &gg.Context = unsafe { nil }
11 image int
12}
13
14fn 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
27fn 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
33fn 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