diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-03-29 16:19:01 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-03-29 16:19:01 -0400 |
commit | bd4e7ca64ed3d203ab7c938387d7ab32df8e5f23 (patch) | |
tree | 5e108c1b175e87af9e820541af23501f17bc5816 | |
parent | 40bacd7e2ba29a1813a8fcd8070cf9ea4a9abca8 (diff) |
Don't load font shaders upon importing (2d font) module.
* 2d/font.scm (font-shader): Set to #f initially.
(enable-fonts): New procedure.
* examples/font.scm: Enable fonts.
-rw-r--r-- | 2d/font.scm | 25 | ||||
-rw-r--r-- | examples/font.scm | 2 |
2 files changed, 17 insertions, 10 deletions
diff --git a/2d/font.scm b/2d/font.scm index 4e9d401..5cdc9cf 100644 --- a/2d/font.scm +++ b/2d/font.scm @@ -36,7 +36,8 @@ #:use-module (2d vector2) #:use-module (2d window) #:use-module (2d wrappers gl) - #:export (load-font + #:export (enable-fonts + load-font load-default-font font? font-point-size @@ -48,12 +49,23 @@ label-color draw-label)) -(SDL:ttf-init) - ;;; ;;; Font ;;; +(define font-shader #f) + +(define (enable-fonts) + (SDL:ttf-init) + (set! font-shader + (make-shader-program + (load-vertex-shader + (string-append %pkgdatadir + "/shaders/font-vertex.glsl")) + (load-fragment-shader + (string-append %pkgdatadir + "/shaders/font-fragment.glsl"))))) + (define-record-type <font> (make-font ttf point-size) font? @@ -131,13 +143,6 @@ white and ANCHOR with a default of 'top-left." (anchor (anchor-texture texture anchor))) (%make-label font text position anchor color texture vertices))) -(define font-shader - (make-shader-program - (load-vertex-shader (string-append %pkgdatadir - "/shaders/font-vertex.glsl")) - (load-fragment-shader (string-append %pkgdatadir - "/shaders/font-fragment.glsl")))) - (define (draw-label label) "Draw LABEL on the screen." (with-shader-program font-shader diff --git a/examples/font.scm b/examples/font.scm index a5167fa..a48bc37 100644 --- a/examples/font.scm +++ b/examples/font.scm @@ -27,6 +27,8 @@ (load "common.scm") +(enable-fonts) + (define font (load-default-font 18)) (define label (make-label font "The quick brown fox jumped over the lazy dog." |