Created
December 15, 2010 18:08
-
-
Save gaborpapp/742364 to your computer and use it in GitHub Desktop.
examples of using an ffgl plugins on a pixel primitive with multiple texture attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; example of using an ffgl plugin on a pixel primitive | |
(clear) | |
(scale #(20 15 1)) | |
; pixel primitive with 2 textures and an active renderer | |
(define p (build-pixels 512 512 #t 2)) | |
(define plugin (ffgl-load "cibloom" 512 512)) | |
(with-ffgl plugin | |
(ffgl-process p ; output pixel primitive | |
(pixels->texture p 1) ; output texture of the pixel primitive | |
(pixels->texture p 0) ; input texture | |
)) | |
(with-primitive p | |
; the renderer of the pixels primitive renders to texture index 0 | |
(pixels-render-to (pixels->texture p 0)) | |
; the primitive is displayed using texture index 1, the output texture | |
; of the ffgl plugin | |
(pixels-display (pixels->texture p 1))) | |
(define (anim) | |
(with-pixels-renderer p | |
(with-state | |
(clear-colour 0) | |
(scale 5) | |
(rotate (vector (* 50 (time)) -17 (* -35 (time)))) | |
(draw-cube)))) | |
(every-frame (anim)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; example of using 2 ffgl plugins on the same pixel primitive | |
(clear) | |
(scale #(20 15 1)) | |
; pixel primitive with 3 textures and an active renderer | |
(define p (build-pixels 512 512 #t 3)) | |
(define plugin1 (ffgl-load "cibloom" 512 512)) | |
(with-ffgl plugin1 | |
(ffgl-process p ; output pixel primitive | |
(pixels->texture p 1) ; output texture of the pixel primitive | |
(pixels->texture p 0) ; input texture | |
)) | |
(define plugin2 (ffgl-load "cioptile" 512 512)) | |
(with-ffgl plugin2 | |
(ffgl-process p ; output pixel primitive | |
(pixels->texture p 2) ; output texture | |
(pixels->texture p 1) ; input texture is the output of the previous plugin | |
)) | |
(with-primitive p | |
; the renderer of the pixels primitive renders to texture index 0 | |
(pixels-render-to (pixels->texture p 0)) | |
; the primitive is displayed using texture index 2, the output texture | |
; of the last ffgl plugin | |
(pixels-display (pixels->texture p 2))) | |
(every-frame | |
(with-pixels-renderer p | |
(with-state | |
(clear-colour 0) | |
(scale 5) | |
(rotate (vector (* 50 (time)) -17 (* -35 (time)))) | |
(draw-cube)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment