summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2d/font.scm15
-rw-r--r--2d/vector2.scm14
2 files changed, 20 insertions, 9 deletions
diff --git a/2d/font.scm b/2d/font.scm
index 45b59d0..182f25b 100644
--- a/2d/font.scm
+++ b/2d/font.scm
@@ -95,14 +95,13 @@ upper-left corner rather than the bottom-left."
(%make-textbox font text position color alignment line-length layout)))
(define (draw-textbox textbox)
- (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)
- (ftgl-render-mode all)))))
+ (with-gl-push-matrix
+ (vector2-translate (textbox-position textbox))
+ (flip-text (textbox-font textbox))
+ (apply-color (textbox-color textbox))
+ (ftgl-render-layout (textbox-layout textbox)
+ (textbox-text textbox)
+ (ftgl-render-mode all))))
(export <textbox>
make-textbox
diff --git a/2d/vector2.scm b/2d/vector2.scm
index 7720095..d231f93 100644
--- a/2d/vector2.scm
+++ b/2d/vector2.scm
@@ -22,6 +22,7 @@
;;; Code:
(define-module (2d vector2)
+ #:use-module (figl gl)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:export (<vector2>
@@ -38,7 +39,9 @@
vmag
vnorm
vdot
- vcross))
+ vcross
+ vector2-translate
+ vector2-scale))
(define-record-type <vector2>
(vector2 x y)
@@ -105,3 +108,12 @@ vector is not defined. This function instead returns the Z coordinate
of the cross product as if the vectors were in 3D space."
(- (* (vx v1) (vy v2))
(* (vy v1) (vx v2))))
+
+(define (vector2-translate v)
+ "Perform an OpenGL translate matrix operation with the given
+vector2."
+ (gl-translate (vx v) (vy v) 0))
+
+(define (vector2-scale v)
+ "Perform an OpenGL scale matrix operation with the given vector2."
+ (gl-scale (vx v) (vy v) 1))