@Test public final void testArrayUpdateNotBound() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(a); ga.arrayBufferUnbind(); this.expected.expect(JCGLExceptionBufferNotBound.class); ga.arrayBufferUpdate(u); Assert.fail(); }
@Test public final void testArrayDeleteUnbinds() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); ga.arrayBufferBind(a); Assert.assertEquals(Optional.of(a), ga.arrayBufferGetCurrentlyBound()); ga.arrayBufferDelete(a); Assert.assertTrue(a.isDeleted()); Assert.assertFalse(ga.arrayBufferGetCurrentlyBound().isPresent()); }
@Test public final void testArrayReadDeleted() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); ga.arrayBufferDelete(a); this.expected.expect(JCGLExceptionDeleted.class); ga.arrayBufferRead(a, size -> ByteBuffer.allocateDirect((int) size)); Assert.fail(); }
@Test public final void testArrayReallocateNotBound() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); ga.arrayBufferUnbind(); this.expected.expect(JCGLExceptionBufferNotBound.class); ga.arrayBufferReallocate(a); Assert.fail(); }
final long sz = size.longValue(); final JCGLArrayBuffersType ga = g33.getArrayBuffers(); ga.arrayBufferUnbind(); return ga.arrayBufferAllocate(sz, array_usage); })); final CompletableFuture<JCGLIndexBufferType> f_index_alloc = up -> this.g.evaluate((g33, unused) -> { final JCGLArrayBuffersType ga = g33.getArrayBuffers(); ga.arrayBufferBind(up.getBuffer()); ga.arrayBufferUpdate(up); ga.arrayBufferUnbind(); return up.getBuffer(); }));
@Test public final void testArrayBufferDeletion() { final Interfaces i = this.getInterfaces("main"); final JCGLArrayBuffersType ga = i.getArrayBuffers(); final JCGLArrayObjectsType go = i.getArrayObjects(); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); ga.arrayBufferUnbind(); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); b.setAttributeIntegral( 0, a, 1, JCGLScalarIntegralType.TYPE_UNSIGNED_BYTE, 0, 0L); final JCGLArrayObjectType ao = go.arrayObjectAllocate(b); Assert.assertEquals(ao, go.arrayObjectGetCurrentlyBound()); ga.arrayBufferDelete(a); go.arrayObjectBind(ao); final Set<JCGLReferableType> refs = ao.getReferences(); Assert.assertEquals(1L, (long) refs.size()); Assert.assertTrue(refs.contains(a)); }
@Test public final void testArrayBindDeleted() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); ga.arrayBufferDelete(a); Assert.assertTrue(a.isDeleted()); this.expected.expect(JCGLExceptionDeleted.class); ga.arrayBufferBind(a); Assert.fail(); }
@Test public final void testArrayDeleteDeleted() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); ga.arrayBufferDelete(a); Assert.assertTrue(a.isDeleted()); this.expected.expect(JCGLExceptionDeleted.class); ga.arrayBufferDelete(a); Assert.fail(); }
@Test public final void testArrayBindIdentities() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); Assert.assertFalse(ga.arrayBufferGetCurrentlyBound().isPresent()); Assert.assertFalse(ga.arrayBufferAnyIsBound()); final JCGLArrayBufferType a0 = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLArrayBufferType a1 = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); Assert.assertTrue(ga.arrayBufferAnyIsBound()); Assert.assertTrue(ga.arrayBufferIsBound(a1)); Assert.assertEquals(Optional.of(a1), ga.arrayBufferGetCurrentlyBound()); ga.arrayBufferBind(a0); Assert.assertTrue(ga.arrayBufferAnyIsBound()); Assert.assertTrue(ga.arrayBufferIsBound(a0)); Assert.assertEquals(Optional.of(a0), ga.arrayBufferGetCurrentlyBound()); ga.arrayBufferBind(a1); Assert.assertTrue(ga.arrayBufferAnyIsBound()); Assert.assertTrue(ga.arrayBufferIsBound(a1)); Assert.assertEquals(Optional.of(a1), ga.arrayBufferGetCurrentlyBound()); ga.arrayBufferUnbind(); Assert.assertEquals(Optional.empty(), ga.arrayBufferGetCurrentlyBound()); Assert.assertFalse(ga.arrayBufferGetCurrentlyBound().isPresent()); Assert.assertFalse(ga.arrayBufferAnyIsBound()); }
@Test public final void testArrayAllocateNegative() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); this.expected.expect(RangeCheckException.class); ga.arrayBufferAllocate(-1L, JCGLUsageHint.USAGE_STATIC_DRAW); Assert.fail(); }
@Test public final void testArrayUpdateDeleted() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(a); ga.arrayBufferDelete(a); this.expected.expect(JCGLExceptionDeleted.class); ga.arrayBufferUpdate(u); Assert.fail(); }
@Test public final void testArrayUpdateShared() { final JCGLSharedContextPair<JCGLArrayBuffersType> p = this.getArrayBuffersSharedWith("main", "alt"); final JCGLContextType ca = p.getMasterContext(); final JCGLContextType cb = p.getSlaveContext(); final JCGLArrayBuffersType ga = p.getMasterValue(); final JCGLArrayBuffersType gb = p.getSlaveValue(); Assert.assertTrue(ca.contextIsCurrent()); Assert.assertFalse(cb.contextIsCurrent()); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(a); ca.contextReleaseCurrent(); cb.contextMakeCurrent(); gb.arrayBufferBind(a); gb.arrayBufferUpdate(u); }
private void deleteActual() { if (this.array != null) { this.g33_array_buffers.arrayBufferDelete(this.array); this.array = null; } if (this.array_object != null) { this.g33_array_objects.arrayObjectDelete(this.array_object); this.array_object = null; } }
@Test public final void testArrayRead() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(a); final ByteBuffer b = u.data(); for (int index = 0; index < 100; ++index) { b.put(index, (byte) 0x50); } ga.arrayBufferUpdate(u); final ByteBuffer e = ga.arrayBufferRead(a, size -> ByteBuffer.allocateDirect((int) size)); for (int index = 0; index < 100; ++index) { final long bv = (long) b.get(index); final long ev = (long) e.get(index); Assert.assertEquals("index " + index, bv, ev); } }
@Test public final void testArrayIsBoundDeleted() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); ga.arrayBufferDelete(a); Assert.assertTrue(a.isDeleted()); this.expected.expect(JCGLExceptionDeleted.class); ga.arrayBufferIsBound(a); Assert.fail(); }
@Test public final void testArrayReadNotBound() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); ga.arrayBufferUnbind(); this.expected.expect(JCGLExceptionBufferNotBound.class); ga.arrayBufferRead(a, size -> ByteBuffer.allocateDirect((int) size)); Assert.fail(); } }
@Test public final void testArrayUpdateWrongContext() { final JCGLUnsharedContextPair<JCGLArrayBuffersType> p = this.getArrayBuffersUnshared("main", "alt"); final JCGLContextType ca = p.getContextA(); final JCGLContextType cb = p.getContextB(); final JCGLArrayBuffersType ga = p.getValueA(); final JCGLArrayBuffersType gb = p.getValueB(); Assert.assertFalse(ca.contextIsCurrent()); Assert.assertTrue(cb.contextIsCurrent()); cb.contextReleaseCurrent(); ca.contextMakeCurrent(); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(a); ca.contextReleaseCurrent(); cb.contextMakeCurrent(); this.expected.expect(JCGLExceptionWrongContext.class); gb.arrayBufferUpdate(u); Assert.fail(); }
@Override public void update( final JCGLInterfaceGL33Type g, final R2TransformContextType context) { NullCheck.notNull(context); NullCheck.notNull(g); final JCGLArrayBuffersType g_ab = g.getArrayBuffers(); final JCGLArrayObjectsType g_ao = g.getArrayObjects(); final FloatBuffer floats = this.update_vbo.getData().asFloatBuffer(); for (int index = this.used; index < this.max_size; ++index) { final int offset = Math.multiplyExact(index, 5); floats.put(offset + 0, 0.0f); floats.put(offset + 1, 0.0f); floats.put(offset + 2, 0.0f); floats.put(offset + 3, 0.0f); floats.put(offset + 4, 0.0f); } g_ao.arrayObjectBind(this.data_vao); g_ab.arrayBufferBind(this.data_vbo); g_ab.arrayBufferReallocate(this.data_vbo); g_ab.arrayBufferUpdate(this.update_vbo); g_ao.arrayObjectUnbind(); }
pc.set3F(far_x_max, far_y_min, far_z); ga.arrayBufferBind(this.array_buffer); ga.arrayBufferUpdate(this.array_update); ga.arrayBufferUnbind(); this.mesh_needs_update = false;
@Override public void onFinish() { final JCGLArrayBuffersType g_ab = this.g.getArrayBuffers(); final JCGLIndexBuffersType g_ib = this.g.getIndexBuffers(); if (!this.errors.isEmpty()) { if (this.array_buffer != null) { g_ab.arrayBufferDelete(this.array_buffer); this.array_buffer = null; } if (this.index_buffer != null) { g_ib.indexBufferDelete(this.index_buffer); this.index_buffer = null; } } g_ab.arrayBufferUpdate(this.array_update); g_ib.indexBufferUpdate(this.index_update); this.array_object = this.g.getArrayObjects().arrayObjectAllocate(this.array_object_builder); }