Commits

Michael Ludwig  committed d8be658

API documentation for resource package, improve TextureFormat options and make their names more forward-compatible.

  • Participants
  • Parent commits df1f7de

Comments (0)

Files changed (8)

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

 package com.ferox.resource;
 
 /**
+ * <p>
+ * BufferData represents a block of primitive memory that can be pushed to the
+ * GPU to store texture data, vertex data, or more. Each BufferData instance has
+ * a fixed length and data type to allow Frameworks to safely allocate internal
+ * or GPU storage.
+ * <p>
+ * BufferData's store their data in Java primitive arrays. Depending on the data
+ * type, different array types must be used.
+ * <p>
+ * BufferData is not thread safe, it is assumed that mutations of a BufferData
+ * object will be done within the synchronization block of whatever resource
+ * owns it.
  * 
- * @author michaelludwig
- *
+ * @author Michael Ludwig
  */
 public class BufferData {
     /**
-     * 
-     * @author michaelludwig
-     *
+     * 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).
      */
     public static enum DataType {
-        FLOAT(4), UNSIGNED_INT(4), UNSIGNED_SHORT(2), UNSIGNED_BYTE(1);
+        /**
+         * Each primitive is a 4-byte float, and is stored internally as a Java
+         * float array (e.g. <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.
+         */
+        UNSIGNED_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.
+         */
+        UNSIGNED_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.
+         */
+        UNSIGNED_BYTE(1);
         
         private final int byteCount;
         private DataType(int byteCount) { this.byteCount = byteCount; }
         
+        /**
+         * @return The number of bytes used by each primitive
+         */
         public int getByteCount() { return byteCount; }
     }
     
-    private Object data;
+    private Object data; // actually a primitive array, of different types
     private final int length;
     private final DataType type;
+    
+    // key is an identity specifier that does not prevent the BufferData from
+    // being GC'ed, so the Framework can store the keys instead of the actual
+    // BufferData when it tracks a resource's state
     private final Object key = new Object();
     
+    /**
+     * <p>
+     * Create a BufferData that uses the given float[] as its data store. The
+     * DataType of the BufferData will be FLOAT, 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
+     * {@link #setData(float[])}, the length and type of the BufferData cannot.
+     * 
+     * @param data The initial float data
+     * @throws NullPointerException if data is null
+     */
     public BufferData(float[] data) {
         if (data == null)
             throw new NullPointerException("Array cannot be null");
         type = DataType.FLOAT;
     }
     
+    /**
+     * <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.
+     * <p>
+     * Any changes to the primitives 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.
+     * 
+     * @param data The initial unsigned int data
+     * @throws NullPointerException if data is null
+     */
     public BufferData(int[] data) {
         if (data == null)
             throw new NullPointerException("Array cannot be null");
         type = DataType.UNSIGNED_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.
+     * <p>
+     * Any changes to the primitives in the array will affect the BufferData.
+     * Although the array reference can be changed later with
+     * {@link #setData(short[])}, the length and type of the BufferData cannot.
+     * 
+     * @param data The initial unsigned short data
+     * @throws NullPointerException if data is null
+     */
     public BufferData(short[] data) {
         if (data == null)
             throw new NullPointerException("Array cannot be null");
         type = DataType.UNSIGNED_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.
+     * <p>
+     * Any changes to the primitives in the array will affect the BufferData.
+     * Although the array reference can be changed later with
+     * {@link #setData(byte[])}, the length and type of the BufferData cannot.
+     * 
+     * @param data The initial unsigned byte data
+     * @throws NullPointerException if data is null
+     */
     public BufferData(byte[] data) {
         if (data == null)
             throw new NullPointerException("Array cannot be null");
         type = DataType.UNSIGNED_BYTE;
     }
     
+    /**
+     * <p>
+     * Create a BufferData with a null internal array, but will be configured to
+     * 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.
+     * 
+     * @param type The data type of this BufferData
+     * @param length The length of the buffer data
+     * @throws NullPointerException if type is null
+     * @throws IllegalArgumentException if length is less than 1
+     */
     public BufferData(DataType type, int length) {
         if (type == null)
             throw new NullPointerException("DataType cannot be null");
         data = null;
     }
     
+    /**
+     * <p>
+     * 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.
+     * <p>
+     * This is primarily intended for Framework implementations, so they can
+     * store the identify of a BufferData used by a resource without preventing
+     * the BufferData from being garbage collected.
+     * 
+     * @return An identity key for this data instance
+     */
     public Object getKey() {
         return key;
     }
     
+    /**
+     * Get the length or size of this BufferData. All arrays stored by this
+     * buffer data will have this length. This allows BufferData to describe an
+     * effective block of memory but have the actual array underneath change as
+     * needed.
+     * 
+     * @return The size of this BufferData
+     */
     public int getLength() {
         return length;
     }
     
+    /**
+     * Get the data type of this BufferData. After creation, the data type
+     * cannot be changed. This allows the BufferData to describe the data type
+     * stored in its effective memory block but have the actual array underneath
+     * change as needed.
+     * 
+     * @return The data type of this BufferData
+     */
     public DataType getDataType() {
         return type;
     }
     
+    /**
+     * <p>
+     * Get the current data array that this BufferData wraps. If the returned
+     * array is not null, its length will equal the return value of
+     * {@link #getLength()}.
+     * <p>
+     * This method uses an unchecked generic cast to make it more convenient to
+     * get at the array. Care must be given to use the proper type parameter
+     * 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>
+     * </ul>
+     * 
+     * @return The backing data array, which might be null
+     * @throws ClassCastException if the improper array type is expected
+     */
     @SuppressWarnings("unchecked")
     public <T> T getArray() {
         return (T) data;
     }
 
+    /**
+     * 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 FLOAT.
+     * 
+     * @param data The new float array
+     * @throws IllegalStateException if this BufferData's type is not FLOAT
+     * @throws IllegalArgumentException if the array length is not equal to the
+     *             buffer's length
+     */
     public void setData(float[] data) {
-        if (type != DataType.FLOAT)
-            throw new IllegalStateException("Incorrect DataType, FLOAT is required but BufferData is " + type);
-        if (data != null && data.length != length)
-            throw new IllegalArgumentException("Incorrect array length, must be " + length + ", but is " + data.length);
-        
-        this.data = data;
+        setData(data, (data == null ? length : data.length), DataType.FLOAT);
     }
     
+    /**
+     * 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.
+     * 
+     * @param data The new int array
+     * @throws IllegalStateException if this BufferData's type is not
+     *             UNSIGNED_INT
+     * @throws IllegalArgumentException if the array length is not equal to the
+     *             buffer's length
+     */
     public void setData(int[] data) {
-        if (type != DataType.UNSIGNED_INT)
-            throw new IllegalStateException("Incorrect DataType, UNSIGNED_INT is required but BufferData is " + type);
-        if (data != null && data.length != length)
-            throw new IllegalArgumentException("Incorrect array length, must be " + length + ", but is " + data.length);
-        
-        this.data = data;
+        setData(data, (data == null ? length : data.length), DataType.UNSIGNED_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.
+     * 
+     * @param data The new short array
+     * @throws IllegalStateException if this BufferData's type is not
+     *             UNSIGNED_SHORT
+     * @throws IllegalArgumentException if the array length is not equal to the
+     *             buffer's length
+     */
     public void setData(short[] data) {
-        if (type != DataType.UNSIGNED_SHORT)
-            throw new IllegalStateException("Incorrect DataType, UNSIGNED_SHORT is required but BufferData is " + type);
-        if (data != null && data.length != length)
-            throw new IllegalArgumentException("Incorrect array length, must be " + length + ", but is " + data.length);
-        
-        this.data = data;
+        setData(data, (data == null ? length : data.length), DataType.UNSIGNED_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.
+     * 
+     * @param data The new byte array
+     * @throws IllegalStateException if this BufferData's type is not
+     *             UNSIGNED_BYTE
+     * @throws IllegalArgumentException if the array length is not equal to the
+     *             buffer's length
+     */
     public void setData(byte[] data) {
-        if (type != DataType.UNSIGNED_BYTE)
-            throw new IllegalStateException("Incorrect DataType, UNSIGNED_BYTE is required but BufferData is " + type);
-        if (data != null && data.length != length)
-            throw new IllegalArgumentException("Incorrect array length, must be " + length + ", but is " + data.length);
+        setData(data, (data == null ? length : data.length), DataType.UNSIGNED_BYTE);
+    }
+    
+    private void setData(Object array, int arrayLength, DataType expectedType) {
+        if (type != expectedType) {
+            throw new IllegalStateException("BufferData's type is " + type + ", but " + expectedType + " is required");
+        }
+        if (arrayLength != length) {
+            throw new IllegalArgumentException("Incorrect array length, must be " + length + ", by is " + arrayLength);
+        }
         
-        this.data = data;
+        data = array;
     }
 }

File ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/resource/DataRange.java

 package com.ferox.resource;
 
 /**
- * DataRange is a small object that tracks changes with an array or buffer that
+ * DataRange is a small object that tracks changes within an array or buffer that
  * is one-dimensional. It has both an offset into the data and a length; these
  * are measured in number of indices and not any other concept such as pixel or
  * vector.

File ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/resource/GlslShader.java

 
 public class GlslShader extends Resource {
     public static enum Version {
+        // FIXME are there more?
+        // should I really limit it to an enum, I could just have
+        // it be an integer that is parsed that is probably safer
         V1_20, V1_30, V1_40, V1_50, V3_30, V4_00
     }
     

File ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/resource/Resource.java

 import java.util.concurrent.atomic.AtomicInteger;
 
 import com.ferox.renderer.Framework;
+import com.ferox.renderer.HardwareAccessLayer;
 
 /**
  * <p>
  * An abstract class that represents some type of data stored on the graphics
- * card. A resource is fairly abstract so there many things can be
- * represented (assuming there are hardware capabilities supporting it). Some
- * examples include {@link Texture}, {@link VertexBufferObject}, and
- * {@link GlslShader}.
- * </p>
+ * card. A resource is fairly abstract so there many things can be represented
+ * (assuming there are hardware capabilities supporting it). Some examples
+ * include {@link Texture}, {@link VertexBufferObject}, and {@link GlslShader}.
  * <p>
- * There are multiple ways that a Resource can be managed with a Framework. A
- * Resource cannot be used until its been updated by a Framework. There are
+ * A Resource cannot be used until its been updated by a Framework. There are
  * different ways that a Resource can be updated, some of which are automatic.
  * See {@link UpdatePolicy} for more details.
- * </p>
  * <p>
  * When a Resource can only be accessed by weak references, a Framework will
  * automatically schedule it for disposal. A Framework that's destroyed will
- * have any remaining Resource's internal data disposed, too.
- * </p>
+ * have any remaining Resource's internal data disposed, as well.
  * <p>
  * To provide thread safety while accessing and using resources, each resource
  * is guarded by its built-in monitor, meaning manipulating the resource should
  * simple setters are recommended to be 'synchronized'. Application code should
  * acquire the lock when performing bulk manipulation such as editing any
  * associated {@link BufferData buffer data}.
- * </p>
  * 
  * @author Michael Ludwig
  */
 public abstract class Resource {
     /**
-     * Each resource will have a status with each active {@link Framework}. A
-     * Resource is usable if it has a status of READY. Resources that are
-     * DISPOSED have no stored data on the graphics card or in memory. A
-     * Resource that has a status of ERROR is unusable until it's been repaired.
+     * Each resource will have a status with each {@link Framework}. A Resource
+     * is usable if it has a status of READY. Resources that are DISPOSED have
+     * no stored data on the graphics card or in memory. A Resource that has a
+     * status of ERROR is unusable until it's been repaired.
      */
     public static enum Status {
-        /** The resource has been updated successfully and is ready to use. */
+        /** 
+         * The resource has been updated successfully and is ready to use. 
+         */
         READY,
         /**
+         * <p>
          * The Framework has tried to update the resource and there may be
          * internal storage used for the Resource, but something is wrong and
          * the Resource isn't usable.
+         * <p>
+         * In many cases, the hardware could not support a configuration option,
+         * the resource type in general is still supported. An example would be
+         * if 3D textures were not supported, but 1D and 2D still were.
          */
         ERROR,
         /**
          * The Framework has no support for the Resource sub-class. Like ERROR
          * it means the Resource is unusable. Unlike ERROR, the Resource cannot
-         * be used, and it's impossible to modify the Resource to change this
+         * ever used, and it's impossible to modify the Resource to change this
          * status.
          */
         UNSUPPORTED,
      * ON_DEMAND policy, which checks for changes when a Resource is needed for
      * rendering. The MANUAL
      * policy forces Resources to be updated manually with
-     * {@link Framework#update(Resource)} as needed.
+     * {@link HardwareAccessLayer#update(Resource)} as needed.
      */
     public static enum UpdatePolicy {
         /**
-         * Like AUTOMATIC, changes are applied automatically, however, changes
-         * are only flushed before the Resource is used by a Framework. Calling
-         * {@link Framework#update(Resource)} on an ON_DEMAND resource will
-         * flush all pending changes and will return a FUTURE that blocks until
-         * they are completed. A scheduled update can be used to flush changes
-         * before a resource is needed.
+         * Changes are applied automatically, however, they are only flushed
+         * immediately before the Resource is used by a Renderer. Manual updates
+         * can still be done.
          */
         ON_DEMAND,
         /**
          * Frameworks track changes to a Resource but do not apply the changes
          * until specifically requested with a call to
-         * {@link Framework#update(Resource)}. Changes are not flushed even if
-         * the Resource is needed by the Framework.
+         * {@link HardWareAccessLayer#update(Resource)}. Changes are not flushed
+         * even if the Resource is used by a Renderer.
          */
         MANUAL
     }
     private static AtomicInteger idCounter = new AtomicInteger(0);
     
     private final int id;
-    private UpdatePolicy policy;
+    private volatile UpdatePolicy policy;
     
     public Resource() {
         id = idCounter.incrementAndGet();
         policy = UpdatePolicy.ON_DEMAND;
     }
     
-    public synchronized UpdatePolicy getUpdatePolicy() {
+    /**
+     * @return The current UpdatePolicy
+     */
+    public UpdatePolicy getUpdatePolicy() {
         return policy;
     }
     
-    public synchronized void setUpdatePolicy(UpdatePolicy policy) {
+    /**
+     * Set the update policy for the Resource. It is not necessary to
+     * synchronize on the Resource to safely call this method, as it is stored
+     * as a volatile field.
+     * 
+     * @param policy The new policy
+     * @throws NullPointerException if policy is null
+     */
+    public void setUpdatePolicy(UpdatePolicy policy) {
         if (policy == null)
             throw new NullPointerException("UpdatePolicy cannot be null");
         this.policy = policy;
     }
 
     @Override
-    public int hashCode() {
+    public final int hashCode() {
         return id;
     }
     
     @Override
-    public boolean equals(Object o) {
+    public final boolean equals(Object o) {
         return o == this;
     }
 }

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

 /**
  * <p>
  * Describes all of the supported texture formats. Some of the formats are only
- * available on newer hardware, such as RGBA_FLOAT. In cases such as this the
- * Framework is allowed to change the type of texture, in which case the image
- * should be flagged as DIRTY.
- * </p>
+ * available on newer hardware, such as RGBA_FLOAT or DEPTH_STENCIL. In cases
+ * such as this the Framework might mark the resource as UNSUPPORTED.
  * <p>
  * The name of the format describes the layout of the data, and possibly the
  * primitive type required.
- * </p>
  * <p>
- * <b>Named formatting:</b>
+ * <b>Name formatting:</b>
  * <ul>
  * <li>XYZ: Formats such as this list their components in order of increasing
  * index in the data array. Each component uses one primitive value (ex. RGBA
  * </ul>
  * </p>
  * <p>
- * <b>EffectType conversion: </b><br>
- * For now, all textures are internally represented as floating point textures
- * with color values in the range [0.0, 1.0]. Non-fp types are scaled to the
- * range [0.0, 1.0] by dividing the UNSIGNED component value by (2^N - 1), where
- * N is the number of bits used to represent that component.
- * </p>
- * <p>
- * For formats of XYZ, this is the bitcount of the primitive type. <br>
- * For XYZ_123, the packed number of bits per component is used (ex. red and
- * blue values in RGB_565 are divided by 31 and green values are divided by 63).
- * </p>
- * <p>
  * Formats using data with type FLOAT will be clamped to [0.0, 1.0] with one
- * exception: <br>
- * If the format is XYZ_FLOAT, the renderer must attempt to leverage unclamped
- * floating-point textures. This is only available on newer hardware. If it's
- * not available, the renderer may decide to use normal clamped float values.
- * </p>
+ * exception: If the format is XYZ_FLOAT, the renderer must attempt to leverage
+ * unclamped 32-bit floating-point textures. This is only available on newer
+ * hardware. If it's not available, the renderer may decide to use normal
+ * clamped float values.
  * <p>
  * <b>An important note about formats:</b> the unclamped formats are only
  * available if a RenderCapabilities returns true in its
- * getUnclampedTextureSupport(). <br>
- * Similarly, the DXT_n options are only available if
- * getS3TCTextureCompression() is true. <br>
- * The DEPTH format is only usable in Textur1D, Texture2D and TextureRectangle.
- * TextureSurfaces created for the other target types will not have a depth
- * image of the same target (since that's not available, a 2d image will be used
- * instead).
- * </p>
+ * getUnclampedTextureSupport(). Similarly, the DXT_n options are only available
+ * if getS3TCTextureCompression() is true. The compressed and DEPTH-based
+ * TextureFormats might be supported on a limited set of texture targets.
  * 
  * @author Michael Ludwig
  */
     BGR(null, 3, 3, false), 
     BGR_565(DataType.UNSIGNED_SHORT, 1, 3, false, true),
 
-    // FIXME: remove these types and replace with R and RG, and R_FLOAT and RG_FLOAT
-    // I must determine the proper mapping of format type for FFP mode, though
-    // Should R be alpha or luminance?  I would think it should be alpha but that is kind of limiting
-    LUMINANCE_ALPHA(null, 2, 2, true), 
-    LUMINANCE(null, 1, 1, false), 
-    ALPHA(null, 1, 1, true),
-
-    LUMINANCE_ALPHA_FLOAT(DataType.FLOAT, 2, 2, true), 
-    LUMINANCE_FLOAT(DataType.FLOAT, 1, 1, false), 
-    ALPHA_FLOAT(DataType.FLOAT, 1, 1, true),
-
-    DEPTH(null, 1, 1, false);
+    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);
 
     private DataType type;
     private boolean hasAlpha, isPacked;

File ferox-renderer/ferox-renderer-api/src/main/java/com/ferox/resource/VertexBufferObject.java

  * rendering an indexed geometry. The data placed in a vbo is extremely flexible
  * and it is possible to pack multiple attributes into a single resource
  * instance. The type of data, however, will limit how the vbo can be used by
- * the render.
+ * the Renderer.
  * </p>
  * <p>
  * If the array contained in the VBO's BufferData is null, it should allocate
  */
 public class VertexBufferObject extends Resource {
     /**
-     * StorageMode represents the various ways that a Framework can 'compile' a
-     * Geometry resource into something that it can use when rendering them.
-     * There are currently three types, each progressing along the spectrum from
-     * faster updates to faster rendering performance.
+     * StorageMode represents the various ways that a Framework can store a VBO
+     * resource into something that it can use when rendering them. There are
+     * currently three types, each progressing along the spectrum from faster
+     * updates to faster rendering performance.
      */
     public static enum StorageMode {
         /**
          */
         IN_MEMORY,
         /**
-         * The Geometry data is stored on the graphics card in specialized
-         * memory designed to be updated frequently. This means that, although
-         * slower than IN_MEMORY, the updates are faster than RESIDENT_DYNAMIC.
-         * Because it's on the graphics card, rendering times should be faster
-         * compared to IN_MEMORY.
+         * The VBO data is stored on the graphics card in specialized memory
+         * designed to be updated frequently. This means that, although slower
+         * than IN_MEMORY, the updates are faster than GPU_STATIC. Because it's
+         * on the graphics card, rendering times should be faster compared to
+         * IN_MEMORY.
          */
         GPU_DYNAMIC,
         /**
-         * Geometry data is stored on the graphics card in memory designed for
-         * fast read access. This allows rendering to be the fastest, but
-         * updates are slower.
+         * VBO data is stored on the graphics card in memory designed for fast
+         * read access. This allows rendering to be the fastest, but updates are
+         * slower.
          */
         GPU_STATIC
     }
     /**
      * <p>
      * Mark the specified region of the buffer data as dirty so that the next
-     * time this VertexBufferObejct is updated (manually or automatically), the
+     * time this VertexBufferObject is updated (manually or automatically), the
      * range will be updated. The nature of this update depends on the
      * configured StorageMode.
      * </p>

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

 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.Buffer;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
 
 import com.ferox.resource.BufferData;
+import com.ferox.resource.BufferData.DataType;
 import com.ferox.resource.Mipmap;
 import com.ferox.resource.Texture;
+import com.ferox.resource.Texture.Target;
 import com.ferox.resource.TextureFormat;
-import com.ferox.resource.BufferData.DataType;
-import com.ferox.resource.Texture.Target;
 
 /**
  * <p>
         DXGI_FORMAT_R16G16B16A16_SNORM, 
         DXGI_FORMAT_R16G16B16A16_SINT,
         DXGI_FORMAT_R32G32_TYPELESS,
-        DXGI_FORMAT_R32G32_FLOAT(DataType.FLOAT, TextureFormat.LUMINANCE_ALPHA_FLOAT), 
+        DXGI_FORMAT_R32G32_FLOAT(DataType.FLOAT, TextureFormat.RG_FLOAT), 
         DXGI_FORMAT_R32G32_UINT, 
         DXGI_FORMAT_R32G32_SINT, 
         DXGI_FORMAT_R32G8X24_TYPELESS,
         DXGI_FORMAT_R8G8B8A8_SINT, 
         DXGI_FORMAT_R16G16_TYPELESS, 
         DXGI_FORMAT_R16G16_FLOAT, 
-        DXGI_FORMAT_R16G16_UNORM(DataType.UNSIGNED_SHORT, TextureFormat.LUMINANCE_ALPHA), 
+        DXGI_FORMAT_R16G16_UNORM(DataType.UNSIGNED_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.LUMINANCE_FLOAT), 
+        DXGI_FORMAT_R32_FLOAT(DataType.FLOAT, TextureFormat.R_FLOAT), 
         DXGI_FORMAT_R32_UINT, 
         DXGI_FORMAT_R32_SINT, 
         DXGI_FORMAT_R24G8_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.LUMINANCE_ALPHA), 
+        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.LUMINANCE), 
+        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.LUMINANCE),
+        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.ALPHA), 
+        DXGI_FORMAT_A8_UNORM(DataType.UNSIGNED_BYTE, TextureFormat.R), 
         DXGI_FORMAT_R1_UNORM, 
         DXGI_FORMAT_R9G9B9E5_SHAREDEXP, 
         DXGI_FORMAT_R8G8_B8G8_UNORM, 
 
     // Supported Luminance types
     private static final DDPFMap[] pfL = new DDPFMap[] { 
-        new DDPFMap(8, 0xff, 0, 0, 0, DataType.UNSIGNED_BYTE, TextureFormat.LUMINANCE) 
+        new DDPFMap(8, 0xff, 0, 0, 0, DataType.UNSIGNED_BYTE, TextureFormat.R) 
     };
 
     // Supported Luminance/Alpha types
     private static final DDPFMap[] pfLA = new DDPFMap[] { 
-        new DDPFMap(16, 0xff, 0, 0, 0xff00, DataType.UNSIGNED_BYTE, TextureFormat.LUMINANCE_ALPHA)
+        new DDPFMap(16, 0xff, 0, 0, 0xff00, DataType.UNSIGNED_BYTE, TextureFormat.RG)
     };
 
     // Supported Alpha types
     private static final DDPFMap[] pfA = new DDPFMap[] { 
-        new DDPFMap(8, 0, 0, 0, 0xff, DataType.UNSIGNED_BYTE, TextureFormat.ALPHA) 
+        new DDPFMap(8, 0, 0, 0, 0xff, DataType.UNSIGNED_BYTE, TextureFormat.R) 
     };
 
     /*

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

 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.nio.Buffer;
 import java.nio.ByteBuffer;
-import java.nio.ShortBuffer;
 import java.util.ArrayList;
 import java.util.List;
 
 import com.ferox.resource.BufferData;
+import com.ferox.resource.BufferData.DataType;
 import com.ferox.resource.Mipmap;
 import com.ferox.resource.Texture;
 import com.ferox.resource.Texture.Target;
     private static class RasterImage {
         // Ferox specific variables
         TextureFormat format;
-        Class<? extends Buffer> type;
+        DataType type;
 
         // BufferImage specific variables
         ColorModel colorModel;
                                                      Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
                 data = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height, 3, null);
 
-                type = ByteBuffer.class;
+                type = DataType.UNSIGNED_BYTE;
                 format = TextureFormat.RGB;
                 break;
             case BufferedImage.TYPE_USHORT_GRAY:
                                                      Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
                 data = Raster.createInterleavedRaster(DataBuffer.TYPE_USHORT, width, height, 1, null);
 
-                type = ShortBuffer.class;
-                format = TextureFormat.LUMINANCE;
+                type = DataType.UNSIGNED_SHORT;
+                format = TextureFormat.R;
                 break;
             case BufferedImage.TYPE_BYTE_GRAY:
                 colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), 
                                                      Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
                 data = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height, 1, null);
 
-                type = ByteBuffer.class;
-                format = TextureFormat.LUMINANCE;
+                type = DataType.UNSIGNED_BYTE;
+                format = TextureFormat.R;
                 break;
             default:
                 colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), 
                                                      Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
                 data = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height, 4, null);
 
-                type = ByteBuffer.class;
+                type = DataType.UNSIGNED_BYTE;
                 format = TextureFormat.RGBA;
                 break;
             }