Commits

Michael Ludwig committed 7129cb9

Add preliminary support for signed int values, and improve primitive access for unsigned and color primitives.

Comments (0)

Files changed (16)

ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/resource/BufferData.java

  * @author Michael Ludwig
  */
 public class BufferData {
+    public static double MAX_UBYTE = (double) Byte.MAX_VALUE - (double) Byte.MIN_VALUE;
+    public static double MAX_USHORT = (double) Short.MAX_VALUE - (double) Short.MIN_VALUE;
+    public static double MAX_UINT = (double) Integer.MAX_VALUE - (double) Integer.MIN_VALUE;
+
     /**
+     * <p>
      * DataType represents the supported set of primitive data types that can be
      * transfered to the GPU. Depending on how the data is to be used, some
      * types might be invalid (e.g. a VBO for indices cannot use FLOAT).
+     * <p>
+     * For the integral types, signed and unsigned data can be stored using the
+     * same data type. The most significant bit that stores sign information in
+     * Java is treated by the GPU like any other bit when an unsigned type is
+     * required.
      */
     public static enum DataType {
         /**
-         * Each primitive is a 4-byte float, and is stored internally as a Java
-         * float array (e.g. <code>float[]</code>).
+         * Primitive data is stored in a <code>float[]</code>.
          */
         FLOAT(4),
         /**
-         * <p>
-         * Each primitive is an unsigned 4-byte integer and is stored internally
-         * as a Java int array (e.g. <code>int[]</code>).
-         * <p>
-         * Although Java does not support unsigned ints, the GPU will interpret
-         * the 32-bit int as unsigned, so values must be assigned appropriately.
+         * Primitive data is stored in a <code>int[]</code>. When the data is
+         * used to encode colors for texture data or indices for rendering, the
+         * values are treated as unsigned 32-bit integers. You can use the data
+         * views provided by {@link BufferData#getTextureView()} and
+         * {@link BufferData#getUnsignedView()} to help with this.
          */
-        UNSIGNED_INT(4),
+        INT(4),
         /**
-         * <p>
-         * Each primitive is an unsigned 2-byte integer and should be stored
-         * internally as a Java short array (e.g. <code>short[]</code>).
-         * <p>
-         * Although Java does not support unsigned shorts, the GPU will
-         * interpret the 16-bit short as unsigned, so values must be assigned
-         * appropriately.
+         * Primitive data is stored in a <code>short[]</code>. When the data is
+         * used to encode colors for texture data or indices for rendering, the
+         * values are treated as unsigned 16-bit integers. You can use the data
+         * views provided by {@link BufferData#getTextureView()} and
+         * {@link BufferData#getUnsignedView()} to help with this.
          */
-        UNSIGNED_SHORT(2),
+        SHORT(2),
         /**
-         * <p>
-         * Each primitive is an unsigned byte and should be stored internally as
-         * a Java byte array (e.g. <code>byte[]</code>).
-         * <p>
-         * Although Java does not support unsigned bytes, the GPU will interpret
-         * the 8-bit byte as unsigned, so values must be assigned appropriately.
+         * Primitive data is stored in a <code>byte[]</code>. When the data is
+         * used to encode colors for texture data or indices for rendering, the
+         * values are treated as unsigned 8-bit integers. You can use the data
+         * views provided by {@link BufferData#getTextureView()} and
+         * {@link BufferData#getUnsignedView()} to help with this.
          */
-        UNSIGNED_BYTE(1);
+        BYTE(1);
 
         private final int byteCount;
 
     /**
      * <p>
      * Create a BufferData that uses the given int[] as its data store. The
-     * DataType of the BufferData will be UNSIGNED_INT, and its length will
-     * equal that of the array.
+     * DataType of the BufferData will be INT, and its length will equal that of
+     * the array.
      * <p>
-     * Any changes to the primitives in the array will affect the BufferData.
+     * Any changes to the values in the array will affect the BufferData.
      * Although the array reference can be changed later with
      * {@link #setData(int[])}, the length and type of the BufferData cannot.
      * 
         }
         this.data = data;
         length = data.length;
-        type = DataType.UNSIGNED_INT;
+        type = DataType.INT;
     }
 
     /**
      * <p>
      * Create a BufferData that uses the given short[] as its data store. The
-     * DataType of the BufferData will be UNSIGNED_SHORT, and its length will
-     * equal that of the array.
+     * DataType of the BufferData will be SHORT, and its length will equal that
+     * of the array.
      * <p>
      * Any changes to the primitives in the array will affect the BufferData.
      * Although the array reference can be changed later with
         }
         this.data = data;
         length = data.length;
-        type = DataType.UNSIGNED_SHORT;
+        type = DataType.SHORT;
     }
 
     /**
      * <p>
      * Create a BufferData that uses the given byte[] as its data store. The
-     * DataType of the BufferData will be UNSIGNED_BYTE, and its length will
-     * equal that of the array.
+     * DataType of the BufferData will be BYTE, and its length will equal that
+     * of the array.
      * <p>
      * Any changes to the primitives in the array will affect the BufferData.
      * Although the array reference can be changed later with
         }
         this.data = data;
         length = data.length;
-        type = DataType.UNSIGNED_BYTE;
+        type = DataType.BYTE;
     }
 
     /**
      * have the given DataType and length. These parameters will control the
      * type of array that can be assigned later when actual data is available.
      * <p>
-     * The constructor can be used when the actual buffer data never resides in
-     * memory but exists only on the GPU, such as with a framebuffer object.
+     * The constructor can be used when the actual data never resides in memory
+     * but exists only on the GPU, such as with an FBO used in render-to-texture
+     * features.
      * 
      * @param type The data type of this BufferData
      * @param length The length of the buffer data
      * Get a simple object whose identity mirrors the reference identity of this
      * BufferData object. The relationship
      * <code>(buffer1 == buffer2) == (buffer1.getKey() == buffer2.getKey())</code>
-     * will always be true. Basically, if two keys are the same instance, the
-     * producing buffer datas are the same.
+     * will always be true. If two keys are the same instance, the producing
+     * BufferData objects are the same instance.
      * <p>
      * This is primarily intended for Framework implementations, so they can
      * store the identify of a BufferData used by a resource without preventing
      * based on the data type of the buffer data.
      * <ul>
      * <li>If T = float[], then data type must be FLOAT</li>
-     * <li>If T = int[], then data type must be UNSIGNED_INT</li>
-     * <li>If T = short[], then data type must be UNSIGNED_SHORT</li>
-     * <li>If T = byte[], then data type must be UNSIGNED_BYTE</li>
+     * <li>If T = int[], then data type must be INT</li>
+     * <li>If T = short[], then data type must be SHORT</li>
+     * <li>If T = byte[], then data type must be BYTE</li>
      * </ul>
      * 
      * @return The backing data array, which might be null
     /**
      * Set the data this BufferData wraps to the given array. The given array
      * must have a length equal to the value returned by {@link #getLength()}.
-     * The data type of this BufferData must be UNSIGNED_INT.
+     * The data type of this BufferData must be INT.
      * 
      * @param data The new int array
-     * @throws IllegalStateException if this BufferData's type is not
-     *             UNSIGNED_INT
+     * @throws IllegalStateException if this BufferData's type is not INT
      * @throws IllegalArgumentException if the array length is not equal to the
      *             buffer's length
      */
     public void setData(int[] data) {
-        setData(data, (data == null ? length : data.length), DataType.UNSIGNED_INT);
+        setData(data, (data == null ? length : data.length), DataType.INT);
     }
 
     /**
      * Set the data this BufferData wraps to the given array. The given array
      * must have a length equal to the value returned by {@link #getLength()}.
-     * The data type of this BufferData must be UNSIGNED_SHORT.
+     * The data type of this BufferData must be SHORT.
      * 
      * @param data The new short array
-     * @throws IllegalStateException if this BufferData's type is not
-     *             UNSIGNED_SHORT
+     * @throws IllegalStateException if this BufferData's type is not SHORT
      * @throws IllegalArgumentException if the array length is not equal to the
      *             buffer's length
      */
     public void setData(short[] data) {
-        setData(data, (data == null ? length : data.length), DataType.UNSIGNED_SHORT);
+        setData(data, (data == null ? length : data.length), DataType.SHORT);
     }
 
     /**
      * Set the data this BufferData wraps to the given array. The given array
      * must have a length equal to the value returned by {@link #getLength()}.
-     * The data type of this BufferData must be UNSIGNED_BYTE.
+     * The data type of this BufferData must be BYTE.
      * 
      * @param data The new byte array
-     * @throws IllegalStateException if this BufferData's type is not
-     *             UNSIGNED_BYTE
+     * @throws IllegalStateException if this BufferData's type is not BYTE
      * @throws IllegalArgumentException if the array length is not equal to the
      *             buffer's length
      */
     public void setData(byte[] data) {
-        setData(data, (data == null ? length : data.length), DataType.UNSIGNED_BYTE);
+        setData(data, (data == null ? length : data.length), DataType.BYTE);
+    }
+
+    /**
+     * <p>
+     * Return a view over this data that will convert the data to and from
+     * doubles in the range of 0 to 1. This is intended for texture data storage
+     * where primitives hold color component values from 0 to 1.
+     * <p>
+     * For the integral data types, it treats the bits as unsigned integers and
+     * converts them to floating point according to the OpenGL spec for
+     * converting integers to floating points. Note that this is dependent on
+     * the number of bits in the data.
+     * <p>
+     * As an example, a byte data buffer can hold values from 0 to 255
+     * (unsigned), and during conversion, 0 becomes 0.0 and 255 becomes 1.0. An
+     * int data buffer would not consider 255 to be 1.0.
+     * <p>
+     * Note that this view assumes that each primitive represents a single color
+     * component, and will not function as expected when used with texture
+     * formats that pack multiple components into a single primitive, or are
+     * compressed
+     * 
+     * @see TextureFormat
+     * 
+     * @return A data view to make accessing/mutating data more convenient when
+     *         the data stores texture color data
+     */
+    public TextureDataView getTextureView() {
+        switch (type) {
+        case BYTE:
+            return new TextureDataView() {
+                @Override
+                public BufferData getBufferData() {
+                    return BufferData.this;
+                }
+
+                @Override
+                public double get(int index) {
+                    int unsigned = 0xff & ((byte[]) data)[index];
+                    return unsigned / MAX_UBYTE;
+                }
+
+                @Override
+                public void set(int index, double value) {
+                    int discrete = (int) (value * MAX_UBYTE);
+                    ((byte[]) data)[index] = (byte) discrete;
+                }
+            };
+        case SHORT:
+            return new TextureDataView() {
+                @Override
+                public BufferData getBufferData() {
+                    return BufferData.this;
+                }
+
+                @Override
+                public double get(int index) {
+                    int unsigned = 0xffff & ((short[]) data)[index];
+                    return unsigned / MAX_USHORT;
+                }
+
+                @Override
+                public void set(int index, double value) {
+                    int discrete = (int) (value * MAX_USHORT);
+                    ((short[]) data)[index] = (short) discrete;
+                }
+            };
+        case INT:
+            return new TextureDataView() {
+                @Override
+                public BufferData getBufferData() {
+                    return BufferData.this;
+                }
+
+                @Override
+                public double get(int index) {
+                    long unsigned = 0xffffffffL & ((int[]) data)[index];
+                    return unsigned / MAX_UINT;
+                }
+
+                @Override
+                public void set(int index, double value) {
+                    long discrete = (long) (value * MAX_UINT);
+                    ((int[]) data)[index] = (int) discrete;
+                }
+            };
+        case FLOAT:
+            return new TextureDataView() {
+                @Override
+                public BufferData getBufferData() {
+                    return BufferData.this;
+                }
+
+                @Override
+                public double get(int index) {
+                    return ((float[]) data)[index];
+                }
+
+                @Override
+                public void set(int index, double value) {
+                    ((float[]) data)[index] = (float) value;
+                }
+            };
+        default:
+            throw new UnsupportedOperationException("Unsupported data type");
+        }
+    }
+
+    /**
+     * <p>
+     * Return a view over the buffer data that automatically converts the signed
+     * Java primitives into <code>long</code>'s. By converting them to 64-bits,
+     * all values for unsigned bytes, shorts, and longs can be properly
+     * represented. The view correctly casts and masks values coming into the
+     * buffer so that you can easily store unsigned integers as well.
+     * <p>
+     * As an example, if a byte data buffer held the value
+     * <code>(byte) -1</code>, the view would report a value of <code>255</code>
+     * , which is the maximum unsigned byte value and has the same bit
+     * representation as a signed -1.
+     * 
+     * @return A view over 'unsigned' data
+     * @throws IllegalStateException if the buffer is a float buffer, because
+     *             that cannot become an unsigned integer
+     */
+    public UnsignedDataView getUnsignedView() {
+        switch (type) {
+        case BYTE:
+            return new UnsignedDataView() {
+                @Override
+                public BufferData getBufferData() {
+                    return BufferData.this;
+                }
+
+                @Override
+                public long get(int index) {
+                    return 0xffL & ((byte[]) data)[index];
+                }
+
+                @Override
+                public void set(int index, long value) {
+                    ((byte[]) data)[index] = (byte) value;
+                }
+            };
+        case SHORT:
+            return new UnsignedDataView() {
+                @Override
+                public BufferData getBufferData() {
+                    return BufferData.this;
+                }
+
+                @Override
+                public long get(int index) {
+                    return 0xffffL & ((short[]) data)[index];
+                }
+
+                @Override
+                public void set(int index, long value) {
+                    ((short[]) data)[index] = (short) value;
+                }
+            };
+        case INT:
+            return new UnsignedDataView() {
+                @Override
+                public BufferData getBufferData() {
+                    return BufferData.this;
+                }
+
+                @Override
+                public long get(int index) {
+                    return 0xffffffffL & ((int[]) data)[index];
+                }
+
+                @Override
+                public void set(int index, long value) {
+                    ((int[]) data)[index] = (int) value;
+                }
+            };
+        case FLOAT:
+            throw new IllegalStateException("UnsignedDataView only supports BYTE, SHORT, and INT types");
+        default:
+            throw new UnsupportedOperationException("Unsupported data type");
+        }
     }
 
     private void setData(Object array, int arrayLength, DataType expectedType) {

ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/resource/TextureDataView.java

+package com.ferox.resource;
+
+public interface TextureDataView {
+    public BufferData getBufferData();
+
+    public double get(int index);
+
+    public void set(int index, double value);
+}

ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/resource/TextureFormat.java

  * blue, 7-0 are alpha).</li>
  * <li>XYZ_DXT?: The format represents texture data in a specific DXT
  * compression algorithm. At the moment, only DXT1, DXT3 and DXT5 formats are
- * supported for RGB and RGBA textures. The data type must be UNSIGNED_BYTE and
- * have dimensions a multiple of 4.</li>
+ * supported for RGB and RGBA textures. The data type must be BYTE and have
+ * dimensions a multiple of 4.</li>
  * <li>XYZ_FLOAT: Formats with this are treated identically to the equivalent
  * XYZ with a required type of FLOAT, except that when stored on the graphics
  * cards, the floating point values are NOT clamped.</li>
  * @author Michael Ludwig
  */
 public enum TextureFormat {
-    RGBA(null, 4, 4, true), RGBA_4444(DataType.UNSIGNED_SHORT, 1, 4, true, true),
-    RGBA_8888(DataType.UNSIGNED_INT, 1, 4, true, true),
-    RGBA_5551(DataType.UNSIGNED_SHORT, 1, 4, true, true), RGBA_FLOAT(DataType.FLOAT, 4,
-                                                                     4, true),
+    RGBA(null, 4, 4, true), RGBA_4444(DataType.SHORT, 1, 4, true, true),
+    RGBA_8888(DataType.INT, 1, 4, true, true),
+    RGBA_5551(DataType.SHORT, 1, 4, true, true), RGBA_FLOAT(DataType.FLOAT, 4, 4, true),
 
-    RGBA_DXT1(DataType.UNSIGNED_BYTE, -1, 4, true), RGBA_DXT3(DataType.UNSIGNED_BYTE, -1,
-                                                              4, true),
-    RGBA_DXT5(DataType.UNSIGNED_BYTE, -1, 4, true),
+    RGBA_DXT1(DataType.BYTE, -1, 4, true), RGBA_DXT3(DataType.BYTE, -1, 4, true),
+    RGBA_DXT5(DataType.BYTE, -1, 4, true),
 
-    BGRA(null, 4, 4, true), BGRA_4444(DataType.UNSIGNED_SHORT, 1, 4, true, true),
-    BGRA_8888(DataType.UNSIGNED_INT, 1, 4, true, true),
-    BGRA_5551(DataType.UNSIGNED_SHORT, 1, 4, true, true),
+    BGRA(null, 4, 4, true), BGRA_4444(DataType.SHORT, 1, 4, true, true),
+    BGRA_8888(DataType.INT, 1, 4, true, true),
+    BGRA_5551(DataType.SHORT, 1, 4, true, true),
 
-    ARGB_4444(DataType.UNSIGNED_SHORT, 1, 4, true, true),
-    ARGB_1555(DataType.UNSIGNED_SHORT, 1, 4, true, true),
-    ARGB_8888(DataType.UNSIGNED_INT, 1, 4, true, true),
+    ARGB_4444(DataType.SHORT, 1, 4, true, true), ARGB_1555(DataType.SHORT, 1, 4, true,
+                                                           true), ARGB_8888(DataType.INT,
+                                                                            1, 4, true,
+                                                                            true),
 
-    ABGR_4444(DataType.UNSIGNED_SHORT, 1, 4, true, true),
-    ABGR_1555(DataType.UNSIGNED_SHORT, 1, 4, true, true),
-    ABGR_8888(DataType.UNSIGNED_INT, 1, 4, true, true),
+    ABGR_4444(DataType.SHORT, 1, 4, true, true), ABGR_1555(DataType.SHORT, 1, 4, true,
+                                                           true), ABGR_8888(DataType.INT,
+                                                                            1, 4, true,
+                                                                            true),
 
-    RGB(null, 3, 3, false), RGB_565(DataType.UNSIGNED_SHORT, 1, 3, false, true),
-    RGB_FLOAT(DataType.FLOAT, 3, 3, false),
-    RGB_DXT1(DataType.UNSIGNED_BYTE, -1, 3, false),
+    RGB(null, 3, 3, false), RGB_565(DataType.SHORT, 1, 3, false, true),
+    RGB_FLOAT(DataType.FLOAT, 3, 3, false), RGB_DXT1(DataType.BYTE, -1, 3, false),
 
-    BGR(null, 3, 3, false), BGR_565(DataType.UNSIGNED_SHORT, 1, 3, false, true),
+    BGR(null, 3, 3, false), BGR_565(DataType.SHORT, 1, 3, false, true),
 
     R(null, 1, 1, false), R_FLOAT(DataType.FLOAT, 1, 1, false), RG(null, 2, 2, false),
     RG_FLOAT(DataType.FLOAT, 2, 2, false),
 
-    DEPTH(DataType.UNSIGNED_INT, 1, 1, false), DEPTH_FLOAT(DataType.FLOAT, 1, 1, false),
-    DEPTH_STENCIL(DataType.UNSIGNED_INT, 1, 1, false);
+    DEPTH(DataType.INT, 1, 1, false), DEPTH_FLOAT(DataType.FLOAT, 1, 1, false),
+    DEPTH_STENCIL(DataType.INT, 1, 1, false);
 
     private DataType type;
     private boolean hasAlpha, isPacked;

ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/resource/UnsignedDataView.java

+package com.ferox.resource;
+
+public interface UnsignedDataView {
+    public BufferData getBufferData();
+
+    public long get(int index);
+
+    public void set(int index, long value);
+}

ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/util/texture/DDSTexture.java

         DXGI_FORMAT_R32G32B32_SINT,
         DXGI_FORMAT_R16G16B16A16_TYPELESS,
         DXGI_FORMAT_R16G16B16A16_FLOAT,
-        DXGI_FORMAT_R16G16B16A16_UNORM(DataType.UNSIGNED_SHORT, TextureFormat.RGBA),
+        DXGI_FORMAT_R16G16B16A16_UNORM(DataType.SHORT, TextureFormat.RGBA),
         DXGI_FORMAT_R16G16B16A16_UINT,
         DXGI_FORMAT_R16G16B16A16_SNORM,
         DXGI_FORMAT_R16G16B16A16_SINT,
         DXGI_FORMAT_R10G10B10A2_UINT,
         DXGI_FORMAT_R11G11B10_FLOAT,
         DXGI_FORMAT_R8G8B8A8_TYPELESS,
-        DXGI_FORMAT_R8G8B8A8_UNORM(DataType.UNSIGNED_INT, TextureFormat.RGBA_8888),
-        DXGI_FORMAT_R8G8B8A8_UNORM_SRGB(DataType.UNSIGNED_INT, TextureFormat.RGBA_8888),
+        DXGI_FORMAT_R8G8B8A8_UNORM(DataType.INT, TextureFormat.RGBA_8888),
+        DXGI_FORMAT_R8G8B8A8_UNORM_SRGB(DataType.INT, TextureFormat.RGBA_8888),
         DXGI_FORMAT_R8G8B8A8_UINT,
         DXGI_FORMAT_R8G8B8A8_SNORM,
         DXGI_FORMAT_R8G8B8A8_SINT,
         DXGI_FORMAT_R16G16_TYPELESS,
         DXGI_FORMAT_R16G16_FLOAT,
-        DXGI_FORMAT_R16G16_UNORM(DataType.UNSIGNED_SHORT, TextureFormat.RG),
+        DXGI_FORMAT_R16G16_UNORM(DataType.SHORT, TextureFormat.RG),
         DXGI_FORMAT_R16G16_UINT,
         DXGI_FORMAT_R16G16_SNORM,
         DXGI_FORMAT_R16G16_SINT,
         DXGI_FORMAT_R32_TYPELESS,
         DXGI_FORMAT_D32_FLOAT(DataType.FLOAT, TextureFormat.DEPTH),
-        // not the best mapping, but it works
         DXGI_FORMAT_R32_FLOAT(DataType.FLOAT, TextureFormat.R_FLOAT),
         DXGI_FORMAT_R32_UINT,
         DXGI_FORMAT_R32_SINT,
         DXGI_FORMAT_R24_UNORM_X8_TYPELESS,
         DXGI_FORMAT_X24_TYPELESS_G8_UINT,
         DXGI_FORMAT_R8G8_TYPELESS,
-        // not the best mapping, but it works
-        DXGI_FORMAT_R8G8_UNORM(DataType.UNSIGNED_BYTE, TextureFormat.RG),
-        DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_R8G8_SNORM, DXGI_FORMAT_R8G8_SINT,
-        DXGI_FORMAT_R16_TYPELESS, DXGI_FORMAT_R16_FLOAT,
-        DXGI_FORMAT_D16_UNORM(DataType.UNSIGNED_SHORT, TextureFormat.DEPTH),
-        DXGI_FORMAT_R16_UNORM(DataType.UNSIGNED_SHORT, TextureFormat.R),
-        DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16_SNORM, DXGI_FORMAT_R16_SINT,
-        DXGI_FORMAT_R8_TYPELESS, DXGI_FORMAT_R8_UNORM(DataType.UNSIGNED_BYTE,
-                                                      TextureFormat.R),
-        DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8_SNORM, DXGI_FORMAT_R8_SINT,
-        DXGI_FORMAT_A8_UNORM(DataType.UNSIGNED_BYTE, TextureFormat.R),
-        DXGI_FORMAT_R1_UNORM, DXGI_FORMAT_R9G9B9E5_SHAREDEXP,
-        DXGI_FORMAT_R8G8_B8G8_UNORM, DXGI_FORMAT_G8R8_G8B8_UNORM,
-        DXGI_FORMAT_BC1_TYPELESS, DXGI_FORMAT_BC1_UNORM(DataType.UNSIGNED_BYTE,
-                                                        TextureFormat.RGB_DXT1),
-        DXGI_FORMAT_BC1_UNORM_SRGB(DataType.UNSIGNED_BYTE, TextureFormat.RGBA_DXT1),
-        DXGI_FORMAT_BC2_TYPELESS, DXGI_FORMAT_BC2_UNORM(DataType.UNSIGNED_BYTE,
-                                                        TextureFormat.RGBA_DXT3),
-        DXGI_FORMAT_BC2_UNORM_SRGB(DataType.UNSIGNED_BYTE, TextureFormat.RGBA_DXT3),
-        DXGI_FORMAT_BC3_TYPELESS, DXGI_FORMAT_BC3_UNORM(DataType.UNSIGNED_BYTE,
-                                                        TextureFormat.RGBA_DXT5),
-        DXGI_FORMAT_BC3_UNORM_SRGB(DataType.UNSIGNED_BYTE, TextureFormat.RGBA_DXT5),
-        DXGI_FORMAT_BC4_TYPELESS, DXGI_FORMAT_BC4_UNORM, DXGI_FORMAT_BC4_SNORM,
-        DXGI_FORMAT_BC5_TYPELESS, DXGI_FORMAT_BC5_UNORM, DXGI_FORMAT_BC5_SNORM,
-        DXGI_FORMAT_B5G6R5_UNORM(DataType.UNSIGNED_SHORT, TextureFormat.BGR_565),
-        DXGI_FORMAT_B5G5R5A1_UNORM(DataType.UNSIGNED_SHORT, TextureFormat.BGRA_5551),
-        DXGI_FORMAT_B8G8R8A8_UNORM(DataType.UNSIGNED_INT, TextureFormat.BGRA_8888),
+        DXGI_FORMAT_R8G8_UNORM(DataType.BYTE, TextureFormat.RG),
+        DXGI_FORMAT_R8G8_UINT,
+        DXGI_FORMAT_R8G8_SNORM,
+        DXGI_FORMAT_R8G8_SINT,
+        DXGI_FORMAT_R16_TYPELESS,
+        DXGI_FORMAT_R16_FLOAT,
+        DXGI_FORMAT_D16_UNORM(DataType.SHORT, TextureFormat.DEPTH),
+        DXGI_FORMAT_R16_UNORM(DataType.SHORT, TextureFormat.R),
+        DXGI_FORMAT_R16_UINT,
+        DXGI_FORMAT_R16_SNORM,
+        DXGI_FORMAT_R16_SINT,
+        DXGI_FORMAT_R8_TYPELESS,
+        DXGI_FORMAT_R8_UNORM(DataType.BYTE, TextureFormat.R),
+        DXGI_FORMAT_R8_UINT,
+        DXGI_FORMAT_R8_SNORM,
+        DXGI_FORMAT_R8_SINT,
+        DXGI_FORMAT_A8_UNORM(DataType.BYTE, TextureFormat.R),
+        DXGI_FORMAT_R1_UNORM,
+        DXGI_FORMAT_R9G9B9E5_SHAREDEXP,
+        DXGI_FORMAT_R8G8_B8G8_UNORM,
+        DXGI_FORMAT_G8R8_G8B8_UNORM,
+        DXGI_FORMAT_BC1_TYPELESS,
+        DXGI_FORMAT_BC1_UNORM(DataType.BYTE, TextureFormat.RGB_DXT1),
+        DXGI_FORMAT_BC1_UNORM_SRGB(DataType.BYTE, TextureFormat.RGBA_DXT1),
+        DXGI_FORMAT_BC2_TYPELESS,
+        DXGI_FORMAT_BC2_UNORM(DataType.BYTE, TextureFormat.RGBA_DXT3),
+        DXGI_FORMAT_BC2_UNORM_SRGB(DataType.BYTE, TextureFormat.RGBA_DXT3),
+        DXGI_FORMAT_BC3_TYPELESS,
+        DXGI_FORMAT_BC3_UNORM(DataType.BYTE, TextureFormat.RGBA_DXT5),
+        DXGI_FORMAT_BC3_UNORM_SRGB(DataType.BYTE, TextureFormat.RGBA_DXT5),
+        DXGI_FORMAT_BC4_TYPELESS,
+        DXGI_FORMAT_BC4_UNORM,
+        DXGI_FORMAT_BC4_SNORM,
+        DXGI_FORMAT_BC5_TYPELESS,
+        DXGI_FORMAT_BC5_UNORM,
+        DXGI_FORMAT_BC5_SNORM,
+        DXGI_FORMAT_B5G6R5_UNORM(DataType.SHORT, TextureFormat.BGR_565),
+        DXGI_FORMAT_B5G5R5A1_UNORM(DataType.SHORT, TextureFormat.BGRA_5551),
+        DXGI_FORMAT_B8G8R8A8_UNORM(DataType.INT, TextureFormat.BGRA_8888),
         DXGI_FORMAT_B8G8R8X8_UNORM;
 
         boolean supported;
                                                                       0xff00,
                                                                       0xff,
                                                                       0,
-                                                                      DataType.UNSIGNED_BYTE,
+                                                                      DataType.BYTE,
                                                                       TextureFormat.RGB),
                                                           new DDPFMap(24,
                                                                       0xff,
                                                                       0xff00,
                                                                       0xff0000,
                                                                       0,
-                                                                      DataType.UNSIGNED_BYTE,
+                                                                      DataType.BYTE,
                                                                       TextureFormat.BGR),
                                                           new DDPFMap(16,
                                                                       0xf800,
                                                                       0x7e0,
                                                                       0x1f,
                                                                       0,
-                                                                      DataType.UNSIGNED_BYTE,
+                                                                      DataType.BYTE,
                                                                       TextureFormat.RGB_565),
                                                           new DDPFMap(16,
                                                                       0x1f,
                                                                       0x7e0,
                                                                       0xf800,
                                                                       0,
-                                                                      DataType.UNSIGNED_BYTE,
+                                                                      DataType.BYTE,
                                                                       TextureFormat.BGR_565)};
 
     // Supported RGBA types
                                                                        0xff00,
                                                                        0xff,
                                                                        0xff000000,
-                                                                       DataType.UNSIGNED_INT,
+                                                                       DataType.INT,
                                                                        TextureFormat.ARGB_8888),
                                                            new DDPFMap(32,
                                                                        0xff000000,
                                                                        0xff0000,
                                                                        0xff00,
                                                                        0x000000ff,
-                                                                       DataType.UNSIGNED_INT,
+                                                                       DataType.INT,
                                                                        TextureFormat.RGBA_8888),
                                                            new DDPFMap(32,
                                                                        0xff,
                                                                        0xff00,
                                                                        0xff0000,
                                                                        0xff000000,
-                                                                       DataType.UNSIGNED_INT,
+                                                                       DataType.INT,
                                                                        TextureFormat.ABGR_8888),
                                                            new DDPFMap(32,
                                                                        0xff00,
                                                                        0xff0000,
                                                                        0xff000000,
                                                                        0xff,
-                                                                       DataType.UNSIGNED_INT,
+                                                                       DataType.INT,
                                                                        TextureFormat.BGRA_8888)};
 
     // Supported Luminance types
                                                                     0,
                                                                     0,
                                                                     0,
