(define screen #f)
(define flags 0)
-(define (init-video width height bpp #:key (mode '2d) (title ""))
+(define* (init-video width height bpp #:key (mode '2d) (title ""))
(cond ((not screen)
(SDL_Init SDL_INIT_VIDEO)
(let ((info (SDL_GetVideoInfo)))
;;; Frames per second
-(define set-frames-per-second #f)
-(define init-frame-time #f)
-(define get-frame-time #f)
-(define delay-frame #f)
+(define time 0)
+(define time-per-frame 50) ;in ms
-;; (let ((time 0) (time-per-frame (/ 1000.0 *frames-per-second*)))
-;; (set! set-frames-per-second
-;; (lambda (fps)
-;; (set! time-per-frame (/ 1000.0 fps))))
+(define (set-frames-per-second fps)
+ (set! time-per-frame (/ 1000.0 fps)))
-;; (set! init-frame-time
-;; (lambda ()
-;; (set! time (SDL_GetTicks))))
+(define (init-frame-time)
+ (set! time (SDL_GetTicks)))
-;; (set! get-frame-time
-;; (lambda ()
-;; time))
+(define (get-frame-time)
+ time)
-;; (set! delay-frame
-;; (lambda ()
-;; (let ((frame-time (- (SDL_GetTicks) time)))
-;; (cond ((< frame-time time-per-frame)
-;; (SDL_Delay (- time-per-frame frame-time))))))))
+(define (delay-frame)
+ (let ((frame-time (- (SDL_GetTicks) time)))
+ (cond ((< frame-time time-per-frame)
+ (SDL_Delay (- time-per-frame frame-time))))))
;;; Drawing
(glNormal3f 0 1 0)
(draw-quad (list size size size) (list -size size size) (list -size size -size) (list size size -size) #:texture (or texture-3 texture) #:color (or color-3 color))
(glNormal3f 0 -1 0)
- (draw-quad (list -size -size size) (list size -size size) (list size -size -size) (list -size -size -size) :texture (or texture-4 texture) #:color (or color-4 color))
+ (draw-quad (list -size -size size) (list size -size size) (list size -size -size) (list -size -size -size) #:texture (or texture-4 texture) #:color (or color-4 color))
(glNormal3f 1 0 0)
- (draw-quad (list size -size -size) (list size -size size) (list size size size) (list size size -size) :texture (or texture-5 texture) #:color (or color-5 color))
+ (draw-quad (list size -size -size) (list size -size size) (list size size size) (list size size -size) #:texture (or texture-5 texture) #:color (or color-5 color))
(glNormal3f -1 0 0)
- (draw-quad (list -size -size size) (list -size -size -size) (list -size size -size) (list -size size size) :texture (or texture-6 texture) #:color (or color-6 color)))))
+ (draw-quad (list -size -size size) (list -size -size -size) (list -size size -size) (list -size size size) #:texture (or texture-6 texture) #:color (or color-6 color)))))
(define* (translate x y #:optional (z 0))
(glTranslatef x y z))
;;; Lights
-(define* (add-light #:key light position ambient (id GL_LIGHT1) (turn-on t))
- (init-lighting)
- (and light (glLightfv id GL_DIFFUSE (first light) (second light) (third light) (fourth light)))
- (and light position (glLightfv GL_POSITION (first position) (second position) (third position) (fourth position)))
- (and ambient (glLightfv id GL_AMBIENT (first ambient) (second ambient) (third ambient) (fourth ambient)))
- (and turn-on (glEnable id))
- id)
+;; (define* (add-light #:key light position ambient (id GL_LIGHT1) (turn-on t))
+;; (init-lighting)
+;; (and light (glLightfv id GL_DIFFUSE (car light) (cadr light) (caddr light) (cadddr light)))
+;; (and light position (glLightfv GL_POSITION (car position) (cadr position) (caddr position) (cadddr position)))
+;; (and ambient (glLightfv id GL_AMBIENT (car ambient) (cadr ambient) (caddr ambient) (cadddr ambient)))
+;; (and turn-on (glEnable id))
+;; id)
;;; Camera