VideoGL Wrapper (internal)


Enumerations

enum  UL_BANKS {
  UL_BANK_A = 0x1, UL_BANK_B = 0x2, UL_BANK_C = 0x4, UL_BANK_D = 0x8,
  UL_BANK_E = 0x10, UL_BANK_F = 0x20, UL_BANK_G = 0x40, UL_BANK_H = 0x100,
  UL_BANK_I = 0x200
}
enum  UL_BANK_TYPE { UL_BANK_TYPE_LCD = 1, UL_BANK_TYPE_TEXTURE = 2, UL_BANK_TYPE_TEXPAL = 4 }

Functions

int ulSetTexVramParameters (UL_BANKS activeBanks, void *baseAddr, int totalSize)
int ulSetTexPalVramParameters (UL_BANKS activeBanks, void *baseAddr, int totalSize)
int ulTexImage2D (int target, int empty1, int type, int sizeX, int sizeY, int empty2, int param, uint8 *texture)
void ulTexParameter (uint8 sizeX, uint8 sizeY, uint32 *addr, uint8 mode, uint32 param)
int ulGetTexParameter ()
int ulGenTextures (int n, int *names)
void ulBindTexture (int target, int name)
void ulFreeTextures (int n, int *names)
int uluTexLoadPal (u16 *pal, u16 count, uint8 format)
void uluTexUnloadPal (u32 addr)
void ulBindTextureToGl (int target, int name)
void ulSetTexAlphaMask (int enable)
void ulChangeVramAllocation (UL_BANKS banks, UL_BANK_TYPE type)
void * ulReadTextureToMemory (int textureID, int sizeX, int sizeY, int type)
void * ulReadPaletteToMemory (int paletteID, int palCount)
int ulGetTexVramAvailMemory ()
int ulGetTexVramUsedMemory ()
int ulGetTexVramTotalMemory ()
int ulGetTexPalAvailMemory ()
int ulGetTexPalUsedMemory ()
int ulGetTexPalTotalMemory ()
int ulGetVertexAvailMemory ()
int ulGetVertexUsedMemory ()
int ulGetVertexTotalMemory ()

Variables

u8 ul_optimizeTextureSize
u8 ul_initTexturesToZero

Detailed Description

Wrapper for the default libnds VideoGL utility library. Implements namely a dynamic texture system, which allows you to create and remove textures / palettes into VRAM as you want. It's used for internal purposes but you can still use it if you want, however I can't guarantee full forward compatibility for some "hacky" functions.

Enumeration Type Documentation

enum UL_BANKS

Available banks for memory allocation.

Enumerator:
UL_BANK_A  Bank A (128 kB).
UL_BANK_B  Bank B (128 kB).
UL_BANK_C  Bank C (128 kB).
UL_BANK_D  Bank D (128 kB).
UL_BANK_E  Bank E (64 kB).
UL_BANK_F  Bank F (16 kB).
UL_BANK_G  Bank G (16 kB).
UL_BANK_H  Bank H (32 kB).
UL_BANK_I  Bank I (16 kB).

enum UL_BANK_TYPE

Bank types.

Enumerator:
UL_BANK_TYPE_LCD  LCD (mapped to ARM9 memory).
UL_BANK_TYPE_TEXTURE  Texture memory.
UL_BANK_TYPE_TEXPAL  Texture palette memory.


Function Documentation

int ulSetTexVramParameters ( UL_BANKS  activeBanks,
void *  baseAddr,
int  totalSize 
)

Changes the VRAM allocation parameters for textures. By default, it is allocated to bank A and is 128 kB wide.

Parameters:
activeBanks Banks that will be allocated to texture memory. OR them to allocate several banks. Usually UL_BANK_A | UL_BANK_B.
baseAddr Video memory base address. Usually (void*)0x06800000. If you select UL_BANK_B only, it will be 0x06820000 and so on.
totalSize Total video memory size. For one bank (UL_BANK_A) it's 128 << 10, for two banks (UL_BANK_A | UL_BANK_B) it's 256 << 10, and so on. << 10 multiplies a number by 1024, meaning kilobytes. Should be a multiple of 16.
Returns:
1 on success, 0 on failure.
By calling this function, you must be very careful:

