Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Forgot to commit these late last night. Need more sleep :P

  • Loading branch information...
commit 87d11c9957adf215f1111003928f3bc9aba85543 1 parent d1adb6c
Sean Grove authored
View
1  config/settings.scm
@@ -6,6 +6,7 @@
(define *window-position* '(100 100))
(define *clear-color* '(1 1 1 0))
(define *clear-depth* 1.0)
+(define *display-mode* (+ glut:DOUBLE glut:RGBA glut:DEPTH))
(define *ignore-key-repeat* #t)
View
172 examples/nehe_tutorials_5.scm
@@ -3,97 +3,97 @@
(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
-
- ;; Move left 1.5 units and "out of" the screen 6 units
- (gl:Translatef -1.5 0.0 -6.0)
-
- ;; Rotate about the Y axis before we draw the triangle
- (gl:Rotatef triangle-rotation 0 1 0)
-
- ;; Draw one face of the pyramid (a colored triangle)
- (triangle (color 1 0 0) ;; Red
- (vertex 0 1 0) ;; Top
- (color 0 1 0) ;; Green
- (vertex -1 -1 1) ;; Bottom Left
- (color 0 0 1) ;; Blue
- (vertex 1 -1 1)) ;; Bottom Right
-
- (triangle (color 1 0 0) ;; Red
- (vertex 0 1 0) ;; Top
- (color 0 0 1) ;; Blue
- (vertex 1 -1 1) ;; Bottom Left
- (color 0 1 0) ;; Green
- (vertex 1 -1 -1)) ;; Bottom Right
-
- (triangle (color 1 0 0) ;; Red
- (vertex 0 1 0) ;; Top
- (color 0 1 0) ;; Green
- (vertex 1 -1 -1) ;; Bottom Left
- (color 0 0 1) ;; Blue
- (vertex -1 -1 -1)) ;; Bottom Right
-
- (triangle (color 1 0 0) ;; Red
- (vertex 0 1 0) ;; Top
- (color 0 0 1) ;; Blue
- (vertex -1 -1 -1) ;; Bottom Left
- (color 0 1 0) ;; Green
- (vertex -1 -1 1)) ;; Bottom Right
- )
-
+ (lambda ()
+
+ ;; 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
+ (rotate triangle-rotation 0 1 0)
+
+ ;; Draw one face of the pyramid (a colored triangle)
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 1 0) ;; Green
+ (vertex -1 -1 1) ;; Bottom Left
+ (color 0 0 1) ;; Blue
+ (vertex 1 -1 1)) ;; Bottom Right
+
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 0 1) ;; Blue
+ (vertex 1 -1 1) ;; Bottom Left
+ (color 0 1 0) ;; Green
+ (vertex 1 -1 -1)) ;; Bottom Right
+
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 1 0) ;; Green
+ (vertex 1 -1 -1) ;; Bottom Left
+ (color 0 0 1) ;; Blue
+ (vertex -1 -1 -1)) ;; Bottom Right
+
+ (triangle (color 1 0 0) ;; Red
+ (vertex 0 1 0) ;; Top
+ (color 0 0 1) ;; Blue
+ (vertex -1 -1 -1) ;; Bottom Left
+ (color 0 1 0) ;; Green
+ (vertex -1 -1 1)) ;; Bottom Right
+ ))
+
;; Reset to the default matrix
(with-new-matrix
-
- ;; Move left 1.5 units and "out of" the screen 6 units
- (gl:Translatef 1.5 0.0 -7.0)
-
- ;; Rotate about the X, Y, and Z axis before we draw the triangle
- (gl:Rotatef quad-rotation 1 1 1)
-
- ;; Draw a flat-colored (one-color) quad
- (flat-quad (color 0 1 0) ;; Green
- (vertex 1 1 -1) ;; Top Left
- (vertex -1 1 -1) ;; Top Right
- (vertex -1 1 1) ;; Bottom Right
- (vertex 1 1 1)) ;; Bottom Left
-
- (flat-quad (color 1 0.5 1) ;; Orange
- (vertex 1 -1 1) ;; Top Left
- (vertex -1 -1 1) ;; Top Right
- (vertex -1 -1 -1) ;; Bottom Right
- (vertex 1 -1 -1)) ;; Bottom Left
-
- (flat-quad (color 1 0 0) ;; Red
- (vertex 1 1 1) ;; Top Left
- (vertex -1 1 1) ;; Top Right
- (vertex -1 -1 1) ;; Bottom Right
- (vertex 1 -1 1)) ;; Bottom Left
-
- (flat-quad (color 1 1 0) ;; Yellow
- (vertex 1 -1 -1) ;; Top Left
- (vertex -1 -1 -1) ;; Top Right
- (vertex -1 1 -1) ;; Bottom Right
- (vertex 1 1 -1)) ;; Bottom Left
-
- (flat-quad (color 0 0 1) ;; Blue
- (vertex -1 1 1) ;; Top Left
- (vertex -1 1 -1) ;; Top Right
- (vertex -1 -1 -1) ;; Bottom Right
- (vertex -1 -1 1)) ;; Bottom Left
-
- (flat-quad (color 1 0 1) ;; Violet
- (vertex 1 1 -1) ;; Top Left
- (vertex 1 1 1) ;; Top Right
- (vertex 1 -1 1) ;; Bottom Right
- (vertex 1 -1 -1)) ;; Bottom Left
- )))
-
-;; No keyboard control in this tutorial
+ (lambda ()
+
+ ;; Move left 1.5 units and "out of" the screen 6 units
+ (translate 1.5 0.0 -7.0)
+
+ ;; Rotate about the X, Y, and Z axis before we draw the triangle
+ (rotate quad-rotation 0.25 1 1)
+
+ ;; Draw a flat-colored (one-color) quad
+ (flat-quad (color 0 1 0) ;; Green
+ (vertex 1 1 -1) ;; Top Left
+ (vertex -1 1 -1) ;; Top Right
+ (vertex -1 1 1) ;; Bottom Right
+ (vertex 1 1 1)) ;; Bottom Left
+
+ (flat-quad (color 1 0.5 1) ;; Orange
+ (vertex 1 -1 1) ;; Top Left
+ (vertex -1 -1 1) ;; Top Right
+ (vertex -1 -1 -1) ;; Bottom Right
+ (vertex 1 -1 -1)) ;; Bottom Left
+
+ (flat-quad (color 1 0 0) ;; Red
+ (vertex 1 1 1) ;; Top Left
+ (vertex -1 1 1) ;; Top Right
+ (vertex -1 -1 1) ;; Bottom Right
+ (vertex 1 -1 1)) ;; Bottom Left
+
+ (flat-quad (color 1 1 0) ;; Yellow
+ (vertex 1 -1 -1) ;; Top Left
+ (vertex -1 -1 -1) ;; Top Right
+ (vertex -1 1 -1) ;; Bottom Right
+ (vertex 1 1 -1)) ;; Bottom Left
+
+ (flat-quad (color 0 0 1) ;; Blue
+ (vertex -1 1 1) ;; Top Left
+ (vertex -1 1 -1) ;; Top Right
+ (vertex -1 -1 -1) ;; Bottom Right
+ (vertex -1 -1 1)) ;; Bottom Left
+
+ (flat-quad (color 1 0 1) ;; Violet
+ (vertex 1 1 -1) ;; Top Left
+ (vertex 1 1 1) ;; Top Right
+ (vertex 1 -1 1) ;; Bottom Right
+ (vertex 1 -1 -1)) ;; Bottom Left
+ ))))
+
+;; q for quit in this tutorial
(define (handle-keyboard-state delta)
- '())
+ (if (kb:key-pressed? #\q) (exit)))
View
7 lib/core.scm
@@ -91,9 +91,9 @@
(glut:TimerFunc 0 render-loop 0))
(define (main)
- (glut:InitDisplayMode (+ glut:DOUBLE glut:RGBA glut:DEPTH))
- (glut:InitWindowSize (nth *window-resolution* 0) (nth *window-resolution* 1))
- (glut:InitWindowPosition (nth *window-position* 0) (nth *window-position* 1))
+ (glut:InitDisplayMode *display-mode*)
+ (glut:InitWindowSize (nth *window-resolution* 0) (nth *window-resolution* 1))
+ (glut:InitWindowPosition (nth *window-position* 0) (nth *window-position* 1))
(glut:CreateWindow *window-title*)
(init)
(glut:DisplayFunc display)
@@ -112,4 +112,5 @@
(glut:MainLoop)
(post-main-hook))
+(print "Stepping into main function...")
(main)
View
13 lib/gl_utils.scm
@@ -3,6 +3,12 @@
(body)
(gl:End))
+(define (translate . args)
+ (apply gl:Translatef args))
+
+(define (rotate . args)
+ (apply gl:Rotatef args))
+
;; (define (vertex? item)
;; (if (and (equal? (length item) 3)
@@ -226,13 +232,18 @@
;; Matrix utils
-(define-syntax with-new-matrix
+(define-syntax with-new-matrix-m
(syntax-rules () ((_ body ...)
(begin
(gl:PushMatrix)
body ...
(gl:PopMatrix)))))
+(define (with-new-matrix f)
+ (gl:PushMatrix)
+ (f)
+ (gl:PopMatrix))
+
(define (bottomless-cube top-texture
side-texture
position
View
19 lib/image_utils.scm
@@ -11,8 +11,6 @@
(nth data 10))
(define (bmp-header data)
- (print "File data:")
- (print data)
(sublist data 0 (bmp-data-offset data)))
(define (bmp-width data)
@@ -62,15 +60,12 @@
;; (print (string-append "Offset: " (number->string (bmp-data-offset bmp))))
;(print (string-append "Header: " (list->string header)))
(do ((row 0 (+ row 1))) ((> row (- height 1)) buffer)
- (print (string-append "New Row: " (number->string row)))
(do ((column 3 (+ column bpp))) ((> column (* width bpp)))
- (print (string-append "--- (" (number->string row) ", " (number->string column) ") ---"))
(let* ((position (+ (* row width bpp) column))
(red (vector-ref body (- position 3)))
(green (vector-ref body (- position 2)))
(blue (vector-ref body (- position 1))))
- (print (string-append (number->string counter) "-" (number->string position)))
(u8vector-set! buffer (+ counter 0) red)
(u8vector-set! buffer (+ counter 1) green)
(u8vector-set! buffer (+ counter 2) blue)
@@ -82,7 +77,6 @@
(u8vector-set! buffer (+ counter 3) (vector-ref body (- position 0)))))
(u8vector-set! buffer counter (vector-ref body counter))
- ;(print (string-append (number->string counter) ". [O->N] [" (number->string (vector-ref body counter)) " -> " (number->string (u8vector-ref buffer counter)) "]"))
(set! counter (+ counter bpp)))))
buffer))
;(flip-bmp-vertically (* width 4) buffer)))
@@ -90,7 +84,6 @@
(define (load-textures filenames type)
(if (equal? type 'bmp)
(begin
- (print (gl:GenTextures (length filenames) texture-handles))
(for-each (lambda (file) (load-texture file *texture-count*) (add1 *texture-count*)) filenames))))
; works on u8vectors
@@ -100,7 +93,6 @@
(buffer (make-u8vector data-size 0))
(height (/ data-size row-width))
(counter 0))
- ;; (print (string-append (number->string height) " rows tall"))
(do ((row (- height 1) (- row 1))) ((equal? row -1) buffer)
(do ((column 0 (+ column 4))) ((equal? column row-width))
(let ((position (+ (* row row-width) column)))
@@ -109,8 +101,6 @@
(u8vector-set! buffer (+ counter 1) (u8vector-ref data (+ position 1)))
(u8vector-set! buffer (+ counter 2) (u8vector-ref data (+ position 2)))
(u8vector-set! buffer (+ counter 3) (u8vector-ref data (+ position 3))))
-
- ;; (print (string-append (number->string (+ (* row row-width) column)) " -> " (number->string counter))))
(set! counter (+ counter 4))))))
; works on u8vectors
@@ -120,7 +110,6 @@
(buffer (make-u8vector data-size 255))
(height (/ data-size row-width))
(counter 0))
- ;(print (string-append (number->string height) " rows tall"))
(do ((row 0 (+ row 1))) ((equal? row height))
(do ((column 1 (+ column 4))) ((> column row-width))
(let ((position (+ (* row row-width) (- row-width column))))
@@ -128,13 +117,7 @@
(u8vector-set! buffer (+ counter 0) (u8vector-ref data (- position 1)))
(u8vector-set! buffer (+ counter 1) (u8vector-ref data (- position 2)))
(u8vector-set! buffer (+ counter 2) (u8vector-ref data (- position 3)))
- (u8vector-set! buffer (+ counter 3) (u8vector-ref data (- position 0)))
-
- ;; (print (string-append (number->string (+ counter 0)) " = " (number->string (u8vector-ref data (- position 3))) ", Actual: [" (number->string (u8vector-ref buffer (+ counter 0)))))
- ;; (print (string-append (number->string (+ counter 1)) " = " (number->string (u8vector-ref data (- position 2))) ", Actual: [" (number->string (u8vector-ref buffer (+ counter 1)))))
- ;; (print (string-append (number->string (+ counter 2)) " = " (number->string (u8vector-ref data (- position 1))) ", Actual: [" (number->string (u8vector-ref buffer (+ counter 2)))))
- ;; (print (string-append (number->string (+ counter 3)) " = " (number->string (u8vector-ref data (- position 0))) ", Actual: [" (number->string (u8vector-ref buffer (+ counter 3)))))
- )
+ (u8vector-set! buffer (+ counter 3) (u8vector-ref data (- position 0))))
(set! counter (+ counter 4))))
buffer))
View
9 lib/texture_utils.scm
@@ -1,9 +1,6 @@
(define (load-texture filename position)
(let* ((dummy (bmp-load filename))
- (dummy2 (print "here1"))
- (dummy2 (print dummy))
(t-meta (bmp-header (bmp-load filename)))
- (dummy (print "here"))
(width (bmp-width t-meta))
(bpp (bmp-bits-per-pixel t-meta))
(height (bmp-height t-meta))
@@ -14,10 +11,10 @@
;(t (flip-bmp-vertically (* width bpp) (load-bmp-texture filename))))
;(t (flip-bmp-horizontally (* width bpp) (load-bmp-texture filename))))
(t (flip-bmp-vertically (* width bpp) (flip-bmp-horizontally (* width bpp) (load-bmp-texture filename)))))
- (print "---------------------------------------------------------------------------")
- (print (string-append "Setting " filename " to texture: " (number->string position)))
+ ;(print "---------------------------------------------------------------------------")
+ ;(print (string-append "Setting " filename " to texture: " (number->string position)))
;; (print t)
- (print (string-append (number->string width) "x" (number->string height) " pixels"))
+ ;(print (string-append (number->string width) "x" (number->string height) " pixels"))
(gl:BindTexture gl:TEXTURE_2D (u32vector-ref texture-handles position))
(gl:PixelStorei gl:UNPACK_ALIGNMENT 1)
(gl:PixelStorei gl:UNPACK_ROW_LENGTH 0)
Please sign in to comment.
Something went wrong with that request. Please try again.