-                                                                    DataType.UNSIGNED_BYTE,
+                                                                    DataType.BYTE,
                                                                     TextureFormat.R)};
 
     // Supported Luminance/Alpha types
                                                                      0,
                                                                      0,
                                                                      0xff00,
-                                                                     DataType.UNSIGNED_BYTE,
+                                                                     DataType.BYTE,
                                                                      TextureFormat.RG)};
 
     // Supported Alpha types
                                                                     0,
                                                                     0,
                                                                     0xff,
-                                                                    DataType.UNSIGNED_BYTE,
+                                                                    DataType.BYTE,
                                                                     TextureFormat.R)};
 
     /*
             }
         } else if (isFlagSet(header.pixelFormat.flags, DDPF_FOURCC)) {
             // interpret the FOURCC flag. Currently only supports DXT1, DXT3, and DXT5
-            type = DataType.UNSIGNED_BYTE;
+            type = DataType.BYTE;
             format = null;
 
             if (header.pixelFormat.fourCC == FOURCC_DXT1) {
             }
             return new BufferData(data);
         }
-        case UNSIGNED_INT: {
+        case INT: {
             int[] data = new int[image.length / 4];
             for (int i = 0; i < data.length; i++) {
                 data[i] = bytesToInt(image, i << 2);
             }
             return new BufferData(data);
         }
-        case UNSIGNED_SHORT: {
+        case SHORT: {
             short[] data = new short[image.length / 2];
             for (int i = 0; i < data.length; i++) {
                 data[i] = bytesToShort(image, i << 1);
             }
             return new BufferData(data);
         }
-        case UNSIGNED_BYTE: {
+        case BYTE: {
             return new BufferData(image);
         }
         }

ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/util/texture/TextureLoader.java

         g2.dispose();
 
         BufferData data;
-        if (im.type.equals(DataType.UNSIGNED_BYTE)) {
+        if (im.type.equals(DataType.BYTE)) {
             byte[] rd = ((DataBufferByte) formatted.getRaster().getDataBuffer()).getData();
             data = new BufferData(rd);
         } else { // assumes ShortBuffer
         g2.dispose();
 
         BufferData data;
-        if (im.type.equals(DataType.UNSIGNED_BYTE)) {
+        if (im.type.equals(DataType.BYTE)) {
             byte[] rd = ((DataBufferByte) formatted.getRaster().getDataBuffer()).getData();
             data = new BufferData(rd);
         } else { // assumes ShortBuffer
         g2.dispose();
 
         BufferData data;
-        if (im.type.equals(DataType.UNSIGNED_BYTE)) {
+        if (im.type.equals(DataType.BYTE)) {
             byte[] rd = ((DataBufferByte) faceStore.getRaster().getDataBuffer()).getData();
             data = new BufferData(rd);
         } else { // assumes ShortBuffer
                 data = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width,
                                                       height, 3, null);
 
-                type = DataType.UNSIGNED_BYTE;
+                type = DataType.BYTE;
                 format = TextureFormat.RGB;
                 break;
             case BufferedImage.TYPE_USHORT_GRAY:
                 data = Raster.createInterleavedRaster(DataBuffer.TYPE_USHORT, width,
                                                       height, 1, null);
 
-                type = DataType.UNSIGNED_SHORT;
+                type = DataType.SHORT;
                 format = TextureFormat.R;
                 break;
             case BufferedImage.TYPE_BYTE_GRAY:
                 data = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width,
                                                       height, 1, null);
 
-                type = DataType.UNSIGNED_BYTE;
+                type = DataType.BYTE;
                 format = TextureFormat.R;
                 break;
             default:
                 data = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width,
                                                       height, 4, null);
 
-                type = DataType.UNSIGNED_BYTE;
+                type = DataType.BYTE;
                 format = TextureFormat.RGBA;
                 break;
             }

ferox-renderer/ferox-renderer-impl/src/main/java/com/ferox/renderer/impl/BufferUtil.java

      * @return A new direct IntBuffer
      */
     public static IntBuffer newIntBuffer(int size) {
-        return newByteBuffer(size * DataType.UNSIGNED_INT.getByteCount()).asIntBuffer();
+        return newByteBuffer(size * DataType.INT.getByteCount()).asIntBuffer();
     }
 
     /**
      * @return A new direct ShortBuffer
      */
     public static ShortBuffer newShortBuffer(int size) {
-        return newByteBuffer(size * DataType.UNSIGNED_SHORT.getByteCount()).asShortBuffer();
+        return newByteBuffer(size * DataType.SHORT.getByteCount()).asShortBuffer();
     }
 
     /**
         switch (type) {
         case FLOAT:
             return newFloatBuffer(size);
-        case UNSIGNED_BYTE:
+        case BYTE:
             return newByteBuffer(size);
-        case UNSIGNED_INT:
+        case INT:
             return newIntBuffer(size);
-        case UNSIGNED_SHORT:
+        case SHORT:
             return newShortBuffer(size);
         default:
             throw new IllegalArgumentException();
         case FLOAT:
             float[] fd = data.getArray();
             return (fd == null ? newFloatBuffer(data.getLength()) : newFloatBuffer(fd));
-        case UNSIGNED_BYTE:
+        case BYTE:
             byte[] bd = data.getArray();
             return (bd == null ? newByteBuffer(data.getLength()) : newByteBuffer(bd));
-        case UNSIGNED_SHORT:
+        case SHORT:
             short[] sd = data.getArray();
             return (sd == null ? newShortBuffer(data.getLength()) : newShortBuffer(sd));
-        case UNSIGNED_INT:
+        case INT:
             int[] id = data.getArray();
             return (id == null ? newIntBuffer(data.getLength()) : newIntBuffer(id));
         default:
      * Return the Class of Buffer that will be created by
      * {@link #newBuffer(BufferData)} and {@link #newBuffer(DataType, int)}
      * based on the given DataType. A DataType of FLOAT creates FloatBuffers; a
-     * DataType of UNSIGNED_BYTE creates ByteBuffers; a type of UNSIGNED_INT
-     * creates IntBuffers; and a type of UNSIGNED_SHORT creates ShortBuffers.
+     * DataType of BYTE creates ByteBuffers; a type of INT creates IntBuffers;
+     * and a type of SHORT creates ShortBuffers.
      * 
      * @param type The DataType
      * @return The class of buffer matching the given DataType
         switch (type) {
         case FLOAT:
             return FloatBuffer.class;
-        case UNSIGNED_BYTE:
+        case BYTE:
             return ByteBuffer.class;
-        case UNSIGNED_INT:
+        case INT:
             return IntBuffer.class;
-        case UNSIGNED_SHORT:
+        case SHORT:
             return ShortBuffer.class;
         }
 

ferox-renderer/ferox-renderer-impl/src/main/java/com/ferox/renderer/impl/drivers/AbstractVertexBufferObjectResourceDriver.java

                 case FLOAT:
                     ((FloatBuffer) result).put(data.<float[]> getArray());
                     break;
-                case UNSIGNED_BYTE:
+                case BYTE:
                     ((ByteBuffer) result).put(data.<byte[]> getArray());
                     break;
-                case UNSIGNED_INT:
+                case INT:
                     ((IntBuffer) result).put(data.<int[]> getArray());
                     break;
-                case UNSIGNED_SHORT:
+                case SHORT:
                     ((ShortBuffer) result).put(data.<short[]> getArray());
                     break;
                 }
             float[] fd = data.getArray();
             ((FloatBuffer) result).put(fd, offset, length);
             break;
-        case UNSIGNED_BYTE:
+        case BYTE:
             byte[] bd = data.getArray();
             ((ByteBuffer) result).put(bd, offset, length);
             break;
-        case UNSIGNED_INT:
+        case INT:
             int[] id = data.getArray();
             ((IntBuffer) result).put(id, offset, length);
             break;
-        case UNSIGNED_SHORT:
+        case SHORT:
             short[] sd = data.getArray();
             ((ShortBuffer) result).put(sd, offset, length);
             break;

ferox-renderer/ferox-renderer-jogl/src/main/java/com/ferox/renderer/impl/jogl/JoglPbufferTextureSurface.java

         }
 
         if (depth != null) {
-            if (depth.getDataType() == DataType.UNSIGNED_BYTE) {
+            if (depth.getDataType() == DataType.BYTE) {
                 caps.setDepthBits(16);
-            } else if (depth.getDataType() == DataType.UNSIGNED_SHORT) {
+            } else if (depth.getDataType() == DataType.SHORT) {
                 caps.setDepthBits(24);
             } else {
                 caps.setDepthBits(32);

ferox-renderer/ferox-renderer-jogl/src/main/java/com/ferox/renderer/impl/jogl/JoglRendererDelegate.java

     protected void glDrawElements(PolygonType type, VertexBufferObjectHandle h,
                                   int offset, int count) {
         int glPolyType = Utils.getGLPolygonConnectivity(type);
-        int glDataType = Utils.getGLType(h.dataType);
+        int glDataType = Utils.getGLType(h.dataType, false);
 
         if (h.mode == StorageMode.IN_MEMORY) {
             Buffer data = h.inmemoryBuffer;

ferox-renderer/ferox-renderer-jogl/src/main/java/com/ferox/renderer/impl/jogl/JoglTextureResourceDriver.java

         int target = (h.target == Target.T_CUBEMAP ? Utils.getGLCubeFace(layer) : Utils.getGLTextureTarget(h.target));
         int srcFormat = Utils.getGLSrcFormat(h.format);
         int dstFormat = Utils.getGLDstFormat(h.format, h.type);
-        int type = (h.format.isPackedFormat() ? Utils.getGLPackedType(h.format) : Utils.getGLType(h.type));
+        int type = (h.format.isPackedFormat() ? Utils.getGLPackedType(h.format) : Utils.getGLType(h.type,
+                                                                                                  false));
 
         switch (h.target) {
         case T_1D:
                                  int depth, Buffer data) {
         int target = (h.target == Target.T_CUBEMAP ? Utils.getGLCubeFace(layer) : Utils.getGLTextureTarget(h.target));
         int srcFormat = Utils.getGLSrcFormat(h.format);
-        int type = (h.format.isPackedFormat() ? Utils.getGLPackedType(h.format) : Utils.getGLType(h.type));
+        int type = (h.format.isPackedFormat() ? Utils.getGLPackedType(h.format) : Utils.getGLType(h.type,
+                                                                                                  false));
 
         switch (h.target) {
         case T_1D:

ferox-renderer/ferox-renderer-jogl/src/main/java/com/ferox/renderer/impl/jogl/Utils.java

             // if we've gotten here, we have a type-less format, and have to
             // take the type into account
         case R:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL2.GL_ALPHA8;
-            } else if (type == DataType.UNSIGNED_SHORT || type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.SHORT || type == DataType.INT) {
                 return GL2.GL_ALPHA16;
             } else {
                 return GL.GL_ALPHA;
             }
         case RG:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL2.GL_LUMINANCE8_ALPHA8;
-            } else if (type == DataType.UNSIGNED_SHORT || type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.SHORT || type == DataType.INT) {
                 return GL2.GL_LUMINANCE16_ALPHA16;
             } else {
                 return GL.GL_LUMINANCE_ALPHA;
             }
         case DEPTH:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL.GL_DEPTH_COMPONENT16;
-            } else if (type == DataType.UNSIGNED_SHORT) {
+            } else if (type == DataType.SHORT) {
                 return GL.GL_DEPTH_COMPONENT24;
-            } else if (type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.INT) {
                 return GL.GL_DEPTH_COMPONENT32;
             } else {
                 return GL2ES2.GL_DEPTH_COMPONENT;
             }
         case RGB:
         case BGR:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL.GL_RGB8;
-            } else if (type == DataType.UNSIGNED_SHORT || type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.SHORT || type == DataType.INT) {
                 return GL2GL3.GL_RGB16;
             } else {
                 return GL.GL_RGB;
             }
         case RGBA:
         case BGRA:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL.GL_RGBA8;
-            } else if (type == DataType.UNSIGNED_SHORT || type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.SHORT || type == DataType.INT) {
                 return GL2GL3.GL_RGBA16;
             } else {
                 return GL.GL_RGBA;
     }
 
     /**
-     * This shouldn't be used for packed data types.
+     * This shouldn't be used for packed data types
      */
