@Test public final void testArrayBindDeleteBindPreserves() { 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); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); Assert.assertTrue(b.getMaximumVertexAttributes() >= 16); b.setAttributeFloatingPoint( 0, a, 4, JCGLScalarType.TYPE_FLOAT, 16, 0L, false); final JCGLArrayObjectType a0 = go.arrayObjectAllocate(b); final JCGLArrayObjectType a1 = go.arrayObjectAllocate(b); go.arrayObjectBind(a0); Assert.assertEquals(a0, go.arrayObjectGetCurrentlyBound()); go.arrayObjectDelete(a1); Assert.assertEquals(a0, go.arrayObjectGetCurrentlyBound()); }
@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(); }
@Test public final void testArrayBindIdentity() { 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); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); Assert.assertTrue(b.getMaximumVertexAttributes() >= 16); b.setAttributeFloatingPoint( 0, a, 4, JCGLScalarType.TYPE_FLOAT, 16, 0L, false); final JCGLArrayObjectType ao0 = go.arrayObjectAllocate(b); Assert.assertEquals(ao0, go.arrayObjectGetCurrentlyBound()); final JCGLArrayObjectType ao1 = go.arrayObjectAllocate(b); Assert.assertEquals(ao1, go.arrayObjectGetCurrentlyBound()); go.arrayObjectBind(ao0); Assert.assertEquals(ao0, go.arrayObjectGetCurrentlyBound()); go.arrayObjectBind(ao1); Assert.assertEquals(ao1, go.arrayObjectGetCurrentlyBound()); go.arrayObjectUnbind(); Assert.assertEquals( go.arrayObjectGetDefault(), go.arrayObjectGetCurrentlyBound()); }
@Test public final void testArrayDeleteDefault() { final Interfaces i = this.getInterfaces("main"); final JCGLArrayBuffersType ga = i.getArrayBuffers(); final JCGLArrayObjectsType go = i.getArrayObjects(); final JCGLArrayObjectUsableType unsafe = go.arrayObjectGetDefault(); if (unsafe instanceof JCGLArrayObjectType) { this.expected.expect(JCGLExceptionObjectNotDeletable.class); go.arrayObjectDelete((JCGLArrayObjectType) unsafe); Assert.fail(); } }
@Test public final void testArrayDeleteDeleted() { 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); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); Assert.assertTrue(b.getMaximumVertexAttributes() >= 16); b.setAttributeFloatingPoint( 0, a, 4, JCGLScalarType.TYPE_FLOAT, 16, 0L, false); final JCGLArrayObjectType ai = go.arrayObjectAllocate(b); go.arrayObjectDelete(ai); this.expected.expect(JCGLExceptionDeleted.class); go.arrayObjectDelete(ai); Assert.fail(); }
@Override public void onStart() { this.array_object_builder = this.g.getArrayObjects().arrayObjectNewBuilder(); }
@Test public final void testDrawElementsOK() { final Interfaces i = this.getInterfaces("main"); final JCGLArrayObjectsType go = i.getArrayObjects(); final JCGLIndexBuffersType gi = i.getIndexBuffers(); final JCGLDrawType gd = i.getDraw(); final JCGLIndexBufferType ib = gi.indexBufferAllocate( 100L, JCGLUnsignedType.TYPE_UNSIGNED_BYTE, JCGLUsageHint.USAGE_STATIC_DRAW); gi.indexBufferUnbind(); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); b.setIndexBuffer(ib); final JCGLArrayObjectType ao = go.arrayObjectAllocate(b); gd.drawElements(JCGLPrimitives.PRIMITIVE_POINTS); }
g_ao.arrayObjectNewBuilderFromObject(o); 1); vao = g_ao.arrayObjectAllocate(aob); g_ao.arrayObjectUnbind(); g_ao.arrayObjectDelete(vao);
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; } }
ga.arrayObjectAllocate(ga.arrayObjectNewBuilder()); final Set<JCGLReferableType> a0_refs = a0.getReferences(); ga.arrayObjectAllocate(ga.arrayObjectNewBuilder()); final Set<JCGLReferableType> a1_refs = a1.getReferences(); final Set<JCGLReferenceContainerType> i0_refs = i0.getReferringContainers(); Assert.assertEquals(a1, ga.arrayObjectGetCurrentlyBound()); Assert.assertEquals(Optional.of(i0), gi.indexBufferGetCurrentlyBound()); Assert.assertEquals(Optional.of(i0), a1.getIndexBufferBound()); Assert.assertEquals(a1, ga.arrayObjectGetCurrentlyBound()); Assert.assertEquals(Optional.empty(), gi.indexBufferGetCurrentlyBound()); Assert.assertEquals(Optional.empty(), a1.getIndexBufferBound());
static JCGLArrayObjectType getArrayObject( final JCGLInterfaceGL33Type g) { final JCGLArrayBuffersType g_ab = g.getArrayBuffers(); final JCGLIndexBuffersType g_ib = g.getIndexBuffers(); final JCGLArrayObjectsType g_ao = g.getArrayObjects(); final JCGLIndexBufferType ib = g_ib.indexBufferAllocate( 3L, JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLArrayBufferUsableType a = g_ab.arrayBufferAllocate(3L * 4L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLArrayObjectBuilderType aob = g_ao.arrayObjectNewBuilder(); aob.setAttributeFloatingPoint( 0, a, 3, JCGLScalarType.TYPE_FLOAT, 3 * 4, 0L, false); aob.setIndexBuffer(ib); final JCGLArrayObjectType ao = g_ao.arrayObjectAllocate(aob); g_ao.arrayObjectUnbind(); return ao; }
JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); Assert.assertTrue(b.getMaximumVertexAttributes() >= 16); b.setIndexBuffer(ib); final JCGLArrayObjectType ai_0 = go.arrayObjectAllocate(b); final JCGLArrayObjectType ai_1 = go.arrayObjectAllocate(b); final JCGLArrayObjectType ai_2 = go.arrayObjectAllocate(b); Assert.assertEquals(go.arrayObjectGetCurrentlyBound(), ai_2); Assert.assertEquals(Optional.of(ib), ai_0.getIndexBufferBound()); Assert.assertEquals(Optional.of(ib), ai_1.getIndexBufferBound()); Assert.assertTrue(ib_refs.contains(go.arrayObjectGetDefault())); Assert.assertTrue(ib_refs.contains(ai_0)); Assert.assertTrue(ib_refs.contains(ai_1));
@Test public final void testArrayFromIdentities() { 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); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); Assert.assertTrue(b.getMaximumVertexAttributes() >= 16); b.setAttributeFloatingPointWithDivisor( 0, a, 4, JCGLScalarType.TYPE_FLOAT, 16, 0L, false, 23); b.setAttributeFloatingPoint( 1, a, 3, JCGLScalarType.TYPE_INT, 20, 4L, true); b.setAttributeIntegral( 2, a, 2, JCGLScalarIntegralType.TYPE_INT, 24, 8L); final JCGLArrayObjectType o = go.arrayObjectAllocate(b); final JCGLArrayObjectBuilderType c = go.arrayObjectNewBuilderFromObject(o); for (int index = 0; index < b.getMaximumVertexAttributes(); ++index) { Assert.assertEquals(b.getAttributeAt(index), c.getAttributeAt(index)); } }
JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); Assert.assertTrue(b.getMaximumVertexAttributes() >= 16); b.setIndexBuffer(i); final JCGLArrayObjectType ai = go.arrayObjectAllocate(b); Assert.assertFalse(ai.isDeleted()); Assert.assertEquals( Assert.assertEquals(2L, (long) i_refs.size()); Assert.assertTrue(i_refs.contains(ai)); Assert.assertTrue(i_refs.contains(go.arrayObjectGetDefault()));
@Override public void onInstanceSingleArrayStart( final R2InstanceSingleType i) { this.array_objects.arrayObjectBind(i.arrayObject()); }
@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); }
@Test public final void testIndexBufferBindIdentity() { final Interfaces i = this.getIndexBuffers("name"); final JCGLIndexBuffersType gi = i.getIndexBuffers(); final JCGLArrayObjectsType ga = i.getArrayObjects(); final JCGLArrayObjectUsableType a0 = ga.arrayObjectGetDefault(); final Set<JCGLReferableType> a0_refs = a0.references(); final JCGLIndexBufferType i0 = gi.indexBufferAllocate( 1000L, JCGLUnsignedType.TYPE_UNSIGNED_BYTE, JCGLUsageHint.USAGE_STATIC_DRAW); final Set<JCGLReferenceContainerType> i0_refs = i0.referringContainers(); Assert.assertEquals(Optional.of(i0), gi.indexBufferGetCurrentlyBound()); Assert.assertEquals(Optional.of(i0), a0.indexBufferBound()); Assert.assertEquals(1L, (long) a0_refs.size()); Assert.assertTrue(a0_refs.contains(i0)); Assert.assertEquals(1L, (long) i0_refs.size()); Assert.assertTrue(i0_refs.contains(a0)); gi.indexBufferUnbind(); Assert.assertEquals(a0, ga.arrayObjectGetCurrentlyBound()); Assert.assertEquals(Optional.empty(), gi.indexBufferGetCurrentlyBound()); Assert.assertEquals(Optional.empty(), a0.indexBufferBound()); Assert.assertEquals(0L, (long) a0_refs.size()); Assert.assertEquals(0L, (long) a0_refs.size()); Assert.assertEquals(0L, (long) i0_refs.size()); }
@Test public final void testArrayDeleteDeleted() { 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); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); Assert.assertTrue(b.getMaximumVertexAttributes() >= 16); b.setAttributeFloatingPoint( 0, a, 4, JCGLScalarType.TYPE_FLOAT, 16, 0L, false); final JCGLArrayObjectType ai = go.arrayObjectAllocate(b); go.arrayObjectDelete(ai); this.expected.expect(JCGLExceptionDeleted.class); go.arrayObjectDelete(ai); Assert.fail(); }
@Test public final void testArrayGetBadIndex() { final Interfaces i = this.getInterfaces("main"); final JCGLArrayObjectsType go = i.getArrayObjects(); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); Assert.assertTrue(b.getMaximumVertexAttributes() >= 16); this.expected.expect(RangeCheckException.class); b.getAttributeAt(-1); Assert.fail(); }
@Test public final void testDrawElementsInstancedOK() { final Interfaces i = this.getInterfaces("main"); final JCGLArrayObjectsType go = i.getArrayObjects(); final JCGLIndexBuffersType gi = i.getIndexBuffers(); final JCGLDrawType gd = i.getDraw(); final JCGLIndexBufferType ib = gi.indexBufferAllocate( 100L, JCGLUnsignedType.TYPE_UNSIGNED_BYTE, JCGLUsageHint.USAGE_STATIC_DRAW); gi.indexBufferUnbind(); final JCGLArrayObjectBuilderType b = go.arrayObjectNewBuilder(); b.setIndexBuffer(ib); final JCGLArrayObjectType ao = go.arrayObjectAllocate(b); gd.drawElementsInstanced(JCGLPrimitives.PRIMITIVE_POINTS, 1); }