BasicVertexArray
in package
A simple wrapper around a vertex array and vertex buffer That assumes all values to be floats.
You can specify a simple vertex layout by specifying the element sizes in sequence. Example: [3, 2] = vec3, vec2 = 5 floats per vertex [3, 2, 3] = vec3, vec2, vec3 = 8 floats per vertex [3, 2, 3, 1] = vec3, vec2, vec3, float = 9 floats per vertex // etc..
Table of Contents
Properties
- $vertexArray : int
- The vertex array object from GL
- $vertexBuffer : int
- The vertex buffer object from GL
- $floatsPerVertex : int
- Number of floats per vertex
- $state : GLState
- $vertexCount : int
- Vertex count
Methods
- __construct() : void
- Constructor
- __destruct() : void
- Destructor
- bind() : void
- Binds the vertex array
- draw() : void
- Draws a range of vertices
- drawAll() : void
- Draws all vertices
- upload() : void
- Uploads the vertex data to the GPU
Properties
$vertexArray read-only
The vertex array object from GL
public
int
$vertexArray
$vertexBuffer read-only
The vertex buffer object from GL
public
int
$vertexBuffer
$floatsPerVertex
Number of floats per vertex
private
int
$floatsPerVertex
= 0
$state
private
GLState
$state
$vertexCount
Vertex count
private
int
$vertexCount
= 0
Methods
__construct()
Constructor
public
__construct(GLState $state, array<string|int, int> $vertexLayout) : void
Parameters
- $state : GLState
- $vertexLayout : array<string|int, int>
-
The vertex layout
__destruct()
Destructor
public
__destruct() : void
bind()
Binds the vertex array
public
bind() : void
draw()
Draws a range of vertices
public
draw(int $offset, int $count[, int $renderMode = GL_TRIANGLES ]) : void
Parameters
- $offset : int
-
The offset
- $count : int
-
The count
- $renderMode : int = GL_TRIANGLES
drawAll()
Draws all vertices
public
drawAll([int $renderMode = GL_TRIANGLES ]) : void
Parameters
- $renderMode : int = GL_TRIANGLES
upload()
Uploads the vertex data to the GPU
public
upload(FloatBuffer $vertexData) : void
Parameters
- $vertexData : FloatBuffer
-
The vertex data