All Packages This Package Class Hierarchy Class Search Index
java.lang.Object | +----com.hermetica.util3d.Texture
Summary |
public class Texture extends java.lang.Object implements java.awt.image.ImageConsumer { // Fields 4 public static final int SCALE_DONT; public static final int SCALE_MAGNIFY; public static final int SCALE_MINIFY; public static final int SCALE_NEAREST; // Constructors 4 public Texture(Image, GLDrawable); public Texture(Image, GLDrawable, int); public Texture(ImageProducer, GLDrawable); public Texture(ImageProducer, GLDrawable, int); // Methods 17 public static int nearestPower2(int, int); public int getHeight(); public byte[] getTexture(); public int getWidth(); public void imageComplete(int); public boolean isInitialized(); public boolean isValid(); public void setColorModel(ColorModel); public void setDimensions(int, int); public void setHints(int); public void setPixels(int, int, int, int, ColorModel, byte[], int, int); public void setPixels(int, int, int, int, ColorModel, int[], int, int); public void setProperties(Hashtable); public String toAWTByteArray(String); public String toAWTIntArray(String); public String toOpenGLIntArray(String); public String toString(); }
Encapsulation of a chunk of texture information. This class provides the programmer with the ability to retrieve images, such as GIF and JPEG images, from arbitrary URLs and use them in OpenGL as texture maps. This class will handle the processing of the images into arrays of data that OpenGL uses for texture-map specification. The isValid() method should be invoked prior to using the texture to make sure it has completely downloaded, due to the asynchronous nature of Java's AWT.
In addition to this, all textures exist in the RGBA colourspace, thereby allowing you to easily build textures with transparency.
See Also: glTexImage1D, glTexImage2D
Fields |
· SCALE_DONT | Summary | Top |
public static final int SCALE_DONT
Don't scale the texture at all. No way, Jose
· SCALE_NEAREST | Summary | Top |
public static final int SCALE_NEAREST
Scale the texture to the nearest ^2 in each axis. Note that this will scale the texture in the same direction in both axes depending on how the first axis calculates to preserve the aspect ratio
· SCALE_MAGNIFY | Summary | Top |
public static final int SCALE_MAGNIFY
Scale the texture up on both axes
· SCALE_MINIFY | Summary | Top |
public static final int SCALE_MINIFY
Scale the texture down on both axes
Constructors |
· Texture | Summary | Top |
public Texture(Image image, GLDrawable component)
Default constructor with just the image we wish to create the texture from
· Texture | Summary | Top |
public Texture(Image image, GLDrawable component, int scaling)
Slightly more sophisticated constructor that allows us to specify what we wish to do with regards to scaling the texture. The Texture class can either create the texture as is, scale it to the nearest sizes, scale it arbitrarily up, or scale it arbitrarily down.
· Texture | Summary | Top |
public Texture(ImageProducer producer, GLDrawable component)
Default constructor with just the ImageProducer we wish to create the texture from
· Texture | Summary | Top |
public Texture(ImageProducer producer, GLDrawable component, int scaling)
Slightly more sophisticated constructor that allows us to specify what we wish to do with regards to scaling the texture. The Texture class can either create the texture as is, scale it to the nearest sizes, scale it arbitrarily up, or scale it arbitrarily down.
Methods |
· getWidth | Summary | Top |
public int getWidth()
Returns the width of the texture
· getHeight | Summary | Top |
public int getHeight()
Returns the height of the texture
· isValid | Summary | Top |
public boolean isValid()
Returns whether or not this texture is valid, ie, whether all the data has been received and processed into suitable OpenGL data.
· isInitialized | Summary | Top |
public boolean isInitialized()
Handy object-orientated store that signifies whether or not you have used your texture yet.
· getTexture | Summary | Top |
public byte[] getTexture()
Returns the textureData array
· imageComplete | Summary | Top |
public void imageComplete(int status)
Indicates the image is complete
- Implements:
- imageComplete in interface ImageConsumer
· setColorModel | Summary | Top |
public void setColorModel(ColorModel model)
Sets the colour model of this texture
- Implements:
- setColorModel in interface ImageConsumer
· setDimensions | Summary | Top |
public void setDimensions(int width, int height)
Sets the dimensions of the texture
- Implements:
- setDimensions in interface ImageConsumer
· setHints | Summary | Top |
public void setHints(int hintflags)
Sets any hints on image production
- Implements:
- setHints in interface ImageConsumer
· setPixels | Summary | Top |
public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize)
Sets the pixels of the image in byte format
- Implements:
- setPixels in interface ImageConsumer
· setPixels | Summary | Top |
public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize)
Sets the pixels of the image in byte format
- Implements:
- setPixels in interface ImageConsumer
· setProperties | Summary | Top |
public void setProperties(Hashtable props)
Sets the properties of this ImageConsumer
- Implements:
- setProperties in interface ImageConsumer
· toString | Summary | Top |
public String toString()
Returns a String representation of the texture
- Overrides:
- toString in class Object
· toAWTByteArray | Summary | Top |
public String toAWTByteArray(String variableName)
Returns a String containing a byte array declaration of this texture in a format suitable for use within AWT
· toAWTIntArray | Summary | Top |
public String toAWTIntArray(String variableName)
Returns a String containing an int[] declaration of this texture for use with AWT, ie, each 4 component pixel is packed into a 24-bit value ( ALPHA | RED | GREEN | BLUE )
· toOpenGLIntArray | Summary | Top |
public String toOpenGLIntArray(String variableName)
Returns a String containing an int[] declaration of this texture for use with OpenGL's texture mapping routines.
· nearestPower2 | Summary | Top |
public static int nearestPower2(int value, int scaleRule)
Calculates the nearest power of two to the given number
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7