use new get-argb-pixels to convert bitmap to GL
svn: r4743
This commit is contained in:
parent
166f2ea539
commit
33e75ab6ec
|
@ -4,7 +4,8 @@
|
|||
(lib "class.ss")
|
||||
(lib "gl-vectors.ss" "sgl")
|
||||
(prefix gl- (lib "sgl.ss" "sgl"))
|
||||
(lib "gl.ss" "sgl"))
|
||||
(lib "gl.ss" "sgl")
|
||||
(lib "kw.ss"))
|
||||
|
||||
(provide bitmap->gl-list)
|
||||
|
||||
|
@ -20,22 +21,22 @@
|
|||
(loop (+ i 4))))
|
||||
rgba))
|
||||
|
||||
(define (bitmap->argb bmp)
|
||||
(define (bitmap->argb bmp bmp-mask)
|
||||
(let* ((width (send bmp get-width))
|
||||
(height (send bmp get-height))
|
||||
(argb (make-bytes (* 4 width height) 255))
|
||||
(dc (make-object bitmap-dc% bmp)))
|
||||
(send dc get-argb-pixels 0 0 width height argb #f)
|
||||
(when (send bmp get-loaded-mask)
|
||||
(send dc set-bitmap (send bmp get-loaded-mask))
|
||||
(send dc get-argb-pixels 0 0 width height argb #t))
|
||||
(send dc set-bitmap #f)
|
||||
(argb (make-bytes (* 4 width height) 255)))
|
||||
(send bmp get-argb-pixels 0 0 width height argb #f)
|
||||
(when bmp-mask
|
||||
(send bmp-mask get-argb-pixels 0 0 width height argb #t))
|
||||
argb))
|
||||
|
||||
(define (bitmap->gl-list bm with-gl)
|
||||
(define/kw (bitmap->gl-list bm
|
||||
#:key
|
||||
[with-gl (lambda (f) (f))]
|
||||
[mask (send bm get-loaded-mask)])
|
||||
(let ([w (send bm get-width)]
|
||||
[h (send bm get-height)]
|
||||
[rgba (argb->rgba (bitmap->argb bm))])
|
||||
[rgba (argb->rgba (bitmap->argb bm mask))])
|
||||
(with-gl
|
||||
(lambda ()
|
||||
(let ((tex (gl-vector-ref (glGenTextures 1) 0))
|
||||
|
|
|
@ -277,14 +277,20 @@ _bitmap.ss_
|
|||
The "bitmap.ss" library in the "sgl" collection provides a helper
|
||||
function for converting a MrEd bitmap to a GL list:
|
||||
|
||||
> (bitmap->gl-list bitmap with-gl-proc)
|
||||
> (bitmap->gl-list bitmap #:with-gl with-gl-proc
|
||||
#:mask bitmap)
|
||||
|
||||
Converts the given bitmap (an instance of bitmap%) into a GL list that
|
||||
can be rendered with `call-list' or `glCallList'. The rendered object
|
||||
is a square on the z=0 plane with corners at (0,0) and (1,1).
|
||||
|
||||
The given `with-gl-proc' function must accept a thunk and call it
|
||||
while the relevant GL context is selected.
|
||||
If `with-gl-proc' is provided, it must accept a thunk and call it
|
||||
while the relevant GL context is selected. Otherwise, the relevant GL
|
||||
context must be selected already.
|
||||
|
||||
If `mask' is given, it is used as the mask bitmap (for extracting
|
||||
alpha values). The default is the result of the `get-loaded-mask'
|
||||
method of `bm'.
|
||||
|
||||
=================================================================
|
||||
Function indexes
|
||||
|
|
Loading…
Reference in New Issue
Block a user