(bind-func load_assim_material_texture
(lambda (scene:aiScene* material type dir)
(let ((texfile:aiString* (salloc))
(tex:Texture* null))
(if (= (aiGetMaterialTexture material type 0 texfile null null null null null null) 0)
(let ((s1 (cast (tref-ptr texfile 1) i8*))
(lgth (+ (strlen dir) (tref texfile 0) 1))
(s2 (salloc lgth)))
(if (= (pref s1 0) 42)
(let ((texidx:i32 (atoi (pref-ptr s1 1)))
(texture:aiTexture* (pref (tref scene 9) texidx))
(achformat (tref texture 2))
(texwidth (tref texture 0))
(texheight (tref texture 1))
(texdata (cast (tref texture 3) i8*))
(datasize (if (= texheight 0) texwidth (* 4 texwidth texheight))))
;;(printf "tidx:%d of num:%d w:%d h:%d size:%d\n" texidx (tref scene 8) texwidth texheight datasize)
(set! tex (Texture texwidth texheight 4 texdata))
(update tex)
;; (bind tex #t) ;; send to card
;; (unbind tex)
(println tex)
;; (set! texid (ai_load_ogl_texture_from_buffer texdata datasize 0))
void)
(begin
(memset s2 0 lgth)
(memcpy s2 dir (strlen dir))
(memcpy (pref-ptr s2 (strlen dir)) s1 (tref texfile 0))
(println 'load-texture-from-file: (Str s2))
(set! tex (Texture (Str s2)))
(update tex)
(println tex)
;; (set! texid (ai_load_ogl_texture s2 0))
void))))
tex)))