mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[CHG] Optimization in tile calculation
i only modded DrawTile, if this mod is ok for all and fully tested we need to make this change to all functions the needs calculation like this. (drawpart, drawtilequad, etc...)
This commit is contained in:
parent
db1246ce52
commit
8f2e7413e5
3 changed files with 9 additions and 4 deletions
|
@ -111,5 +111,7 @@ void GRRLIB_InitTileSet (GRRLIB_texImg *tex,
|
|||
tex->nbtileh = tex->h / tileh;
|
||||
tex->tilestart = tilestart;
|
||||
tex->tiledtex = true;
|
||||
tex->ofnormaltexx = 1.0F/tex->nbtilew;
|
||||
tex->ofnormaltexy = 1.0F/tex->nbtileh;
|
||||
GRRLIB_SetHandle( tex, 0, 0 );
|
||||
}
|
||||
|
|
|
@ -177,10 +177,10 @@ void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
|
|||
if (tex == NULL || tex->data == NULL) return ;
|
||||
|
||||
// The 0.001f/x is the frame correction formula by spiffen
|
||||
s1 = (( (frame %tex->nbtilew) ) /(f32)tex->nbtilew) +(0.001f /tex->w);
|
||||
s2 = (( (frame %tex->nbtilew) +1) /(f32)tex->nbtilew) -(0.001f /tex->w);
|
||||
t1 = (((int)(frame /tex->nbtilew) ) /(f32)tex->nbtileh) +(0.001f /tex->h);
|
||||
t2 = (((int)(frame /tex->nbtilew) +1) /(f32)tex->nbtileh) -(0.001f /tex->h);
|
||||
s1 = (frame % tex->nbtilew) * tex->ofnormaltexx;
|
||||
s2 = s1 + tex->ofnormaltexx;
|
||||
t1 = (int)(frame/tex->nbtilew) * tex->ofnormaltexy;
|
||||
t2 = t1 + tex->ofnormaltexy;
|
||||
|
||||
GX_InitTexObj(&texObj, tex->data,
|
||||
tex->tilew * tex->nbtilew, tex->tileh * tex->nbtileh,
|
||||
|
|
|
@ -115,6 +115,9 @@ typedef struct GRRLIB_texImg {
|
|||
uint nbtilew; /**< Number of tiles for the x axis. */
|
||||
uint nbtileh; /**< Number of tiles for the y axis. */
|
||||
uint tilestart; /**< Offset to tile starting position. */
|
||||
f32 ofnormaltexx; /**< Offset of normalized texture on x */
|
||||
f32 ofnormaltexy; /**< Offset of normalized texture on y */
|
||||
|
||||
|
||||
void *data; /**< Pointer to the texture data. */
|
||||
} GRRLIB_texImg;
|
||||
|
|
Loading…
Reference in a new issue