;; get texture-width
;; for TEXTURE_2D only!
(bind-func gl_tex_width
(lambda (tex)
(glDisable GL_TEXTURE_RECTANGLE_ARB)
(glEnable GL_TEXTURE_2D)
(glBindTexture GL_TEXTURE_2D tex)
(let ((v:|1,i32|* (salloc)))
(glGetTexLevelParameteriv GL_TEXTURE_2D 0 GL_TEXTURE_WIDTH (cast v))
(glDisable GL_TEXTURE_2D)
(glBindTexture GL_TEXTURE_2D 0)
(aref v 0))))