rev: 3827f53bae88e48a594610914ba74b9512ead6dd tukan/testing/test_spritepainter.sc -rw-r--r-- 1.3 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
using import glm

import ..tukan.use
using import tukan.SpritePainter
using import tukan.GLMain
using import tukan.gl
using import tukan.bitmap

let glmain =
    GLMain
        title = "SpritePainter"
        resizable = true

global t = 0.0

global painter = (SpritePainter)
let spritesheet =
    load-bitmap
        .. module-dir "/data/7x4_font.png"
        components = 4
        #flip = false
global texture_spritesheet = (GL.Texture2D)
'setup texture_spritesheet
    bitmap = spritesheet
let sz = spritesheet.size
va-map
    inline (rc)
        'register painter rc sz
    ivec4 0 0 5 8
    ivec4 6 0 10 8
    ivec4 10 0 15 8

@@ 'on GLMain.on-draw
fn draw (time size glmain)
    GL.BindFramebuffer GL.FRAMEBUFFER 0
    GL.Viewport 0 0 (i32 size.x) (i32 size.y)
    GL.ClearColor 0 0 0.5 1
    GL.Clear
        |
            GL.COLOR_BUFFER_BIT
            GL.DEPTH_BUFFER_BIT
            GL.STENCIL_BUFFER_BIT

    t += (/ 60.0)

    from (methodsof painter) let sprite screen
    screen size 8
    sprite 0 (vec2 5 40) (vec4 -0.5 -0.5 0.5 0.5)
        angle = t
    sprite 1 (vec2 11 40) (vec4 -0.5 -0.5 0.5 0.5)
        angle = t
    sprite 2 (vec2 17 40) (vec4 -0.5 -0.5 0.5 0.5)
        angle = t
    GL.BindTextureUnit 0 texture_spritesheet
    'draw painter

'run glmain

;