public void release() { // unbind the VBO and VAO gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0); // gl.glBindVertexArray(0); }
public void release() { // unbind the VBO and VAO gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, 0); }
public void bind() { gl.glBindBuffer(gl.GL_ARRAY_BUFFER, getGLHandle()); }
public void bind() { gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, getGLHandle()); }
public void bindAsElementArrayBuffer(final GL3 gl) { // gl.glEnableClientState(GL2.GL_ELEMENT_ARRAY_BUFFER); gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, getBufferID()); }
public void unbind(GL3 gl) { gl.glBindBuffer(getBindingTarget(), 0); }
@Override public void renderIndexed( int glVertexArray, int mode, int glIndicesBuffer, int numIndices, int indicesType, int offset) { gl.glBindVertexArray(glVertexArray); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glIndicesBuffer); gl.glDrawElements(mode, numIndices, indicesType, offset); }
@Override public void glBindBuffer(int target, int buffer) { GLContext.getCurrentGL().getGL3().glBindBuffer(target, buffer); }
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; }
@Override public void updateVertexAttribute(int glVertexArray, int target, int glBufferView, int offset, int size, ByteBuffer data) { gl.glBindVertexArray(glVertexArray); gl.glBindBuffer(target, glBufferView); gl.glBufferSubData(target, offset, size, data); }
@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; }
public void unmap(GL3 gl) { if (!mapped) return; gl.glBindBuffer(getBindingTarget(), bufferID); gl.glUnmapBuffer(getBindingTarget()); gl.glBindBuffer(getBindingTarget(), 0); mapped = false; }
public void bind(GL3 gl3) { gl3.glBindBuffer(getBindingTarget(), getBufferID()); }
public void map(GL3 gl, MapMode ... mapModes ) { if (mapped) return; int mapMode = 0; for(MapMode mode:mapModes) mapMode|=mode.getGlMask(); gl.glBindBuffer(getBindingTarget(), bufferID); localBuffer = gl.glMapBufferRange(getBindingTarget(), 0, sizeInBytes, mapMode); if (localBuffer == null) { throw new NullPointerException("Failed to map buffer."); } gl.glBindBuffer(getBindingTarget(), 0); mapped = true; }
@Override public void createVertexAttribute(int glVertexArray, int target, int glBufferView, int attributeLocation, int size, int type, int stride, int offset) { gl.glBindVertexArray(glVertexArray); gl.glBindBuffer(target, glBufferView); gl.glVertexAttribPointer( attributeLocation, size, type, false, stride, offset); gl.glEnableVertexAttribArray(attributeLocation); }
@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
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
/** * @param target * @param buffer * @see com.jogamp.opengl.GL#glBindBuffer(int, int) */ public void glBindBuffer(int target, int buffer) { try{delegate.glBindBuffer(target, buffer);} catch(GLException e){glException(e); throw e;} switch(target){ case GL3.GL_ARRAY_BUFFER: bean.setArrayBufferBinding(buffer); break; case GL3.GL_TEXTURE_BUFFER: bean.setTextureBufferBufferBinding(buffer); break; default: unhandledState("Unimplemented handler for buffer target "+target); } } /**
@Override public void apply(GL3 gl, Collection<SoundEvent> events, double bufferStartTimeSeconds) { gl.glLineWidth(1); gl.glDisable(GL3.GL_LINE_SMOOTH); gl.glDisable(GL3.GL_CULL_FACE); gl.glEnable(GL3.GL_BLEND); gl.glDepthFunc(GL3.GL_ALWAYS); //gl.glProvokingVertex(GL3.GL_FIRST_VERTEX_CONVENTION); gl.glDepthMask(false); gl.glBlendFunc(GL3.GL_ONE, GL3.GL_ONE); soundProgram.use(); //assert vertexIDAttribLocation != -1:"VertexIDAttribLocation failed to init!"; //gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vertexBufferID); // gl.glEnableVertexAttribArray(vertexIDAttribLocation); //gl.glVertexAttribPointer(vertexIDAttribLocation, 1, GL3.GL_FLOAT, false, 0, 0); soundTextureU.set((int)0); for(SoundEvent ev:events) ev.apply(gl, bufferStartTimeSeconds); //Cleanup //gl.glDisableVertexAttribArray(vertexIDAttribLocation); gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0); gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); gl.glDisable(GL3.GL_BLEND); gl.glUseProgram(0); }//end apply(...)
public void updateTextureCoords(FloatBuffer pTextureCoordsBuffer) { if (!isDynamic()) throw new UnsupportedOperationException("Cannot update non dynamic buffers!"); getGL().getGL3().glBindVertexArray(mVertexArrayObject[0]); GLError.printGLErrors(getGL(), "1"); getGL().getGL3().glBindBuffer(GL.GL_ARRAY_BUFFER, mVertexBuffers[2]); GLError.printGLErrors(getGL(), "2"); getGL().getGL3().glEnableVertexAttribArray(2); GLError.printGLErrors(getGL(), "3"); getGL().glBufferSubData(GL.GL_ARRAY_BUFFER, 0, pTextureCoordsBuffer.limit() * (Float.SIZE / Byte.SIZE), pTextureCoordsBuffer); GLError.printGLErrors(getGL(), "4"); getGL().getGL3().glVertexAttribPointer(2, mTextureCoordSize, GL.GL_FLOAT, false, 0, 0); GLError.printGLErrors(getGL(), "5"); getGL().getGL3().glBindVertexArray(0); GLError.printGLErrors(getGL(), "6"); getGL().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); GLError.printGLErrors(getGL(), "7"); }