summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-07-26 14:53:24 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-07-26 14:53:24 -0400
commit0e783848964a2f800e63c284dfde05e737e76841 (patch)
tree125fbb2bcab039dcad4b78aacc364fde6c9a812a
parentec6b19e4c1628516a31767b0ed9fec4c5d62be87 (diff)
graphics: texture: Add texture-copy-pixbuf! procedure.
-rw-r--r--chickadee/graphics/texture.scm11
1 files changed, 11 insertions, 0 deletions
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))