/** * @param target * @param size * @param data * @param usage * @see com.jogamp.opengl.GL#glBufferData(int, long, java.nio.Buffer, int) */ public void glBufferData(int target, long size, Buffer data, int usage) { try{delegate.glBufferData(target, size, data, usage);} catch(GLException e){glException(e); throw e;} } /**
public void allocate(float[] data) { this.size = data.length; Buffer buffer = Buffers.newDirectFloatBuffer(data); int bufferByteSize = buffer.capacity() * Buffers.SIZEOF_FLOAT; gl.glBufferData(gl.GL_ARRAY_BUFFER, bufferByteSize, buffer, gl.GL_STATIC_DRAW); }
public void allocate(int[] data) { this.size = data.length; Buffer buffer = Buffers.newDirectIntBuffer(data); int bufferByteSize = buffer.capacity() * Buffers.SIZEOF_INT; gl.glBufferData(gl.GL_ELEMENT_ARRAY_BUFFER, bufferByteSize, buffer, gl.GL_STATIC_DRAW); }
@Override public int createGlBufferView( int target, int byteLength, ByteBuffer bufferViewData) { int bufferViewArray[] = {0}; gl.glGenBuffers(1, bufferViewArray, 0); int glBufferView = bufferViewArray[0]; gl.glBindBuffer(target, glBufferView); gl.glBufferData(target, byteLength, bufferViewData, GL_STATIC_DRAW); return glBufferView; }
private static int makeIndices( final GL3 g) { final IntBuffer data = Buffers.newDirectIntBuffer(2 * 3); data.put(0, 0); data.put(1, 1); data.put(2, 2); data.put(3, 0); data.put(4, 2); data.put(5, 3); final IntBuffer buffers = Buffers.newDirectIntBuffer(1); g.glGenBuffers(1, buffers); final int id = buffers.get(0); g.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, id); g .glBufferData( GL.GL_ELEMENT_ARRAY_BUFFER, (long) (6 * 4), data, GL.GL_STATIC_DRAW); g.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0); return id; }
final int id = buffers.get(0); g.glBindBuffer(GL.GL_ARRAY_BUFFER, id); g.glBufferData( GL.GL_ARRAY_BUFFER, (long) VERTICES_TOTAL_SIZE_BYTES,
final int id = buffers.get(0); g.glBindBuffer(GL.GL_ARRAY_BUFFER, id); g.glBufferData( GL.GL_ARRAY_BUFFER, (long) VERTICES_TOTAL_SIZE_BYTES,
@Override public void glBufferData(int target, IntBuffer data, int usage) { GLContext.getCurrentGL().getGL3().glBufferData(target, data.remaining() * 4, data, usage); }
@Override public void glBufferData(int target, FloatBuffer data, int usage) { GLContext.getCurrentGL().getGL3().glBufferData(target, data.remaining() * 4, data, usage); }
protected RawGLBuffer(int sizeInBytes, GPU gpu) { if (sizeInBytes == 0) throw new RuntimeException("Cannot allocate a buffer of size zero."); this.sizeInBytes=sizeInBytes; final GL3 gl = gpu.getGl(); final IntBuffer iBuf = IntBuffer.allocate(1); gl.glGenBuffers(1, iBuf); bufferID = iBuf.get(); gl.glBindBuffer(getBindingTarget(), bufferID); gl.glBufferData(getBindingTarget(), sizeInBytes, null, getReadWriteParameter()); gl.glBindBuffer(getBindingTarget(), 0); }// end constructor
@Override public Void call() throws Exception { final GL3 gl = gpu.getGl(); gl.glGenBuffers(1, ib); ib.clear(); dummyBufferID = ib.get(); gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, dummyBufferID); gl.glBufferData(GL3.GL_ARRAY_BUFFER, 1, null, GL3.GL_STATIC_DRAW); gl.glEnableVertexAttribArray(0); gl.glVertexAttribPointer(0, 1, GL3.GL_BYTE, false, 0, 0); gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0); return null; } });//end task0