[ < ] | [ Up ] | [ > ] | [Top] | [Contents] | [Index] | [ ? ] |
A texture is an image that can be applied onto the surface of a three dimensional model. In Ogre, textures are represented by the Texture resource class.
Textures are created through the TextureManager. In most cases they are created from image files directly by the Ogre resource system. If you are reading this, you most probably want to create a texture manually so that you can provide it with image data yourself. This is done through TextureManager::createManual:
ptex = TextureManager::getSingleton().createManual( "MyManualTexture", // Name of texture "General", // Name of resource group in which the texture should be created TEX_TYPE_2D, // Texture type 256, // Width 256, // Height 1, // Depth (Must be 1 for two dimensional textures) 0, // Number of mipmaps PF_A8R8G8B8, // Pixel format TU_DYNAMIC_WRITE_ONLY // usage ); |
This example creates a texture named MyManualTexture in resource group General. It is a square two dimensional texture, with width 256 and height 256. It has no mipmaps, internal format PF_A8R8G8B8 and usage TU_DYNAMIC_WRITE_ONLY.
The different texture types will be discussed in 2.8.3 Texture Types. Pixel formats are summarised in 2.8.4 Pixel Formats.
In addition to the hardware buffer usages as described in See section 2.2 Buffer Usage there are some usage flags specific to textures:
A Texture can consist of multiple PixelBuffers, one for each combo if mipmap level and face number. To get a PixelBuffer from a Texture object the method Texture::getBuffer(face, mipmap) is used:
face should be zero for non-cubemap textures. For cubemap textures it identifies the face to use, which is one of the cube faces described in See section 2.8.3 Texture Types.
mipmap is zero for the zeroth mipmap level, one for the first mipmap level, and so on. On textures that have automatic mipmap generation (TU_AUTOMIPMAP) only level 0 should be accessed, the rest will be taken care of by the rendering API.
A simple example of using getBuffer is
// Get the PixelBuffer for face 0, mipmap 0. HardwarePixelBufferSharedPtr ptr = tex->getBuffer(0,0); |
[ < ] | [ Up ] | [ > ] | [Top] | [Contents] | [Index] | [ ? ] |