@Test public final void testLoadTextureIOError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLTexture2DType> f = loader.loadTexture( () -> { throw new UncheckedIOException(new IOException("IO failure")); }, JCGLTextureFormat.TEXTURE_FORMAT_RGB_8_3BPP, JCGLTextureWrapS.TEXTURE_WRAP_REPEAT, JCGLTextureWrapT.TEXTURE_WRAP_REPEAT, JCGLTextureFilterMinification.TEXTURE_FILTER_NEAREST, JCGLTextureFilterMagnification.TEXTURE_FILTER_NEAREST, (tex, data) -> JCGLTextureUpdates.newUpdateReplacingAll2D(tex) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
@Test public final void testLoadTextureIOError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLTexture2DType> f = loader.loadTexture( () -> { throw new UncheckedIOException(new IOException("IO failure")); }, JCGLTextureFormat.TEXTURE_FORMAT_RGB_8_3BPP, JCGLTextureWrapS.TEXTURE_WRAP_REPEAT, JCGLTextureWrapT.TEXTURE_WRAP_REPEAT, JCGLTextureFilterMinification.TEXTURE_FILTER_NEAREST, JCGLTextureFilterMagnification.TEXTURE_FILTER_NEAREST, (tex, data) -> JCGLTextureUpdates.newUpdateReplacingAll2D(tex) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
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 JCGLTexture2DType newTexture2D( final JCGLInterfaceGL33Type g, final JCGLTextureFormat f, final int w, final int h, final JCGLTextureUnitType u) { final JCGLTexturesType gt = g.getTextures(); 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.getData(); for (int index = 0; index < data.capacity(); ++index) { data.put(index, (byte) 0); } gt.texture2DUpdate(u, up); gt.textureUnitUnbind(u); return t; } }
JCGLTextureUpdates.newUpdateReplacingAll2D(ta); final ByteBuffer data = up.getData(); Assert.assertEquals(512L * 512L * 4L, (long) data.capacity());
JCGLTextureUpdates.newUpdateReplacingAll2D(ta); final ByteBuffer data = up.getData(); Assert.assertEquals(512L * 512L * 2L, (long) data.capacity());
JCGLTextureUpdates.newUpdateReplacingAll2D(ta); final ByteBuffer data = up.getData(); for (int index = 0; index < data.capacity(); ++index) {
JCGLTextureUpdates.newUpdateReplacingAll2D(ta); final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 4L, (long) data.capacity());
JCGLTextureUpdates.newUpdateReplacingAll2D(ta); final ByteBuffer data = up.data(); for (int index = 0; index < data.capacity(); ++index) {
JCGLTextureUpdates.newUpdateReplacingAll2D(ta); final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 3L, (long) data.capacity());
JCGLTextureUpdates.newUpdateReplacingAll2D(ta); final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 2L, (long) data.capacity());
JCGLTextureUpdates.newUpdateReplacingAll2D(ta); final ByteBuffer data = up.getData(); Assert.assertEquals(512L * 512L * 3L, (long) data.capacity());
JCGLTextureUpdates.newUpdateReplacingAll2D(ta); final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 3L, (long) data.capacity());
@Test public final void testTexture2DUpdateAllIdentities() { final JCGLTexturesType t = this.getTextures("main"); final List<JCGLTextureUnitType> us = t.textureGetUnits(); final JCGLTextureUnitType u = us.get(0); final JCGLTexture2DType ta = t.texture2DAllocate( u, 128L, 256L, JCGLTextureFormat.TEXTURE_FORMAT_RGBA_8_4BPP, JCGLTextureWrapS.TEXTURE_WRAP_REPEAT, JCGLTextureWrapT.TEXTURE_WRAP_REPEAT, JCGLTextureFilterMinification.TEXTURE_FILTER_LINEAR, JCGLTextureFilterMagnification.TEXTURE_FILTER_LINEAR); final JCGLTexture2DUpdateType up = JCGLTextureUpdates.newUpdateReplacingAll2D(ta); Assert.assertEquals(ta, up.texture()); final AreaL expected_area = AreasL.create(0L, 0L, 128L, 256L); Assert.assertEquals(expected_area, up.area()); final ByteBuffer data = up.data(); final long expected_size = 128L * 256L * 4L; Assert.assertEquals(expected_size, (long) data.capacity()); final UnsignedRangeInclusiveL expected_range = new UnsignedRangeInclusiveL(0L, expected_size - 1L); Assert.assertEquals(expected_range, up.dataUpdateRange()); }
@Override public JCGLTexture2DUpdateType getTextureUpdate2D( final JCGLTexture2DUsableType t, final JCGLTLTextureDataType data) { final JCGLTexture2DUpdateType u = JCGLTextureUpdates.newUpdateReplacingAll2D(t); final int tw = (int) t.textureGetWidth(); final int th = (int) t.textureGetHeight(); final long dw = data.getWidth(); final long dh = data.getHeight(); RangeCheck.checkGreaterEqualLong( (long) tw, "Texture width", dw, "Data width"); RangeCheck.checkGreaterEqualLong( (long) th, "Texture height", dh, "Data height"); JCGLTLTextureUpdateProvider.populate( t.textureGetFormat(), data, u.getData(), tw, th); return u; }
@Override public JCGLTexture2DUpdateType createTextureUpdate2D( final JCGLTexture2DUsableType t, final JCGLTLTextureDataType data) { final JCGLTexture2DUpdateType u = JCGLTextureUpdates.newUpdateReplacingAll2D(t); final int tw = (int) t.width(); final int th = (int) t.height(); final long dw = data.width(); final long dh = data.height(); RangeCheck.checkGreaterEqualLong( (long) tw, "Texture width", dw, "Data width"); RangeCheck.checkGreaterEqualLong( (long) th, "Texture height", dh, "Data height"); populate( t.format(), data, u.data(), tw, th); return u; }
JCGLTextureUpdates.newUpdateReplacingAll2D(ta);
JCGLTextureUpdates.newUpdateReplacingAll2D(rt.texture()); final JPRACursor2DType<JCGLR8Type> c = JPRACursor2DByteBufferedUnchecked.newCursor(
JCGLTextureUpdates.newUpdateReplacingAll2D(t); final ByteBuffer d = up.getData(); final JPRACursor2DType<JCGLRGB8Type> c =
JCGLTextureUpdates.newUpdateReplacingAll2D(t); final ByteBuffer d = up.getData(); final JPRACursor2DType<JCGLRGB8Type> c =