Move texture stuff to its own file

This commit is contained in:
Jaime Passos 2020-01-07 12:35:10 -03:00
parent 9e0d28f32f
commit f85476c723
23 changed files with 1594 additions and 1548 deletions

View File

@ -123,6 +123,7 @@ set(SRB2_CORE_RENDER_SOURCES
r_sky.c
r_splats.c
r_things.c
r_textures.c
r_picformats.c
r_portal.c
@ -138,6 +139,7 @@ set(SRB2_CORE_RENDER_SOURCES
r_splats.h
r_state.h
r_things.h
r_textures.h
r_picformats.h
r_portal.h
)

View File

@ -471,6 +471,7 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/r_sky.o \
$(OBJDIR)/r_splats.o \
$(OBJDIR)/r_things.o \
$(OBJDIR)/r_textures.o \
$(OBJDIR)/r_picformats.o \
$(OBJDIR)/r_portal.o \
$(OBJDIR)/screen.o \

View File

@ -28,6 +28,7 @@
#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_picformats.h"
#include "r_sky.h"

View File

@ -26,6 +26,7 @@
#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"

View File

@ -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"

View File

@ -22,6 +22,7 @@
#include "p_setup.h"
#include "p_saveg.h"
#include "r_data.h"
#include "r_textures.h"
#include "r_things.h"
#include "r_state.h"
#include "w_wad.h"

View File

@ -28,6 +28,7 @@
#include "r_data.h"
#include "r_things.h"
#include "r_textures.h"
#include "r_picformats.h"
#include "r_sky.h"
#include "r_draw.h"

View File

@ -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"

File diff suppressed because it is too large Load Diff

View File

@ -22,103 +22,31 @@
#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};
UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha);
UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 alpha);
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
@ -173,6 +101,4 @@ const char *R_NameForColormap(extracolormap_t *extra_colormap);
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
extern INT32 numtextures;
#endif

View File

@ -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"

View File

@ -16,6 +16,7 @@
#include "d_player.h"
#include "r_data.h"
#include "r_textures.h"
//
// POV related.

View File

@ -16,6 +16,7 @@
#include "dehacked.h"
#include "i_video.h"
#include "r_data.h"
#include "r_textures.h"
#include "r_draw.h"
#include "r_picformats.h"
#include "r_things.h"
@ -66,6 +67,8 @@ fixed_t sinang2rad[ROTANGLES];
* \param intopoffset Input picture top offset, for patches.
* \param flags Input picture flags.
* \return A pointer to the converted picture.
* \sa Picture_PatchConvert
* \sa Picture_FlatConvert
*/
void *Picture_Convert(
pictureformat_t informat, void *picture, pictureformat_t outformat,

View File

@ -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

View File

@ -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

View File

@ -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.

1441
src/r_textures.c Normal file

File diff suppressed because it is too large Load Diff

109
src/r_textures.h Normal file
View File

@ -0,0 +1,109 @@
// 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"
#include "r_textures.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 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 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);
UINT8 *R_GenerateTexture(size_t texnum);
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);
// 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);
extern INT32 numtextures;
#endif

View File

@ -280,13 +280,14 @@
<ClInclude Include="..\r_draw.h" />
<ClInclude Include="..\r_local.h" />
<ClInclude Include="..\r_main.h" />
<ClInclude Include="..\r_plane.h" />
<ClInclude Include="..\r_picformats.h" />
<ClInclude Include="..\r_plane.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" />
@ -442,12 +443,13 @@
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\r_main.c" />
<ClCompile Include="..\r_picformats.c" />
<ClCompile Include="..\r_plane.c" />
<ClCompile Include="..\r_picformats.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" />

View File

@ -465,6 +465,9 @@
<ClInclude Include="..\hardware\hw_clip.h">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\r_textures.h">
<Filter>R_Rend</Filter>
</ClInclude>
<ClInclude Include="..\r_picformats.h">
<Filter>R_Rend</Filter>
</ClInclude>
@ -928,6 +931,9 @@
<Filter>Hw_Hardware</Filter>
</ClCompile>
<ClCompile Include="..\apng.c" />
<ClCompile Include="..\r_textures.c">
<Filter>R_Rend</Filter>
</ClCompile>
<ClCompile Include="..\r_picformats.c">
<Filter>R_Rend</Filter>
</ClCompile>

View File

@ -56,6 +56,7 @@
#include "d_clisrv.h"
#include "r_defs.h"
#include "r_data.h"
#include "r_textures.h"
#include "i_system.h"
#include "md5.h"
#include "lua_script.h"
@ -65,7 +66,6 @@
#include "m_misc.h" // M_MapNumber
#ifdef HWRENDER
#include "r_data.h"
#include "hardware/hw_main.h"
#include "hardware/hw_glob.h"
#endif

View File

@ -299,12 +299,13 @@
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\r_main.c" />
<ClCompile Include="..\r_plane.c" />
<ClCompile Include="..\r_picformats.c" />
<ClCompile Include="..\r_plane.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" />
@ -455,13 +456,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_picformats.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" />

View File

@ -892,6 +892,9 @@
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\apng.h" />
<ClInclude Include="..\r_textures.h">
<Filter>R_Rend</Filter>
</ClInclude>
<ClInclude Include="..\r_picformats.h">
<Filter>R_Rend</Filter>
</ClInclude>