diff options
author | David Thompson <dthompson@member.fsf.org> | 2013-08-17 23:00:36 -0400 |
---|---|---|
committer | David Thompson <dthompson@member.fsf.org> | 2013-08-17 23:00:36 -0400 |
commit | 075dbfca506afcc8de2b48b47bcc8b47423cdbab (patch) | |
tree | d89f72a5129e2b9fcd43aee701c12449850a6dca /examples | |
parent | 54493fb7dc845fcf68a868ec72cdc94999e2597b (diff) |
Create a font example.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/font.scm | 38 | ||||
-rw-r--r-- | examples/fonts/Boxy-Bold.ttf | bin | 0 -> 14432 bytes |
2 files changed, 38 insertions, 0 deletions
diff --git a/examples/font.scm b/examples/font.scm new file mode 100644 index 0000000..3bb0af0 --- /dev/null +++ b/examples/font.scm @@ -0,0 +1,38 @@ +(use-modules (2d game-loop) + (2d window) + (2d helpers) + (figl gl) + (2d wrappers ftgl)) + +(define window-width 800) +(define window-height 600) +(define font (ftgl-create-texture-font "fonts/Boxy-Bold.ttf")) +(define text "The quick brown fox jumped over the lazy dog.") + +(ftgl-set-font-face-size font 48 72) + +;; Open the window. +(open-window window-width window-height) + +(define (quit-demo) + (close-window) + (quit)) + +(define (key-down key mod unicode) + (cond ((any-equal? key 'escape 'q) + (quit-demo)))) + +;; Draw our sprite +(define (render) + (gl-color 1 1 1) + (ftgl-render-font font text (ftgl-render-mode all))) + +;; Register callbacks. +(add-hook! on-quit-hook (lambda () (quit-demo))) +(add-hook! on-render-hook (lambda () (render))) +(add-hook! on-key-down-hook (lambda (key mod unicode) (key-down key mod unicode))) + + +;; Start the game loop. +;; The render callback will be called through this procedure. +(run-game-loop) diff --git a/examples/fonts/Boxy-Bold.ttf b/examples/fonts/Boxy-Bold.ttf Binary files differnew file mode 100644 index 0000000..8076dc5 --- /dev/null +++ b/examples/fonts/Boxy-Bold.ttf |