io7m
io7m-jcanephora 0.45.2
3.12
JCGLIndexBuffersType

- 3.12.1. Description
- 3.12.2. Usage examples
- 3.12.3. State

3.12.1
Description
1
The JCGLIndexBuffersType interface provides functions for allocating, updating, and using index buffers. It provides a typed interface to the glGenBuffers and glBufferData functions.
2
Index buffers are used to store indices for indexed rendering as provided by the OpenGL glDrawElements family of functions.
3.12.2
Usage examples
1
Usage of index buffers is similar to array buffers with the main difference being that index buffers know the type of their indices.
3.12.2.1. Allocation and Updates

    JCGLIndexBuffersType g;

    JCGLIndexBufferType a = g.indexBufferAllocate(3, JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW);

    final JCGLBufferUpdateType<JCGLIndexBufferType> u =
      JCGLBufferUpdates.newUpdateReplacingAll(this.index_buffer);
    final IntBuffer i = u.getData().asIntBuffer();

    i.put(0, 0);
    i.put(1, 1);
    i.put(2, 2);

    g.indexBufferUpdate(u);
    g.indexBufferUnbind();

3.12.3
State
1
OpenGL specifies that at most one index buffer can be bound to the current array object at any given time. OpenGL provides a default array object that is used when attempting to bind an index buffer, if no user-created array object is bound.