< Zurück | Inhalt | Weiter >

From TextureTest.java

//Create TextureLoader and initialize it with an image file name

//and a mode

TextureLoader texLoader = new TextureLoader( texInfo.m_szImage, Texture.RGB, this );


//Extract a Texture object from the loader Texture tex = texLoader.getTexture();


//Assign the Texture to the Appearance Appearance app = new Appearance(); app.setTexture( tex );


image


The advantages of using the TextureLoader class are:


Loading the image from disk (JPEG or GIF)

Rescaling the image so that it is a power of 2, that is, width and height.

Creating the appropriate Texture object, either Texture2D or Texture3D


If an ImageComponent2D or ImageComponent3D is passed to Texture.setImage directly and the TextureLoader class is not used, the application developer is responsible for ensuring that the images are a power of 2 (1, 2, 4, 8…) in both width and height. This is a requirement imposed by the underlying graphics API that is optimized to rescale images of this size.