From fc2584672c096ae63469cce9ede9abaa4a95ece7 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 16 Feb 2014 10:44:24 -0500 Subject: Rewrite font module. FTGL has been dropped in favor of SDL_ttf. * 2d/font: Rewrite everything! * 2d/wrappers/ftgl.scm: Delete it. * configure.ac: Check for SDL_ttf. * data/Makefile.am (shaders_DATA): Add font shaders. * data/shaders/font-fragment.glsl: New shader. * data/shaders/font-vertex.glsl: New shader. * examples/font.scm: Rewrite font example. * examples/fonts/AUTHORS: Delete it. * examples/fonts/Boxy-Bold.ttf: Delete it. --- examples/font.scm | 50 ++++++++++++++++++++++++++++++++++++------- examples/fonts/AUTHORS | 2 -- examples/fonts/Boxy-Bold.ttf | Bin 14432 -> 0 bytes 3 files changed, 42 insertions(+), 10 deletions(-) delete mode 100644 examples/fonts/AUTHORS delete mode 100644 examples/fonts/Boxy-Bold.ttf (limited to 'examples') diff --git a/examples/font.scm b/examples/font.scm index 465600c..2398b36 100644 --- a/examples/font.scm +++ b/examples/font.scm @@ -1,22 +1,56 @@ (use-modules (srfi srfi-9) (figl gl) + (2d agenda) + (2d fps) (2d color) (2d font) (2d game) + (2d mouse) + (2d signals) (2d vector2) (2d window)) (load "common.scm") -(define textbox - (make-textbox (load-font "fonts/Boxy-Bold.ttf" 48) - "The quick brown fox jumped over the lazy dog." - (vector2 240 160) - white - 'left - 200)) +(define font (load-default-font 18)) +(define position (vector2 320 240)) +(define text "The quick brown fox jumped over the lazy dog.") +(define label (make-label font text position #:anchor 'center)) -(add-hook! draw-hook (lambda (dt alpha) (draw-textbox textbox))) +(define fps-label-position (vector2 0 0)) +(define (make-fps-label) + (make-label font (format #f "FPS: ~d" (fps)) fps-label-position)) +(define fps-label (make-fps-label)) + +(define mouse-label-position (vector2 0 20)) +(define mouse-label + (signal-map (lambda (p) + (let ((text (format #f "Mouse: (~d, ~d)" (vx p) (vy p)))) + (make-label font text mouse-label-position))) + mouse-position)) + +(define gc-label-position (vector2 0 40)) +(define gc-counter (make-root-signal 0)) +(define gc-label + (signal-map (lambda (counter) + (let ((text (format #f "GCs: ~d" counter))) + (make-label font text gc-label-position))) + gc-counter)) + +(add-hook! after-gc-hook + (lambda () + (signal-set! gc-counter (1+ (signal-ref gc-counter))))) + +(schedule-interval game-agenda + (lambda () + (set! fps-label (make-fps-label))) + 60) + +(add-hook! draw-hook (lambda (dt alpha) + (draw-label label) + (draw-label fps-label) + (draw-label (signal-ref mouse-label)) + (draw-label (signal-ref gc-label)))) (with-window (make-window #:title "Fonts") (run-game-loop)) diff --git a/examples/fonts/AUTHORS b/examples/fonts/AUTHORS deleted file mode 100644 index 0f278b8..0000000 --- a/examples/fonts/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Clint Bellanger and William Thompson -http://opengameart.org/content/boxy-bold-truetype-font \ No newline at end of file diff --git a/examples/fonts/Boxy-Bold.ttf b/examples/fonts/Boxy-Bold.ttf deleted file mode 100644 index 8076dc5..0000000 Binary files a/examples/fonts/Boxy-Bold.ttf and /dev/null differ -- cgit v1.2.3