add #:fail argument to with-gl-context' in
canvas%'
original commit: 0f6c26779876beaaa5463a4f478aa569af79db28
This commit is contained in:
parent
9fdb98c9c2
commit
9641cb5e70
|
@ -117,9 +117,17 @@
|
|||
(check-label-string/false cwho label)))
|
||||
(public
|
||||
[on-scroll (lambda (e) (send wx do-on-scroll e))]
|
||||
[swap-gl-buffers (lambda () (send (send (send wx get-dc) get-gl-context) swap-buffers))]
|
||||
[with-gl-context (lambda (thunk)
|
||||
(send (send (send wx get-dc) get-gl-context) call-as-current thunk))]
|
||||
[swap-gl-buffers (lambda ()
|
||||
(let ([ctx (send (send wx get-dc) get-gl-context)])
|
||||
(when ctx
|
||||
(send ctx swap-buffers))))]
|
||||
[with-gl-context (lambda (thunk #:fail [fail (lambda ()
|
||||
(error (who->name '(method canvas% with-gl-context))
|
||||
"no gl context available"))])
|
||||
(let ([ctx (send (send wx get-dc) get-gl-context)])
|
||||
(if ctx
|
||||
(send ctx call-as-current thunk)
|
||||
(fail))))]
|
||||
[accept-tab-focus (entry-point
|
||||
(case-lambda
|
||||
[() (send wx get-tab-focus)]
|
||||
|
|
|
@ -415,27 +415,32 @@ for this canvas's DC as returned by
|
|||
@method[canvas<%> get-dc].
|
||||
|
||||
The
|
||||
@method[gl-context<%> swap-buffers]
|
||||
@xmethod[gl-context<%> swap-buffers]
|
||||
method acquires a re-entrant lock, so nested calls to
|
||||
@method[canvas% with-gl-context] on different threads or OpenGL contexts can block or deadlock.
|
||||
@method[canvas% swap-gl-buffers] or @method[canvas% with-gl-context]
|
||||
on different threads or OpenGL contexts can block or deadlock.
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@defmethod[(with-gl-context [thunk (-> any)])
|
||||
@defmethod[(with-gl-context [thunk (-> any)]
|
||||
[#:fail fail (-> any) (lambda () (error ....))])
|
||||
any]{
|
||||
Passes the given thunk to
|
||||
@method[gl-context<%> call-as-current]
|
||||
of the result of
|
||||
@method[dc<%> get-gl-context]
|
||||
for this canvas's DC as returned by
|
||||
@method[canvas<%> get-dc].
|
||||
@method[canvas<%> get-dc]. If @method[dc<%> get-gl-context]
|
||||
returns @racket[#f], then @racket[fail] is called,
|
||||
instead.
|
||||
|
||||
The
|
||||
@method[gl-context<%> call-as-current]
|
||||
@xmethod[gl-context<%> call-as-current]
|
||||
method acquires a re-entrant lock, so nested calls to
|
||||
@method[canvas% with-gl-context] on different threads or OpenGL contexts can block or deadlock.
|
||||
@method[canvas% with-gl-context] or @method[canvas% swap-gl-buffers]
|
||||
on different threads or OpenGL contexts can block or deadlock.
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user