#include <ctexture.h>
Public Types | |
typedef CTexture *(* | fpTextureCreate )(void) |
Function pointer to a texture creation function. | |
Public Member Functions | |
CTexture () | |
Default constructor. Initially, no texture memory is allocated. | |
virtual | ~CTexture () |
Destructor. | |
unsigned int | getW () const |
Returns the width of the texture. | |
unsigned int | getH () const |
Returns the height of the texture. | |
unsigned int | getBPP () const |
Returns the number of bytes per pixel. | |
Locking / unlocking (you need to do this before/after modification) | |
virtual void | lock () |
virtual void | unlock () |
Texture modification | |
virtual void | resize (unsigned int w, unsigned int h, unsigned int bpp=0) |
virtual unsigned char * | getDataPointer () |
Static Public Member Functions | |
static void | setTextureCreateFunction (fpTextureCreate func) |
static fpTextureCreate | getTextureCreateFunction () |
Protected Member Functions | |
bool | reallocData () |
Re-allocates data based on m_W*m_H*m_BPP. | |
Protected Attributes | |
unsigned char * | m_Data |
Texture data stored in RAM. | |
Width, height and bytes per pixel | |
unsigned int | m_W |
unsigned int | m_H |
unsigned int | m_BPP |
An application developer may want to supply a derived class, to implement platform-specific code, e.g. for uploading the texture to video memory.
typedef CTexture*(* libProcTer::CTexture::fpTextureCreate)(void) |
Function pointer to a texture creation function.
libProcTer::CTexture::CTexture | ( | ) |
Default constructor. Initially, no texture memory is allocated.
virtual libProcTer::CTexture::~CTexture | ( | ) | [virtual] |
Destructor.
unsigned int libProcTer::CTexture::getBPP | ( | ) | const [inline] |
Returns the number of bytes per pixel.
virtual unsigned char* libProcTer::CTexture::getDataPointer | ( | ) | [virtual] |
Returns a pointer to the texture memory in RAM. Use this to access pixels for reading/writing.
unsigned int libProcTer::CTexture::getH | ( | ) | const [inline] |
Returns the height of the texture.
static fpTextureCreate libProcTer::CTexture::getTextureCreateFunction | ( | ) | [static] |
Returns the function pointer that has been set with setTextureCreateFunction(). libProcTer calls this method, and the returned function, for creating new texture objects.
unsigned int libProcTer::CTexture::getW | ( | ) | const [inline] |
Returns the width of the texture.
virtual void libProcTer::CTexture::lock | ( | ) | [virtual] |
Lock the texture. You should always lock before you try to modify the texture in any way.
May be overloaded by derived classes. The base method uses a lock for thread safety.
Reimplemented from libProcTer::CCriticalSection.
bool libProcTer::CTexture::reallocData | ( | ) | [protected] |
Re-allocates data based on m_W*m_H*m_BPP.
virtual void libProcTer::CTexture::resize | ( | unsigned int | w, | |
unsigned int | h, | |||
unsigned int | bpp = 0 | |||
) | [virtual] |
Resizes the texture to the given width, height and bytes per pixel. If bpp=0 is given, the number of bytes per pixel is unchanged.
static void libProcTer::CTexture::setTextureCreateFunction | ( | fpTextureCreate | func | ) | [static] |
If you have a custom, CTexture-derived class, and you want libProcter to use it, then you should call this function before creating CPlanet objects.
func | A function pointer to a function that returns a newly allocated texture object of your derived type. The texture returned by the function should be allocated with 'new'. |
virtual void libProcTer::CTexture::unlock | ( | ) | [virtual] |
Unlock the texture. You should always unlock after you are finished modifying the texture. Always unlock if you locked it, even if you didn't make any actual changes.
May be overloaded by derived classes. The base method uses a lock for thread safety.
Reimplemented from libProcTer::CCriticalSection.
unsigned char* libProcTer::CTexture::m_Data [protected] |
Texture data stored in RAM.