|
MTek-GDL 0.100.4-muffintrap
|
Texture handling class. More...
#include <mgdl-wii-texture.h>
Public Member Functions | |
| Texture () | |
| Constructor. | |
| virtual | ~Texture () |
| Deconstructor. | |
| bool | Create (short xSize, short ySize, u_int filterMode, u_int format) |
| Creates a texture image. | |
| bool | CreateMipmapped (short xSize, short ySize, u_int minFilt, u_int magFilt, short maxMipmaps, u_int format) |
| Creates a mipmapped texture image. | |
| bool | LoadTexture (const char *fileName) |
| Loads a TPL texture file generated by gxtexconv. | |
| bool | ConvertRawImage (short rawXres, short rawYres, void *rawBuff, short srcFormat) |
| Converts raw image data into a texture. | |
| void | CopyFromScreen (short x, short y, short width, short height, u_char clearScreen) |
| Copies pixel data from the active framebuffer. | |
| void | Delete () |
| Deletes the texture (but not the object itself). | |
| void | Flush () |
| Flushes the texture's data block. | |
| void | SetFilterMode (u_int minFilt, u_int magFilt) |
| Sets filter modes to a texture. | |
| void | SetWrapMode (u_int wrap_s, u_int wrap_t) |
| Sets the wrapping strategy of the texture. | |
| void | PokePixel (short x, short y, u_int col) |
| Pokes a pixel into the texture. | |
| u_int | PeekPixel (short x, short y) |
| Peeks a pixel from the texture. | |
| void * | TexAddr () |
| Returns the pointer to the texture data block. | |
| u_int | TexSize () |
| Returns the size of the texture data in bytes. | |
| short | TexFmt () |
| Returns the texture format index of the texture. | |
| GXTexObj * | TexObj () |
| Returns a pointer to the GXTexObj object of the texture. | |
| short | TXsize () |
| Returns the X size of the texture in pixels. | |
| short | TYsize () |
| Returns the Y size of the texture in pixels. | |
Texture handling class.
This class is used for conveniently handling textures for storing 2D graphics data such as images, sprites and textures. These are used by the library in image and sprite set classes and can be used by itself to ease loading and converting of textures when developing custom graphics engines.
| bool Texture::ConvertRawImage | ( | short | rawXres, |
| short | rawYres, | ||
| void * | rawBuff, | ||
| short | srcFormat | ||
| ) |
Converts raw image data into a texture.
Converts raw image data into an appropriate texture format specified by gdl::Texture::Create() or gdl::Texture::CreateMipmapped(). If the texture is created with gdl::Texture::CreateMipmapped(), the function will generate mipmaps internally.
| [in] | rawXres | X size of raw image data in pixels. |
| [in] | rawYres | Y size of raw image data in pixels. |
| [in] | *rawBuff | Pointer to raw image data. |
| [in] | srcFormat | Format of raw image data (see gdl::ColorFormats). |
| void Texture::CopyFromScreen | ( | short | x, |
| short | y, | ||
| short | width, | ||
| short | height, | ||
| u_char | clearScreen | ||
| ) |
Copies pixel data from the active framebuffer.
This function copies pixels from the active framebuffer to be used as a texture which is useful for doing render-to-texture based effects. Take note that the range at which you can capture depends on the current video mode that the system is running on and is best to take into account of the actual framebuffer resolution using the variables gdl::wii::rmode->fbWidth and gdl::wii::rmode->efbHeight.
| [in] | x | X offset of screen to copy from in framebuffer pixels. |
| [in] | y | Y offset of screen to copy from in framebuffer pixels. |
| [in] | width | Width of copy region in framebuffer pixels. |
| [in] | height | Height of copy region in framebuffer pixels. |
| [in] | clearScreen | If true, the framebuffer is cleared after copying. |
| bool Texture::Create | ( | short | xSize, |
| short | ySize, | ||
| u_int | filterMode, | ||
| u_int | format | ||
| ) |
Creates a texture image.
Creates a memory buffer for storing texture data.
| [in] | xSize | X size of texture in pixels. |
| [in] | ySize | Y size of texture in pixels. |
| [in] | filterMode | Filtering mode (see gdl::TextureFilterModes). |
| [in] | format | Texture format (see gdl::TextureFormatModes). |
| bool Texture::CreateMipmapped | ( | short | xSize, |
| short | ySize, | ||
| u_int | minFilt, | ||
| u_int | magFilt, | ||
| short | maxMipmaps, | ||
| u_int | format | ||
| ) |
Creates a mipmapped texture image.
Unlike gdl::Texture::Create(), this function creates a mipmapped texture buffer which improves rendering quality (and in some cases performance) when the texture is drawn smaller than its original resolution. It is recommended to use mipmapped textures for large 3D geometry or images that get scaled up or down immensely and you don't want it to look all jagged and pixelated when it gets small enough.
| [in] | xSize | X size of texture in pixels. |
| [in] | ySize | Y size of texture in pixels. |
| [in] | minFilt | Filtering mode when texture is drawn less than the original resolution (see gdl::TextureFilterModes). |
| [in] | magFilt | Filtering mode when texture is drawn higher than the original resolution (see gdl::TextureFilterModes). |
| [in] | maxMipmaps | Number of mipmaps to generate. |
| [in] | format | Texture format (see gdl::TextureFormatModes). |
| void Texture::Delete | ( | ) |
Deletes the texture (but not the object itself).
This function deallocates the texture data block associated to it and resets various parameters of the texture to 0.
| void Texture::Flush | ( | ) |
Flushes the texture's data block.
If gdl::SetAutoFlush() is set to false, you must call this function whenever you modify the contents of the texture data block otherwise, the changes will not take effect or it will initially appear as corrupted blocks.
| bool Texture::LoadTexture | ( | const char * | fileName | ) |
Loads a TPL texture file generated by gxtexconv.
This function loads a texture from a TPL texture file. TPL actually stands for Texture PaLette as the file format can contain multiple textures at once. However, this function only supports single texture TPL files currently. If the texture has mipmaps, trilinear mipmap filtering is set.
| [in] | fileName | File name of TPL texture file to load. |
| u_int Texture::PeekPixel | ( | short | x, |
| short | y | ||
| ) |
Peeks a pixel from the texture.
Peeks a pixel from the texture for generating things from images
| [in] | x | X offset of pixel to read. |
| [in] | y | Y offset of pixel to read. |
| void Texture::PokePixel | ( | short | x, |
| short | y, | ||
| u_int | col | ||
| ) |
Pokes a pixel into the texture.
Pokes a pixel into a texture useful for procedurally generating textures easily.
| [in] | x | X offset of pixel to draw to. |
| [in] | y | Y offset of pixel to draw to. |
| [in] | col | Color of pixel (use the RGBA() or IA() macros for this). |
| void Texture::SetFilterMode | ( | u_int | minFilt, |
| u_int | magFilt | ||
| ) |
Sets filter modes to a texture.
| [in] | minFilt | Filter mode when texture is < 1.0 of original size (see gdl::TextureFilterModes for more filter modes). |
| [in] | magFilt | Filter mode when texture is >= 1.0 of original size. |
| void Texture::SetWrapMode | ( | u_int | wrap_s, |
| u_int | wrap_t | ||
| ) |
| void * Texture::TexAddr | ( | ) |
Returns the pointer to the texture data block.
| short Texture::TexFmt | ( | ) |
Returns the texture format index of the texture.
| GXTexObj * Texture::TexObj | ( | ) |
Returns a pointer to the GXTexObj object of the texture.
Useful if you want to set the texture with GX_LoadTexObj() to be used as your current texture object.
| u_int Texture::TexSize | ( | ) |
Returns the size of the texture data in bytes.
| short Texture::TXsize | ( | ) |
Returns the X size of the texture in pixels.
| short Texture::TYsize | ( | ) |
Returns the Y size of the texture in pixels.