mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Merge branch 'pictureformats' into patch-stuff-again-2
This commit is contained in:
commit
9b426b474c
33 changed files with 3783 additions and 3275 deletions
|
@ -126,7 +126,9 @@ set(SRB2_CORE_RENDER_SOURCES
|
|||
r_sky.c
|
||||
r_splats.c
|
||||
r_things.c
|
||||
r_textures.c
|
||||
r_patch.c
|
||||
r_picformats.c
|
||||
r_portal.c
|
||||
|
||||
r_bsp.h
|
||||
|
@ -142,7 +144,9 @@ set(SRB2_CORE_RENDER_SOURCES
|
|||
r_splats.h
|
||||
r_state.h
|
||||
r_things.h
|
||||
r_textures.h
|
||||
r_patch.h
|
||||
r_picformats.h
|
||||
r_portal.h
|
||||
)
|
||||
|
||||
|
|
|
@ -469,7 +469,9 @@ OBJS:=$(i_main_o) \
|
|||
$(OBJDIR)/r_sky.o \
|
||||
$(OBJDIR)/r_splats.o \
|
||||
$(OBJDIR)/r_things.o \
|
||||
$(OBJDIR)/r_textures.o \
|
||||
$(OBJDIR)/r_patch.o \
|
||||
$(OBJDIR)/r_picformats.o \
|
||||
$(OBJDIR)/r_portal.o \
|
||||
$(OBJDIR)/screen.o \
|
||||
$(OBJDIR)/v_video.o \
|
||||
|
|
|
@ -29,8 +29,10 @@
|
|||
#include "p_local.h" // for var1 and var2, and some constants
|
||||
#include "p_setup.h"
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "r_draw.h"
|
||||
#include "r_patch.h"
|
||||
#include "r_picformats.h"
|
||||
#include "r_things.h" // R_Char2Frame
|
||||
#include "r_sky.h"
|
||||
#include "fastcmp.h"
|
||||
|
|
|
@ -20,11 +20,13 @@
|
|||
#include "../doomstat.h" //gamemode
|
||||
#include "../i_video.h" //rendermode
|
||||
#include "../r_data.h"
|
||||
#include "../r_textures.h"
|
||||
#include "../w_wad.h"
|
||||
#include "../z_zone.h"
|
||||
#include "../v_video.h"
|
||||
#include "../r_draw.h"
|
||||
#include "../r_patch.h"
|
||||
#include "../r_picformats.h"
|
||||
#include "../p_setup.h"
|
||||
|
||||
INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes
|
||||
|
@ -99,6 +101,10 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
|
|||
count--;
|
||||
|
||||
texel = source[yfrac>>FRACBITS];
|
||||
alpha = 0xFF;
|
||||
// Make pixel transparent if chroma keyed
|
||||
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
|
||||
alpha = 0x00;
|
||||
|
||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||
if (mipmap->colormap)
|
||||
|
@ -211,17 +217,15 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block,
|
|||
count--;
|
||||
|
||||
texel = source[yfrac>>FRACBITS];
|
||||
alpha = 0xFF;
|
||||
// Make pixel transparent if chroma keyed
|
||||
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
|
||||
alpha = 0x00;
|
||||
|
||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||
if (mipmap->colormap)
|
||||
texel = mipmap->colormap[texel];
|
||||
|
||||
// If the mipmap is chromakeyed, check if the texel's color
|
||||
// is equivalent to the chroma key's color index.
|
||||
alpha = 0xff;
|
||||
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
|
||||
alpha = 0x00;
|
||||
|
||||
// hope compiler will get this switch out of the loops (dreams...)
|
||||
// gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?)
|
||||
// Alam: SRB2 uses Mingw, HUGS
|
||||
|
@ -508,13 +512,17 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
|
|||
realpatch = (softwarepatch_t *)pdata;
|
||||
|
||||
#ifndef NO_PNG_LUMPS
|
||||
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
||||
realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL);
|
||||
if (Picture_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
||||
{
|
||||
// Dummy variables.
|
||||
INT32 pngwidth, pngheight;
|
||||
realpatch = (softwarepatch_t *)Picture_PNGConvert(pdata, PICFMT_PATCH, &pngwidth, &pngheight, NULL, NULL, lumplength, NULL, 0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef WALLFLATS
|
||||
if (texture->type == TEXTURETYPE_FLAT)
|
||||
realpatch = R_FlatToPatch(pdata, texture->width, texture->height, 0, 0, NULL, false);
|
||||
realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_PATCH, 0, NULL, texture->width, texture->height, 0, 0, 0);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
@ -834,6 +842,8 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
|||
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
|
||||
{
|
||||
UINT8 *flat;
|
||||
UINT8 *converted;
|
||||
size_t size;
|
||||
|
||||
// setup the texture info
|
||||
grMipmap->format = GL_TEXFMT_P_8;
|
||||
|
@ -841,11 +851,12 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
|
|||
|
||||
grMipmap->width = (UINT16)textures[texturenum]->width;
|
||||
grMipmap->height = (UINT16)textures[texturenum]->height;
|
||||
size = (grMipmap->width * grMipmap->height);
|
||||
|
||||
flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->data);
|
||||
memset(flat, TRANSPARENTPIXEL, grMipmap->width * grMipmap->height);
|
||||
|
||||
R_TextureToFlat(texturenum, flat);
|
||||
flat = Z_Malloc(size, PU_HWRCACHE, &grMipmap->data);
|
||||
converted = (UINT8 *)Picture_TextureToFlat(texturenum);
|
||||
M_Memcpy(flat, converted, size);
|
||||
Z_Free(converted);
|
||||
}
|
||||
|
||||
// Download a Doom 'flat' to the hardware cache and make it ready for use
|
||||
|
@ -885,7 +896,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
|
|||
INT32 texturenum = levelflat->u.texture.num;
|
||||
#ifdef PARANOIA
|
||||
if ((unsigned)texturenum >= gl_numtextures)
|
||||
I_Error("HWR_GetLevelFlat: texturenum >= numtextures\n");
|
||||
I_Error("HWR_GetLevelFlat: texturenum >= numtextures");
|
||||
#endif
|
||||
|
||||
// Who knows?
|
||||
|
@ -907,6 +918,53 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
|
|||
// The system-memory data can be purged now.
|
||||
Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
else if (levelflat->type == LEVELFLAT_PATCH)
|
||||
{
|
||||
patch_t *patch = W_CachePatchNum(levelflat->u.flat.lumpnum, PU_CACHE);
|
||||
levelflat->width = (UINT16)(patch->width);
|
||||
levelflat->height = (UINT16)(patch->height);
|
||||
HWR_GetPatch(patch);
|
||||
}
|
||||
#ifndef NO_PNG_LUMPS
|
||||
else if (levelflat->type == LEVELFLAT_PNG)
|
||||
{
|
||||
INT32 pngwidth, pngheight;
|
||||
GLMipmap_t *mipmap = levelflat->mipmap;
|
||||
UINT8 *flat;
|
||||
size_t size;
|
||||
|
||||
// Cache the picture.
|
||||
if (!levelflat->picture)
|
||||
{
|
||||
levelflat->picture = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0);
|
||||
levelflat->width = (UINT16)pngwidth;
|
||||
levelflat->height = (UINT16)pngheight;
|
||||
}
|
||||
|
||||
// Make the mipmap.
|
||||
if (mipmap == NULL)
|
||||
{
|
||||
mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_LEVEL, NULL);
|
||||
mipmap->format = GL_TEXFMT_P_8;
|
||||
mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
|
||||
levelflat->mipmap = mipmap;
|
||||
}
|
||||
|
||||
if (!mipmap->data && !mipmap->downloaded)
|
||||
{
|
||||
mipmap->width = levelflat->width;
|
||||
mipmap->height = levelflat->height;
|
||||
size = (mipmap->width * mipmap->height);
|
||||
flat = Z_Malloc(size, PU_LEVEL, &mipmap->data);
|
||||
if (levelflat->picture == NULL)
|
||||
I_Error("HWR_GetLevelFlat: levelflat->picture == NULL");
|
||||
M_Memcpy(flat, levelflat->picture, size);
|
||||
}
|
||||
|
||||
// Tell the hardware driver to bind the current texture to the flat's mipmap
|
||||
HWD.pfnSetTexture(mipmap);
|
||||
}
|
||||
#endif
|
||||
else // set no texture
|
||||
HWR_SetCurrentTexture(NULL);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "../p_setup.h"
|
||||
#include "../r_local.h"
|
||||
#include "../r_patch.h"
|
||||
#include "../r_picformats.h"
|
||||
#include "../r_bsp.h"
|
||||
#include "../d_clisrv.h"
|
||||
#include "../w_wad.h"
|
||||
|
@ -358,7 +359,6 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
||||
INT32 flatflag = 63;
|
||||
boolean texflat = false;
|
||||
size_t len;
|
||||
float scrollx = 0.0f, scrolly = 0.0f;
|
||||
angle_t angle = 0;
|
||||
FSurfaceInfo Surf;
|
||||
|
@ -413,16 +413,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
// set texture for polygon
|
||||
if (levelflat != NULL)
|
||||
{
|
||||
if (levelflat->type == LEVELFLAT_TEXTURE)
|
||||
if (levelflat->type == LEVELFLAT_FLAT)
|
||||
{
|
||||
fflatwidth = textures[levelflat->u.texture.num]->width;
|
||||
fflatheight = textures[levelflat->u.texture.num]->height;
|
||||
texflat = true;
|
||||
}
|
||||
else if (levelflat->type == LEVELFLAT_FLAT)
|
||||
{
|
||||
len = W_LumpLength(levelflat->u.flat.lumpnum);
|
||||
|
||||
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
|
||||
switch (len)
|
||||
{
|
||||
case 4194304: // 2048x2048 lump
|
||||
|
@ -447,9 +440,22 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
fflatwidth = fflatheight = 64.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
flatflag = ((INT32)fflatwidth)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (levelflat->type == LEVELFLAT_TEXTURE)
|
||||
{
|
||||
fflatwidth = textures[levelflat->u.texture.num]->width;
|
||||
fflatheight = textures[levelflat->u.texture.num]->height;
|
||||
}
|
||||
else if (levelflat->type == LEVELFLAT_PATCH || levelflat->type == LEVELFLAT_PNG)
|
||||
{
|
||||
fflatwidth = levelflat->width;
|
||||
fflatheight = levelflat->height;
|
||||
}
|
||||
texflat = true;
|
||||
}
|
||||
}
|
||||
else // set no texture
|
||||
HWR_SetCurrentTexture(NULL);
|
||||
|
@ -2659,7 +2665,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
||||
INT32 flatflag = 63;
|
||||
boolean texflat = false;
|
||||
size_t len;
|
||||
float scrollx = 0.0f, scrolly = 0.0f;
|
||||
angle_t angle = 0;
|
||||
FSurfaceInfo Surf;
|
||||
|
@ -2693,16 +2698,9 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
// set texture for polygon
|
||||
if (levelflat != NULL)
|
||||
{
|
||||
if (levelflat->type == LEVELFLAT_TEXTURE)
|
||||
if (levelflat->type == LEVELFLAT_FLAT)
|
||||
{
|
||||
fflatwidth = textures[levelflat->u.texture.num]->width;
|
||||
fflatheight = textures[levelflat->u.texture.num]->height;
|
||||
texflat = true;
|
||||
}
|
||||
else if (levelflat->type == LEVELFLAT_FLAT)
|
||||
{
|
||||
len = W_LumpLength(levelflat->u.flat.lumpnum);
|
||||
|
||||
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
|
||||
switch (len)
|
||||
{
|
||||
case 4194304: // 2048x2048 lump
|
||||
|
@ -2727,9 +2725,22 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
fflatwidth = fflatheight = 64.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
flatflag = ((INT32)fflatwidth)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (levelflat->type == LEVELFLAT_TEXTURE)
|
||||
{
|
||||
fflatwidth = textures[levelflat->u.texture.num]->width;
|
||||
fflatheight = textures[levelflat->u.texture.num]->height;
|
||||
}
|
||||
else if (levelflat->type == LEVELFLAT_PATCH || levelflat->type == LEVELFLAT_PNG)
|
||||
{
|
||||
fflatwidth = levelflat->width;
|
||||
fflatheight = levelflat->height;
|
||||
}
|
||||
texflat = true;
|
||||
}
|
||||
}
|
||||
else // set no texture
|
||||
HWR_SetCurrentTexture(NULL);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "p_local.h"
|
||||
#include "z_zone.h"
|
||||
#include "r_patch.h"
|
||||
#include "r_picformats.h"
|
||||
#include "r_things.h"
|
||||
#include "r_draw.h" // R_GetColorByName
|
||||
#include "doomstat.h" // luabanks[]
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "p_local.h"
|
||||
#include "r_main.h"
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "p_maputl.h"
|
||||
#include "p_polyobj.h"
|
||||
#include "p_slopes.h"
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "p_setup.h"
|
||||
#include "p_saveg.h"
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "r_things.h"
|
||||
#include "r_skins.h"
|
||||
#include "r_state.h"
|
||||
#include "w_wad.h"
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
|
||||
#include "r_data.h"
|
||||
#include "r_things.h" // for R_AddSpriteDefs
|
||||
#include "r_textures.h"
|
||||
#include "r_patch.h"
|
||||
#include "r_picformats.h"
|
||||
#include "r_sky.h"
|
||||
#include "r_draw.h"
|
||||
|
||||
|
@ -547,6 +549,8 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize)
|
|||
|
||||
lumpnum_t flatnum;
|
||||
int texturenum;
|
||||
patch_t *flatpatch;
|
||||
size_t lumplength;
|
||||
|
||||
size_t i;
|
||||
|
||||
|
@ -603,7 +607,9 @@ texturefound:
|
|||
{
|
||||
flatfound:
|
||||
/* This could be a flat, patch, or PNG. */
|
||||
if (Patch_CheckIfDoom((patch_t *)W_CacheLumpNum(flatnum, PU_STATIC), W_LumpLength(flatnum)))
|
||||
flatpatch = W_CacheLumpNum(flatnum, PU_CACHE);
|
||||
lumplength = W_LumpLength(flatnum);
|
||||
if (Picture_CheckIfPatch(flatpatch, lumplength))
|
||||
levelflat->type = LEVELFLAT_PATCH;
|
||||
else
|
||||
{
|
||||
|
@ -613,12 +619,14 @@ flatfound:
|
|||
FIXME: Put this elsewhere.
|
||||
*/
|
||||
W_ReadLumpHeader(flatnum, buffer, 8, 0);
|
||||
if (R_IsLumpPNG(buffer, W_LumpLength(flatnum)))
|
||||
if (Picture_IsLumpPNG(buffer, lumplength))
|
||||
levelflat->type = LEVELFLAT_PNG;
|
||||
else
|
||||
#endif/*NO_PNG_LUMPS*/
|
||||
levelflat->type = LEVELFLAT_FLAT;/* phew */
|
||||
}
|
||||
if (flatpatch)
|
||||
Z_Free(flatpatch);
|
||||
|
||||
levelflat->u.flat. lumpnum = flatnum;
|
||||
levelflat->u.flat.baselumpnum = LUMPERROR;
|
||||
|
|
|
@ -37,9 +37,7 @@ enum
|
|||
LEVELFLAT_NONE,/* HOM time my friend */
|
||||
LEVELFLAT_FLAT,
|
||||
LEVELFLAT_PATCH,
|
||||
#ifndef NO_PNG_LUMPS
|
||||
LEVELFLAT_PNG,
|
||||
#endif
|
||||
LEVELFLAT_TEXTURE,
|
||||
};
|
||||
|
||||
|
@ -72,15 +70,17 @@ typedef struct
|
|||
u;
|
||||
|
||||
UINT16 width, height;
|
||||
fixed_t topoffset, leftoffset;
|
||||
|
||||
// for flat animation
|
||||
INT32 animseq; // start pos. in the anim sequence
|
||||
INT32 numpics;
|
||||
INT32 speed;
|
||||
|
||||
// for patchflats
|
||||
UINT8 *flatpatch;
|
||||
// for textures
|
||||
UINT8 *picture;
|
||||
#ifdef HWRENDER
|
||||
void *mipmap;
|
||||
#endif
|
||||
} levelflat_t;
|
||||
|
||||
extern size_t numlevelflats;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "p_local.h"
|
||||
#include "p_setup.h" // levelflats for flat animation
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "m_random.h"
|
||||
#include "p_mobj.h"
|
||||
#include "i_system.h"
|
||||
|
|
1467
src/r_data.c
1467
src/r_data.c
File diff suppressed because it is too large
Load diff
90
src/r_data.h
90
src/r_data.h
|
@ -22,6 +22,14 @@
|
|||
#pragma interface
|
||||
#endif
|
||||
|
||||
// Store lists of lumps for F_START/F_END etc.
|
||||
typedef struct
|
||||
{
|
||||
UINT16 wadfile;
|
||||
UINT16 firstlump;
|
||||
size_t numlumps;
|
||||
} lumplist_t;
|
||||
|
||||
// Possible alpha types for a patch.
|
||||
enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY};
|
||||
|
||||
|
@ -31,97 +39,17 @@ UINT8 ASTBlendPaletteIndexes(UINT8 background, UINT8 foreground, int style, UINT
|
|||
|
||||
extern INT32 ASTTextureBlendingThreshold[2];
|
||||
|
||||
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
|
||||
|
||||
// moved here for r_sky.c (texpatch_t is used)
|
||||
|
||||
// A single patch from a texture definition,
|
||||
// basically a rectangular area within
|
||||
// the texture rectangle.
|
||||
typedef struct
|
||||
{
|
||||
// Block origin (always UL), which has already accounted for the internal origin of the patch.
|
||||
INT16 originx, originy;
|
||||
UINT16 wad, lump;
|
||||
UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both
|
||||
UINT8 alpha; // Translucency value
|
||||
enum patchalphastyle style;
|
||||
} texpatch_t;
|
||||
|
||||
// texture type
|
||||
enum
|
||||
{
|
||||
TEXTURETYPE_UNKNOWN,
|
||||
TEXTURETYPE_SINGLEPATCH,
|
||||
TEXTURETYPE_COMPOSITE,
|
||||
#ifdef WALLFLATS
|
||||
TEXTURETYPE_FLAT,
|
||||
#endif
|
||||
};
|
||||
|
||||
// A maptexturedef_t describes a rectangular texture,
|
||||
// which is composed of one or more mappatch_t structures
|
||||
// that arrange graphic patches.
|
||||
typedef struct
|
||||
{
|
||||
// Keep name for switch changing, etc.
|
||||
char name[8];
|
||||
UINT8 type; // TEXTURETYPE_
|
||||
INT16 width, height;
|
||||
boolean holes;
|
||||
UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both
|
||||
|
||||
// All the patches[patchcount] are drawn back to front into the cached texture.
|
||||
INT16 patchcount;
|
||||
texpatch_t patches[0];
|
||||
} texture_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 *flat;
|
||||
INT16 width, height;
|
||||
} textureflat_t;
|
||||
|
||||
// all loaded and prepared textures from the start of the game
|
||||
extern texture_t **textures;
|
||||
extern textureflat_t *texflats;
|
||||
|
||||
extern INT32 *texturewidth;
|
||||
extern fixed_t *textureheight; // needed for texture pegging
|
||||
|
||||
extern INT16 color8to16[256]; // remap color index to highcolor
|
||||
extern INT16 *hicolormaps; // remap high colors to high colors..
|
||||
|
||||
extern CV_PossibleValue_t Color_cons_t[];
|
||||
|
||||
// Load TEXTURES definitions, create lookup tables
|
||||
void R_LoadTextures(void);
|
||||
void R_FlushTextureCache(void);
|
||||
|
||||
INT32 R_GetTextureNum(INT32 texnum);
|
||||
void R_CheckTextureCache(INT32 tex);
|
||||
|
||||
// Retrieve column data for span blitting.
|
||||
UINT8 *R_GetColumn(fixed_t tex, INT32 col);
|
||||
UINT8 *R_GetFlat(lumpnum_t flatnum);
|
||||
|
||||
// I/O, setting up the stuff.
|
||||
void R_InitData(void);
|
||||
void R_PrecacheLevel(void);
|
||||
|
||||
extern size_t flatmemory, spritememory, texturememory;
|
||||
|
||||
// Retrieval.
|
||||
// Floor/ceiling opaque texture tiles,
|
||||
// lookup by name. For animation?
|
||||
lumpnum_t R_GetFlatNumForName(const char *name);
|
||||
|
||||
// Called by P_Ticker for switches and animations,
|
||||
// returns the texture number for the texture name.
|
||||
void R_ClearTextureNumCache(boolean btell);
|
||||
INT32 R_TextureNumForName(const char *name);
|
||||
INT32 R_CheckTextureNumForName(const char *name);
|
||||
|
||||
// Extra Colormap lumps (C_START/C_END) are not used anywhere
|
||||
// Uncomment to enable
|
||||
//#define EXTRACOLORMAPLUMPS
|
||||
|
@ -195,6 +123,4 @@ const char *R_NameForColormap(extracolormap_t *extra_colormap);
|
|||
UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette);
|
||||
#define NearestColor(r, g, b) NearestPaletteColor(r, g, b, NULL)
|
||||
|
||||
extern INT32 numtextures;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "r_plane.h"
|
||||
#include "r_sky.h"
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "r_things.h"
|
||||
#include "r_draw.h"
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "d_player.h"
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
|
||||
//
|
||||
// POV related.
|
||||
|
|
1407
src/r_patch.c
1407
src/r_patch.c
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,6 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos.
|
||||
// Copyright (C) 2019-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 2020 by Jaime "Lactozilla" Passos.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -17,26 +15,6 @@
|
|||
#include "r_defs.h"
|
||||
#include "doomdef.h"
|
||||
|
||||
// Structs
|
||||
typedef enum
|
||||
{
|
||||
ROTAXIS_X, // Roll (the default)
|
||||
ROTAXIS_Y, // Pitch
|
||||
ROTAXIS_Z // Yaw
|
||||
} rotaxis_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT32 x, y;
|
||||
rotaxis_t rotaxis;
|
||||
} spriteframepivot_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
spriteframepivot_t pivot[64];
|
||||
boolean available;
|
||||
} spriteinfo_t;
|
||||
|
||||
// Patch functions
|
||||
patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest);
|
||||
void Patch_Free(patch_t *patch);
|
||||
|
@ -46,38 +24,4 @@ void *Patch_AllocateHardwarePatch(patch_t *patch);
|
|||
void *Patch_CreateGL(patch_t *patch);
|
||||
#endif
|
||||
|
||||
boolean Patch_CheckIfDoom(softwarepatch_t *patch, size_t length);
|
||||
|
||||
// Conversions between patches / flats / textures...
|
||||
void R_TextureToFlat(size_t tex, UINT8 *flat);
|
||||
void R_PatchToFlat(patch_t *patch, UINT8 *flat);
|
||||
void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip);
|
||||
softwarepatch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency);
|
||||
softwarepatch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize);
|
||||
|
||||
// PNGs
|
||||
boolean R_IsLumpPNG(const UINT8 *d, size_t s);
|
||||
#define W_ThrowPNGError(lumpname, wadfilename) I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .png - please convert to either Doom or Flat (raw) image format.", lumpname, wadfilename); // Fears Of LJ Sonic
|
||||
|
||||
#ifndef NO_PNG_LUMPS
|
||||
UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size);
|
||||
softwarepatch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize);
|
||||
boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size);
|
||||
#endif
|
||||
|
||||
// SpriteInfo
|
||||
extern spriteinfo_t spriteinfo[NUMSPRITES];
|
||||
void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps);
|
||||
void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum);
|
||||
|
||||
// Sprite rotation
|
||||
#ifdef ROTSPRITE
|
||||
INT32 R_GetRollAngle(angle_t rollangle);
|
||||
void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, UINT8 flip);
|
||||
void R_FreeRotSprite(spritedef_t *spritedef);
|
||||
void R_FreeSkinRotSprite(size_t skinnum);
|
||||
extern fixed_t rollcosang[ROTANGLES];
|
||||
extern fixed_t rollsinang[ROTANGLES];
|
||||
#endif
|
||||
|
||||
#endif // __R_PATCH__
|
||||
|
|
1693
src/r_picformats.c
Normal file
1693
src/r_picformats.c
Normal file
File diff suppressed because it is too large
Load diff
132
src/r_picformats.h
Normal file
132
src/r_picformats.h
Normal file
|
@ -0,0 +1,132 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos.
|
||||
// Copyright (C) 2019-2020 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file r_picformats.h
|
||||
/// \brief Patch generation.
|
||||
|
||||
#ifndef __R_PICFORMATS__
|
||||
#define __R_PICFORMATS__
|
||||
|
||||
#include "r_defs.h"
|
||||
#include "doomdef.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PICFMT_NONE = 0,
|
||||
|
||||
// Doom formats
|
||||
PICFMT_PATCH,
|
||||
PICFMT_FLAT,
|
||||
|
||||
// PNG
|
||||
PICFMT_PNG,
|
||||
|
||||
// 16bpp
|
||||
PICFMT_PATCH16,
|
||||
PICFMT_FLAT16,
|
||||
|
||||
// 32bpp
|
||||
PICFMT_PATCH32,
|
||||
PICFMT_FLAT32
|
||||
} pictureformat_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PICFLAGS_XFLIP = 1,
|
||||
PICFLAGS_YFLIP = 1<<1
|
||||
} pictureflags_t;
|
||||
|
||||
enum
|
||||
{
|
||||
PICDEPTH_NONE = 0,
|
||||
PICDEPTH_8BPP = 8,
|
||||
PICDEPTH_16BPP = 16,
|
||||
PICDEPTH_32BPP = 32
|
||||
};
|
||||
|
||||
void *Picture_Convert(
|
||||
pictureformat_t informat, void *picture, pictureformat_t outformat,
|
||||
size_t insize, size_t *outsize,
|
||||
INT32 inwidth, INT32 inheight, INT32 inleftoffset, INT32 intopoffset,
|
||||
pictureflags_t flags);
|
||||
|
||||
void *Picture_PatchConvert(
|
||||
pictureformat_t informat, void *picture, pictureformat_t outformat,
|
||||
size_t insize, size_t *outsize,
|
||||
INT16 inwidth, INT16 inheight, INT16 inleftoffset, INT16 intopoffset,
|
||||
pictureflags_t flags);
|
||||
void *Picture_FlatConvert(
|
||||
pictureformat_t informat, void *picture, pictureformat_t outformat,
|
||||
size_t insize, size_t *outsize,
|
||||
INT16 inwidth, INT16 inheight, INT16 inleftoffset, INT16 intopoffset,
|
||||
pictureflags_t flags);
|
||||
void *Picture_GetPatchPixel(
|
||||
patch_t *patch, pictureformat_t informat,
|
||||
INT32 x, INT32 y,
|
||||
pictureflags_t flags);
|
||||
|
||||
void *Picture_TextureToFlat(size_t trickytex);
|
||||
|
||||
INT32 Picture_FormatBPP(pictureformat_t format);
|
||||
boolean Picture_IsPatchFormat(pictureformat_t format);
|
||||
boolean Picture_IsFlatFormat(pictureformat_t format);
|
||||
boolean Picture_CheckIfPatch(softwarepatch_t *patch, size_t size);
|
||||
|
||||
// Structs
|
||||
typedef enum
|
||||
{
|
||||
ROTAXIS_X, // Roll (the default)
|
||||
ROTAXIS_Y, // Pitch
|
||||
ROTAXIS_Z // Yaw
|
||||
} rotaxis_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT32 x, y;
|
||||
rotaxis_t rotaxis;
|
||||
} spriteframepivot_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
spriteframepivot_t pivot[64];
|
||||
boolean available;
|
||||
} spriteinfo_t;
|
||||
|
||||
// Portable Network Graphics
|
||||
boolean Picture_IsLumpPNG(const UINT8 *d, size_t s);
|
||||
#define Picture_ThrowPNGError(lumpname, wadfilename) I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .png - please convert to either Doom or Flat (raw) image format.", lumpname, wadfilename); // Fears Of LJ Sonic
|
||||
|
||||
#ifndef NO_PNG_LUMPS
|
||||
void *Picture_PNGConvert(
|
||||
const UINT8 *png, pictureformat_t outformat,
|
||||
INT32 *w, INT32 *h,
|
||||
INT16 *topoffset, INT16 *leftoffset,
|
||||
size_t insize, size_t *outsize,
|
||||
pictureflags_t flags);
|
||||
boolean Picture_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size);
|
||||
#endif
|
||||
|
||||
// SpriteInfo
|
||||
extern spriteinfo_t spriteinfo[NUMSPRITES];
|
||||
void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps);
|
||||
void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum);
|
||||
|
||||
// Sprite rotation
|
||||
#ifdef ROTSPRITE
|
||||
INT32 R_GetRollAngle(angle_t rollangle);
|
||||
void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, UINT8 flip);
|
||||
void R_FreeRotSprite(spritedef_t *spritedef);
|
||||
void R_FreeSkinRotSprite(size_t skinnum);
|
||||
extern fixed_t rollcosang[ROTANGLES];
|
||||
extern fixed_t rollsinang[ROTANGLES];
|
||||
void R_FreeAllRotSprite(void);
|
||||
#endif
|
||||
|
||||
#endif // __R_PICFORMATS__
|
209
src/r_plane.c
209
src/r_plane.c
|
@ -19,6 +19,7 @@
|
|||
#include "p_setup.h" // levelflats
|
||||
#include "p_slopes.h"
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "r_local.h"
|
||||
#include "r_state.h"
|
||||
#include "r_splats.h" // faB(21jan):testing
|
||||
|
@ -644,188 +645,6 @@ static void R_DrawSkyPlane(visplane_t *pl)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// R_CheckPowersOfTwo
|
||||
//
|
||||
// Self-explanatory?
|
||||
//
|
||||
boolean R_CheckPowersOfTwo(void)
|
||||
{
|
||||
boolean wpow2 = (!(ds_flatwidth & (ds_flatwidth - 1)));
|
||||
boolean hpow2 = (!(ds_flatheight & (ds_flatheight - 1)));
|
||||
|
||||
// Initially, the flat isn't powers-of-two-sized.
|
||||
ds_powersoftwo = false;
|
||||
|
||||
// But if the width and height are powers of two,
|
||||
// and are EQUAL, then it's okay :]
|
||||
if ((ds_flatwidth == ds_flatheight) && (wpow2 && hpow2))
|
||||
ds_powersoftwo = true;
|
||||
|
||||
// Just return ds_powersoftwo.
|
||||
return ds_powersoftwo;
|
||||
}
|
||||
|
||||
//
|
||||
// R_CheckFlatLength
|
||||
//
|
||||
// Determine the flat's dimensions from the lump length.
|
||||
//
|
||||
void R_CheckFlatLength(size_t size)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
case 4194304: // 2048x2048 lump
|
||||
nflatmask = 0x3FF800;
|
||||
nflatxshift = 21;
|
||||
nflatyshift = 10;
|
||||
nflatshiftup = 5;
|
||||
ds_flatwidth = ds_flatheight = 2048;
|
||||
break;
|
||||
case 1048576: // 1024x1024 lump
|
||||
nflatmask = 0xFFC00;
|
||||
nflatxshift = 22;
|
||||
nflatyshift = 12;
|
||||
nflatshiftup = 6;
|
||||
ds_flatwidth = ds_flatheight = 1024;
|
||||
break;
|
||||
case 262144:// 512x512 lump
|
||||
nflatmask = 0x3FE00;
|
||||
nflatxshift = 23;
|
||||
nflatyshift = 14;
|
||||
nflatshiftup = 7;
|
||||
ds_flatwidth = ds_flatheight = 512;
|
||||
break;
|
||||
case 65536: // 256x256 lump
|
||||
nflatmask = 0xFF00;
|
||||
nflatxshift = 24;
|
||||
nflatyshift = 16;
|
||||
nflatshiftup = 8;
|
||||
ds_flatwidth = ds_flatheight = 256;
|
||||
break;
|
||||
case 16384: // 128x128 lump
|
||||
nflatmask = 0x3F80;
|
||||
nflatxshift = 25;
|
||||
nflatyshift = 18;
|
||||
nflatshiftup = 9;
|
||||
ds_flatwidth = ds_flatheight = 128;
|
||||
break;
|
||||
case 1024: // 32x32 lump
|
||||
nflatmask = 0x3E0;
|
||||
nflatxshift = 27;
|
||||
nflatyshift = 22;
|
||||
nflatshiftup = 11;
|
||||
ds_flatwidth = ds_flatheight = 32;
|
||||
break;
|
||||
default: // 64x64 lump
|
||||
nflatmask = 0xFC0;
|
||||
nflatxshift = 26;
|
||||
nflatyshift = 20;
|
||||
nflatshiftup = 10;
|
||||
ds_flatwidth = ds_flatheight = 64;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// R_GenerateFlat
|
||||
//
|
||||
// Generate a flat from specified width and height.
|
||||
//
|
||||
static UINT8 *R_GenerateFlat(UINT16 width, UINT16 height)
|
||||
{
|
||||
UINT8 *flat = Z_Malloc(width * height, PU_LEVEL, NULL);
|
||||
memset(flat, TRANSPARENTPIXEL, width * height);
|
||||
return flat;
|
||||
}
|
||||
|
||||
//
|
||||
// R_GetTextureFlat
|
||||
//
|
||||
// Convert a texture or patch to a flat.
|
||||
//
|
||||
static UINT8 *R_GetTextureFlat(levelflat_t *levelflat, boolean leveltexture, boolean ispng)
|
||||
{
|
||||
UINT8 *flat;
|
||||
textureflat_t *texflat = &texflats[levelflat->u.texture.num];
|
||||
patch_t *patch = NULL;
|
||||
boolean texturechanged = (leveltexture ? (levelflat->u.texture.num != levelflat->u.texture.lastnum) : false);
|
||||
|
||||
(void)ispng;
|
||||
|
||||
// Check if the texture changed.
|
||||
if (leveltexture && (!texturechanged))
|
||||
{
|
||||
if (texflat != NULL && texflat->flat)
|
||||
{
|
||||
flat = texflat->flat;
|
||||
ds_flatwidth = texflat->width;
|
||||
ds_flatheight = texflat->height;
|
||||
texturechanged = false;
|
||||
}
|
||||
else
|
||||
texturechanged = true;
|
||||
}
|
||||
|
||||
// If the texture changed, or the patch doesn't exist, convert either of them to a flat.
|
||||
if (levelflat->flatpatch == NULL || texturechanged)
|
||||
{
|
||||
// Level texture
|
||||
if (leveltexture)
|
||||
{
|
||||
texture_t *texture = textures[levelflat->u.texture.num];
|
||||
texflat->width = ds_flatwidth = texture->width;
|
||||
texflat->height = ds_flatheight = texture->height;
|
||||
|
||||
texflat->flat = R_GenerateFlat(ds_flatwidth, ds_flatheight);
|
||||
R_TextureToFlat(levelflat->u.texture.num, texflat->flat);
|
||||
flat = texflat->flat;
|
||||
|
||||
levelflat->flatpatch = flat;
|
||||
levelflat->width = ds_flatwidth;
|
||||
levelflat->height = ds_flatheight;
|
||||
}
|
||||
// Patch (never happens yet)
|
||||
else
|
||||
{
|
||||
patch = (patch_t *)ds_source;
|
||||
#ifndef NO_PNG_LUMPS
|
||||
if (ispng)
|
||||
{
|
||||
levelflat->flatpatch = R_PNGToFlat(&levelflat->width, &levelflat->height, ds_source, W_LumpLength(levelflat->u.flat.lumpnum));
|
||||
levelflat->topoffset = levelflat->leftoffset = 0;
|
||||
ds_flatwidth = levelflat->width;
|
||||
ds_flatheight = levelflat->height;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
levelflat->width = ds_flatwidth = SHORT(patch->width);
|
||||
levelflat->height = ds_flatheight = SHORT(patch->height);
|
||||
|
||||
levelflat->topoffset = patch->topoffset * FRACUNIT;
|
||||
levelflat->leftoffset = patch->leftoffset * FRACUNIT;
|
||||
|
||||
levelflat->flatpatch = R_GenerateFlat(ds_flatwidth, ds_flatheight);
|
||||
R_PatchToFlat(patch, levelflat->flatpatch);
|
||||
}
|
||||
flat = levelflat->flatpatch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flat = levelflat->flatpatch;
|
||||
ds_flatwidth = levelflat->width;
|
||||
ds_flatheight = levelflat->height;
|
||||
}
|
||||
|
||||
xoffs += levelflat->leftoffset;
|
||||
yoffs += levelflat->topoffset;
|
||||
|
||||
levelflat->u.texture.lastnum = levelflat->u.texture.num;
|
||||
return flat;
|
||||
}
|
||||
|
||||
static void R_SlopeVectors(visplane_t *pl, INT32 i, float fudge)
|
||||
{
|
||||
// Potentially override other stuff for now cus we're mean. :< But draw a slope plane!
|
||||
|
@ -919,12 +738,11 @@ d.z = (v1.x * v2.y) - (v1.y * v2.x)
|
|||
|
||||
void R_DrawSinglePlane(visplane_t *pl)
|
||||
{
|
||||
UINT8 *flat;
|
||||
levelflat_t *levelflat;
|
||||
INT32 light = 0;
|
||||
INT32 x;
|
||||
INT32 stop, angle;
|
||||
ffloor_t *rover;
|
||||
levelflat_t *levelflat;
|
||||
int type;
|
||||
int spanfunctype = BASEDRAWFUNC;
|
||||
|
||||
|
@ -1077,30 +895,15 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
case LEVELFLAT_NONE:
|
||||
return;
|
||||
case LEVELFLAT_FLAT:
|
||||
ds_source = W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE);
|
||||
ds_source = (UINT8 *)R_GetFlat(levelflat->u.flat.lumpnum);
|
||||
R_CheckFlatLength(W_LumpLength(levelflat->u.flat.lumpnum));
|
||||
// Raw flats always have dimensions that are powers-of-two numbers.
|
||||
ds_powersoftwo = true;
|
||||
break;
|
||||
default:
|
||||
switch (type)
|
||||
{
|
||||
case LEVELFLAT_TEXTURE:
|
||||
/* Textures get cached differently and don't need ds_source */
|
||||
ds_source = R_GetTextureFlat(levelflat, true, false);
|
||||
break;
|
||||
default:
|
||||
ds_source = W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_STATIC);
|
||||
flat = R_GetTextureFlat(levelflat, false,
|
||||
#ifndef NO_PNG_LUMPS
|
||||
( type == LEVELFLAT_PNG )
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
);
|
||||
Z_ChangeTag(ds_source, PU_CACHE);
|
||||
ds_source = flat;
|
||||
}
|
||||
ds_source = (UINT8 *)R_GetLevelFlat(levelflat);
|
||||
if (!ds_source)
|
||||
return;
|
||||
// Check if this texture or patch has power-of-two dimensions.
|
||||
if (R_CheckPowersOfTwo())
|
||||
R_CheckFlatLength(ds_flatwidth * ds_flatheight);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "screen.h" // needs MAXVIDWIDTH/MAXVIDHEIGHT
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "p_polyobj.h"
|
||||
|
||||
#define MAXVISPLANES 512
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define __R_PORTAL__
|
||||
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "r_plane.h" // visplanes
|
||||
|
||||
/** Portal structure for the software renderer.
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
#include "info.h"
|
||||
#include "sounds.h"
|
||||
#include "d_player.h" // skinflags
|
||||
#include "r_patch.h" // spriteinfo_t
|
||||
#include "r_patch.h"
|
||||
#include "r_picformats.h" // spriteinfo_t
|
||||
#include "r_defs.h" // spritedef_t
|
||||
|
||||
/// Defaults
|
||||
|
|
1653
src/r_textures.c
Normal file
1653
src/r_textures.c
Normal file
File diff suppressed because it is too large
Load diff
103
src/r_textures.h
Normal file
103
src/r_textures.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file r_textures.h
|
||||
/// \brief Texture generation.
|
||||
|
||||
#ifndef __R_TEXTURES__
|
||||
#define __R_TEXTURES__
|
||||
|
||||
#include "r_defs.h"
|
||||
#include "r_state.h"
|
||||
#include "p_setup.h" // levelflats
|
||||
#include "r_data.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
// A single patch from a texture definition,
|
||||
// basically a rectangular area within
|
||||
// the texture rectangle.
|
||||
typedef struct
|
||||
{
|
||||
// Block origin (always UL), which has already accounted for the internal origin of the patch.
|
||||
INT16 originx, originy;
|
||||
UINT16 wad, lump;
|
||||
UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both
|
||||
UINT8 alpha; // Translucency value
|
||||
enum patchalphastyle style;
|
||||
} texpatch_t;
|
||||
|
||||
// texture type
|
||||
enum
|
||||
{
|
||||
TEXTURETYPE_UNKNOWN,
|
||||
TEXTURETYPE_SINGLEPATCH,
|
||||
TEXTURETYPE_COMPOSITE,
|
||||
#ifdef WALLFLATS
|
||||
TEXTURETYPE_FLAT,
|
||||
#endif
|
||||
};
|
||||
|
||||
// A texture_t describes a rectangular texture,
|
||||
// which is composed of one or more texpatch_t structures
|
||||
// that arrange graphic patches.
|
||||
typedef struct
|
||||
{
|
||||
// Keep name for switch changing, etc.
|
||||
char name[8];
|
||||
UINT8 type; // TEXTURETYPE_
|
||||
INT16 width, height;
|
||||
boolean holes;
|
||||
UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both
|
||||
void *flat; // The texture, as a flat.
|
||||
|
||||
// All the patches[patchcount] are drawn back to front into the cached texture.
|
||||
INT16 patchcount;
|
||||
texpatch_t patches[0];
|
||||
} texture_t;
|
||||
|
||||
// all loaded and prepared textures from the start of the game
|
||||
extern texture_t **textures;
|
||||
|
||||
extern INT32 *texturewidth;
|
||||
extern fixed_t *textureheight; // needed for texture pegging
|
||||
|
||||
extern UINT32 **texturecolumnofs; // column offset lookup table for each texture
|
||||
extern UINT8 **texturecache; // graphics data for each generated full-size texture
|
||||
|
||||
// Load TEXTURES definitions, create lookup tables
|
||||
void R_LoadTextures(void);
|
||||
void R_FlushTextureCache(void);
|
||||
|
||||
// Texture generation
|
||||
UINT8 *R_GenerateTexture(size_t texnum);
|
||||
UINT8 *R_GenerateTextureAsFlat(size_t texnum);
|
||||
INT32 R_GetTextureNum(INT32 texnum);
|
||||
void R_CheckTextureCache(INT32 tex);
|
||||
void R_ClearTextureNumCache(boolean btell);
|
||||
|
||||
// Retrieve texture data.
|
||||
void *R_GetLevelFlat(levelflat_t *levelflat);
|
||||
UINT8 *R_GetColumn(fixed_t tex, INT32 col);
|
||||
void *R_GetFlat(lumpnum_t flatnum);
|
||||
|
||||
boolean R_CheckPowersOfTwo(void);
|
||||
void R_CheckFlatLength(size_t size);
|
||||
|
||||
// Returns the texture number for the texture name.
|
||||
INT32 R_TextureNumForName(const char *name);
|
||||
INT32 R_CheckTextureNumForName(const char *name);
|
||||
lumpnum_t R_GetFlatNumForName(const char *name);
|
||||
|
||||
extern INT32 numtextures;
|
||||
|
||||
#endif
|
|
@ -25,6 +25,7 @@
|
|||
#include "i_system.h"
|
||||
#include "r_things.h"
|
||||
#include "r_patch.h"
|
||||
#include "r_picformats.h"
|
||||
#include "r_plane.h"
|
||||
#include "r_portal.h"
|
||||
#include "p_tick.h"
|
||||
|
@ -280,10 +281,14 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
|||
softwarepatch_t *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC);
|
||||
size_t len = W_LumpLengthPwad(wadnum, l);
|
||||
// lump is a png so convert it
|
||||
if (R_IsLumpPNG((UINT8 *)png, len))
|
||||
if (Picture_IsLumpPNG((UINT8 *)png, len))
|
||||
{
|
||||
png = R_PNGToPatch((UINT8 *)png, len, NULL);
|
||||
M_Memcpy(&patch, png, sizeof(INT16)*4);
|
||||
// Dummy variables.
|
||||
INT32 pngwidth, pngheight;
|
||||
INT16 topoffset, leftoffset;
|
||||
patch_t *converted = (patch_t *)Picture_PNGConvert((UINT8 *)png, PICFMT_PATCH, &pngwidth, &pngheight, &topoffset, &leftoffset, len, NULL, 0);
|
||||
M_Memcpy(&patch, converted, sizeof(INT16)*4); // only copy the header because that's all we need
|
||||
Z_Free(converted);
|
||||
}
|
||||
Z_Free(png);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "r_plane.h"
|
||||
#include "r_patch.h"
|
||||
#include "r_picformats.h"
|
||||
#include "r_portal.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_skins.h"
|
||||
|
|
|
@ -281,14 +281,15 @@
|
|||
<ClInclude Include="..\r_draw.h" />
|
||||
<ClInclude Include="..\r_local.h" />
|
||||
<ClInclude Include="..\r_main.h" />
|
||||
<ClInclude Include="..\r_picformats.h" />
|
||||
<ClInclude Include="..\r_plane.h" />
|
||||
<ClInclude Include="..\r_patch.h" />
|
||||
<ClInclude Include="..\r_portal.h" />
|
||||
<ClInclude Include="..\r_segs.h" />
|
||||
<ClInclude Include="..\r_skins.h" />
|
||||
<ClInclude Include="..\r_sky.h" />
|
||||
<ClInclude Include="..\r_splats.h" />
|
||||
<ClInclude Include="..\r_state.h" />
|
||||
<ClInclude Include="..\r_textures.h" />
|
||||
<ClInclude Include="..\r_things.h" />
|
||||
<ClInclude Include="..\screen.h" />
|
||||
<ClInclude Include="..\sounds.h" />
|
||||
|
@ -446,13 +447,14 @@
|
|||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\r_main.c" />
|
||||
<ClCompile Include="..\r_picformats.c" />
|
||||
<ClCompile Include="..\r_plane.c" />
|
||||
<ClCompile Include="..\r_patch.c" />
|
||||
<ClCompile Include="..\r_portal.c" />
|
||||
<ClCompile Include="..\r_segs.c" />
|
||||
<ClCompile Include="..\r_skins.c" />
|
||||
<ClCompile Include="..\r_sky.c" />
|
||||
<ClCompile Include="..\r_splats.c" />
|
||||
<ClCompile Include="..\r_textures.c" />
|
||||
<ClCompile Include="..\r_things.c" />
|
||||
<ClCompile Include="..\screen.c" />
|
||||
<ClCompile Include="..\sounds.c" />
|
||||
|
|
|
@ -471,7 +471,10 @@
|
|||
<ClInclude Include="..\hardware\hw_clip.h">
|
||||
<Filter>Hw_Hardware</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\r_patch.h">
|
||||
<ClInclude Include="..\r_textures.h">
|
||||
<Filter>R_Rend</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\r_picformats.h">
|
||||
<Filter>R_Rend</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\r_portal.h">
|
||||
|
@ -943,7 +946,10 @@
|
|||
<Filter>Hw_Hardware</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\apng.c" />
|
||||
<ClCompile Include="..\r_patch.c">
|
||||
<ClCompile Include="..\r_textures.c">
|
||||
<Filter>R_Rend</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\r_picformats.c">
|
||||
<Filter>R_Rend</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\r_portal.c">
|
||||
|
|
21
src/w_wad.c
21
src/w_wad.c
|
@ -56,6 +56,9 @@
|
|||
#include "d_clisrv.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_data.h"
|
||||
#include "r_textures.h"
|
||||
#include "r_patch.h"
|
||||
#include "r_picformats.h"
|
||||
#include "i_system.h"
|
||||
#include "md5.h"
|
||||
#include "lua_script.h"
|
||||
|
@ -65,7 +68,6 @@
|
|||
#include "m_misc.h" // M_MapNumber
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "r_data.h"
|
||||
#include "hardware/hw_main.h"
|
||||
#include "hardware/hw_glob.h"
|
||||
#endif
|
||||
|
@ -1384,8 +1386,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
|||
#ifdef NO_PNG_LUMPS
|
||||
{
|
||||
size_t bytesread = fread(dest, 1, size, handle);
|
||||
if (R_IsLumpPNG((UINT8 *)dest, bytesread))
|
||||
W_ThrowPNGError(l->fullname, wadfiles[wad]->filename);
|
||||
if (Picture_IsLumpPNG((UINT8 *)dest, bytesread))
|
||||
Picture_ThrowPNGError(l->fullname, wadfiles[wad]->filename);
|
||||
return bytesread;
|
||||
}
|
||||
#else
|
||||
|
@ -1426,8 +1428,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
|||
Z_Free(rawData);
|
||||
Z_Free(decData);
|
||||
#ifdef NO_PNG_LUMPS
|
||||
if (R_IsLumpPNG((UINT8 *)dest, size))
|
||||
W_ThrowPNGError(l->fullname, wadfiles[wad]->filename);
|
||||
if (Picture_IsLumpPNG((UINT8 *)dest, size))
|
||||
Picture_ThrowPNGError(l->fullname, wadfiles[wad]->filename);
|
||||
#endif
|
||||
return size;
|
||||
#else
|
||||
|
@ -1489,8 +1491,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
|
|||
Z_Free(decData);
|
||||
|
||||
#ifdef NO_PNG_LUMPS
|
||||
if (R_IsLumpPNG((UINT8 *)dest, size))
|
||||
W_ThrowPNGError(l->fullname, wadfiles[wad]->filename);
|
||||
if (Picture_IsLumpPNG((UINT8 *)dest, size))
|
||||
Picture_ThrowPNGError(l->fullname, wadfiles[wad]->filename);
|
||||
#endif
|
||||
return size;
|
||||
}
|
||||
|
@ -1678,10 +1680,11 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
|||
|
||||
#ifndef NO_PNG_LUMPS
|
||||
// lump is a png so convert it
|
||||
if (R_IsLumpPNG((UINT8 *)lumpdata, len))
|
||||
if (Picture_IsLumpPNG((UINT8 *)lumpdata, len))
|
||||
{
|
||||
size_t newlen;
|
||||
void *converted = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen);
|
||||
INT32 pngwidth, pngheight; // Dummy variables.
|
||||
void *converted = Picture_PNGConvert((UINT8 *)lumpdata, PICFMT_PATCH, &pngwidth, &pngheight, NULL, NULL, len, &newlen, 0);
|
||||
ptr = Z_Malloc(newlen, PU_STATIC, NULL);
|
||||
M_Memcpy(ptr, converted, newlen);
|
||||
Z_Free(converted);
|
||||
|
|
|
@ -298,12 +298,13 @@
|
|||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\r_main.c" />
|
||||
<ClCompile Include="..\r_picformats.c" />
|
||||
<ClCompile Include="..\r_plane.c" />
|
||||
<ClCompile Include="..\r_patch.c" />
|
||||
<ClCompile Include="..\r_portal.c" />
|
||||
<ClCompile Include="..\r_segs.c" />
|
||||
<ClCompile Include="..\r_sky.c" />
|
||||
<ClCompile Include="..\r_splats.c" />
|
||||
<ClCompile Include="..\r_textures.c" />
|
||||
<ClCompile Include="..\r_things.c" />
|
||||
<ClCompile Include="..\screen.c" />
|
||||
<ClCompile Include="..\sounds.c" />
|
||||
|
@ -453,13 +454,14 @@
|
|||
<ClInclude Include="..\r_draw.h" />
|
||||
<ClInclude Include="..\r_local.h" />
|
||||
<ClInclude Include="..\r_main.h" />
|
||||
<ClInclude Include="..\r_picformats.h" />
|
||||
<ClInclude Include="..\r_plane.h" />
|
||||
<ClInclude Include="..\r_patch.h" />
|
||||
<ClInclude Include="..\r_portal.h" />
|
||||
<ClInclude Include="..\r_segs.h" />
|
||||
<ClInclude Include="..\r_sky.h" />
|
||||
<ClInclude Include="..\r_splats.h" />
|
||||
<ClInclude Include="..\r_state.h" />
|
||||
<ClInclude Include="..\r_textures.h" />
|
||||
<ClInclude Include="..\r_things.h" />
|
||||
<ClInclude Include="..\screen.h" />
|
||||
<ClInclude Include="..\sounds.h" />
|
||||
|
|
|
@ -469,7 +469,7 @@
|
|||
<Filter>Hw_Hardware</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\apng.c" />
|
||||
<ClCompile Include="..\r_patch.c">
|
||||
<ClCompile Include="..\r_picformats.c">
|
||||
<Filter>R_Rend</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\r_portal.c">
|
||||
|
@ -886,7 +886,10 @@
|
|||
<Filter>Hw_Hardware</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\apng.h" />
|
||||
<ClInclude Include="..\r_patch.h">
|
||||
<ClInclude Include="..\r_textures.h">
|
||||
<Filter>R_Rend</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\r_picformats.h">
|
||||
<Filter>R_Rend</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\r_portal.h">
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "doomdef.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_patch.h"
|
||||
#include "r_picformats.h"
|
||||
#include "i_system.h" // I_GetFreeMem
|
||||
#include "i_video.h" // rendermode
|
||||
#include "z_zone.h"
|
||||
|
|
Loading…
Reference in a new issue