code: def test_use_framebuffer():
      """Test drawing to a framebuffer"""
      shape = (
          100,
          300,
      )  # for some reason Windows wants a tall window...
      data = np.random.rand(*shape).astype(np.float32)
      use_shape = shape + (3,)
      with Canvas(size=shape[::-1]) as c:
          c.app.process_events()
          c.set_current()
          if c.app.backend_name.lower() == "pyqt5":
              # PyQt5 on OSX for some reason sets this to 1024x768...
              c.size = shape[::-1]
          c.app.process_events()
          orig_tex = Texture2D(data)
          fbo_tex = Texture2D(use_shape, format="rgb")
          rbo = RenderBuffer(shape, "color")
          fbo = FrameBuffer(color=fbo_tex)
          c.context.glir.set_verbose(True)
          assert c.size == shape[::-1]
          c.set_current()
          set_viewport((0, 0) + c.size)
          with fbo:
              draw_texture(orig_tex)
          draw_texture(fbo_tex)
          out_tex = _screenshot()[::-1, :, 0].astype(np.float32)
          assert out_tex.shape == c.size[::-1]
          assert_raises(
              TypeError, FrameBuffer.color_buffer.fset, fbo, 1.0
          )
          assert_raises(
              TypeError, FrameBuffer.depth_buffer.fset, fbo, 1.0
          )
          assert_raises(
              TypeError, FrameBuffer.stencil_buffer.fset, fbo, 1.0
          )
          fbo.color_buffer = rbo
          fbo.depth_buffer = RenderBuffer(shape)
          fbo.stencil_buffer = None
          print(
              (fbo.color_buffer, fbo.depth_buffer, fbo.stencil_buffer)
          )
          clear(color="black")
          with fbo:
              clear(color="black")
              draw_texture(orig_tex)
              out_rbo = _screenshot()[:, :, 0].astype(np.float32)
      assert_allclose(data * 255.0, out_tex, atol=1)
      assert_allclose(data * 255.0, out_rbo, atol=1)
  
file_path: vispy/vispy/gloo/tests/test_use_gloo.py
imports: import sys
  import numpy
  from numpy.testing import assert_allclose
  import pytest
  from vispy.app import Canvas
  from vispy.gloo import Texture2D, Texture3D, Program, FrameBuffer, RenderBuffer, set_viewport, clear
  from vispy.gloo.util import draw_texture, _screenshot
  from vispy.testing import requires_application, has_pyopengl, run_tests_if_main, assert_raises, assert_equal, IS_TRAVIS_CI
label_desc: Use image node_id 2 for calling a global function with example usage: test_use_framebuffer() without return types