1 ! Copyright (C) 2010 Erik Charlebois
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors colors.constants game.debug game.loop
4 game.worlds gpu gpu.framebuffers gpu.util.wasd kernel literals
5 locals make math math.matrices math.matrices.extras math.parser
6 math.trig sequences specialized-arrays ui.gadgets.worlds
8 FROM: alien.c-types => float ;
9 SPECIALIZED-ARRAY: float
12 :: clear-screen ( color -- )
14 { default-attachment color }
17 :: draw-debug-tests ( world -- )
18 world [ wasd-p-matrix ] [ wasd-mv-matrix ] bi mdot :> mvp-matrix
19 { 0 0 0 } clear-screen
22 { 0 0 0 } { 1 0 0 } COLOR: red debug-line
23 { 0 0 0 } { 0 1 0 } COLOR: green debug-line
24 { 0 0 0 } { 0 0 1 } COLOR: blue debug-line
25 { -1.2 0 0 } { 0 1 0 } 0 deg>rad <rotation-matrix3> debug-axes
26 { 3 5 -2 } { 3 2 1 } COLOR: white debug-box
27 { 0 9 0 } 8 2 COLOR: blue debug-cylinder
29 mvp-matrix draw-debug-lines
32 { 0 4.0 0 } COLOR: red debug-point
33 { 0 4.1 0 } COLOR: green debug-point
34 { 0 4.2 0 } COLOR: blue debug-point
36 mvp-matrix draw-debug-points
38 "Frame: " world frame#>> number>string append
39 COLOR: purple { 5 5 } world dim>> draw-text
40 world [ 1 + ] change-frame# drop ;
42 TUPLE: tests-world < wasd-world frame# ;
43 M: tests-world draw-world* draw-debug-tests ;
44 M: tests-world wasd-movement-speed drop 1/16. ;
45 M: tests-world wasd-near-plane drop 1/32. ;
46 M: tests-world wasd-far-plane drop 1024.0 ;
47 M: tests-world begin-game-world
50 { 0.0 0.0 2.0 } 0 0 set-wasd-view drop ;
53 { world-class tests-world }
54 { title "game.debug.tests" }
55 { pixel-format-attributes {
58 T{ depth-bits { value 24 } }
62 { pref-dim { 1024 768 } }
63 { tick-interval-nanos $[ 60 fps ] }