/** * Returns a ByteBuffer of BufferedImage data. Ensure BufferedImage is of 4BYTE_ABGR type. If * imageFormat is set to GL_RGBA, byte stream will be converted. */ private ByteBuffer getByteBuffer(final BufferedImage _image) { final DataBuffer buffer = _image.getRaster().getDataBuffer(); final int type = buffer.getDataType(); if (type == DataBuffer.TYPE_BYTE) { final byte[] data = ((DataBufferByte) buffer).getData(); if (imageFormat == GL3.GL_RGBA) { convertABGRtoRGBA(data); } return ByteBuffer.wrap(data); } System.out.println("Failed to determine DataBuffer type."); return null; }