Permalink
Browse files

Examples updated to remove need for macros. Just functions. Wrapped s…

…ome gl functions.
  • Loading branch information...
1 parent 87d11c9 commit bd23ebb53198c49fedbe90070459c7e56c84cdc0 Sean Grove committed Apr 13, 2010
Showing with 50 additions and 60 deletions.
  1. +7 −9 README.md
  2. +8 −7 examples/nehe_tutorials_2.scm
  3. +8 −10 examples/nehe_tutorials_3.scm
  4. +27 −27 examples/nehe_tutorials_4.scm
  5. +0 −7 lib/gl_utils.scm
View
@@ -2,21 +2,19 @@ Tehila
======
A 3d engine written in scheme.
-Currently Tehila is alpha-quality, and very [Chicken Scheme](http://chicken.wiki.br/) specific.
+Currently Tehila is alpha-quality, and very [Chicken Scheme](http://chicken.wiki.br/) specific. There's tons of room for speed optimization, and plenty to do to make it more scheme-like. But it's progressing quite nicely.
Dependencies
------------
-I may be missing some requirements. I will install on a secondary machine and document to ensure this is accurate. That said, it should be right.
-
You'll need the following [eggs](http://chicken.wiki.br/eggs):
-[opengl](http://chicken.wiki.br/opengl)
-[glut](http://chicken.wiki.br/eggref/4/glut)
+[opengl](http://chicken.wiki.br/opengl)
+[glut](http://chicken.wiki.br/eggref/4/glut)
-And the following extensions (don't worry, **they should be included by default**):
-lolevel
-[srfi-1](http://srfi.schemers.org/srfi-1/srfi-1.html)
-[srfi-4](http://srfi.schemers.org/srfi-4/srfi-4.html)
+And the following extensions (don't worry, **they should be included by default**):
+lolevel
+[srfi-1](http://srfi.schemers.org/srfi-1/srfi-1.html)
+[srfi-4](http://srfi.schemers.org/srfi-4/srfi-4.html)
Usage
-----
@@ -2,11 +2,12 @@
(define *clear-color* '(0 0 0 0))
(define (game-loop delta)
- ;; Get a new matrix (same as pushing and popping the matrix)
- (with-new-matrix
+ ;; Get a new matrix (same as pushing and popping the matrix)
+ (with-new-matrix
+ (lambda ()
;; Move left 1.5 units and "out of" the screen 6 units
- (gl:Translatef -1.5 0.0 -6.0)
+ (translate -1.5 0.0 -6.0)
;; Draw a flat-colored (one-color) triangle
(flat-triangle (color 1 1 1) ;; White
@@ -15,16 +16,16 @@
(vertex 1 -1 0)) ;; Bottom Right
;; Move right 3 units
- (gl:Translatef 3 0 0)
+ (translate 3 0 0)
;; Draw a flat-colored (one-color) quad
(flat-quad (color 1 1 1) ;; White
(vertex -1 1 0) ;; Top Left
(vertex 1 1 0) ;; Top Right
(vertex 1 -1 0) ;; Bottom Right
(vertex -1 -1 0)) ;; Bottom Left
- ))
+ )))
-;; No keyboard control in this tutorial
+;; q for quit in this tutorial
(define (handle-keyboard-state delta)
- '())
+ (if (kb:key-pressed? #\q) (exit)))
@@ -2,15 +2,12 @@
(define *clear-color* '(0 0 0 0))
(define (game-loop delta)
- (let* ((total-time (- (current-milliseconds) *start-time*))
- (seconds (/ (inexact->exact (truncate total-time)) 1000))
- (current-texture (inexact->exact (truncate (remainder seconds 2)))))
-
- ;; Get a new matrix (same as pushing and popping the matrix)
- (with-new-matrix
+ ;; Get a new matrix (same as pushing and popping the matrix)
+ (with-new-matrix
+ (lambda ()
;; Move left 1.5 units and "out of" the screen 6 units
- (gl:Translatef -1.5 0.0 -6.0)
+ (translate -1.5 0.0 -6.0)
;; Draw a colored triangle
(triangle (color 1 0 0) ;; Red
@@ -21,7 +18,7 @@
(vertex 1 -1 0)) ;; Bottom Right
;; Move right 3 units
- (gl:Translatef 3 0 0)
+ (translate 3 0 0)
;; Draw a flat-colored (one-color) quad
(flat-quad (color 0 0 1) ;; Blue
@@ -31,6 +28,7 @@
(vertex -1 -1 0)) ;; Bottom Left
)))
-;; No keyboard control in this tutorial
+;; q for quit in this tutorial
(define (handle-keyboard-state delta)
- '())
+ (if (kb:key-pressed? #\q) (exit)))
+
@@ -3,46 +3,46 @@
(define (game-loop delta)
(let* ((total-time (- (current-milliseconds) *start-time*))
- (seconds (/ (inexact->exact (truncate total-time)) 1000))
- (current-texture (inexact->exact (truncate (remainder seconds 2))))
(triangle-rotation (/ total-time 4))
(quad-rotation (/ total-time 2)))
;; Get a new matrix (same as pushing and popping the matrix)
(with-new-matrix
+ (lambda ()
- ;; Move left 1.5 units and "out of" the screen 6 units
- (gl:Translatef -1.5 0.0 -6.0)
+ ;; Move left 1.5 units and "out of" the screen 6 units
+ (translate -1.5 0.0 -6.0)
- ;; Rotate about the Y axis before we draw the triangle
- (gl:Rotatef triangle-rotation 0 1 0)
+ ;; Rotate about the Y axis before we draw the triangle
+ (rotate triangle-rotation 0 1 0)
- ;; Draw a colored triangle
- (triangle (color 1 0 0) ;; Red
- (vertex 0 1 0) ;; Top
- (color 0 1 0) ;; Green
- (vertex -1 -1 0) ;; Bottom Left
- (color 0 0 1) ;; Blue
- (vertex 1 -1 0)) ;; Bottom Right
- )
+ ;; Draw a colored triangle
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 1 0) ;; Green
+ (vertex -1 -1 0) ;; Bottom Left
+ (color 0 0 1) ;; Blue
+ (vertex 1 -1 0)) ;; Bottom Right
+ ))
;; Reset to the default matrix
(with-new-matrix
+ (lambda ()
- ;; Move left 1.5 units and "out of" the screen 6 units
- (gl:Translatef 1.5 0.0 -6.0)
+ ;; Move left 1.5 units and "out of" the screen 6 units
+ (translate 1.5 0.0 -6.0)
- ;; Rotate about the Y axis before we draw the triangle
- (gl:Rotatef quad-rotation 1 0 0)
+ ;; Rotate about the Y axis before we draw the triangle
+ (rotate quad-rotation 1 0 0)
- ;; Draw a flat-colored (one-color) quad
- (flat-quad (color 0 0 1) ;; Blue
- (vertex -1 1 0) ;; Top Left
- (vertex 1 1 0) ;; Top Right
- (vertex 1 -1 0) ;; Bottom Right
- (vertex -1 -1 0)) ;; Bottom Left
- )))
+ ;; Draw a flat-colored (one-color) quad
+ (flat-quad (color 0 0 1) ;; Blue
+ (vertex -1 1 0) ;; Top Left
+ (vertex 1 1 0) ;; Top Right
+ (vertex 1 -1 0) ;; Bottom Right
+ (vertex -1 -1 0)) ;; Bottom Left
+ ))))
-;; No keyboard control in this tutorial
+;; q for quit in this tutorial
(define (handle-keyboard-state delta)
- '())
+ (if (kb:key-pressed? #\q) (exit)))
View
@@ -232,13 +232,6 @@
;; Matrix utils
-(define-syntax with-new-matrix-m
- (syntax-rules () ((_ body ...)
- (begin
- (gl:PushMatrix)
- body ...
- (gl:PopMatrix)))))
-
(define (with-new-matrix f)
(gl:PushMatrix)
(f)

0 comments on commit bd23ebb

Please sign in to comment.