User:Monster Iestyn/Source Code Documentation/r_data.h

From SRB2 Wiki
Jump to navigation Jump to search
This article or section is incomplete. It doesn't have all of the necessary core information on this topic. Please help the SRB2 Wiki by finishing this article.
Online link GitHub entry
File type C header file
#include guard __R_DATA__

Includes

Typedefs

Name Type Description
texpatch_t struct A single patch from a texture definition.
texture_t struct A texture definition.
textureflat_t struct A texture flat definition.

Enumerations

patchalphastyle

Structs

texpatch_t

Data name Data type Description
originx
originy
INT16
wad
lump
UINT16
flip UINT8
alpha UINT8
style enum patchalphastyle

texture_t

Data name Data type Description
name[8] char
width
height
INT16
holes boolean
flip UINT8
patchcount INT16
patches[0] texpatch_t

textureflat_t

Externs

Data name Data type Non-extern location(s) Description
**textures texture_t r_data.c Texture data table.

Note: R_LoadTextures allocates memory to this table for 5 buffers at once:

  • The textures table itself
  • texturecolumnofs (offset by numtextures * sizeof(void *) bytes)
  • texturecache (offset by 2 × numtextures * sizeof(void *) bytes)
  • texturewidth (offset by 3 × numtextures * sizeof(void *) bytes)
  • textureheight (offset by 4 × numtextures * sizeof(void *) bytes)

The other four tables listed above are therefore pointers to textures plus an offset. Note that texturecolumnofs and texturecache are static pointers only defined in r_data.c.

*texflats textureflat_t r_data.c Texture flat data table.
*texturewidth INT32 r_data.c Texture width table.

This is a pointer to textures, offset by 3 × numtextures * sizeof(void *) bytes.

*textureheight fixed_t r_data.c Texture height mask table.

This is a pointer to textures, offset by 4 × numtextures * sizeof(void *) bytes.

color8to16[256] INT16 r_data.c Used by 16bpp drawing functions.
*hicolormaps INT16 r_data.c Used by 16bpp drawing functions.
Color_cons_t[] CV_PossibleValue_t r_draw.c
flatmemory
spritememory
texturememory
size_t r_data.c
numtextures INT32 r_data.c The total number of textures found in a level.

Function prototypes

Function name Return type Params Defined in Description
ASTBlendPixel UINT32 RGBA_t background,
RGBA_t foreground,
int style,
UINT8 alpha
r_data.c
ASTBlendPixel_8bpp UINT8 UINT8 background,
UINT8 foreground,
int style,
UINT8 alpha
r_data.c
NearestColor UINT8 UINT8 r,
UINT8 g,
UINT8 b
r_data.c
R_LoadTextures void none r_data.c Initialises the texture buffers, searches through all currently loaded WADs for textures (both in TEXTURES and between TX_START/TX_END) and loads their properties into the corresponding tables.

This function is called at game startup (via R_InitData) and whenever a new WAD file is added to the game.

R_FlushTextureCache void none r_data.c Empties the texture cache table.
R_GetTextureNum INT32 INT32 texnum r_data.c Returns the current texture number to be used. This may be either the original texture number given, the texture number of the current frame if the texture is animated, or 0 if not a valid texture number.
R_CheckTextureCache void INT32 texnum r_data.c Checks if the texture has already been cached by the game; if not, this function will cause the texture to be cached.
R_GetColumn UINT8 * fixed_t tex,
INT32 col
r_data.c Gets and returns a pointer to a column from the given texture and column numbers. If the texture has not already been cached by the game, this function will cause the texture to be cached.
R_GetFlat UINT8 * lumpnum_t flatnum r_data.c Gets and returns a pointer to a flat from the given lump number.
R_InitData void none r_data.c Initialises texture, sprite and colormap data. Called at game startup.
R_PrecacheLevel void none r_data.c Preloads all relevant graphics for the level.
R_GetFlatNumForName lumpnum_t const char *name r_data.c
R_ClearTextureNumCache void boolean btell r_data.c Clears the texture id cache table.
R_TextureNumForName INT32 const char *name r_data.c Gets the texture number from the texture name. If the texture does not exist, this returns REDWALL's texture number instead (or 1 if REDWALL itself is not available).

Note: This function calls R_CheckTextureNumForName as part of its definition.

R_CheckTextureNumForName INT32 const char *name r_data.c Checks whether a texture is available, using the texture's name as reference. Returns the texture number, or -1 if the texture does not exist. Found textures are added to a texture id cache table, to speed up map loading.

Note: The "no texture" indicator used in map editors ("-") returns 0.

R_ReInitColormaps void UINT16 num r_data.c
R_ClearColormaps void none r_data.c
R_CreateDefaultColormap extracolormap_t * boolean lighttable r_data.c
R_GetDefaultColormap extracolormap_t * none r_data.c
R_CopyColormap extracolormap_t * extracolormap_t *extra_colormap,
boolean lighttable
r_data.c
R_AddColormapToList void extracolormap_t *extra_colormap r_data.c
R_CheckDefaultColormapByValues boolean r_data.c
R_GetColormapFromListByValues extracolormap_t * r_data.c
R_CheckDefaultColormap boolean r_data.c
R_CheckEqualColormaps boolean r_data.c
R_GetColormapFromList extracolormap_t * r_data.c
R_CreateLightTable lighttable_t * r_data.c
R_CreateColormap extracolormap_t * r_data.c
R_AddColormaps extracolormap_t * r_data.c

Macros

Macro Defined as Description
R_GetRgbaR(rgba) (rgba & 0xFF)
R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF)
R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF)
R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF)
R_GetRgbaRGB(rgba) (rgba & 0xFFFFFF)
R_PutRgbaR(r) (r)
R_PutRgbaG(g) (g << 8)
R_PutRgbaB(b) (b << 16)
R_PutRgbaA(a) (a << 24)
R_PutRgbaRGB(r, g, b) (R_PutRgbaR(r) + R_PutRgbaG(g) + R_PutRgbaB(b))
R_PutRgbaRGBA(r, g, b, a) (R_PutRgbaRGB(r, g, b) + R_PutRgbaA(a))