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; } }
@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()); }
final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 4L, (long) data.capacity()); for (int index = 0; index < data.capacity(); ++index) {
@Test public final void testTexture2DUpdateAreaIdentities() { final JCGLTexturesType t = this.getTextures("main"); final List<JCGLTextureUnitType> us = t.textureGetUnits(); final JCGLTextureUnitType u = us.get(0); final JCGLTexture2DType ta = t.texture2DAllocate( u, 512L, 512L, JCGLTextureFormat.TEXTURE_FORMAT_R_8_1BPP, JCGLTextureWrapS.TEXTURE_WRAP_REPEAT, JCGLTextureWrapT.TEXTURE_WRAP_REPEAT, JCGLTextureFilterMinification.TEXTURE_FILTER_LINEAR, JCGLTextureFilterMagnification.TEXTURE_FILTER_LINEAR); final AreaL expected_area = AreasL.create(128L, 128L, 128L, 128L); final JCGLTexture2DUpdateType up = JCGLTextureUpdates.newUpdateReplacingArea2D(ta, expected_area); Assert.assertEquals(ta, up.texture()); Assert.assertEquals(expected_area, up.area()); final ByteBuffer data = up.data(); final long expected_size = 128L * 128L; Assert.assertEquals(expected_size, (long) data.capacity()); final UnsignedRangeInclusiveL expected_range = new UnsignedRangeInclusiveL(0L, expected_size - 1L); Assert.assertEquals(expected_range, up.dataUpdateRange()); }
final ByteBuffer data = up.data(); for (int index = 0; index < data.capacity(); ++index) { data.put(index, (byte) 0xff);
final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 3L, (long) data.capacity()); for (int index = 0; index < data.capacity(); ++index) {
final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 2L, (long) data.capacity()); for (int index = 0; index < data.capacity(); ++index) {
final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 2L, (long) data.capacity()); for (int index = 0; index < data.capacity(); ++index) { final ByteBuffer data = up.data(); Assert.assertEquals(128L * 128L * 2L, (long) data.capacity()); for (int index = 0; index < data.capacity(); index += 2) {
final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 3L, (long) data.capacity()); for (int index = 0; index < data.capacity(); ++index) { final ByteBuffer data = up.data(); Assert.assertEquals(128L * 128L * 3L, (long) data.capacity()); for (int index = 0; index < data.capacity(); index += 3) {
final ByteBuffer data = up.data(); Assert.assertEquals(512L * 512L * 4L, (long) data.capacity()); for (int index = 0; index < data.capacity(); ++index) { final ByteBuffer data = up.data(); Assert.assertEquals(128L * 128L * 4L, (long) data.capacity()); for (int index = 0; index < data.capacity(); index += 4) {
final ByteBuffer data = this.texture_update.data(); for (int index = 0; index < data.capacity(); ++index) { data.put(index, (byte) random.nextInt(0xff));
final ByteBuffer data = this.texture_update.data(); for (int index = 0; index < data.capacity(); ++index) { data.put(index, (byte) random.nextInt(0xff));
this.texture_update_cursor = JPRACursor2DByteBufferedChecked.newCursor( this.texture_update.data(), 64, 64, JCGLRGB8ByteBuffered::newValueWithOffset);
final ByteBuffer data = all.data(); for (int index = 0; index < data.capacity(); ++index) { data.put(index, (byte) 0xff);
@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; }
expected_contents = up.data(); for (int index = 0; index < expected_contents.capacity(); ++index) { expected_contents.put(index, (byte) (Math.random() * 0xff));
final ByteBuffer buffer = data.data();
final long source_min_y = update_area.minimumY(); final long source_height = update_area.height(); final ByteBuffer source_data = data.data();