-    public static int getGLType(DataType type) {
+    public static int getGLType(DataType type, boolean signed) {
         switch (type) {
         case FLOAT:
             return GL.GL_FLOAT;
-        case UNSIGNED_BYTE:
-            return GL.GL_UNSIGNED_BYTE;
-        case UNSIGNED_INT:
-            return GL.GL_UNSIGNED_INT;
-        case UNSIGNED_SHORT:
-            return GL.GL_UNSIGNED_SHORT;
+        case BYTE:
+            return (signed ? GL.GL_BYTE : GL.GL_UNSIGNED_BYTE);
+        case INT:
+            return (signed ? GL2.GL_INT : GL.GL_UNSIGNED_INT);
+        case SHORT:
+            return (signed ? GL2.GL_SHORT : GL.GL_UNSIGNED_SHORT);
         }
 
         return -1;

ferox-renderer/ferox-renderer-lwjgl/src/main/java/com/ferox/renderer/impl/lwjgl/LwjglRendererDelegate.java

     protected void glDrawElements(PolygonType type, VertexBufferObjectHandle h,
                                   int offset, int count) {
         int glPolyType = Utils.getGLPolygonConnectivity(type);
-        int glDataType = Utils.getGLType(h.dataType);
+        int glDataType = Utils.getGLType(h.dataType, false);
 
         if (h.mode == StorageMode.IN_MEMORY) {
             Buffer data = h.inmemoryBuffer;
             data.limit(offset + count).position(offset);
             switch (h.dataType) {
-            case UNSIGNED_BYTE:
+            case BYTE:
                 GL11.glDrawElements(glPolyType, (ByteBuffer) data);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 GL11.glDrawElements(glPolyType, (ShortBuffer) data);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 GL11.glDrawElements(glPolyType, (IntBuffer) data);
                 break;
             default:

ferox-renderer/ferox-renderer-lwjgl/src/main/java/com/ferox/renderer/impl/lwjgl/LwjglTextureResourceDriver.java

         int target = (h.target == Target.T_CUBEMAP ? Utils.getGLCubeFace(layer) : Utils.getGLTextureTarget(h.target));
         int srcFormat = Utils.getGLSrcFormat(h.format);
         int dstFormat = Utils.getGLDstFormat(h.format, h.type);
-        int type = (h.format.isPackedFormat() ? Utils.getGLPackedType(h.format) : Utils.getGLType(h.type));
+        int type = (h.format.isPackedFormat() ? Utils.getGLPackedType(h.format) : Utils.getGLType(h.type,
+                                                                                                  false));
 
         switch (h.target) {
         case T_1D:
                 GL11.glTexImage1D(target, mipmap, dstFormat, width, 0, srcFormat, type,
                                   (FloatBuffer) data);
                 break;
-            case UNSIGNED_BYTE:
+            case BYTE:
                 GL11.glTexImage1D(target, mipmap, dstFormat, width, 0, srcFormat, type,
                                   (ByteBuffer) data);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 GL11.glTexImage1D(target, mipmap, dstFormat, width, 0, srcFormat, type,
                                   (IntBuffer) data);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 GL11.glTexImage1D(target, mipmap, dstFormat, width, 0, srcFormat, type,
                                   (ShortBuffer) data);
                 break;
                     GL11.glTexImage2D(target, mipmap, dstFormat, width, height, 0,
                                       srcFormat, type, (FloatBuffer) data);
                     break;
-                case UNSIGNED_BYTE:
+                case BYTE:
                     GL11.glTexImage2D(target, mipmap, dstFormat, width, height, 0,
                                       srcFormat, type, (ByteBuffer) data);
                     break;
-                case UNSIGNED_INT:
+                case INT:
                     GL11.glTexImage2D(target, mipmap, dstFormat, width, height, 0,
                                       srcFormat, type, (IntBuffer) data);
                     break;
-                case UNSIGNED_SHORT:
+                case SHORT:
                     GL11.glTexImage2D(target, mipmap, dstFormat, width, height, 0,
                                       srcFormat, type, (ShortBuffer) data);
                     break;
                 GL12.glTexImage3D(target, mipmap, dstFormat, width, height, depth, 0,
                                   srcFormat, type, (FloatBuffer) data);
                 break;
-            case UNSIGNED_BYTE:
+            case BYTE:
                 GL12.glTexImage3D(target, mipmap, dstFormat, width, height, depth, 0,
                                   srcFormat, type, (ByteBuffer) data);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 GL12.glTexImage3D(target, mipmap, dstFormat, width, height, depth, 0,
                                   srcFormat, type, (IntBuffer) data);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 GL12.glTexImage3D(target, mipmap, dstFormat, width, height, depth, 0,
                                   srcFormat, type, (ShortBuffer) data);
                 break;
                                  int depth, Buffer data) {
         int target = (h.target == Target.T_CUBEMAP ? Utils.getGLCubeFace(layer) : Utils.getGLTextureTarget(h.target));
         int srcFormat = Utils.getGLSrcFormat(h.format);
-        int type = (h.format.isPackedFormat() ? Utils.getGLPackedType(h.format) : Utils.getGLType(h.type));
+        int type = (h.format.isPackedFormat() ? Utils.getGLPackedType(h.format) : Utils.getGLType(h.type,
+                                                                                                  false));
 
         switch (h.target) {
         case T_1D:
                 GL11.glTexSubImage1D(target, mipmap, x, width, srcFormat, type,
                                      (FloatBuffer) data);
                 break;
-            case UNSIGNED_BYTE:
+            case BYTE:
                 GL11.glTexSubImage1D(target, mipmap, x, width, srcFormat, type,
                                      (ByteBuffer) data);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 GL11.glTexSubImage1D(target, mipmap, x, width, srcFormat, type,
                                      (IntBuffer) data);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 GL11.glTexSubImage1D(target, mipmap, x, width, srcFormat, type,
                                      (ShortBuffer) data);
                 break;
                 GL11.glTexSubImage2D(target, mipmap, x, y, width, height, srcFormat,
                                      type, (FloatBuffer) data);
                 break;
-            case UNSIGNED_BYTE:
+            case BYTE:
                 GL11.glTexSubImage2D(target, mipmap, x, y, width, height, srcFormat,
                                      type, (ByteBuffer) data);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 GL11.glTexSubImage2D(target, mipmap, x, y, width, height, srcFormat,
                                      type, (IntBuffer) data);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 GL11.glTexSubImage2D(target, mipmap, x, y, width, height, srcFormat,
                                      type, (ShortBuffer) data);
                 break;
                 GL12.glTexSubImage3D(target, mipmap, x, y, z, width, height, depth,
                                      srcFormat, type, (FloatBuffer) data);
                 break;
-            case UNSIGNED_BYTE:
+            case BYTE:
                 GL12.glTexSubImage3D(target, mipmap, x, y, z, width, height, depth,
                                      srcFormat, type, (ByteBuffer) data);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 GL12.glTexSubImage3D(target, mipmap, x, y, z, width, height, depth,
                                      srcFormat, type, (IntBuffer) data);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 GL12.glTexSubImage3D(target, mipmap, x, y, z, width, height, depth,
                                      srcFormat, type, (ShortBuffer) data);
                 break;

ferox-renderer/ferox-renderer-lwjgl/src/main/java/com/ferox/renderer/impl/lwjgl/LwjglVertexBufferObjectResourceDriver.java

             case FLOAT:
                 ARBBufferObject.glBufferDataARB(target, (FloatBuffer) data, usage);
                 break;
-            case UNSIGNED_BYTE:
+            case BYTE:
                 ARBBufferObject.glBufferDataARB(target, (ByteBuffer) data, usage);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 ARBBufferObject.glBufferDataARB(target, (IntBuffer) data, usage);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 ARBBufferObject.glBufferDataARB(target, (ShortBuffer) data, usage);
                 break;
             }
             case FLOAT:
                 GL15.glBufferData(target, (FloatBuffer) data, usage);
                 break;
-            case UNSIGNED_BYTE:
+            case BYTE:
                 GL15.glBufferData(target, (ByteBuffer) data, usage);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 GL15.glBufferData(target, (IntBuffer) data, usage);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 GL15.glBufferData(target, (ShortBuffer) data, usage);
                 break;
             }
             case FLOAT:
                 ARBBufferObject.glBufferSubDataARB(target, vboOffset, (FloatBuffer) data);
                 break;
-            case UNSIGNED_BYTE:
+            case BYTE:
                 ARBBufferObject.glBufferSubDataARB(target, vboOffset, (ByteBuffer) data);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 ARBBufferObject.glBufferSubDataARB(target, vboOffset, (IntBuffer) data);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 ARBBufferObject.glBufferSubDataARB(target, vboOffset, (ShortBuffer) data);
                 break;
             }
             case FLOAT:
                 GL15.glBufferSubData(target, vboOffset, (FloatBuffer) data);
                 break;
-            case UNSIGNED_BYTE:
+            case BYTE:
                 GL15.glBufferSubData(target, vboOffset, (ByteBuffer) data);
                 break;
-            case UNSIGNED_INT:
+            case INT:
                 GL15.glBufferSubData(target, vboOffset, (IntBuffer) data);
                 break;
-            case UNSIGNED_SHORT:
+            case SHORT:
                 GL15.glBufferSubData(target, vboOffset, (ShortBuffer) data);
                 break;
             }

ferox-renderer/ferox-renderer-lwjgl/src/main/java/com/ferox/renderer/impl/lwjgl/Utils.java

             // if we've gotten here, we have a type-less format, and have to
             // take the type into account
         case R:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL11.GL_LUMINANCE8;
-            } else if (type == DataType.UNSIGNED_SHORT || type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.SHORT || type == DataType.INT) {
                 return GL11.GL_LUMINANCE16;
             } else {
                 return GL11.GL_LUMINANCE;
             }
         case RG:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL11.GL_LUMINANCE8_ALPHA8;
-            } else if (type == DataType.UNSIGNED_SHORT || type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.SHORT || type == DataType.INT) {
                 return GL11.GL_LUMINANCE16_ALPHA16;
             } else {
                 return GL11.GL_LUMINANCE_ALPHA;
             }
         case DEPTH:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL14.GL_DEPTH_COMPONENT16;
-            } else if (type == DataType.UNSIGNED_SHORT) {
+            } else if (type == DataType.SHORT) {
                 return GL14.GL_DEPTH_COMPONENT24;
-            } else if (type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.INT) {
                 return GL14.GL_DEPTH_COMPONENT32;
             } else {
                 return GL11.GL_DEPTH_COMPONENT;
             }
         case RGB:
         case BGR:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL11.GL_RGB8;
