Class VertexArray

java.lang.Object
foundry.veil.api.client.render.vertex.VertexArray
All Implemented Interfaces:
AutoCloseable, org.lwjgl.system.NativeResource
Direct Known Subclasses:
ARBVertexAttribBindingVertexArray, DSAVertexAttribBindingVertexArray, LegacyVertexArray

public abstract class VertexArray extends Object implements org.lwjgl.system.NativeResource
More genetic alternative to VertexBuffer that uses the latest available OpenGL version.
  • Field Details

    • VERTEX_BUFFER

      public static final int VERTEX_BUFFER
      See Also:
    • ELEMENT_ARRAY_BUFFER

      public static final int ELEMENT_ARRAY_BUFFER
      See Also:
    • id

      protected final int id
    • buffers

      protected final it.unimi.dsi.fastutil.ints.Int2IntMap buffers
    • indexCount

      protected int indexCount
    • indexType

      protected VertexArray.IndexType indexType
  • Constructor Details

    • VertexArray

      @Internal protected VertexArray(int id)
  • Method Details

    • create

      public static VertexArray create()
      Creates a single new vertex array.
      Returns:
      A new vertex array
    • create

      public static VertexArray[] create(int count)
      Creates an array of vertex arrays.
      Parameters:
      count - The number of arrays to create
      Returns:
      An array of new vertex arrays
    • create

      public static void create(VertexArray[] fill)
      Replaces each element of the specified array with a new vertex array.
      Parameters:
      fill - The array to fill
    • getOrCreateBuffer

      public int getOrCreateBuffer(int index)
      Creates a new buffer object owned by this vertex array or retrieves an existing buffer.
      Parameters:
      index - The index of the buffer to get
      Returns:
      A vertex array object
    • getId

      public int getId()
      Returns:
      The OpenGL id of this vertex array
    • getIndexCount

      public int getIndexCount()
      Returns:
      The number of indices in this array
    • getIndexType

      public VertexArray.IndexType getIndexType()
      Returns:
      The data type of the index buffer
    • upload

      public static void upload(int buffer, ByteBuffer data, VertexArray.DrawUsage usage)
      Uploads mesh data into the specified buffer.
      Parameters:
      data - The data to upload
      usage - The draw usage
    • upload

      public void upload(com.mojang.blaze3d.vertex.MeshData meshData, VertexArray.DrawUsage usage)
      Uploads vanilla mc mesh data into this vertex array. Only a single mesh can be uploaded this way.
      Parameters:
      meshData - The data to upload
      usage - The draw usage
    • upload

      public void upload(int attributeStart, com.mojang.blaze3d.vertex.MeshData meshData, VertexArray.DrawUsage usage)
      Uploads vanilla mc mesh data into this vertex array. Only a single mesh can be uploaded this way.
      Parameters:
      attributeStart - The attribute to start uploading vertex data to
      meshData - The data to upload
      usage - The draw usage
    • uploadIndexBuffer

      public void uploadIndexBuffer(com.mojang.blaze3d.vertex.MeshData.DrawState drawState)
      Uploads index data to the vertex array.
      Parameters:
      drawState - The buffer draw state
    • uploadIndexBuffer

      public void uploadIndexBuffer(ByteBuffer data)
      Uploads index data to the vertex array.
      Parameters:
      data - The data to upload
    • createBuffer

      protected abstract int createBuffer()
      Returns:
      Creates a new vertex buffer
    • uploadVertexBuffer

      protected abstract void uploadVertexBuffer(int buffer, ByteBuffer data, int usage)
      Uploads vertex data to the specified buffer.
      Parameters:
      buffer - The buffer to upload into
      data - The data to upload
      usage - The data usage
    • editFormat

      public abstract VertexArrayBuilder editFormat()
      Returns:
      A builder for applying changes to this array
    • bind

      public void bind()
      Binds this vertex array and applies any changes to the format automatically.
    • unbind

      public static void unbind()
      Unbinds the current vertex array.
    • draw

      public void draw(int mode)
    • drawInstanced

      public void drawInstanced(int mode, int instances)
    • drawIndirect

      public void drawIndirect(int mode, long indirect, int drawCount, int stride)
    • setIndexCount

      public void setIndexCount(int indexCount, VertexArray.IndexType indexType)
    • free

      public void free()
      Specified by:
      free in interface org.lwjgl.system.NativeResource