class_docstr: A class holding OpenGL machinery used by MeshRasterizerOpenGL.
class_docstr_tok: ["A","class","holding","OpenGL","machinery","used","by","MeshRasterizerOpenGL","."]
docstr: Prepare OpenGL objects that we want to persist between rasterizations.
  
  Args:
      program: The OpenGL program the resources will be tied to.
      max_faces: Max number of faces of any mesh we will rasterize.
  
  Returns:
      perspective_projection_uniform: An OpenGL object pointing to a location of
          the perspective projection matrix in OpenGL memory.
      mesh_buffer_object: An OpenGL object pointing to the location of the mesh
          buffer object in OpenGL memory.
      vao: The OpenGL input array object.
      fbo: The OpenGL output framebuffer.
docstr_tok: ["Prepare","OpenGL","objects","that","we","want","to","persist","between","rasterizations",".","Args",":","program",":","The","OpenGL","program","the","resources","will","be","tied","to",".","max_faces",":","Max","number","of","faces","of","any","mesh","we","will","rasterize",".","Returns",":","perspective_projection_uniform",":","An","OpenGL","object","pointing","to","a","location","of","the","perspective","projection","matrix","in","OpenGL","memory",".","mesh_buffer_object",":","An","OpenGL","object","pointing","to","the","location","of","the","mesh","buffer","object","in","OpenGL","memory",".","vao",":","The","OpenGL","input","array","object",".","fbo",":","The","OpenGL","output","framebuffer","."]
code: def _prepare_persistent_opengl_objects(program, max_faces: int):
      """
      Prepare OpenGL objects that we want to persist between rasterizations.
  
      Args:
          program: The OpenGL program the resources will be tied to.
          max_faces: Max number of faces of any mesh we will rasterize.
  
      Returns:
          perspective_projection_uniform: An OpenGL object pointing to a location of
              the perspective projection matrix in OpenGL memory.
          mesh_buffer_object: An OpenGL object pointing to the location of the mesh
              buffer object in OpenGL memory.
          vao: The OpenGL input array object.
          fbo: The OpenGL output framebuffer.
  
      """
      gl.glUseProgram(program)
      # Get location of the "uniform" (that is, an internal OpenGL variable available
      # to the shaders) that we'll load the projection matrices to.
      perspective_projection_uniform = gl.glGetUniformLocation(
          program, "perspective_projection"
      )
  
      # Mesh buffer object -- our main input point. We'll copy the mesh here
      # from pytorch/cuda. The buffer needs enough space to store the three vertices
      # of each face, that is its size in bytes is
      # max_faces * 3 (vertices) * 3 (coordinates) * 4 (bytes)
      mesh_buffer_object = gl.glGenBuffers(1)
      gl.glBindBufferBase(
          gl.GL_SHADER_STORAGE_BUFFER, 0, mesh_buffer_object
      )
  
      gl.glBufferData(
          gl.GL_SHADER_STORAGE_BUFFER,
          max_faces * 9 * 4,
          np.zeros((max_faces, 9), dtype=np.float32),
          gl.GL_DYNAMIC_COPY,
      )
  
      # Input vertex array object. We will only use it implicitly for indexing the
      # vertices, but the actual input data is passed in the shader storage buffer.
      vao = gl.glGenVertexArrays(1)
  
      # Create the framebuffer object (fbo) where we'll store output data.
      MAX_EGL_WIDTH = global_device_context_store.max_egl_width
      MAX_EGL_HEIGHT = global_device_context_store.max_egl_height
      color_buffer = gl.glGenRenderbuffers(1)
      gl.glBindRenderbuffer(gl.GL_RENDERBUFFER, color_buffer)
      gl.glRenderbufferStorage(
          gl.GL_RENDERBUFFER,
          gl.GL_RGBA32F,
          MAX_EGL_WIDTH,
          MAX_EGL_HEIGHT,
      )
      gl.glBindRenderbuffer(gl.GL_RENDERBUFFER, 0)
  
      depth_buffer = gl.glGenRenderbuffers(1)
      gl.glBindRenderbuffer(gl.GL_RENDERBUFFER, depth_buffer)
      gl.glRenderbufferStorage(
          gl.GL_RENDERBUFFER,
          gl.GL_DEPTH_COMPONENT,
          MAX_EGL_WIDTH,
          MAX_EGL_HEIGHT,
      )
      gl.glBindRenderbuffer(gl.GL_RENDERBUFFER, 0)
  
      fbo = gl.glGenFramebuffers(1)
      gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, fbo)
      gl.glFramebufferRenderbuffer(
          gl.GL_FRAMEBUFFER,
          gl.GL_COLOR_ATTACHMENT0,
          gl.GL_RENDERBUFFER,
          color_buffer,
      )
      gl.glFramebufferRenderbuffer(
          gl.GL_FRAMEBUFFER,
          gl.GL_DEPTH_ATTACHMENT,
          gl.GL_RENDERBUFFER,
          depth_buffer,
      )
      gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)
  
      gl.glUseProgram(0)
      return (
          perspective_projection_uniform,
          mesh_buffer_object,
          vao,
          fbo,
      )
  
imports: import warnings
  from typing import Optional, Tuple, Union
  import numpy
  import OpenGL.GL
  import pycuda.gl
  import torch
  import torch.nn
  from pytorch3d.structures.meshes import Meshes
  from ..cameras import FoVOrthographicCameras, FoVPerspectiveCameras
  from ..mesh.rasterizer import Fragments, RasterizationSettings
  from ..utils import parse_image_size
  from .opengl_utils import _torch_to_opengl, global_device_context_store
label_desc: Use image node_id 9 for calling the _OpenGLMachinery obj's underlying member method code with example usage: obj._prepare_persistent_opengl_objects(program, max_faces) and returns: perspective_projection_uniform,  mesh_buffer_object,  vao,  fbo