Nothing is rendering, or if it is, then it is rendering so far away that it is clipped.
Not sure what I’m doing wrong, probably just a rookie mistake! But a gold star to the man who can figure it out.
vertices is an array of instances of the class Vertex, which stores a location which can be retrieved with Vertex.x(), Vertex.y(), or Vertex.z().
This is where I generate the VBO :
public void generateVBO() {
vertexBufferVertices = vertices.length;
float[] verticesData = new float[vertices.length*3];
int i = 0;
for (Vertex vert : vertices) {
verticesData[i] = vert.x();
verticesData[i+1] = vert.y();
verticesData[i+2] = vert.z();
i += 3;
}
FloatBuffer data = BufferUtils.createFloatBuffer(verticesData.length);
data.put(verticesData);
vertexBufferObjectID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBufferObjectID);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, GL15.GL_STATIC_DRAW);
}
The render method :
public void render() {
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBufferObjectID);
GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0);
GL11.glDrawArrays(GL11.GL_QUADS, 0, vertexBufferVertices);
}
Some things you can be sure of :
-vertexBufferObjectID is a int that is not edited between generateVBO() and
render().
-vertices.length is 12
-Both render() and generateVBO() are being called in the correct order.
-generateVBO() is only called once.
Thanks in advance to anyone taking the time to reply!