;; update should be #f for static texture and #t for dynamic texture
(bind-func xtm_draw_tex
(let ((idmat:float* (alloc 16)))
(fill_identity_matrix idmat)
(lambda (shader:ShaderProgram* tex:Texture* uvmat push_new_data:i1 alpha m v p)
(start shader)
(shader_update_matrices shader m v p)
(if push_new_data (update tex))
(bind tex 0)
;; (glEnable GL_BLEND) ;; alpha blending
;; (glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA)
(glUniform1i (glGetUniformLocation (id shader) "tex1") 0)
(if (< alpha 0.0)
(begin
(glUniform1i (glGetUniformLocation (id shader) "override_alpha") 0))
(begin
(glUniform1i (glGetUniformLocation (id shader) "override_alpha") 1)
(glUniform1f (glGetUniformLocation (id shader) "alpha") alpha)))
(if (null? uvmat)
(draw_quad shader idmat)
(draw_quad shader uvmat))
;; (glDisable GL_BLEND)
(unbind tex 0)
(stop shader)
void)))