diff options
author | David Thompson <dthompson@member.fsf.org> | 2013-08-26 22:09:45 -0400 |
---|---|---|
committer | David Thompson <dthompson@member.fsf.org> | 2013-08-26 22:09:45 -0400 |
commit | 95d31ad231800026e7b0a44ddda42c584dad5671 (patch) | |
tree | d76e718c37f3ee40fc1737d1fb58eef7717ff847 /2d/font.scm | |
parent | caec8d997059507b9a3eef497ad0508a2c6073d9 (diff) |
Make the origin the top-left corner of the window again.
Diffstat (limited to '2d/font.scm')
-rw-r--r-- | 2d/font.scm | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/2d/font.scm b/2d/font.scm index 70b0904..8bf66a3 100644 --- a/2d/font.scm +++ b/2d/font.scm @@ -47,11 +47,21 @@ (ftgl-set-font-face-size ftgl-font size 72) (make-font ftgl-font size))) +(define (flip-text font) + "Flips current GL matrix about the x-axis and translates by the +negative font ascender value. This is necessary before rendering text +because guile-2d flips the y-axis so that the origin is in the +upper-left corner rather than the bottom-left." + (gl-scale 1 -1 1) + (gl-translate 0 (- (ftgl-get-font-ascender (font-ftgl-font font))) 0)) + (define (draw-font font text) "Renders the string text using the given font." - (ftgl-render-font (font-ftgl-font font) - text - (ftgl-render-mode all))) + (with-gl-push-matrix + (flip-text font) + (ftgl-render-font (font-ftgl-font font) + text + (ftgl-render-mode all)))) (export <font> make-font @@ -88,6 +98,7 @@ (let ((pos (textbox-position textbox))) (with-gl-push-matrix (gl-translate (vx pos) (vy pos) 0) + (flip-text (textbox-font textbox)) (apply-color (textbox-color textbox)) (ftgl-render-layout (textbox-layout textbox) (textbox-text textbox) |