Hi All,

I am experimenting with mode-lambda. The example below
shows how to draw sprites on different layers using the software backend.
However I would like to try the gl backend instead.

What is the correct incantation?

/Jens Axel


#lang racket
(require mode-lambda
         mode-lambda/static
         mode-lambda/text/static
         mode-lambda/text/runtime
         mode-lambda/color
         ; mode-lambda/backend/gl
         mode-lambda/backend/software
         racket/draw
         racket/gui/base
         pict
         pict/flash)

;;;
;;; BITMAPS
;;;
(define fish-bm     (pict->bitmap (standard-fish  100 50)))
(define lantern-bm  (pict->bitmap (jack-o-lantern 100)))
(define flash-bm    (pict->bitmap (colorize (linewidth 5 (outline-flash 100
100)) "yellow")))

;;;
;;; SPRITES
;;;

(define db (make-sprite-db))
(add-sprite!/bm db 'fish    (λ() fish-bm))
(add-sprite!/bm db 'lantern (λ() lantern-bm))
(add-sprite!/bm db 'flash   (λ() flash-bm))
(define cdb (compile-sprite-db db))
(define fish-idx    (sprite-idx cdb 'fish))
(define lantern-idx (sprite-idx cdb 'lantern))
(define flash-idx   (sprite-idx cdb 'flash))

;;;
;;; LAYERS
;;;
(define W 400)
(define H 400)
(define W/2 (/ W 2.))
(define H/2 (/ H 2.))

(define bgl (layer W/2 H/2))    ; background: layer 0
(define ml  (layer W/2 H/2))    ; middle:     layer 1
(define fgl (layer W/2 H/2))    ; foreground: layer 2
(define lc (vector bgl ml fgl)) ; layer config

;;;
;;; RUNTIME
;;;

(define fish-sprite    (sprite 200. 200. fish-idx    #:layer 0)) ;
background
(define lantern-sprite (sprite 250. 200. lantern-idx #:layer 1)) ; middle
(define flash-sprite   (sprite 250. 200. flash-idx   #:layer 2)) ;
foreground

(define rendering-states->draw (stage-draw/dc cdb W H 3)) ; XXX change 3 to
2 and get a crash

(define draw (rendering-states->draw lc (list fish-sprite lantern-sprite)
(list  flash-sprite)))
(define bm   (make-object bitmap% W H))
(define dc   (new bitmap-dc% [bitmap bm]))
(draw W H dc)
bm

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to