;; create and return a frame buffer struct (E_fbo)
;; if _texid is greater than 0 then use existing _texid
(bind-func create_fbo_no_depth_rect
  (lambda (width:i32 height:i32 _texid:i32)
    (let ((texid:i32 0)
    (fboid:i32* (salloc))
    (fbo:E_fbo* (halloc))) ;; heap alloc
      (glGenFramebuffers 1 fboid)
      ;; bind the fbo
      (glBindFramebuffer GL_FRAMEBUFFER (pref fboid 0))
      (if (> _texid 0) (set! texid _texid))
      (set! texid (fbo_create_texture_rect width height))
      ;; Attach the texture texid to the color buffer of our fbo
      (glFramebufferTexture2D GL_FRAMEBUFFER GL_COLOR_ATTACHMENT0 GL_TEXTURE_RECTANGLE_ARB texid 0)
      (tfill! fbo (pref fboid 0) texid -1 width height)
      (let ((status:i32 (glCheckFramebufferStatus GL_FRAMEBUFFER)))
  (if (<> status GL_FRAMEBUFFER_COMPLETE)
      (set! fbo (cast null E_fbo*))))
      (glClearColor 0.0 1.0 0.0 1.0)
      (glClear GL_COLOR_BUFFER_BIT)
      ;; unbind the frame buffer
      (glBindFramebuffer GL_FRAMEBUFFER 0)
      ;; return the extfbo struct
      fbo)))