@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;
}