`pict3d->bitmap` errors on OSX
florence opened this issue · comments
#lang racket
(require pict3d)
(pict3d->bitmap (sphere origin 1/2))
Errors with:
OpenGL error in procedure glClear: Error code 1286.
context...:
/Applications/Racket/racket/share/pkgs/pict3d/typed/opengl/untyped.rkt:106:11: self-mutating-fun
...private/memo.rkt:101:34
/Applications/Racket/racket/share/pkgs/pict3d/pict3d/private/memo.rkt:63:2
/Applications/Racket/racket/share/pkgs/pict3d/pict3d/private/engine/draw/draw-passes.rkt:429:0: draw-draw-passes*
...e/gl/context.rkt:20:24
/Applications/Racket/racket/collects/racket/contract/private/arrow-higher-order.rkt:346:33
/Applications/Racket/racket/collects/racket/contract/private/arrow-higher-order.rkt:342:33
/Applications/Racket/racket/share/pkgs/pict3d/pict3d/private/gui/untyped-pict3d-bitmap.rkt:29:0: pict3d->bitmap7
...ow-val-first.rkt:306:25
I'm on macOS 10.12.3
Some quick googling shows that error 1286 happens when the framebuffer is not ready to be read from/written too.
It looks like the error is coming from here: https://github.com/jeapostrophe/pict3d/blob/master/pict3d/private/engine/draw/draw-passes.rkt#L393
It seems like the call to glClear
and glClearColor
should be in a with-gl-framebuffer
. However if I wrap those two in a (with-gl-framebuffer fbo ...)
, rebuild, and rerun, i get the same error here:
https://github.com/jeapostrophe/pict3d/blob/master/pict3d/private/engine/draw/draw-passes.rkt#L821
And I'm not sure how to go about fixing that one.
I pushed something to fix this, but in the process I learned about how it was implemented. I'm skeptical the bitmaps ever worked. Right now, your test ends up with a black bitmap.
further developements:
This error has been happening irregulary when using the pict3d-snips and happens when set-pict3d
is called on a pict3d-canvas%
. But it does not happen when constructing the canvas (although the canvas does not render the pict properly).
I tried your fix on this program:
#lang racket
(require pict3d)
(pict3d->bitmap
(combine (sphere origin 1/2)
(light (pos 0 1 1) (emitted "azure" 2))))
And I get a black pict, but with the correct reflected glow coming off the sphere. So at least the lighting pass is working...?
Also, thanks for looking into this so fast!
I believe this is fixed. I used this test to compare bitmaps vs canvas:
#lang racket/base
(require pict3d
pict3d/universe
racket/gui
racket/class)
(module+ main
(define p
(combine (sphere origin 1/2)
(light (pos 0 1 1) (emitted "azure" 2))))
(define bm
(pict3d->bitmap p))
(thread
(λ ()
(define f (new frame% [label "Bitmap Test"]))
(new canvas% [parent f]
[min-width (send bm get-width)]
[min-height (send bm get-height)]
[paint-callback
(λ (c dc)
(send dc draw-bitmap
bm
0 0))])
(send f show #t)))
(define (on-draw s n t) p)
(big-bang3d 0 #:on-draw on-draw))