static JCGLTexture2DType newTexture2D( final JCGLInterfaceGL33Type g, final JCGLTextureFormat f, final int w, final int h, final JCGLTextureUnitType u) { final JCGLTexturesType gt = g.textures(); final JCGLTexture2DType t = gt.texture2DAllocate( u, (long) w, (long) h, f, JCGLTextureWrapS.TEXTURE_WRAP_CLAMP_TO_EDGE, JCGLTextureWrapT.TEXTURE_WRAP_CLAMP_TO_EDGE, JCGLTextureFilterMinification.TEXTURE_FILTER_NEAREST, JCGLTextureFilterMagnification.TEXTURE_FILTER_NEAREST); final JCGLTexture2DUpdateType up = JCGLTextureUpdates.newUpdateReplacingAll2D(t); final ByteBuffer data = up.data(); for (int index = 0; index < data.capacity(); ++index) { data.put(index, (byte) 0); } gt.texture2DUpdate(u, up); gt.textureUnitUnbind(u); return t; } }
static JCGLFramebufferType newColorFramebuffer( final JCGLInterfaceGL33Type g, final JCGLTextureFormat f, final int w, final int h) { final JCGLTexturesType gt = g.textures(); final JCGLFramebuffersType fb = g.framebuffers(); final JCGLFramebufferBuilderType fbb = fb.framebufferNewBuilder(); final List<JCGLFramebufferColorAttachmentPointType> points = fb.framebufferGetColorAttachments(); final List<JCGLFramebufferDrawBufferType> buffers = fb.framebufferGetDrawBuffers(); final List<JCGLTextureUnitType> units = gt.textureGetUnits(); final JCGLTextureUnitType u = units.get(0); final JCGLTexture2DType t = newTexture2D(g, f, w, h, u); fbb.attachColorTexture2DAt(points.get(0), buffers.get(0), t); return fb.framebufferAllocate(fbb); }
final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits();
final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits();
final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits();
final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits();
@Test public final void testOutOfUnits2D_0() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); for (int index = 0; index < us.size(); ++index) { Assert.assertFalse(g_tx.textureUnitIsBound(us.get(index))); } final JCGLTextureUnitType u0 = us.get(0); final JCGLTexture2DType t0 = newTexture(g_tx, u0); g_tx.textureUnitUnbind(u0); final JCGLTexture2DType rt0 = t0; final JCGLTextureUnitAllocatorType alloc = this.newAllocator(2, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); for (int index = 0; index < us.size(); ++index) { final JCGLTextureUnitType ru = c_0.unitContextBindTexture2D(g_tx, rt0); Assert.assertTrue(g_tx.textureUnitIsBound(us.get(index))); } this.expected.expect(JCGLExceptionTextureUnitExhausted.class); c_0.unitContextNewWithReserved(1); }
@Test public final void testOutOfUnitsCube_1() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); for (int index = 0; index < us.size(); ++index) { Assert.assertFalse(g_tx.textureUnitIsBound(us.get(index))); } final JCGLTextureUnitType u0 = us.get(0); final JCGLTextureCubeType t0 = newTextureCube(g_tx, u0); g_tx.textureUnitUnbind(u0); final JCGLTextureCubeType rt0 = t0; final JCGLTextureUnitAllocatorType alloc = this.newAllocator(2, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); for (int index = 0; index < us.size(); ++index) { final JCGLTextureUnitType ru = c_0.unitContextBindTextureCube(g_tx, rt0); Assert.assertTrue(g_tx.textureUnitIsBound(us.get(index))); } this.expected.expect(JCGLExceptionTextureUnitExhausted.class); c_0.unitContextBindTextureCube(g_tx, rt0); }
@Test public final void testOutOfUnits2D_1() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); for (int index = 0; index < us.size(); ++index) { Assert.assertFalse(g_tx.textureUnitIsBound(us.get(index))); } final JCGLTextureUnitType u0 = us.get(0); final JCGLTexture2DType t0 = newTexture(g_tx, u0); g_tx.textureUnitUnbind(u0); final JCGLTexture2DType rt0 = t0; final JCGLTextureUnitAllocatorType alloc = this.newAllocator(2, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); for (int index = 0; index < us.size(); ++index) { final JCGLTextureUnitType ru = c_0.unitContextBindTexture2D(g_tx, rt0); Assert.assertTrue(g_tx.textureUnitIsBound(us.get(index))); } this.expected.expect(JCGLExceptionTextureUnitExhausted.class); c_0.unitContextBindTexture2D(g_tx, rt0); }
@Test public final void testOutOfUnitsCube_0() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); for (int index = 0; index < us.size(); ++index) { Assert.assertFalse(g_tx.textureUnitIsBound(us.get(index))); } final JCGLTextureUnitType u0 = us.get(0); final JCGLTextureCubeType t0 = newTextureCube(g_tx, u0); g_tx.textureUnitUnbind(u0); final JCGLTextureCubeType rt0 = t0; final JCGLTextureUnitAllocatorType alloc = this.newAllocator(2, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); for (int index = 0; index < us.size(); ++index) { final JCGLTextureUnitType ru = c_0.unitContextBindTextureCube(g_tx, rt0); Assert.assertTrue(g_tx.textureUnitIsBound(us.get(index))); } this.expected.expect(JCGLExceptionTextureUnitExhausted.class); c_0.unitContextNewWithReserved(1); }
@Test public final void testNewError0() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); final JCGLTextureUnitAllocatorType alloc = this.newAllocator(2, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); this.expected.expect(JCGLExceptionTextureUnitContextNotActive.class); c_root.unitContextNew(); }
@Test public final void testBindError2D() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); final JCGLTextureUnitAllocatorType alloc = this.newAllocator(2, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); final JCGLTextureUnitType u0 = us.get(0); final JCGLTexture2DType t0 = newTexture(g_tx, u0); g_tx.textureUnitUnbind(u0); c_0.unitContextFinish(g_tx); this.expected.expect(JCGLExceptionTextureUnitContextNotActive.class); c_0.unitContextBindTexture2D(g_tx, t0); }
@Test public final void testBindErrorCube() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); final JCGLTextureUnitAllocatorType alloc = this.newAllocator(2, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); final JCGLTextureUnitType u0 = us.get(0); final JCGLTextureCubeType t0 = newTextureCube(g_tx, u0); g_tx.textureUnitUnbind(u0); c_0.unitContextFinish(g_tx); this.expected.expect(JCGLExceptionTextureUnitContextNotActive.class); c_0.unitContextBindTextureCube(g_tx, t0); }
@Test public final void testFinishError0() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); final JCGLTextureUnitAllocatorType alloc = this.newAllocator(2, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); c_0.unitContextFinish(g_tx); this.expected.expect(JCGLExceptionTextureUnitContextNotActive.class); c_0.unitContextFinish(g_tx); }
@Test public final void testNewError1() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); final JCGLTextureUnitAllocatorType alloc = this.newAllocator(3, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); final JCGLTextureUnitContextType c_1 = c_0.unitContextNew(); this.expected.expect(JCGLExceptionTextureUnitContextNotActive.class); c_0.unitContextNew(); }
@Test public final void testUsageBigStackExceeded() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); final JCGLTextureUnitAllocatorType alloc = this.newAllocator(4, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); final JCGLTextureUnitContextType c_1 = c_0.unitContextNew(); final JCGLTextureUnitContextType c_2 = c_1.unitContextNew(); this.expected.expect(JCGLExceptionTextureUnitContextLimitReached.class); c_2.unitContextNew(); }
@Override public void onRender(final JCGLInterfaceGL33Type g) { final JCGLArrayObjectsType g_ao = g.arrayObjects(); final JCGLClearType g_c = g.clearing(); final JCGLDrawType g_d = g.drawing(); final JCGLShadersType g_sh = g.shaders(); final JCGLTexturesType g_tex = g.textures(); /* * Clear the window. */ g_c.clear(this.clear); /* * Activate the program, bind the created array object, draw a triangle. */ final List<JCGLTextureUnitType> units = g_tex.textureGetUnits(); final JCGLTextureUnitType u0 = units.get(0); g_tex.texture2DBind(u0, this.texture); g_sh.shaderActivateProgram(this.program); g_sh.shaderUniformPutTexture2DUnit(this.texture_uniform, u0); g_ao.arrayObjectBind(this.array_object); g_d.drawElements(JCGLPrimitives.PRIMITIVE_TRIANGLES); g_ao.arrayObjectUnbind(); g_sh.shaderDeactivateProgram(); }
@Test public final void testNew2DNotActive() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); final JCGLTextureUnitAllocatorType alloc = this.newAllocator(4, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); final JCGLTextureUnitContextType c_1 = c_0.unitContextNew(); this.expected.expect(JCGLExceptionTextureUnitContextNotActive.class); c_0.unitContextAllocateTexture2D( g_tx, 128L, 256L, JCGLTextureFormat.TEXTURE_FORMAT_DEPTH_16_2BPP, JCGLTextureWrapS.TEXTURE_WRAP_CLAMP_TO_EDGE, JCGLTextureWrapT.TEXTURE_WRAP_REPEAT, JCGLTextureFilterMinification.TEXTURE_FILTER_LINEAR, JCGLTextureFilterMagnification.TEXTURE_FILTER_NEAREST); }
@Test public final void testNewCubeNotActive() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); final JCGLTextureUnitAllocatorType alloc = this.newAllocator(4, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); final JCGLTextureUnitContextType c_1 = c_0.unitContextNew(); this.expected.expect(JCGLExceptionTextureUnitContextNotActive.class); c_0.unitContextAllocateTextureCube( g_tx, 128L, JCGLTextureFormat.TEXTURE_FORMAT_RGB_8_3BPP, JCGLTextureWrapR.TEXTURE_WRAP_REPEAT, JCGLTextureWrapS.TEXTURE_WRAP_CLAMP_TO_EDGE, JCGLTextureWrapT.TEXTURE_WRAP_REPEAT, JCGLTextureFilterMinification.TEXTURE_FILTER_LINEAR, JCGLTextureFilterMagnification.TEXTURE_FILTER_NEAREST); } }
@Test public final void testUsageBigStack() { final JCGLContextType gc = this.newGL33Context("main", 24, 8); final JCGLInterfaceGL33Type g33 = gc.contextGetGL33(); final JCGLTexturesType g_tx = g33.textures(); final List<JCGLTextureUnitType> us = g_tx.textureGetUnits(); final JCGLTextureUnitAllocatorType alloc = this.newAllocator(10, us); final JCGLTextureUnitContextParentType c_root = alloc.rootContext(); final JCGLTextureUnitContextType c_0 = c_root.unitContextNew(); final JCGLTextureUnitContextType c_1 = c_0.unitContextNew(); final JCGLTextureUnitContextType c_2 = c_1.unitContextNew(); final JCGLTextureUnitContextType c_3 = c_2.unitContextNew(); final JCGLTextureUnitContextType c_4 = c_3.unitContextNew(); final JCGLTextureUnitContextType c_5 = c_4.unitContextNew(); final JCGLTextureUnitContextType c_6 = c_5.unitContextNew(); final JCGLTextureUnitContextType c_7 = c_6.unitContextNew(); final JCGLTextureUnitContextType c_8 = c_7.unitContextNew(); c_8.unitContextFinish(g_tx); c_7.unitContextFinish(g_tx); c_6.unitContextFinish(g_tx); c_5.unitContextFinish(g_tx); c_4.unitContextFinish(g_tx); c_3.unitContextFinish(g_tx); c_2.unitContextFinish(g_tx); c_1.unitContextFinish(g_tx); c_0.unitContextFinish(g_tx); }