(bind-func Texture_create_FBO_depth_texture
(lambda (width height)
(let ((depth_tex (Texture_create)))
(glActiveTexture GL_TEXTURE0)
(glBindTexture GL_TEXTURE_2D depth_tex)
(glTexImage2D GL_TEXTURE_2D 0 GL_DEPTH_COMPONENT width height 0 GL_DEPTH_COMPONENT GL_UNSIGNED_BYTE null)
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_NEAREST)
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER GL_NEAREST)
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_S GL_CLAMP_TO_EDGE)
(glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_T GL_CLAMP_TO_EDGE)
;; attach depth texture to framebuffer
(glFramebufferTexture2D GL_FRAMEBUFFER GL_DEPTH_ATTACHMENT GL_TEXTURE_2D depth_tex 0)
(gl_print_error "Error creating FBO depth texture")
depth_tex)))