Class VertexBuffer

java.lang.Object
net.minecraft.client.gl.VertexBuffer
All Implemented Interfaces:
AutoCloseable

@Environment(CLIENT) public class VertexBuffer extends Object implements AutoCloseable
Stores vertex data on GPU.

If you don't need to change the geometry, you can upload data once and reuse it every frame. For example, star rendering uses this technique to save bandwidth.

Implementation Note:
This is mostly a wrapper around vertex buffer object (VBO), element buffer object (EBO), and vertex array object (VAO).
Mappings:
Namespace Name
named net/minecraft/client/gl/VertexBuffer
intermediary net/minecraft/class_291
official fbf
  • Field Details

    • usage

      private final VertexBuffer.Usage usage
      Mappings:
      Namespace Name Mixin selector
      named usage Lnet/minecraft/client/gl/VertexBuffer;usage:Lnet/minecraft/client/gl/VertexBuffer$Usage;
      intermediary field_44792 Lnet/minecraft/class_291;field_44792:Lnet/minecraft/class_291$class_8555;
      official a Lfbf;a:Lfbf$a;
    • vertexBufferId

      private int vertexBufferId
      Mappings:
      Namespace Name Mixin selector
      named vertexBufferId Lnet/minecraft/client/gl/VertexBuffer;vertexBufferId:I
      intermediary field_1594 Lnet/minecraft/class_291;field_1594:I
      official b Lfbf;b:I
    • indexBufferId

      private int indexBufferId
      Mappings:
      Namespace Name Mixin selector
      named indexBufferId Lnet/minecraft/client/gl/VertexBuffer;indexBufferId:I
      intermediary field_27366 Lnet/minecraft/class_291;field_27366:I
      official c Lfbf;c:I
    • vertexArrayId

      private int vertexArrayId
      Mappings:
      Namespace Name Mixin selector
      named vertexArrayId Lnet/minecraft/client/gl/VertexBuffer;vertexArrayId:I
      intermediary field_29338 Lnet/minecraft/class_291;field_29338:I
      official d Lfbf;d:I
    • vertexFormat

      @Nullable private @Nullable VertexFormat vertexFormat
      Mappings:
      Namespace Name Mixin selector
      named vertexFormat Lnet/minecraft/client/gl/VertexBuffer;vertexFormat:Lnet/minecraft/client/render/VertexFormat;
      intermediary field_29339 Lnet/minecraft/class_291;field_29339:Lnet/minecraft/class_293;
      official e Lfbf;e:Lfbh;
    • sharedSequentialIndexBuffer

      @Nullable private RenderSystem.ShapeIndexBuffer sharedSequentialIndexBuffer
      Mappings:
      Namespace Name Mixin selector
      named sharedSequentialIndexBuffer Lnet/minecraft/client/gl/VertexBuffer;sharedSequentialIndexBuffer:Lcom/mojang/blaze3d/systems/RenderSystem$ShapeIndexBuffer;
      intermediary field_38983 Lnet/minecraft/class_291;field_38983:Lcom/mojang/blaze3d/systems/RenderSystem$class_5590;
      official f Lfbf;f:Lcom/mojang/blaze3d/systems/RenderSystem$a;
    • indexType

      private VertexFormat.IndexType indexType
      Mappings:
      Namespace Name Mixin selector
      named indexType Lnet/minecraft/client/gl/VertexBuffer;indexType:Lnet/minecraft/client/render/VertexFormat$IndexType;
      intermediary field_27367 Lnet/minecraft/class_291;field_27367:Lnet/minecraft/class_293$class_5595;
      official g Lfbf;g:Lfbh$b;
    • indexCount

      private int indexCount
      Mappings:
      Namespace Name Mixin selector
      named indexCount Lnet/minecraft/client/gl/VertexBuffer;indexCount:I
      intermediary field_1593 Lnet/minecraft/class_291;field_1593:I
      official h Lfbf;h:I
    • drawMode

      private VertexFormat.DrawMode drawMode
      Mappings:
      Namespace Name Mixin selector
      named drawMode Lnet/minecraft/client/gl/VertexBuffer;drawMode:Lnet/minecraft/client/render/VertexFormat$DrawMode;
      intermediary field_27368 Lnet/minecraft/class_291;field_27368:Lnet/minecraft/class_293$class_5596;
      official i Lfbf;i:Lfbh$c;
  • Constructor Details

    • VertexBuffer

      public VertexBuffer(VertexBuffer.Usage usage)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/client/gl/VertexBuffer;<init>(Lnet/minecraft/client/gl/VertexBuffer$Usage;)V
      intermediary <init> Lnet/minecraft/class_291;<init>(Lnet/minecraft/class_291$class_8555;)V
      official <init> Lfbf;<init>(Lfbf$a;)V
  • Method Details

    • upload

      public void upload(class_9801 class_9801)
      Uploads the contents of buffer to GPU, discarding previously uploaded data.

      The caller of this method must bind this vertex buffer before calling this method.

      Mappings:
      Namespace Name Mixin selector
      named upload Lnet/minecraft/client/gl/VertexBuffer;upload(Lnet/minecraft/class_9801;)V
      intermediary method_1352 Lnet/minecraft/class_291;method_1352(Lnet/minecraft/class_9801;)V
      official a Lfbf;a(Lfbb;)V
    • method_60829

      public void method_60829(class_9799.class_9800 class_9800)
      Mappings:
      Namespace Name Mixin selector
      named method_60829 Lnet/minecraft/client/gl/VertexBuffer;method_60829(Lnet/minecraft/class_9799$class_9800;)V
      intermediary method_60829 Lnet/minecraft/class_291;method_60829(Lnet/minecraft/class_9799$class_9800;)V
      official a Lfbf;a(Lfaz$a;)V
    • uploadVertexBuffer

      private VertexFormat uploadVertexBuffer(class_9801.DrawParameters parameters, @Nullable @Nullable ByteBuffer vertexBuffer)
      Mappings:
      Namespace Name Mixin selector
      named uploadVertexBuffer Lnet/minecraft/client/gl/VertexBuffer;uploadVertexBuffer(Lnet/minecraft/class_9801$DrawParameters;Ljava/nio/ByteBuffer;)Lnet/minecraft/client/render/VertexFormat;
      intermediary method_43442 Lnet/minecraft/class_291;method_43442(Lnet/minecraft/class_9801$class_4574;Ljava/nio/ByteBuffer;)Lnet/minecraft/class_293;
      official a Lfbf;a(Lfbb$a;Ljava/nio/ByteBuffer;)Lfbh;
    • uploadIndexBuffer

      Mappings:
      Namespace Name Mixin selector
      named uploadIndexBuffer Lnet/minecraft/client/gl/VertexBuffer;uploadIndexBuffer(Lnet/minecraft/class_9801$DrawParameters;Ljava/nio/ByteBuffer;)Lcom/mojang/blaze3d/systems/RenderSystem$ShapeIndexBuffer;
      intermediary method_43443 Lnet/minecraft/class_291;method_43443(Lnet/minecraft/class_9801$class_4574;Ljava/nio/ByteBuffer;)Lcom/mojang/blaze3d/systems/RenderSystem$class_5590;
      official b Lfbf;b(Lfbb$a;Ljava/nio/ByteBuffer;)Lcom/mojang/blaze3d/systems/RenderSystem$a;
    • bind

      public void bind()
      Sets this vertex buffer as the current one.

      This method must be called before uploading or drawing data.

      Mappings:
      Namespace Name Mixin selector
      named bind Lnet/minecraft/client/gl/VertexBuffer;bind()V
      intermediary method_1353 Lnet/minecraft/class_291;method_1353()V
      official a Lfbf;a()V
    • unbind

      public static void unbind()
      Mappings:
      Namespace Name Mixin selector
      named unbind Lnet/minecraft/client/gl/VertexBuffer;unbind()V
      intermediary method_1354 Lnet/minecraft/class_291;method_1354()V
      official b Lfbf;b()V
    • draw

      public void draw()
      Draws the contents in this vertex buffer.

      The caller of this method must bind this vertex buffer before calling this method.

      Unlike draw(Matrix4f, Matrix4f, ShaderProgram), the caller of this method must manually bind a shader program before calling this method.

      Mappings:
      Namespace Name Mixin selector
      named draw Lnet/minecraft/client/gl/VertexBuffer;draw()V
      intermediary method_35665 Lnet/minecraft/class_291;method_35665()V
      official c Lfbf;c()V
    • getIndexType

      private VertexFormat.IndexType getIndexType()
      Mappings:
      Namespace Name Mixin selector
      named getIndexType Lnet/minecraft/client/gl/VertexBuffer;getIndexType()Lnet/minecraft/client/render/VertexFormat$IndexType;
      intermediary method_43445 Lnet/minecraft/class_291;method_43445()Lnet/minecraft/class_293$class_5595;
      official f Lfbf;f()Lfbh$b;
    • draw

      public void draw(Matrix4f viewMatrix, Matrix4f projectionMatrix, ShaderProgram program)
      Draws the contents in this vertex buffer with program.

      The caller of this method must bind this vertex buffer before calling this method.

      Mappings:
      Namespace Name Mixin selector
      named draw Lnet/minecraft/client/gl/VertexBuffer;draw(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lnet/minecraft/client/gl/ShaderProgram;)V
      intermediary method_34427 Lnet/minecraft/class_291;method_34427(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lnet/minecraft/class_5944;)V
      official a Lfbf;a(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lgfh;)V
    • drawInternal

      private void drawInternal(Matrix4f viewMatrix, Matrix4f projectionMatrix, ShaderProgram shaderProgram)
      Mappings:
      Namespace Name Mixin selector
      named drawInternal Lnet/minecraft/client/gl/VertexBuffer;drawInternal(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lnet/minecraft/client/gl/ShaderProgram;)V
      intermediary method_34431 Lnet/minecraft/class_291;method_34431(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lnet/minecraft/class_5944;)V
      official b Lfbf;b(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lgfh;)V
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getVertexFormat

      public VertexFormat getVertexFormat()
      Mappings:
      Namespace Name Mixin selector
      named getVertexFormat Lnet/minecraft/client/gl/VertexBuffer;getVertexFormat()Lnet/minecraft/client/render/VertexFormat;
      intermediary method_34435 Lnet/minecraft/class_291;method_34435()Lnet/minecraft/class_293;
      official d Lfbf;d()Lfbh;
    • isClosed

      public boolean isClosed()
      Mappings:
      Namespace Name Mixin selector
      named isClosed Lnet/minecraft/client/gl/VertexBuffer;isClosed()Z
      intermediary method_43444 Lnet/minecraft/class_291;method_43444()Z
      official e Lfbf;e()Z