Below is what works for me (this is just for the archives).
When run the program prints this warning/info which I assume it is ok to
ignore.

    GL context changed
    You are using OpenGL '(4 1) with gl-backend-version of 3.3
    '#(#(400.0 400.0) #(0.945 0.945) #(378.0 378.0) #(378.0 378.0) #(400.0
378.0))

The computer runs OS X 10.12.2 (Sierra) and the Graphics card is an Intel
Iris Graphics 6100 1536 MB.

#lang racket
(require mode-lambda
         mode-lambda/static
         mode-lambda/text/static
         mode-lambda/text/runtime
         mode-lambda/color
         mode-lambda/backend/gl
         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))

(define static (list fish-sprite lantern-sprite))
(define (paint-canvas c dc)
  (define dynamic (list flash-sprite))
  (define draw (rendering-states->draw lc static dynamic))
  (match/values (send c get-scaled-client-size)
    [(w h) (draw w h dc)]))

(define glc  (new gl-config%))
(send glc set-legacy? #f)
(define f    (new frame% [label "Hello"] [width W] [height H]))
(define c    (new canvas%
                  [parent f]
                  [gl-config glc]
                  [style '(no-autoclear gl)]
                  [paint-callback paint-canvas]))
(send f show #t)




2016-12-28 16:20 GMT+01:00 Jay McCarthy <jay.mccar...@gmail.com>:

> On Wed, Dec 28, 2016 at 5:57 AM, Jens Axel Søgaard
> <jensa...@soegaard.net> wrote:
> > That example is quite involved. It doesn't show how to get things going
> > without using chaos.
>
> I suggest looking at lux/chaos/gui for how to get a canvas.
>
> > If I use (require mode-lambda/backend/gl) instead of (require
> > mode-lambda/backend/software)
> > and use a bitmap with gl backing like this:
> >
> >     (define draw (rendering-states->draw lc (list fish-sprite
> > lantern-sprite) (list  flash-sprite)))
> >     (define glc  (new gl-config%))
> >     (define bm   (make-gl-bitmap W H glc))
> >     (define dc   (new bitmap-dc% [bitmap bm]))
> >     (draw W H dc)
> >     bm
> >
> > Then I get this error:
> >
> >     GL context changed
> >     OpenGL error in procedure glGetString: Error code 1286.
> >
>
> That error means "Unsupported framebuffer format". I'd have to know a
> lot more about your environment to debug. One thing to note is that
> the default gl-config% is a legacy one that isn't support by
> mode-lambda.
>
> Jay
>
> > This is still in DrRacket.
> >
> >
> > 2016-12-28 2:03 GMT+01:00 Jay McCarthy <jay.mccar...@gmail.com>:
> >>
> >> What you have is fine, but you need to give it a DC where
> >> get-gl-context doesn't return false. (Such as by making a canvas with
> >> the 'gl style.) In addition, you do NOT want a legacy context.
> >>
> >> I recommend looking at the example code:
> >>
> >>
> >> https://github.com/jeapostrophe/mode-lambda/blob/
> master/mode-lambda/examples/one.rkt
> >>
> >> On Tue, Dec 27, 2016 at 4:37 PM, Jens Axel Søgaard
> >> <jensa...@soegaard.net> wrote:
> >> > 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.
> >>
> >>
> >>
> >> --
> >> Jay McCarthy
> >> Associate Professor
> >> PLT @ CS @ UMass Lowell
> >> http://jeapostrophe.github.io
> >>
> >>            "Wherefore, be not weary in well-doing,
> >>       for ye are laying the foundation of a great work.
> >> And out of small things proceedeth that which is great."
> >>                           - D&C 64:33
> >
> >
> >
> >
> > --
> > --
> > Jens Axel Søgaard
> >
>
>
>
> --
> Jay McCarthy
> Associate Professor
> PLT @ CS @ UMass Lowell
> http://jeapostrophe.github.io
>
>            "Wherefore, be not weary in well-doing,
>       for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
>                           - D&C 64:33
>



-- 
-- 
Jens Axel Søgaard

-- 
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