root/trunk/thune/gl/test.t

Revision 558, 4.0 kB (checked in by krobillard, 3 months ago)

Thune

  • Pop now pushes last element onto stack.
  • Added ur_strCatInt() & ur_strCatInt64().
  • Array now uses realloc().

Thune-GL

  • gx_startup() now takes userClasses and userLayoutRules.
  • Moved 'layout to gx.t and test style to style/oxif.t.
  • GUI layout now done with 'parse.
  • Eliminated gui_parseLayout() and GWidgetClass::parse.
  • Renamed display.events to handle-events. Removed wait-events.
  • Window widget! now has a title and a close/resize event handler.
Line 
1; Thune GL Test
2
3
4"local_data" change-dir
5
6;1024,768 'fullscreen display
7640,480 display
8
910.0 :zoom
100.0,0.0,0.0 :center
11
12[
13    buffer [color vertex] #[
14        1.0  1.0  1.0   -1.0  -1.0   0
15        1.0  1.0  1.0    1.0  -1.0   0
16        1.0  1.0  1.0   -1.0   1.0   0
17        1.0  1.0  1.0    1.0   1.0   0
18        1.0  0.0  0.0   -0.85 -0.85  0
19        0.0  1.0  0.0    0.85 -0.85  0
20        0.0  0.0  1.0   -0.85  0.85  0
21        1.0  1.0  1.0    0.85  0.85  0
22    ]
23    depth-test/off blend/off cull/off
24    tris #[0 1 2  4 5 6]
25    cull
26]
27draw-list :tri-gp
28
29
30"shader/matte.gx"
31    load.shader :tri-sh
32
33"model/cube.gp"
34    load draw-list :model-gp
35
36"shader/colormap.gp"
37    load.shader :model-sh
38
39texture!
40"image/primal64.png"
41;"image/kr_wood01.png"
42    load.png make :model-sh/cmap
43;model-sh .
44
45font! ["font/20thfont.ttf" 22] make :fontA
46font! ["font/FederationBold-KR.ttf" 12 256,128] make :fontF
47"shader/rfont.gx" load.shader :fontA-sh
48fontA/texture :fontA-sh/cmap
49fontA-sh copy :fontF-sh
50fontF/texture :fontF-sh/cmap
51
52;0,0,0 :strobe
53
54/*
55[
56    [
57          0,  0,  0
58         64, 64, 64
59        128,128,128
60        192,192,192
61        255,255,255
62        192,192,192
63        128,128,128
64         64, 64, 64
65    ] :colors
66][
67    colors next dup tail? ift head
68        dup :colors
69        first display.swap
70]
71proc.env :cycle-colors
72*/
73
74
75camera [
76    'ortho :fov
77    -100.0 :near
78     100.0 :far
79] make :ortho-cam
80
81
82camera [
83    60.0  :fov
84     1.0  :near
85   9000.0 :far
86   20,20,200,200 :viewport
87   #[1.0  0    0    0
88     0    1.0  0    0
89     0    0    1.0  0
90     0    0   15.0  1.0] :orient
91
92    0.0  :azimuth
93    0.0  :elev
94    15.0 :dist
95    0.0,0.0,0.0 :focal-pnt
96
97    [dx dy /*| ced*/]
98    [
99        dx  0.5 mul to-rad azimuth add :azimuth
100        dy -0.5 mul to-rad elev add  -1.53938 1.53938 limit :elev
101
102        ;["az-el" azimuth to-deg elev to-deg] print
103
104        elev cos dist mul dup /*:ced*/
105        azimuth cos /*ced*/  mul focal-pnt/1 add :orient/13
106        elev    sin  dist    mul focal-pnt/2 add :orient/14
107        azimuth sin /*ced*/  mul focal-pnt/3 add :orient/15
108
109        orient focal-pnt look-at
110    ]
111    func :turntable
112
113    0 0 turntable
114] make :view-cam
115
116
117-1,-1 :mouse-pos
118-1,-1 :click-pos
119
120
121[
122    key-down [
123        esc [quit]
124        a   [["area: " area] print]
125        p   [/*[100 usleep] proc :sim-update pause-win show*/]
126        f10 [display.snapshot "snapshot.png" save.png]
127        f12 ["--- stack ---" print .s]
128        ;spc cycle-colors
129    ]
130
131    close [quit]
132
133    resize [
134        dup :area
135        dup :ortho-cam/viewport
136
137        dup :tmp
138        tmp/3 2 div  dup :center/x  :tmp/3
139        tmp/4 2 div  dup :center/y  :tmp/4
140        tmp :view-cam/viewport
141    ]
142
143    mouse-move  [
144        dup :mouse-pos
145        ;"move: "   prin dup .
146
147        mouse-pos/5 zero? iff (
148            mouse-pos/3 mouse-pos/4 view-cam/turntable
149        )
150    ]
151    mouse-down  [
152        "button: " prin dup .
153        ;dup 1 eq? ift (mouse-pos :click-pos)
154    ]
155    mouse-wheel [
156        ;"wheel: "  prin dup .
157        ;dup 40.0 div zoom add :zoom
158        dup 0 gt? 1.1 0.90909 either zoom mul :zoom
159    ]
160
161    joystick [
162        axis0  []
163    ]
164
165    draw [
166        camera view-cam
167
168        blend/off cull depth-test depth-mask
169        shader model-sh
170        call   model-gp
171
172        camera ortho-cam
173        push
174            translate center
175            scale  zoom
176            shader tri-sh
177            call   tri-gp
178        pop
179
180        ;blend-func 0,0
181        blend/trans cull/off depth-test/off depth-mask/off
182        shader fontA-sh
183        font fontA
184        color $ffffff
185        text 0,400 "Line 1 abcdefghijklmnopqrstuvwxyz^/Line 2"
186        text "- more on same line."
187        text 200,200 "200,200"
188       ;text/12 mouse-pos mouse-pos
189
190        font fontF
191        shader fontF-sh
192        text 0,0 "ZERO"
193    ]
194]
195make-widget :background
196
197
1980,0,155 display.swap
199
200[
201    ;[strobe: ping-pong [64,64,64 255,220,64 1]] 'frame-time animate
202
203    handle-events/wait
204    background draw
205    none display.swap
206] forever
207
208
209;eof
Note: See TracBrowser for help on using the browser.