I have been looking at dis code for more than an hour and its getting annoying. I have generated a nice stack of fatal error logs already. Maybe someone can help meh? :’(
.render();
public class Mesh3D {
public static int target = GL_ARRAY_BUFFER;
public int vertexHandle;
public int size;
private int position = 0;
private float[] vertices;
public Mesh3D(int size) {
vertexHandle = glGenBuffers();
this.size = size;
vertices = new float[size * 3];
}
public void put(float x, float y, float z) {
vertices[position++] = x;
vertices[position++] = y;
vertices[position++] = z;
}
public void put(float x, float y, float z, float width, float height){
put(x, y, z);
put(x+width, y, z);
put(x+width, y+height, z);
put(x, y+height, z);
}
public void upload() {
FloatBuffer buffer = BufferUtils.createFloatBuffer(size*3);
buffer.put(vertices);
buffer.flip();
glBindBuffer(target, vertexHandle);
glBufferData(target, buffer, GL_STATIC_DRAW);
}
public void render() {
glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(target, vertexHandle);
glVertexPointer(3, GL_FLOAT, 3 << 2, 0l);
glBindBuffer(target, 0);
// FATAL ERROR OCCURS ON NEXT LINE
glDrawArrays(GL_QUADS, 0, size);
glDisableClientState(GL_VERTEX_ARRAY);
}
public void clear() {
}
}