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