some more mucking about with function arguments (preparing for alpha/flip support adding particularly), also fixed a slipup I made when I first made HWR_DrawColumnInCache
This commit is contained in:
parent
d2c6b995d3
commit
7321df8015
|
@ -67,14 +67,14 @@ static const INT32 format2bpp[16] =
|
||||||
static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap,
|
static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap,
|
||||||
INT32 pblockheight, INT32 blockmodulo,
|
INT32 pblockheight, INT32 blockmodulo,
|
||||||
fixed_t yfracstep, fixed_t scale_y,
|
fixed_t yfracstep, fixed_t scale_y,
|
||||||
INT32 originy,
|
texpatch_t *originPatch, INT32 patchheight,
|
||||||
INT32 bpp
|
INT32 bpp)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
fixed_t yfrac, position, count;
|
fixed_t yfrac, position, count;
|
||||||
UINT8 *dest;
|
UINT8 *dest;
|
||||||
const UINT8 *source;
|
const UINT8 *source;
|
||||||
INT32 topdelta, prevdelta = -1;
|
INT32 topdelta, prevdelta = -1;
|
||||||
|
INT32 originy = 0;
|
||||||
|
|
||||||
// for writing a pixel to dest
|
// for writing a pixel to dest
|
||||||
RGBA_t colortemp;
|
RGBA_t colortemp;
|
||||||
|
@ -82,6 +82,11 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
|
||||||
UINT8 texel;
|
UINT8 texel;
|
||||||
UINT16 texelu16;
|
UINT16 texelu16;
|
||||||
|
|
||||||
|
(void)patchheight; // This parameter is unused
|
||||||
|
|
||||||
|
if (originPatch) // originPatch can be NULL here, unlike in the software version
|
||||||
|
originy = originPatch->originy;
|
||||||
|
|
||||||
while (patchcol->topdelta != 0xff)
|
while (patchcol->topdelta != 0xff)
|
||||||
{
|
{
|
||||||
topdelta = patchcol->topdelta;
|
topdelta = patchcol->topdelta;
|
||||||
|
@ -199,19 +204,17 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
|
||||||
patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[xfrac>>FRACBITS]));
|
patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[xfrac>>FRACBITS]));
|
||||||
|
|
||||||
HWR_DrawColumnInCache(patchcol, block, mipmap,
|
HWR_DrawColumnInCache(patchcol, block, mipmap,
|
||||||
pheight, blockmodulo,
|
pblockheight, blockmodulo,
|
||||||
yfracstep, scale_y,
|
yfracstep, scale_y,
|
||||||
0,
|
NULL, pheight, // not that pheight is going to get used anyway...
|
||||||
bpp
|
bpp);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function we use for caching patches that belong to textures
|
// This function we use for caching patches that belong to textures
|
||||||
static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
|
static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
|
||||||
INT32 pblockwidth, INT32 pblockheight,
|
INT32 pblockwidth, INT32 pblockheight,
|
||||||
INT32 ptexturewidth, INT32 ptextureheight,
|
texture_t *texture, texpatch_t *patch,
|
||||||
INT32 originx, INT32 originy, // where to draw patch in surface block
|
|
||||||
const patch_t *realpatch)
|
const patch_t *realpatch)
|
||||||
{
|
{
|
||||||
INT32 x, x1, x2;
|
INT32 x, x1, x2;
|
||||||
|
@ -222,17 +225,20 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
|
||||||
UINT8 *block = mipmap->grInfo.data;
|
UINT8 *block = mipmap->grInfo.data;
|
||||||
INT32 bpp;
|
INT32 bpp;
|
||||||
INT32 blockmodulo;
|
INT32 blockmodulo;
|
||||||
|
INT32 width, height;
|
||||||
|
|
||||||
if (ptexturewidth <= 0 || ptextureheight <= 0)
|
if (texture->width <= 0 || texture->height <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x1 = originx;
|
x1 = patch->originx;
|
||||||
x2 = x1 + SHORT(realpatch->width);
|
width = SHORT(realpatch->width);
|
||||||
|
height = SHORT(realpatch->height);
|
||||||
|
x2 = x1 + width;
|
||||||
|
|
||||||
if (x1 > ptexturewidth || x2 < 0)
|
if (x1 > texture->width || x2 < 0)
|
||||||
return; // patch not located within texture's x bounds, ignore
|
return; // patch not located within texture's x bounds, ignore
|
||||||
|
|
||||||
if (originy > ptextureheight || (originy + SHORT(realpatch->height)) < 0)
|
if (patch->originy > texture->height || (patch->originy + height) < 0)
|
||||||
return; // patch not located within texture's y bounds, ignore
|
return; // patch not located within texture's y bounds, ignore
|
||||||
|
|
||||||
// patch is actually inside the texture!
|
// patch is actually inside the texture!
|
||||||
|
@ -245,18 +251,17 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
|
||||||
x = x1;
|
x = x1;
|
||||||
|
|
||||||
// right edge
|
// right edge
|
||||||
if (x2 > ptexturewidth)
|
if (x2 > texture->width)
|
||||||
x2 = ptexturewidth;
|
x2 = texture->width;
|
||||||
|
|
||||||
|
|
||||||
col = x * pblockwidth / ptexturewidth;
|
col = x * pblockwidth / texture->width;
|
||||||
ncols = ((x2 - x) * pblockwidth) / ptexturewidth;
|
ncols = ((x2 - x) * pblockwidth) / texture->width;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONS_Debug(DBG_RENDER, "patch %dx%d texture %dx%d block %dx%d\n", SHORT(realpatch->width),
|
CONS_Debug(DBG_RENDER, "patch %dx%d texture %dx%d block %dx%d\n",
|
||||||
SHORT(realpatch->height),
|
width, height,
|
||||||
ptexturewidth,
|
texture->width, texture->height,
|
||||||
textureheight,
|
|
||||||
pblockwidth, pblockheight);
|
pblockwidth, pblockheight);
|
||||||
CONS_Debug(DBG_RENDER, " col %d ncols %d x %d\n", col, ncols, x);
|
CONS_Debug(DBG_RENDER, " col %d ncols %d x %d\n", col, ncols, x);
|
||||||
*/
|
*/
|
||||||
|
@ -266,9 +271,9 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
|
||||||
if (x1 < 0)
|
if (x1 < 0)
|
||||||
xfrac = -x1<<FRACBITS;
|
xfrac = -x1<<FRACBITS;
|
||||||
|
|
||||||
xfracstep = (ptexturewidth << FRACBITS) / pblockwidth;
|
xfracstep = (texture->width << FRACBITS) / pblockwidth;
|
||||||
yfracstep = (ptextureheight<< FRACBITS) / pblockheight;
|
yfracstep = (texture->height<< FRACBITS) / pblockheight;
|
||||||
scale_y = (pblockheight << FRACBITS) / ptextureheight;
|
scale_y = (pblockheight << FRACBITS) / texture->height;
|
||||||
|
|
||||||
bpp = format2bpp[mipmap->grInfo.format];
|
bpp = format2bpp[mipmap->grInfo.format];
|
||||||
|
|
||||||
|
@ -284,11 +289,10 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
|
||||||
patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[xfrac>>FRACBITS]));
|
patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[xfrac>>FRACBITS]));
|
||||||
|
|
||||||
HWR_DrawColumnInCache(patchcol, block, mipmap,
|
HWR_DrawColumnInCache(patchcol, block, mipmap,
|
||||||
ptextureheight, blockmodulo,
|
pblockheight, blockmodulo,
|
||||||
yfracstep, scale_y,
|
yfracstep, scale_y,
|
||||||
originy,
|
patch, height,
|
||||||
bpp
|
bpp);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,8 +538,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
|
||||||
realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE);
|
realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE);
|
||||||
HWR_DrawTexturePatchInCache(&grtex->mipmap,
|
HWR_DrawTexturePatchInCache(&grtex->mipmap,
|
||||||
blockwidth, blockheight,
|
blockwidth, blockheight,
|
||||||
texture->width, texture->height,
|
texture, patch,
|
||||||
patch->originx, patch->originy,
|
|
||||||
realpatch);
|
realpatch);
|
||||||
Z_Unlock(realpatch);
|
Z_Unlock(realpatch);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue