Package k8.buffer.vbo

Source Code of k8.buffer.vbo.VBOColoursBuffer

package k8.buffer.vbo;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;

import k8.buffer.ColoursBuffer;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.ARBVertexBufferObject;


public final class VBOColoursBuffer extends ColoursBuffer {
   
    private int id;
 
    /**
     * Creates an instance of VBOTexCoordsBuffer.
     *
     * @param capacity
     *          Initial capacity (number of indices)
     */
    public VBOColoursBuffer(int capacity) {
        super(capacity);
        IntBuffer int_buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
        ARBVertexBufferObject.glGenBuffersARB(int_buffer);
        id = int_buffer.get(0);
    }

    @Override
    public void destroy() {
        IntBuffer int_buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
        int_buffer.put(id);
        ARBVertexBufferObject.glDeleteBuffersARB(int_buffer);
    }

    @Override
    public void glColourPointer() {
      ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, id);
      if ( flush ) {
        buffer.rewind();
            ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
            flush = false;
      }
        GL11.glColorPointer(3, GL11.GL_FLOAT, 0, 0);
    }
   
}
TOP

Related Classes of k8.buffer.vbo.VBOColoursBuffer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.