Class VertexArray
java.lang.Object
foundry.veil.api.client.render.vertex.VertexArray
- All Implemented Interfaces:
AutoCloseable,org.lwjgl.system.NativeResource
- Direct Known Subclasses:
ARBVertexArray,DSAVertexArray,LegacyVertexArray
More generic alternative to
VertexBuffer that uses the latest available OpenGL version.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies how the graphics card should manage buffer data.static enumThe type of GL indices that can be used. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final it.unimi.dsi.fastutil.ints.Int2IntMapprotected final VertexArrayBuilderprotected com.mojang.blaze3d.vertex.VertexFormat.Modestatic final intprotected final intprotected intprotected VertexArray.IndexTypestatic final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedVertexArray(int id, Function<VertexArray, VertexArrayBuilder> builder) -
Method Summary
Modifier and TypeMethodDescriptionvoidbind()Binds this vertex array and applies any changes to the format automatically.voidclear(net.minecraft.client.renderer.RenderType renderType) Clears the specified render type.static VertexArraycreate()Creates a single new vertex array.static VertexArray[]create(int count) Creates an array of vertex arrays.static voidcreate(VertexArray[] fill) Replaces each element of the specified array with a new vertex array.voiddraw()DrawsindexCountnumber of indices with the previously defined draw mode.voiddrawIndirect(long indirect, int drawCount, int stride) DrawsindexCountnumber of indices with the previously defined draw mode a number of times.voiddrawIndirectWithRenderType(net.minecraft.client.renderer.RenderType renderType, long indirect, int drawCount, int stride) DrawsindexCountnumber of indices with the previously defined draw mode a number of times.voiddrawInstanced(int instances) DrawsindexCountnumber of indices with the previously defined draw mode a number of times.voiddrawInstancedWithRenderType(net.minecraft.client.renderer.RenderType renderType, int instances) DrawsindexCountnumber of indices with the previously defined draw mode a number of times.voiddrawWithRenderType(net.minecraft.client.renderer.RenderType renderType) DrawsindexCountnumber of indices with the previously defined draw mode.voidfree()com.mojang.blaze3d.vertex.VertexFormat.ModeintgetId()intintgetOrCreateBuffer(int index) Creates a new buffer object owned by this vertex array or retrieves an existing buffer.voidsetDrawMode(com.mojang.blaze3d.vertex.VertexFormat.Mode drawMode) Sets the type of polygons draw calls will draw.voidsetIndexCount(int indexCount, VertexArray.IndexType indexType) Sets the number of indices and what data type they are.voidsetup(net.minecraft.client.renderer.RenderType renderType) Sets up the draw state with the specified render type.static voidunbind()Unbinds the current vertex array.voidupload(int attributeStart, com.mojang.blaze3d.vertex.MeshData meshData, VertexArray.DrawUsage usage) Uploads vanilla mc mesh data into this vertex array.static voidupload(int buffer, ByteBuffer data, VertexArray.DrawUsage usage) Uploads mesh data into the specified buffer.voidupload(com.mojang.blaze3d.vertex.MeshData meshData, VertexArray.DrawUsage usage) Uploads vanilla mc mesh data into this vertex array.voiduploadIndexBuffer(com.mojang.blaze3d.vertex.MeshData.DrawState drawState) Uploads index data to the vertex array.voiduploadIndexBuffer(ByteBuffer data) Uploads index data to the vertex array.voiduploadIndexBuffer(ByteBuffer data, VertexArray.IndexType indexType) Uploads index data to the vertex array.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.lwjgl.system.NativeResource
close
-
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 -
builder
-
buffers
protected final it.unimi.dsi.fastutil.ints.Int2IntMap buffers -
indexCount
protected int indexCount -
indexType
-
drawMode
protected com.mojang.blaze3d.vertex.VertexFormat.Mode drawMode
-
-
Constructor Details
-
VertexArray
-
-
Method Details
-
create
Creates a single new vertex array.- Returns:
- A new vertex array
-
create
Creates an array of vertex arrays.- Parameters:
count- The number of arrays to create- Returns:
- An array of new vertex arrays
-
create
Replaces each element of the specified array with a new vertex array.- Parameters:
fill- The array to fill
-
setup
public void setup(net.minecraft.client.renderer.RenderType renderType) Sets up the draw state with the specified render type.- Parameters:
renderType- The render type to set up- Since:
- 1.2.0
-
clear
public void clear(net.minecraft.client.renderer.RenderType renderType) Clears the specified render type.- Parameters:
renderType- The render type to clear- Since:
- 1.2.0
-
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
- Returns:
- The data type of the index buffer
-
getDrawMode
public com.mojang.blaze3d.vertex.VertexFormat.Mode getDrawMode()- Returns:
- The GL polygon draw type
- See Also:
-
upload
Uploads mesh data into the specified buffer.- Parameters:
data- The data to uploadusage- The draw usage
-
upload
Uploads vanilla mc mesh data into this vertex array. Only a single mesh can be uploaded this way.- Parameters:
meshData- The data to uploadusage- 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 tomeshData- The data to uploadusage- 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
Uploads index data to the vertex array.- Parameters:
data- The data to upload
-
uploadIndexBuffer
Uploads index data to the vertex array.- Parameters:
data- The data to uploadindexType- The type of data stored in data- Since:
- 1.2.0
-
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()DrawsindexCountnumber of indices with the previously defined draw mode.
bind()must be called before this. -
drawInstanced
public void drawInstanced(int instances) DrawsindexCountnumber of indices with the previously defined draw mode a number of times.
bind()must be called before this.- Parameters:
instances- The number of instances to draw
-
drawIndirect
public void drawIndirect(long indirect, int drawCount, int stride) DrawsindexCountnumber of indices with the previously defined draw mode a number of times.
bind()must be called before this.
Note: This only works ifVeilRenderSystem.multiDrawIndirectSupported()istrue- Parameters:
indirect- A pointer into the currently boundGL40C.GL_DRAW_INDIRECT_BUFFERor the address of a struct containing draw datadrawCount- The number of instances to drawstride- The stride between commands or0if they are tightly packed
-
drawWithRenderType
public void drawWithRenderType(net.minecraft.client.renderer.RenderType renderType) DrawsindexCountnumber of indices with the previously defined draw mode. This method applies the specified render type automatically.
bind()must be called before this. -
drawInstancedWithRenderType
public void drawInstancedWithRenderType(net.minecraft.client.renderer.RenderType renderType, int instances) DrawsindexCountnumber of indices with the previously defined draw mode a number of times. This method applies the specified render type automatically.
bind()must be called before this.- Parameters:
instances- The number of instances to draw
-
drawIndirectWithRenderType
public void drawIndirectWithRenderType(net.minecraft.client.renderer.RenderType renderType, long indirect, int drawCount, int stride) DrawsindexCountnumber of indices with the previously defined draw mode a number of times. This method applies the specified render type automatically.
bind()must be called before this.
Note: This only works ifVeilRenderSystem.multiDrawIndirectSupported()istrue- Parameters:
indirect- A pointer into the currently boundGL40C.GL_DRAW_INDIRECT_BUFFERor the address of a struct containing draw datadrawCount- The number of instances to drawstride- The stride between commands or0if they are tightly packed
-
setIndexCount
Sets the number of indices and what data type they are.- Parameters:
indexCount- The number of indices in the entire meshindexType- The data type of the indices
-
setDrawMode
public void setDrawMode(com.mojang.blaze3d.vertex.VertexFormat.Mode drawMode) Sets the type of polygons draw calls will draw.- Parameters:
drawMode- The new draw mode
-
free
public void free()- Specified by:
freein interfaceorg.lwjgl.system.NativeResource
-