/**
   * 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;
  }
Exemple #2
0
 protected void fill(GOut g) {
   BGL gl = g.gl;
   Coord dim = new Coord(tdim, tdim);
   for (int i = 0; i < order.length; i++) {
     ByteBuffer data =
         ByteBuffer.wrap(
             TexI.convert(back, dim, new Coord(order[i][0] * tdim, order[i][1] * tdim), dim));
     gl.glTexImage2D(
         GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
         0,
         GL.GL_RGBA,
         tdim,
         tdim,
         0,
         GL.GL_RGBA,
         GL.GL_UNSIGNED_BYTE,
         data);
   }
 }