Package rosequartz.gfx
Class VertexArray
java.lang.Object
rosequartz.gfx.VertexArray
Represents a vertex array, used to upload vertex data and triangles made from 3 of those vertices to the graphics card.
-
Constructor Summary
ConstructorsConstructorDescriptionVertexArray(int... attributeLengths)
Creates a VertexArray from the lengths of each vertex attribute. -
Method Summary
Modifier and TypeMethodDescriptionaddAll(Model model, ModelInstance modelInstance)
Copies all vertices and triangles / fragments from a given vertex array onto this one, transforming the array using a given model instance.addAll(VertexArray vertexArray)
Copies all vertices and triangles / fragments from a given vertex array onto this one.addAllFragments(VertexArray vertexArray)
Copies all triangles / fragments from a given vertex array onto this one.addAllVertices(VertexArray vertexArray)
Copies all vertices from a given vertex array onto this one.clear()
Clears all vertices and triangles / fragments from the array.Clears all triangles / fragments from the array.Clears all vertices from the array.fragment(int index1, int index2, int index3)
Adds triangle / fragment at the end of the array.int
Gets the amount of triangles / fragments in the array.int
Gets the amount of triangles / fragments currently uploaded to the GPU.int
Gets the amount of vertices currently uploaded to the GPU.int
Gets the amount of vertices in the array.render()
Render the array using the current shader program onto the current target frame buffer.toString()
upload()
Upload all vertex and triangle / fragment data to the graphics card.Upload all triangle / fragment data to the graphics card.Uploads all vertex data to the graphics card.vertex(float... data)
Adds a vertex at the end of the array.
-
Constructor Details
-
VertexArray
Creates a VertexArray from the lengths of each vertex attribute.+--------+----------------+ | Length | GLSL data type | +--------+----------------+ | 1 | float | | 2 | vec2 | | 3 | vec3 | | 4 | vec4 | | other | [INVALID] | +--------+----------------+
A vertex array with these lengths:
would be equal to this GLSL vertex shader signature:new VertexArray(2, 4)
#version 330 core layout(location=0) in vec2 in_attribute_1; layout(location=1) in vec4 in_attribute_2;
- Parameters:
attributeLengths
- the lengths for all attributes of every vertex- Throws:
NotOnGraphicsThreadException
-
-
Method Details
-
vertex
Adds a vertex at the end of the array.- Parameters:
data
- the data to add- Returns:
- this
-
clearVertices
Clears all vertices from the array.- Returns:
- this
-
uploadVertices
Uploads all vertex data to the graphics card.- Returns:
- this
- Throws:
NotOnGraphicsThreadException
-
addAllVertices
Copies all vertices from a given vertex array onto this one.- Parameters:
vertexArray
- the buffer to copy from- Returns:
- this
-
getVertexCount
public int getVertexCount()Gets the amount of vertices in the array.- Returns:
- vertex count
-
getUploadedVertexCount
public int getUploadedVertexCount()Gets the amount of vertices currently uploaded to the GPU.- Returns:
- uploaded vertex count
-
fragment
Adds triangle / fragment at the end of the array. Must be made from three vertices already inside this buffer. For correct rendering, the vertices must be in counter-clockwise order.- Parameters:
index1
- vertex 1index2
- vertex 2index3
- vertex 3- Returns:
- this
-
clearFragments
Clears all triangles / fragments from the array.- Returns:
- this
-
uploadFragments
Upload all triangle / fragment data to the graphics card.- Returns:
- this
- Throws:
NotOnGraphicsThreadException
-
addAllFragments
Copies all triangles / fragments from a given vertex array onto this one.- Parameters:
vertexArray
- the array to copy from- Returns:
- this
-
getFragmentCount
public int getFragmentCount()Gets the amount of triangles / fragments in the array.- Returns:
- triangle count
-
getUploadedFragmentCount
public int getUploadedFragmentCount()Gets the amount of triangles / fragments currently uploaded to the GPU.- Returns:
- uploaded triangle count
-
clear
Clears all vertices and triangles / fragments from the array.- Returns:
- this
-
upload
Upload all vertex and triangle / fragment data to the graphics card.- Returns:
- this
- Throws:
NotOnGraphicsThreadException
-
addAll
Copies all vertices and triangles / fragments from a given vertex array onto this one.- Parameters:
vertexArray
- the array to copy from- Returns:
- this
-
addAll
Copies all vertices and triangles / fragments from a given vertex array onto this one, transforming the array using a given model instance.- Parameters:
model
- the model to copy frommodelInstance
- the model instance to apply- Returns:
- this
-
render
Render the array using the current shader program onto the current target frame buffer.- Returns:
- this
- Throws:
NotOnGraphicsThreadException
-
toString
-