Add rudimentary and non-working code for translucency on patches.
This commit is contained in:
parent
cfb5a9d904
commit
bb49362577
47
src/r_data.c
47
src/r_data.c
|
@ -211,6 +211,41 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, INT
|
||||||
patch = (column_t *)((UINT8 *)patch + patch->length + 4);
|
patch = (column_t *)((UINT8 *)patch + patch->length + 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
R_DrawTranslucentColumn_8()
|
||||||
|
static inline void R_DrawTransColumnInCache(column_t *patch, UINT8 *cache, INT32 originy, INT32 cacheheight)
|
||||||
|
{
|
||||||
|
INT32 count, position;
|
||||||
|
UINT8 *source;
|
||||||
|
INT32 topdelta, prevdelta = -1;
|
||||||
|
|
||||||
|
while (patch->topdelta != 0xff)
|
||||||
|
{
|
||||||
|
topdelta = patch->topdelta;
|
||||||
|
if (topdelta <= prevdelta)
|
||||||
|
topdelta += prevdelta;
|
||||||
|
prevdelta = topdelta;
|
||||||
|
source = (UINT8 *)patch + 3;
|
||||||
|
count = patch->length;
|
||||||
|
position = originy + topdelta;
|
||||||
|
|
||||||
|
if (position < 0)
|
||||||
|
{
|
||||||
|
count += position;
|
||||||
|
source -= position; // start further down the column
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position + count > cacheheight)
|
||||||
|
count = cacheheight - position;
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
M_Memcpy(cache + position, source, count);
|
||||||
|
|
||||||
|
patch = (column_t *)((UINT8 *)patch + patch->length + 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_GenerateTexture
|
// R_GenerateTexture
|
||||||
|
@ -588,6 +623,8 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
|
||||||
INT16 patchXPos;
|
INT16 patchXPos;
|
||||||
INT16 patchYPos;
|
INT16 patchYPos;
|
||||||
UINT8 flip = 0;
|
UINT8 flip = 0;
|
||||||
|
UINT8 alpha = 255;
|
||||||
|
enum patchalphastyle style = AST_COPY;
|
||||||
texpatch_t *resultPatch = NULL;
|
texpatch_t *resultPatch = NULL;
|
||||||
lumpnum_t patchLumpNum;
|
lumpnum_t patchLumpNum;
|
||||||
|
|
||||||
|
@ -703,7 +740,13 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
|
||||||
}
|
}
|
||||||
while (strcmp(texturesToken,"}")!=0)
|
while (strcmp(texturesToken,"}")!=0)
|
||||||
{
|
{
|
||||||
if (stricmp(texturesToken, "FLIPX")==0)
|
if (stricmp(texturesToken, "ALPHA")==0)
|
||||||
|
{
|
||||||
|
Z_Free(texturesToken);
|
||||||
|
texturesToken = M_GetToken(NULL);
|
||||||
|
alpha = 255*strtof(texturesToken, NULL);
|
||||||
|
}
|
||||||
|
else if (stricmp(texturesToken, "FLIPX")==0)
|
||||||
flip |= 1;
|
flip |= 1;
|
||||||
else if (stricmp(texturesToken, "FLIPY")==0)
|
else if (stricmp(texturesToken, "FLIPY")==0)
|
||||||
flip |= 2;
|
flip |= 2;
|
||||||
|
@ -736,6 +779,8 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
|
||||||
resultPatch->lump = patchLumpNum & 65535;
|
resultPatch->lump = patchLumpNum & 65535;
|
||||||
resultPatch->wad = patchLumpNum>>16;
|
resultPatch->wad = patchLumpNum>>16;
|
||||||
resultPatch->flip = flip;
|
resultPatch->flip = flip;
|
||||||
|
resultPatch->alpha = alpha;
|
||||||
|
resultPatch->style = style;
|
||||||
// Clean up a little after ourselves
|
// Clean up a little after ourselves
|
||||||
Z_Free(patchName);
|
Z_Free(patchName);
|
||||||
// Then return it
|
// Then return it
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Possible alpha types for a patch.
|
||||||
|
enum patchalphastyle {AST_COPY, AST_TRANSLUCENT}; // , AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY};
|
||||||
|
|
||||||
// moved here for r_sky.c (texpatch_t is used)
|
// moved here for r_sky.c (texpatch_t is used)
|
||||||
|
|
||||||
// A single patch from a texture definition,
|
// A single patch from a texture definition,
|
||||||
|
@ -32,6 +35,8 @@ typedef struct
|
||||||
INT16 originx, originy;
|
INT16 originx, originy;
|
||||||
UINT16 wad, lump;
|
UINT16 wad, lump;
|
||||||
UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both
|
UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both
|
||||||
|
UINT8 alpha; // Translucency value
|
||||||
|
enum patchalphastyle style;
|
||||||
} texpatch_t;
|
} texpatch_t;
|
||||||
|
|
||||||
// A maptexturedef_t describes a rectangular texture,
|
// A maptexturedef_t describes a rectangular texture,
|
||||||
|
|
Loading…
Reference in New Issue