25  Rendering: Texture and Sprite Data

In this section you’ll explore how DOOM represents and initializes wall textures, sprite patches, and color translation used in rendering. You’ll see the core structs patch_t and texture_t, the initializer R_InitData in r_data.c, how translation tables for player colors are built, and the pic_t struct for flats.


25.0.1 patch_t

File: linuxdoom-1.10/r_defs.h

// patch_t defines a single graphic patch used for sprites and masked wall segments.
// width/height are the patch size, leftoffset/topoffset position its origin,
// and columnofs[i] gives the byte offset of column i within the patch data
// (column 0 at &columnofs[width]).

25.0.2 texture_t

File: linuxdoom-1.10/r_data.c

// texture_t combines one or more texpatch_t into a rectangular wall texture.
// name[8] is the texture name, width/height its dimensions,
// patchcount the number of patches, and patches[] the list of origin/patch indices
// used when composing the final texture.

25.0.3 R_InitData

File: linuxdoom-1.10/r_data.c

// R_InitData sets up all rendering data after WAD I/O. It calls R_InitTextures to parse
// TEXTURE1/2 and build lookup tables, R_InitFlats for floor/ceiling flats,
// R_InitSpriteLumps for sprite headers, and R_InitColormaps for lighting tables.

25.0.4 R_InitTranslationTables

File: linuxdoom-1.10/r_draw.c

// R_InitTranslationTables allocates three 256-byte-aligned tables and fills them
// so that the green color ramp (indices 0x70–0x7f) can be remapped to gray, brown,
// or red shirt colors for player sprites. All other colors map to themselves.

25.0.5 pic_t

File: linuxdoom-1.10/d_textur.h

// pic_t models a flat (unmasked floor/ceiling tile) as an 8-bit image block:
// width/height are dimensions and data represents the first pixel,
// with actual pixel data following in memory. Used when loading flats and drawing spans.

You’ve seen how DOOM’s renderer describes patches and textures, initializes all graphic data including textures, flats, sprites, and colormaps via R_InitData, builds player-color translation tables, and represents flats with pic_t.