rev: 21c5e6d2f665d0e8b4ff917a51b664c895dab2ed tukan/testing/test_dockgui.sc -rw-r--r-- 1.7 KiB View raw Log this file
21c5e6d2f665 — Leonard Ritter * renamed project from Liminal to Tukan 2 years 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env scopes

import ..tukan.glmain
import ..tukan.screen
#import ..tukan.imgui
import ..tukan.dockgui

let glmain = tukan.glmain
let screen = tukan.screen
let dockgui = tukan.dockgui

using import ..tukan.gl
using import glm
using import glsl
using import ..tukan.imgui

glmain.init
    title = "Tukan"
    width = 800
    height = 600
    resizable = true

fn varyings (mode)
    xvar (do mode) uv : vec2 (location = 0)
    xvar (do mode) pos : vec2 (location = 1)
    scopeof
        uv = uv; pos = pos

let vertex-fn =
    do
        using (varyings 'out)
        fn main ()
            uv =
                ((screen.set-vertex-position) * 0.5) + 0.5
            return;
let fragment-fn =
    do
        using (varyings 'in)
        xvar out out_Color : vec4
        xvar uniform phase : f32
            location = 0

        fn make-phase ()
            #(sin phase) * 0.5 + 0.5
            0.5

        fn main ()
            out_Color = (vec4 uv (make-phase) 1)
            return;

#let pg = (glCreateProgram)
#let link =
    attach-shaders pg
        vertex-stage = vertex-fn
        fragment-stage = fragment-fn
#link;

global test-window-visible = true
'append dockgui.on-define-windows
    fn ()
        ShowDemoWindow test-window-visible

#global phase = 0.0
#'append glmain.on-draw
    fn (s size)
        glViewport 0 0 size.x size.y
        glClearColor 0 0 1 1
        glClear
            |
                GL_COLOR_BUFFER_BIT
                GL_DEPTH_BUFFER_BIT
                GL_STENCIL_BUFFER_BIT

        glUseProgram pg
        glUniform1f 0 phase
        phase = (phase + 0.1)
        screen.draw;
        glUseProgram 0

glmain.loop;

glmain.shutdown;

print "done."