Main Page | Namespace List | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

NablaPS2Utils::TextureManager Class Reference

Class used to manage texture on PS2. More...

#include <TextureManager.h>

List of all members.

Public Member Functions

 TextureManager (const char *FileName, int SPS2Descriptor)
 Create a textureManger object reading a filename.

 ~TextureManager ()
 Deallocate all memory used.

void SendTexture (sps2uint32 GSAddress, sps2Memory_t *DMAMemory)
 Send texture to GS.

sps2uint64 BuildTEX0 (int TextureFunction) const
 Set TEX0 register.

sps2uint64 BuildTEX1 (int FilteringMode) const
 Set TEX1 register.

int Height () const
 Access height of the image.

int Width () const
 Access width of the image.

 operator void * () const
 Convert to void * for testing.


Private Member Functions

void UpdateImageData (const TextureFileHeader &TFH)
 Used to update data of the image.


Private Attributes

PSM_t m_pixelFormat
 Format of the pixel, used to determine if CLUT is present.

int m_width
 Image width.

int m_height
 Image height.

bool m_swizzled
 Image is swizzled (True/False).

int m_numMemBlocks
 Number of allocated blocks (4KB each).

int m_imageSize
 Size of the image in bytes.

sps2Memory_t * m_imageData
 Pixel of the image, raw data read from file.

sps2Memory_t * m_clutData
 Clut, raw data read from file.

bool m_status
 True if TextureManger object can be used, false otherwise.

int m_UploadAddress
 Last address where the texture was uploaded.

int m_SPS2Desc
 Descriptor of the SPS2 library used to manage memory.


Detailed Description

This is a simple class used to mange a single texture, a real texture manager should manage multiple texture in GS memory. If such a class is needed it can be build using TextureManger to handle single texture, for this reason the function used to send texture to GS accept the address where upload the texture.

Definition at line 33 of file TextureManager.h.


Constructor & Destructor Documentation

NablaPS2Utils::TextureManager::TextureManager const char *  FileName,
int  SPS2Descriptor
 

This is a simple routine because all swizzling, converting, resizing, etc etc is done previously by texture converter program. This way of proceeding is often used, to reduce run time complexity of the program. In this first release only 32 bit clut entries are supported, class must be extended to permit the use of 16 bit clut format. To correctly read the header, first the header structure must be read, then seek the file at first byte after the header, and header size must be taken by structure itself.

Parameters:
FileName Name of the file that contain texture, file must complain structure of the file generated by Texture Converter software
SPS2Descriptor Descriptor of SPS2 library, used to manage memory.

Definition at line 25 of file TextureManager.cpp.

NablaPS2Utils::TextureManager::~TextureManager  ) 
 

Simply release allocated memory for the texture.

Definition at line 78 of file TextureManager.cpp.


Member Function Documentation

sps2uint64 NablaPS2Utils::TextureManager::BuildTEX0 int  TextureFunction  )  const
 

Since TEX0 register must be set by main application when this texture must be used, this function build the structure of TEX0 register using texture function passed as argument by the main program.

Parameters:
TextureFunction Texture function to use.

Definition at line 217 of file TextureManager.cpp.

sps2uint64 NablaPS2Utils::TextureManager::BuildTEX1 int  FilteringMode  )  const
 

Since TEX1 register must be set by main application when this texture must be used but contains texture information, this function is used to build the structure of TEX1 register using filtering mode passed as argument by the main program.

Parameters:
FilteringMode It represent filtering mode for the texture, since in this first implementatio mipmapping is not used same value is used for minification as well for magnification.

Definition at line 244 of file TextureManager.cpp.

void NablaPS2Utils::TextureManager::SendTexture sps2uint32  GSAddress,
sps2Memory_t *  DMAMemory
 

DMA packet is build sequentially updating pointer to memory that hold the packet. This routine assume that texture data is to be uploaded in the first location of GSAdress, remember that is possible to transfer texture not only at the beginning of the buffer using TRXPOS register.

Parameters:
GSAddress Address in GS where to upload texture into, remember that this address must be in word address / 64, so since a word is 4 bytes long, to translate from byte address to word / 64 address it is necessary to divide by 256. If original address is in page address, since a page is 8KB, it is necessary multiplying address by 32 since 8196 / 256 = 32.
DMAMemory Memory used to build DMA packet. Since dma packet is small and is not possible to allocate memory in chunk smaller than 4KB it is convenient allocate a single 4KB area in main program and pass this buffer to every routine that need to do DMA transfer.

Update upload address.

Definition at line 100 of file TextureManager.cpp.

void NablaPS2Utils::TextureManager::UpdateImageData const TextureFileHeader TFH  )  [private]
 

This function update image data into texture manager.

Definition at line 259 of file TextureManager.cpp.


The documentation for this class was generated from the following files:
Generated on Wed Jan 7 19:12:21 2004 for PS2 Tutorial by doxygen 1.3.4