class_docstr: A class holding OpenGL machinery used by MeshRasterizerOpenGL.
class_docstr_tok: ["A","class","holding","OpenGL","machinery","used","by","MeshRasterizerOpenGL","."]
docstr: Rasterize a batch of meshes, using a given batch of projection matrices and
  image size.
  
  Args:
      meshes_gl_ndc: A Meshes object, with vertices in the OpenGL NDC convention.
      projection_matrix: A 3x3 camera projection matrix, or a tensor of projection
          matrices equal in length to the number of meshes in meshes_gl_ndc.
      image_size: Image size to rasterize. Must be smaller than the max height and
          width stored in global_device_context_store.
  
  Returns:
      pix_to_faces: A BHW1 tensor of ints, filled with -1 where no face projects
          to a given pixel.
      bary_coords: A BHW3 float tensor, filled with -1 where no face projects to
          a given pixel.
      zbuf: A BHW1 float tensor, filled with 1 where no face projects to a given
          pixel. NOTE: this zbuf uses the opengl zbuf convention, where the z-vals
          are between 0 (at projection plane) and 1 (at clipping distance), and
          are a non-linear function of the depth values of the camera ray inter-
          sections.
docstr_tok: ["Rasterize","a","batch","of","meshes",",","using","a","given","batch","of","projection","matrices","and","image","size",".","Args",":","meshes_gl_ndc",":","A","Meshes","object",",","with","vertices","in","the","OpenGL","NDC","convention",".","projection_matrix",":","A","3x3","camera","projection","matrix",",","or","a","tensor","of","projection","matrices","equal","in","length","to","the","number","of","meshes","in","meshes_gl_ndc",".","image_size",":","Image","size","to","rasterize",".","Must","be","smaller","than","the","max","height","and","width","stored","in","global_device_context_store",".","Returns",":","pix_to_faces",":","A","BHW1","tensor","of","ints",",","filled","with","-1","where","no","face","projects","to","a","given","pixel",".","bary_coords",":","A","BHW3","float","tensor",",","filled","with","-1","where","no","face","projects","to","a","given","pixel",".","zbuf",":","A","BHW1","float","tensor",",","filled","with","1","where","no","face","projects","to","a","given","pixel",".","NOTE",":","this","zbuf","uses","the","opengl","zbuf","convention",",","where","the","z-vals","are","between","0","(","at","projection","plane",")","and","1","(","at","clipping","distance",")",",","and","are","a","non-linear","function","of","the","depth","values","of","the","camera","ray","inter-","sections","."]
code: def __call__(
      self,
      meshes_gl_ndc: Meshes,
      projection_matrix: torch.Tensor,
      image_size: Tuple[int, int],
  ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
      """
      Rasterize a batch of meshes, using a given batch of projection matrices and
      image size.
  
      Args:
          meshes_gl_ndc: A Meshes object, with vertices in the OpenGL NDC convention.
          projection_matrix: A 3x3 camera projection matrix, or a tensor of projection
              matrices equal in length to the number of meshes in meshes_gl_ndc.
          image_size: Image size to rasterize. Must be smaller than the max height and
              width stored in global_device_context_store.
  
      Returns:
          pix_to_faces: A BHW1 tensor of ints, filled with -1 where no face projects
              to a given pixel.
          bary_coords: A BHW3 float tensor, filled with -1 where no face projects to
              a given pixel.
          zbuf: A BHW1 float tensor, filled with 1 where no face projects to a given
              pixel. NOTE: this zbuf uses the opengl zbuf convention, where the z-vals
              are between 0 (at projection plane) and 1 (at clipping distance), and
              are a non-linear function of the depth values of the camera ray inter-
              sections.
      """
  
      self.initialize_device_data(meshes_gl_ndc.device)
      with self.egl_context.active_and_locked():
          # Perspective projection happens in OpenGL. Move the matrix over if there's only
          # a single camera shared by all the meshes.
          if projection_matrix.shape[0] == 1:
              self._projection_matrix_to_opengl(projection_matrix)
  
          pix_to_faces = []
          bary_coords = []
          zbufs = []
  
          # pyre-ignore Incompatible parameter type [6]
          for mesh_id, mesh in enumerate(meshes_gl_ndc):
              pix_to_face, bary_coord, zbuf = self._rasterize_mesh(
                  mesh,
                  image_size,
                  projection_matrix=projection_matrix[mesh_id]
                  if projection_matrix.shape[0] > 1
                  else None,
              )
              pix_to_faces.append(pix_to_face)
              bary_coords.append(bary_coord)
              zbufs.append(zbuf)
  
      return (
          torch.cat(pix_to_faces, dim=0),
          torch.cat(bary_coords, dim=0),
          torch.cat(zbufs, dim=0),
      )
  
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 2 for calling the _OpenGLMachinery obj's underlying member method code with example usage: obj.__call__(meshes_gl_ndc, projection_matrix, image_size) and returns: torch,  torch,  torch