(bind-func write
(lambda (tex:Texture* filename:String* flip:i1)
(let ((comp (if (= (type tex) GL_RGB) 3 4)))
(if flip (stbi_flip_vertically (width tex) (height tex) comp (data tex)))
(stbi_write_png (cstring filename) (width tex) (height tex)
comp
(data tex) (* (width tex) comp 1))
void)))