rev: 3827f53bae88e48a594610914ba74b9512ead6dd tukan/testing/test_nanovg.sc -rw-r--r-- 1.2 KiB View raw Log this file
3827f53bae88 — Leonard Ritter * more work on module system 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using import glm
using import glsl

using import ..tukan.sdl
using import ..tukan.GLMain

using import ..tukan.gl
using import ..tukan.nanovg

let glmain =
    GLMain
        title = "NanoVG test"
        width = 960
        height = 540
        resizable = true

global vg = (NanoVG.create NanoVG.Antialias)

global monofont =
    'create-font vg "fixed"
        .. module-dir "/../assets/core/fonts/UbuntuMono-R.ttf"

global cursor = (ivec2 100 100)

fn render-view (size)
    GL.BindFramebuffer GL.FRAMEBUFFER 0

    'begin-frame vg size

    'begin-path vg
    'rect vg 0 0 (unpack (vec2 size))
    'fill-color vg
        vec3 0.5
    'fill vg

    'fill-color vg
        vec3 0
    'text vg 200 200 "The Quick Brown Fox Yadda Yadda" null

    'begin-path vg
    'circle vg (f32 cursor.x) (f32 cursor.y) 8
    'stroke-color vg
        vec3 1
    'stroke-width vg 4
    'stroke vg
    'stroke-color vg
        vec3 0
    'stroke-width vg 2
    'stroke vg

    'end-frame vg

@@ 'on GLMain.on-event
fn (event glmain)
    if event.type == SDL_MOUSEMOTION
        cursor =
            ivec2
                event.motion.x
                event.motion.y

@@ 'on GLMain.on-draw
fn (time size glmain)
    render-view size

'run glmain