class_docstr: A helper class to provide an OpenGL context. This context is global
  to the application.
class_docstr_tok: ["A","helper","class","to","provide","an","OpenGL","context",".","This","context","is","global","to","the","application","."]
code: def __init__(self):
      if self._canvas is not None:
          return  # already initialized
  
      self._is_closed = False
  
      # Glfw is probably the most lightweight approach, so let's try that.
      # But there are two incompatible packages providing glfw :/
      self.glfw = None
      try:
          import glfw
      except ImportError:
          pass
      else:
          need_from_glfw = ["create_window", "make_context_current"]
          if all(hasattr(glfw, attr) for attr in need_from_glfw):
              self.glfw = glfw
  
      if self.glfw:
          self.glfw.init()
          self.glfw.window_hint(self.glfw.VISIBLE, 0)
          self._canvas = self.glfw.create_window(
              1, 1, "dummy window", None, None
          )
      else:
          try:
              _app = Application("default")
          except Exception:
              raise RuntimeError(
                  "Cannot find a backend to create an OpenGL context. "
                  "Install e.g. PyQt5, PySide2, or `pip install glfw`."
              )
          self._canvas = Canvas(app=_app)
          self._canvas.show(False)
  
file_path: vispy/vispy/app/backends/_offscreen_util.py
imports: from ..None import Application, Canvas
  from ...None import gloo
label_desc: Use image node_id 2 to create a new OffscreenContext object  with example: obj = OffscreenContext()