private void load_vbo() {
int FLOAT_BYTE_SIZE = 4;
/*
* Define vertices and indices used by the VBO:
*/
float[] vertices = new float[] {
0, 0, 0,
0, 1, 0,
1, 1, 0,
1, 0, 0
};
byte[] indices = new byte[] {
0, 1, 2, 2, 3, 0
};
/*
* Create the vertex buffer; upload vertices into buffer.
*/
vbo_id = GL15.glGenBuffers();
FloatBuffer vbo_buf = ByteBuffer.allocateDirect(vertices.length * FLOAT_BYTE_SIZE).order(ByteOrder.nativeOrder()).asFloatBuffer();
vbo_buf.put(vertices);
vbo_buf.flip();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_id);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vbo_buf, GL15.GL_STATIC_DRAW);
/*
* Create the index buffer; upload indices into buffer.
*/
ibo_id = GL15.glGenBuffers();
ByteBuffer ibo_buf = ByteBuffer.allocateDirect(indices.length).order(ByteOrder.nativeOrder());
ibo_buf.put(indices);
ibo_buf.flip();
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo_id);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo_buf, GL15.GL_STATIC_DRAW);
/*
* Make vbo ready for drawing:
*/
int POS_COUNT = 3;
int TEXCOORD_COUNT = 0;
int stride = (POS_COUNT + TEXCOORD_COUNT) * FLOAT_BYTE_SIZE;
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
//GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
GL11.glVertexPointer(POS_COUNT, GL11.GL_FLOAT, stride, 0);
//GL11.glTexCoordPointer(TEXCOORD_COUNT, GL11.GL_FLOAT, stride, POS_COUNT * FLOAT_BYTE_SIZE);
}