Here are two lines: the first one is the default, the second one is the recommended for accessing the 256 kB of texture memory.

ulSetTexVramParameters(UL_BANK_A, VRAM_A, 128 << 10);
ulSetTexVramParameters(UL_BANK_A | UL_BANK_B, VRAM_A, 256 << 10);

int ulSetTexPalVramParameters ( UL_BANKS  activeBanks,
void *  baseAddr,
int  totalSize 
)

Same as ulSetTexVramParameters but for palettes. Default is:

An equivalent for what VideoGL uses by default is:

int ulTexImage2D ( int  target,
int  empty1,
int  type,
int  sizeX,
int  sizeY,
int  empty2,
int  param,
uint8 *  texture 
)

glTexImage2D replacement.

There are some differences: 1) sizeX and sizeY parameter specifies the texture size IN PIXELS, unlike in libnds. If their size is not a power of two:

void ulTexParameter ( uint8  sizeX,
uint8  sizeY,
uint32 *  addr,
uint8  mode,
uint32  param 
)

glTexParameter replacement.

int ulGetTexParameter (  )  [inline]

glGetTexParameter replacement.

int ulGenTextures ( int  n,
int *  names 
)

glGenTextures replacement.

void ulBindTexture ( int  target,
int  name 
)

glBindTexture replacement.

void ulFreeTextures ( int  n,
int *  names 
)

Frees a list of textures created with ulGenTextures and ulTexImage2D.

int uluTexLoadPal ( u16 *  pal,
u16  count,
uint8  format 
)

gluTexLoadPal replacement, with NULL parameter check for pal.

void uluTexUnloadPal ( u32  addr  ) 

glTexUnloadPal replacement.

void ulBindTextureToGl ( int  target,
int  name 
)

Binds a texture so that you can use it with the standard VideoGL API.

This is an awful hack, and will REPLACE the currently active texture in VideoGL. You should not use both systems at once, this hack is only designed so that you can select a texture and use VideoGL commands that rely on the active texture.

void ulSetTexAlphaMask ( int  enable  )  [inline]

void ulChangeVramAllocation ( UL_BANKS  banks,
UL_BANK_TYPE  type 
)

Changes the current state of one or several VRAM banks. Example (set bank A and B to LCD so you can access it):

void* ulReadTextureToMemory ( int  textureID,
int  sizeX,
int  sizeY,
int  type 
)

Internal, do not use.

void* ulReadPaletteToMemory ( int  paletteID,
int  palCount 
)

Internal, do not use.

int ulGetTexVramAvailMemory (  ) 

Returns the number of bytes available in texture memory.

int ulGetTexVramUsedMemory (  ) 

Returns the number of bytes used in texture memory.

int ulGetTexVramTotalMemory (  ) 

Returns the total number of bytes of texture memory (used + remaining).

int ulGetTexPalAvailMemory (  ) 

Returns the number of bytes available in texture palette memory.

int ulGetTexPalUsedMemory (  ) 

Returns the number of bytes used in texture palette memory.

int ulGetTexPalTotalMemory (  ) 

Returns the total number of bytes of texture palette memory (used + remaining).

int ulGetVertexAvailMemory (  )  [inline]

Returns the number of vertices available in the vertex memory (internal to the GPU).

Each vertex counts as 1 unit, so a quad will take 4 vertices in memory, and a triangle 3 vertices.

When the vertex memory is full, it will no more be possible to draw anything with µLibrary, so this is something very useful to watch!

int ulGetVertexUsedMemory (  )  [inline]

Returns the number of vertex already stored since the render has started.

int ulGetVertexTotalMemory (  )  [inline]

Returns the total number of vertices possible in the vertex memory.


Variable Documentation

u8 ul_optimizeTextureSize

Allows to optimize the image sizes to use less memory. Enabled by default.

u8 ul_initTexturesToZero

Fills textures with zeroes when creating them. See UL_TEXINITZERO for more information.


Generated on Sat Jul 14 23:39:33 2007 by  doxygen 1.5.2