code: def renderToArray(
      self,
      size,
      format=GL_BGRA,
      type=GL_UNSIGNED_BYTE,
      textureSize=1024,
      padding=256,
  ):
      w, h = map(int, size)
  
      self.makeCurrent()
      tex = None
      fb = None
      depth_buf = None
      try:
          output = np.empty((h, w, 4), dtype=np.ubyte)
          fb = glfbo.glGenFramebuffers(1)
          glfbo.glBindFramebuffer(glfbo.GL_FRAMEBUFFER, fb)
  
          glEnable(GL_TEXTURE_2D)
          tex = glGenTextures(1)
          glBindTexture(GL_TEXTURE_2D, tex)
          texwidth = textureSize
          data = np.zeros((texwidth, texwidth, 4), dtype=np.ubyte)
  
          ## Test texture dimensions first
          glTexImage2D(
              GL_PROXY_TEXTURE_2D,
              0,
              GL_RGBA,
              texwidth,
              texwidth,
              0,
              GL_RGBA,
              GL_UNSIGNED_BYTE,
              None,
          )
          if (
              glGetTexLevelParameteriv(
                  GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH
              )
              == 0
          ):
              raise RuntimeError(
                  "OpenGL failed to create 2D texture (%dx%d); too large for this hardware."
                  % data.shape[:2]
              )
          ## create texture
          glTexImage2D(
              GL_TEXTURE_2D,
              0,
              GL_RGBA,
              texwidth,
              texwidth,
              0,
              GL_RGBA,
              GL_UNSIGNED_BYTE,
              data,
          )
  
          # Create depth buffer
          depth_buf = glGenRenderbuffers(1)
          glBindRenderbuffer(GL_RENDERBUFFER, depth_buf)
          glRenderbufferStorage(
              GL_RENDERBUFFER, GL_DEPTH_COMPONENT, texwidth, texwidth
          )
          glFramebufferRenderbuffer(
              GL_FRAMEBUFFER,
              GL_DEPTH_ATTACHMENT,
              GL_RENDERBUFFER,
              depth_buf,
          )
  
          self.opts["viewport"] = (
              0,
              0,
              w,
              h,
          )  # viewport is the complete image; this ensures that paintGL(region=...)
          # is interpreted correctly.
          p2 = 2 * padding
          for x in range(-padding, w - padding, texwidth - p2):
              for y in range(-padding, h - padding, texwidth - p2):
                  x2 = min(x + texwidth, w + padding)
                  y2 = min(y + texwidth, h + padding)
                  w2 = x2 - x
                  h2 = y2 - y
  
                  ## render to texture
                  glfbo.glFramebufferTexture2D(
                      glfbo.GL_FRAMEBUFFER,
                      glfbo.GL_COLOR_ATTACHMENT0,
                      GL_TEXTURE_2D,
                      tex,
                      0,
                  )
  
                  self.paintGL(
                      region=(x, h - y - h2, w2, h2),
                      viewport=(0, 0, w2, h2),
                  )  # only render sub-region
                  glBindTexture(GL_TEXTURE_2D, tex)  # fixes issue #366
  
                  ## read texture back to array
                  data = glGetTexImage(GL_TEXTURE_2D, 0, format, type)
                  data = np.frombuffer(data, dtype=np.ubyte).reshape(
                      texwidth, texwidth, 4
                  )[::-1, ...]
                  output[
                      y + padding : y2 - padding,
                      x + padding : x2 - padding,
                  ] = data[
                      -(h2 - padding) : -padding, padding : w2 - padding
                  ]
  
      finally:
          self.opts["viewport"] = None
          glfbo.glBindFramebuffer(glfbo.GL_FRAMEBUFFER, 0)
          glBindTexture(GL_TEXTURE_2D, 0)
          if tex is not None:
              glDeleteTextures([tex])
          if fb is not None:
              glfbo.glDeleteFramebuffers([fb])
          if depth_buf is not None:
              glDeleteRenderbuffers(1, [depth_buf])
  
      return output
  
imports: from OpenGL.GL import *
  import OpenGL.GL.framebufferobjects
  from math import cos, radians, sin, tan
  import numpy
  from ..None import Vector
  from ..None import functions
  from ..None import getConfigOption
  from ..Qt import QtCore, QtGui, QtWidgets
label_desc: Use image node_id 33 for calling the GLViewMixin obj's underlying member method code with example usage: obj.renderToArray(size, format, type, textureSize, padding) and returns: output