final int bpp = t.format().getBytesPerPixel(); final long size = width * height * (long) bpp;
RangeCheck.checkGreaterEqualLong(height, "Height", 2L, "Valid heights"); final long bytes = width * height * format.getBytesPerPixel(); FakeTextures.LOG.debug( "allocate {} {}x{} {} bytes",
this.width * this.height * (long) this.format.getBytesPerPixel(); final long full_size = 6L * face_size;
final int bpp = t.textureGetFormat().getBytesPerPixel(); final long size = width * height * (long) bpp;
final int bpp = t.textureGetFormat().getBytesPerPixel(); final long size = width * height * (long) bpp;
@Override public ByteBuffer texture2DGetImage( final JCGLTextureUnitType unit, final JCGLTexture2DUsableType texture) throws JCGLException { NullCheck.notNull(texture, "Texture"); NullCheck.notNull(unit, "Unit"); checkTextureUnit(this.context, unit); checkTexture2D(this.context, texture); final JCGLTextureFormat format = texture.format(); final LWJGL3TextureSpec spec = LWJGL3TextureSpecs.getTextureSpec(format); final AreaL area = AreaSizesL.area(texture.size()); final long width = area.width(); final long height = area.height(); final long data_size = width * height * (long) format.getBytesPerPixel(); final ByteBuffer data = ByteBuffer.allocateDirect(Math.toIntExact(data_size)); data.order(ByteOrder.nativeOrder()); this.texture2DBind(unit, texture); GL11.glGetTexImage( GL11.GL_TEXTURE_2D, 0, spec.getFormat(), spec.getType(), data); return data; }
this.width * this.height * (long) this.format.getBytesPerPixel(); this.byte_range = new UnsignedRangeInclusiveL(0L, byte_size - 1L);
@Test public final void testTexture2DGetImageIdentities() { final JCGLTexturesType t = this.getTextures("main"); final List<JCGLTextureUnitType> us = t.textureGetUnits(); final JCGLTextureUnitType u = us.get(0); for (final JCGLTextureFormat v : JCGLTextureFormat.values()) { final JCGLTexture2DType ta = t.texture2DAllocate( u, 128L, 256L, v, JCGLTextureWrapS.TEXTURE_WRAP_REPEAT, JCGLTextureWrapT.TEXTURE_WRAP_REPEAT, JCGLTextureFilterMinification.TEXTURE_FILTER_LINEAR, JCGLTextureFilterMagnification.TEXTURE_FILTER_LINEAR); Assert.assertTrue(t.textureUnitIsBound(u)); Assert.assertTrue(t.texture2DIsBound(u, ta)); final ByteBuffer i = t.texture2DGetImage(u, ta); Assert.assertEquals(ByteOrder.nativeOrder(), i.order()); Assert.assertEquals( 128L * 256L * (long) v.getBytesPerPixel(), (long) i.capacity()); Assert.assertFalse(ta.isDeleted()); t.texture2DDelete(ta); Assert.assertTrue(ta.isDeleted()); } }
FakeTexture2D( final FakeContext in_context, final int in_id, final JCGLTextureFilterMagnification in_filter_mag, final JCGLTextureFilterMinification in_filter_min, final JCGLTextureFormat in_format, final JCGLTextureWrapS in_wrap_s, final JCGLTextureWrapT in_wrap_t, final long in_width, final long in_height) { super(in_context, in_id); this.filter_mag = NullCheck.notNull(in_filter_mag); this.filter_min = NullCheck.notNull(in_filter_min); this.format = NullCheck.notNull(in_format); this.wrap_s = NullCheck.notNull(in_wrap_s); this.wrap_t = NullCheck.notNull(in_wrap_t); this.width = in_width; this.height = in_height; this.range_x = new UnsignedRangeInclusiveL(0L, in_width - 1L); this.range_y = new UnsignedRangeInclusiveL(0L, in_height - 1L); this.area = AreaInclusiveUnsignedL.of(this.range_x, this.range_y); final long size = this.width * this.height * (long) this.format.getBytesPerPixel(); this.byte_range = new UnsignedRangeInclusiveL(0L, size - 1L); this.data = ByteBuffer.allocate((int) size); }
final long width = area.width(); final long height = area.height(); final long size_butes = width * height * (long) format.getBytesPerPixel();
@Test public final void testTexture2DGetImageIdentities() { final JCGLTexturesType t = this.getTextures("main"); final List<JCGLTextureUnitType> us = t.textureGetUnits(); final JCGLTextureUnitType u = us.get(0); for (final JCGLTextureFormat v : JCGLTextureFormat.values()) { final JCGLTexture2DType ta = t.texture2DAllocate( u, 128L, 256L, v, JCGLTextureWrapS.TEXTURE_WRAP_REPEAT, JCGLTextureWrapT.TEXTURE_WRAP_REPEAT, JCGLTextureFilterMinification.TEXTURE_FILTER_LINEAR, JCGLTextureFilterMagnification.TEXTURE_FILTER_LINEAR); Assert.assertTrue(t.textureUnitIsBound(u)); Assert.assertTrue(t.texture2DIsBound(u, ta)); final ByteBuffer i = t.texture2DGetImage(u, ta); Assert.assertEquals(ByteOrder.nativeOrder(), i.order()); Assert.assertEquals( 128L * 256L * (long) v.getBytesPerPixel(), (long) i.capacity()); Assert.assertFalse(ta.isDeleted()); t.texture2DDelete(ta); Assert.assertTrue(ta.isDeleted()); } }
@Override public ByteBuffer texture2DGetImage( final JCGLTextureUnitType unit, final JCGLTexture2DUsableType texture) throws JCGLException { NullCheck.notNull(texture); NullCheck.notNull(unit); LWJGL3Textures.checkTextureUnit(this.context, unit); LWJGL3Textures.checkTexture2D(this.context, texture); final JCGLTextureFormat format = texture.textureGetFormat(); final LWJGL3TextureSpec spec = LWJGL3TextureSpecs.getTextureSpec(format); final AreaInclusiveUnsignedLType area = texture.textureGetArea(); final long width = area.getRangeX().getInterval(); final long height = area.getRangeY().getInterval(); final ByteBuffer data = ByteBuffer.allocateDirect( (int) (width * height * (long) format.getBytesPerPixel())); data.order(ByteOrder.nativeOrder()); this.texture2DBind(unit, texture); GL11.glGetTexImage( GL11.GL_TEXTURE_2D, 0, spec.getFormat(), spec.getType(), data); return data; }
Assert.assertEquals(ByteOrder.nativeOrder(), i.order()); Assert.assertEquals( 128L * 128L * (long) v.getBytesPerPixel(), (long) i.capacity());
Assert.assertEquals(ByteOrder.nativeOrder(), i.order()); Assert.assertEquals( 128L * 128L * (long) v.getBytesPerPixel(), (long) i.capacity());
@Override public ByteBuffer textureCubeGetImageLH( final JCGLTextureUnitType unit, final JCGLCubeMapFaceLH face, final JCGLTextureCubeUsableType texture) throws JCGLException { NullCheck.notNull(texture); NullCheck.notNull(face); NullCheck.notNull(unit); LWJGL3Textures.checkTextureUnit(this.context, unit); LWJGL3Textures.checkTextureCube(this.context, texture); final JCGLTextureFormat format = texture.textureGetFormat(); final LWJGL3TextureSpec spec = LWJGL3TextureSpecs.getTextureSpec(format); final AreaInclusiveUnsignedLType area = texture.textureGetArea(); final long width = area.getRangeX().getInterval(); final long height = area.getRangeY().getInterval(); final ByteBuffer data = ByteBuffer.allocateDirect( (int) (width * height * (long) format.getBytesPerPixel())); data.order(ByteOrder.nativeOrder()); final int gface = LWJGL3TypeConversions.cubeFaceToGL(face); this.textureCubeBind(unit, texture); GL11.glGetTexImage( gface, 0, spec.getFormat(), spec.getType(), data); return data; }
LWJGL3Texture2D( final LWJGL3Context in_context, final int in_id, final JCGLTextureFilterMagnification in_filter_mag, final JCGLTextureFilterMinification in_filter_min, final JCGLTextureFormat in_format, final JCGLTextureWrapS in_wrap_s, final JCGLTextureWrapT in_wrap_t, final long in_width, final long in_height) { super(in_context, in_id); this.filter_mag = NullCheck.notNull(in_filter_mag); this.filter_min = NullCheck.notNull(in_filter_min); this.format = NullCheck.notNull(in_format); this.wrap_s = NullCheck.notNull(in_wrap_s); this.wrap_t = NullCheck.notNull(in_wrap_t); this.width = in_width; this.height = in_height; this.range_x = new UnsignedRangeInclusiveL(0L, in_width - 1L); this.range_y = new UnsignedRangeInclusiveL(0L, in_height - 1L); this.area = AreaInclusiveUnsignedL.of(this.range_x, this.range_y); final long size = this.width * this.height * (long) this.format.getBytesPerPixel(); this.byte_range = new UnsignedRangeInclusiveL(0L, size - 1L); }
this.width * this.height * (long) this.format.getBytesPerPixel(); this.byte_range = new UnsignedRangeInclusiveL(0L, byte_size - 1L);
LWJGL3TextureCube( final LWJGL3Context in_context, final int in_id, final JCGLTextureFilterMagnification in_filter_mag, final JCGLTextureFilterMinification in_filter_min, final JCGLTextureFormat in_format, final JCGLTextureWrapR in_wrap_r, final JCGLTextureWrapS in_wrap_s, final JCGLTextureWrapT in_wrap_t, final long in_size) { super(in_context, in_id); this.filter_mag = NullCheck.notNull(in_filter_mag); this.filter_min = NullCheck.notNull(in_filter_min); this.format = NullCheck.notNull(in_format); this.wrap_r = NullCheck.notNull(in_wrap_r); this.wrap_s = NullCheck.notNull(in_wrap_s); this.wrap_t = NullCheck.notNull(in_wrap_t); this.width = in_size; this.height = in_size; this.range_x = new UnsignedRangeInclusiveL(0L, in_size - 1L); this.range_y = new UnsignedRangeInclusiveL(0L, in_size - 1L); this.area = AreaInclusiveUnsignedL.of(this.range_x, this.range_y); final long size = this.width * this.height * (long) this.format.getBytesPerPixel(); this.byte_range = new UnsignedRangeInclusiveL(0L, size - 1L); }
this.width * this.height * (long) this.format.getBytesPerPixel(); this.byte_range = new UnsignedRangeInclusiveL(0L, size - 1L);
final int bpp = texture.format().getBytesPerPixel(); copyBytes( bpp,