@Override public void arrayBufferUpdate( final JCGLBufferUpdateType<JCGLArrayBufferType> u) throws JCGLException, JCGLExceptionDeleted, JCGLExceptionBufferNotBound { NullCheck.notNull(u); final JCGLArrayBufferType a = u.getBuffer(); this.checkArray(a); if (a.equals(this.bind)) { final UnsignedRangeInclusiveL r = u.getDataUpdateRange(); final ByteBuffer data = u.getData(); data.rewind(); GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, r.getLower(), data); } else { throw this.notBound(a); } }
@Override public void indexBufferUpdate( final JCGLBufferUpdateType<JCGLIndexBufferType> u) throws JCGLException, JCGLExceptionDeleted, JCGLExceptionBufferNotBound { NullCheck.notNull(u); final JCGLIndexBufferType ii = u.getBuffer(); this.checkIndexBuffer(ii); final JCGLArrayObjectUsableType ao = this.array_objects.arrayObjectGetCurrentlyBound(); final Optional<JCGLIndexBufferUsableType> i_opt = ao.getIndexBufferBound(); if (i_opt.isPresent()) { final JCGLIndexBufferUsableType current_ib = i_opt.get(); if (ii.equals(current_ib)) { final UnsignedRangeInclusiveL r = u.getDataUpdateRange(); final ByteBuffer data = u.getData(); data.rewind(); GL15.glBufferSubData( GL15.GL_ELEMENT_ARRAY_BUFFER, r.getLower(), data); return; } } throw LWJGL3IndexBuffers.notBound(ii, i_opt); }
@Override public void arrayBufferUpdate( final JCGLBufferUpdateType<JCGLArrayBufferType> u) throws JCGLException, JCGLExceptionDeleted, JCGLExceptionBufferNotBound { NullCheck.notNull(u); final JCGLArrayBufferType a = u.getBuffer(); this.checkArray(a); if (a.equals(this.bind)) { final UnsignedRangeInclusiveL r = u.getDataUpdateRange(); final ByteBuffer data = u.getData(); data.rewind(); final FakeArrayBuffer fa = (FakeArrayBuffer) a; final ByteBuffer fa_data = fa.getData(); /** * XXX: Clearly overflowing integers. */ final long lo = r.getLower(); final long hi = r.getUpper(); for (long index = lo; Long.compareUnsigned(index, hi) <= 0; ++index) { final int ii = (int) index; fa_data.put(ii, data.get(ii)); } } else { throw this.notBound(a); } }
final JCGLIndexBufferUsableType current_ib = i_opt.get(); if (ii.equals(current_ib)) { final UnsignedRangeInclusiveL r = u.getDataUpdateRange(); final ByteBuffer data = u.getData(); data.rewind();
@Test public final void testBufferUpdateAllIdentities() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(a); Assert.assertSame(a, u.getBuffer()); final UnsignedRangeInclusiveL u_range = u.getDataUpdateRange(); final ByteBuffer u_data = u.getData(); Assert.assertEquals(a.getRange(), u_range); Assert.assertEquals(u_range.getInterval(), (long) u_data.capacity()); }