From 0e783848964a2f800e63c284dfde05e737e76841 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 26 Jul 2023 14:53:24 -0400 Subject: graphics: texture: Add texture-copy-pixbuf! procedure. --- chickadee/graphics/texture.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/chickadee/graphics/texture.scm b/chickadee/graphics/texture.scm index c78db50..65b7300 100644 --- a/chickadee/graphics/texture.scm +++ b/chickadee/graphics/texture.scm @@ -38,6 +38,7 @@ pixbuf->texture load-image load-cube-map + texture-copy-pixbuf! texture->pixbuf write-texture texture? @@ -467,6 +468,16 @@ are 'nearest and 'linear. By default, 'nearest is used." #:min-filter min-filter #:mag-filter mag-filter)) +(define (texture-copy-pixbuf! texture pixbuf) + "Copy the contents of PIXBUF to TEXTURE." + (with-graphics-state! ((g:texture-0 texture)) + (gl-texture-sub-image-2d (texture-target texture-2d) 0 + (texture-x texture) (texture-y texture) + (pixbuf-width pixbuf) (pixbuf-height pixbuf) + (gl-pixel-format 'rgba) + (color-pointer-type unsigned-byte) + (pixbuf-pixels pixbuf)))) + (define (texture->pixbuf texture) "Return a new pixbuf with the contents of TEXTURE." (let* ((w (texture-width texture)) -- cgit v1.2.3