private void bind(int id) { gc.getGL().glBindBuffer(target.glvalue, id); }
public static DncDeviceChunk xferChunkToDevice( DncHostChunk hChunk, GL gl ) { int verticesHandle = genBuffer( gl ); gl.glBindBuffer( GL_ARRAY_BUFFER, verticesHandle ); gl.glBufferData( GL_ARRAY_BUFFER, hChunk.verticesBuf.remaining( ) * SIZEOF_FLOAT, hChunk.verticesBuf, GL_STATIC_DRAW ); return new DncDeviceChunk( hChunk.chunkKey, hChunk.featureCount, hChunk.groups, verticesHandle ); }
public static void setBoundVBO(final RendererRecord rendRecord, final int id) { final GL gl = GLContext.getCurrentGL(); if (!rendRecord.isVboValid() || rendRecord.getCurrentVboId() != id) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, id); rendRecord.setCurrentVboId(id); rendRecord.setVboValid(true); } }
public static void setBoundElementVBO(final RendererRecord rendRecord, final int id) { final GL gl = GLContext.getCurrentGL(); if (!rendRecord.isElementVboValid() || rendRecord.getCurrentElementVboId() != id) { gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, id); rendRecord.setCurrentElementVboId(id); rendRecord.setElementVboValid(true); } }
context.glBindBuffer( GL.GL_ARRAY_BUFFER, bufferID[0] ); context.glBufferData( GL.GL_ARRAY_BUFFER, coordBuffer.capacity() * 4, coordBuffer, GL.GL_STATIC_DRAW ); context.glBindBuffer( GL.GL_ARRAY_BUFFER, bufferID[1] ); context.glBufferData( GL.GL_ARRAY_BUFFER, normalBuffer.capacity() * 4, normalBuffer, GL.GL_STATIC_DRAW ); context.glBindBuffer( GL.GL_ARRAY_BUFFER, bufferID[2] ); context.glBufferData( GL.GL_ARRAY_BUFFER, textureBuffer.capacity() * 4, textureBuffer, GL.GL_STATIC_DRAW ); context.glBindBuffer( GL.GL_ARRAY_BUFFER, bufferID[0] ); context.glVertexPointer( 3, GL.GL_FLOAT, 0, 0 ); context.glBindBuffer( GL.GL_ARRAY_BUFFER, bufferID[1] ); context.glNormalPointer( GL.GL_FLOAT, 0, 0 ); context.glBindBuffer( GL.GL_ARRAY_BUFFER, bufferID[2] ); context.glTexCoordPointer( 2, GL.GL_FLOAT, 0, 0 ); context.glDisableClientState( GL.GL_TEXTURE_COORD_ARRAY ); context.glBindBuffer( GL.GL_ARRAY_BUFFER, 0 );
@Override public final boolean bindBuffer(final GL gl, final boolean bind) { if( !ad.isVBO() ) { return false; } if(bind) { // always bind and refresh the VBO mgr, // in case more than one gl*Pointer objects are in use gl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName()); if(!ad.isVBOWritten()) { final Buffer buffer = ad.getBuffer(); if(null!=buffer) { gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getComponentSizeInBytes(), buffer, ad.getVBOUsage()); } ad.setVBOWritten(true); } } else { gl.glBindBuffer(ad.getVBOTarget(), 0); } return true; }
public static DncDeviceLabelAtlas xferLabelAtlasToDevice( DncHostLabelAtlas hAtlas, GL gl ) { TexturableImage textureImage = hAtlas.textureImage; int textureHandle = genTexture( gl ); gl.glBindTexture( GL_TEXTURE_2D, textureHandle ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); textureImage.pushToTexture( gl, GL_TEXTURE_2D ); int[] bufferHandles = new int[ 2 ]; gl.glGenBuffers( 2, bufferHandles, 0 ); int entriesAlignHandle = bufferHandles[ 0 ]; gl.glBindBuffer( GL_ARRAY_BUFFER, entriesAlignHandle ); gl.glBufferData( GL_ARRAY_BUFFER, hAtlas.entriesAlignBuf.remaining( ) * SIZEOF_FLOAT, hAtlas.entriesAlignBuf, GL_STATIC_DRAW ); int entriesBoundsHandle = bufferHandles[ 1 ]; gl.glBindBuffer( GL_ARRAY_BUFFER, entriesBoundsHandle ); gl.glBufferData( GL_ARRAY_BUFFER, hAtlas.entriesBoundsBuf.remaining( ) * SIZEOF_FLOAT, hAtlas.entriesBoundsBuf, GL_STATIC_DRAW ); return new DncDeviceLabelAtlas( hAtlas.chunkKey, textureImage.getWidth( ), textureImage.getHeight( ), entriesAlignHandle, entriesBoundsHandle, textureHandle ); }
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);