(bind-func Texture_bind_data
"this just uses texture slot 0 (GL_TEXTURE0) - it should probably
allow the texture slot to be specified"
(lambda (tex:Texture data:i8* width height chan:i32 wrap filter)
(if (null? data)
(begin (println "Error: data is null.")
#f)
(let ((format (cond ((= chan 1) GL_RED)
((= chan 3) GL_RGB)
((= chan 4) GL_RGBA)
(else 0:i32))))
(if (= format 0)
(begin (println "Error: only chan must be 1, 3 or 4.")
#f)
(begin (glActiveTexture GL_TEXTURE0)
(glBindTexture GL_TEXTURE_2D tex)
(glTexImage2D GL_TEXTURE_2D 0
format
width height
0
format
GL_UNSIGNED_BYTE
data)
;; set some parameters
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_S wrap)
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_T wrap)
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER filter)
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER filter)
(gl_print_error "couldn't Texture_bind_image")
#t))))))