-            } else if (type == DataType.UNSIGNED_SHORT || type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.SHORT || type == DataType.INT) {
                 return GL11.GL_RGB16;
             } else {
                 return GL11.GL_RGB;
             }
         case RGBA:
         case BGRA:
-            if (type == DataType.UNSIGNED_BYTE) {
+            if (type == DataType.BYTE) {
                 return GL11.GL_RGBA8;
-            } else if (type == DataType.UNSIGNED_SHORT || type == DataType.UNSIGNED_INT) {
+            } else if (type == DataType.SHORT || type == DataType.INT) {
                 return GL11.GL_RGBA16;
             } else {
                 return GL11.GL_RGBA;
     /**
      * This shouldn't be used for packed data types.
      */
-    public static int getGLType(DataType type) {
+    public static int getGLType(DataType type, boolean signed) {
         switch (type) {
         case FLOAT:
             return GL11.GL_FLOAT;
-        case UNSIGNED_BYTE:
-            return GL11.GL_UNSIGNED_BYTE;
-        case UNSIGNED_INT:
-            return GL11.GL_UNSIGNED_INT;
-        case UNSIGNED_SHORT:
-            return GL11.GL_UNSIGNED_SHORT;
+        case BYTE:
+            return (signed ? GL11.GL_BYTE : GL11.GL_UNSIGNED_BYTE);
+        case INT:
+            return (signed ? GL11.GL_INT : GL11.GL_UNSIGNED_INT);
+        case SHORT:
+            return (signed ? GL11.GL_SHORT : GL11.GL_UNSIGNED_SHORT);
         default:
             throw new RuntimeException("Unsupported enum value: " + type);
         }