r_image.c File Reference

#include "r_local.h"
#include "r_error.h"
#include "r_geoscape.h"
#include "../../shared/images.h"
Include dependency graph for r_image.c:

Go to the source code of this file.

Data Structures

struct  glTextureMode_t
struct  gltmode_t

Defines

#define MAX_IMAGEHASH   256
#define MAX_TEXTURE_SIZE   8192

Functions

void R_ImageClearMaterials (void)
 Free previously loaded materials and their stages.
void R_ImageList_f (void)
 Shows all loaded images.
void R_LoadImage (const char *name, byte **pic, int *width, int *height)
 Generic image-data loading fucntion.
void R_ScaleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight)
void R_FilterTexture (byte *in, int width, int height, imagetype_t type, int bpp)
 Applies brightness and contrast to the specified image while optionally computing the image's average color. Also handles image inversion and monochrome. This is all munged into one function to reduce loops on level load.
void R_GetScaledTextureSize (int width, int height, int *scaledWidth, int *scaledHeight)
 Calculates the texture size that should be used to upload the texture data.
void R_UploadTexture (unsigned *data, int width, int height, image_t *image)
 Uploads the opengl texture to the server.
void R_SoftenTexture (byte *in, int width, int height, int bpp)
 Applies blurring to a texture.
void R_UploadAlpha (const image_t *image, const byte *alphaData)
static void R_DeleteImage (image_t *image)
image_tR_GetImage (const char *name)
image_tR_LoadImageData (const char *name, byte *pic, int width, int height, imagetype_t type)
 Creates a new image from RGBA data. Stores it in the gltextures array and also uploads it.
image_tR_FindImage (const char *pname, imagetype_t type)
 Finds or loads the given image.
qboolean R_ImageExists (const char *pname)
void R_FreeImage (image_t *image)
 Free the image and its normalmap (if there is one).
void R_FreeWorldImages (void)
 Any image that is a mesh or world texture will be removed here.
void R_InitImages (void)
void R_ShutdownImages (void)
void R_TextureMode (const char *string)
void R_TextureAlphaMode (const char *string)
void R_TextureSolidMode (const char *string)

Variables

static image_timageHash [MAX_IMAGEHASH]
image_t r_images [MAX_GL_TEXTURES]
int r_numImages
image_tr_envmaptextures [MAX_ENVMAPTEXTURES]
image_tr_flaretextures [NUM_FLARETEXTURES]
static const glTextureMode_t gl_texture_modes []
static const gltmode_t gl_alpha_modes []
static const gltmode_t gl_solid_modes []

Detailed Description

Definition in file r_image.c.


Define Documentation

#define MAX_IMAGEHASH   256

Definition at line 30 of file r_image.c.

Referenced by R_DeleteImage(), R_GetImage(), and R_LoadImageData().

#define MAX_TEXTURE_SIZE   8192

Definition at line 42 of file r_image.c.

Referenced by R_GetScaledTextureSize(), and R_ScaleTexture().


Function Documentation

static void R_DeleteImage ( image_t image  )  [inline, static]
void R_FilterTexture ( byte in,
int  width,
int  height,
imagetype_t  type,
int  bpp 
)

Applies brightness and contrast to the specified image while optionally computing the image's average color. Also handles image inversion and monochrome. This is all munged into one function to reduce loops on level load.

Definition at line 208 of file r_image.c.

References byte, DotProduct, it_lightmap, luminosity, r_brightness, r_contrast, r_modulate, r_saturation, scale, cvar_s::value, VectorCopy, VectorMix(), VectorScale, and VectorSet.

Referenced by R_BuildLightmap(), and R_UploadTexture().

image_t* R_FindImage ( const char *  pname,
imagetype_t  type 
)

Finds or loads the given image.

See also:
R_RegisterImage
Parameters:
[in] pname Image name Path relative to the game dir (e.g. textures/tex_common/nodraw)
[in] type The type of the image. This has influence on image filters and texture parameters when uploading the image data
Note:
the image name has to be at least 5 chars long
See also:
R_LoadTGA
R_LoadJPG
R_LoadPNG

Definition at line 555 of file r_image.c.

Referenced by CL_AddActor(), Con_DrawConsole(), HUD_UpdateCursor(), MAP_DrawMapOneInstallation(), MAP_InitStartup(), R_AliasModelGetSkin(), R_Draw3DGlobe(), R_DrawFlatGeoscape(), R_DrawInitLocal(), R_FindImage(), R_InitImages(), R_LoadAnimImages(), R_LoadMaterials(), R_ModLoadTexinfo(), R_ParseStage(), R_RegisterImage(), R_UploadData(), SCR_DrawCursor(), SCR_DrawPrecacheScreen(), SCR_SetLoadingBackground(), SCR_TouchPics(), SEQ_Render2D(), UI_InitRadar(), and UI_LoadImage().

void R_FreeImage ( image_t image  ) 

Free the image and its normalmap (if there is one).

Parameters:
image The image that should be freed

Definition at line 624 of file r_image.c.

References image_s::glowmap, image_s::normalmap, R_DeleteImage(), image_s::roughnessmap, image_s::specularmap, and image_s::texnum.

Referenced by R_Draw3DGlobe(), and R_FreeWorldImages().

void R_FreeWorldImages ( void   ) 

Any image that is a mesh or world texture will be removed here.

See also:
R_ShutdownImages

Definition at line 646 of file r_image.c.

References i, it_world, R_CheckError, R_FreeImage(), r_numImages, and image_s::type.

Referenced by R_ModBeginLoading().

image_t* R_GetImage ( const char *  name  ) 
void R_GetScaledTextureSize ( int  width,
int  height,
int *  scaledWidth,
int *  scaledHeight 
)

Calculates the texture size that should be used to upload the texture data.

Parameters:
[in] width The width of the source texture data
[in] height The heigt of the source texture data
[out] scaledWidth The resulting width - can be the same as the given width
[out] scaledHeight The resulting height - can be the same as the given height

Definition at line 279 of file r_image.c.

References MAX_TEXTURE_SIZE, rconfig_t::maxTextureSize, and r_config.

Referenced by R_UploadData(), and R_UploadTexture().

void R_ImageClearMaterials ( void   ) 
qboolean R_ImageExists ( const char *  pname  ) 

Definition at line 608 of file r_image.c.

References FS_CheckFile(), i, Img_GetImageTypes(), qfalse, and qtrue.

Referenced by R_InitExtensions().

void R_ImageList_f ( void   ) 
void R_InitImages ( void   ) 
void R_LoadImage ( const char *  name,
byte **  pic,
int *  width,
int *  height 
)

Generic image-data loading fucntion.

Parameters:
[in] name (Full) pathname to the image to load. Extension (if given) will be ignored.
[out] pic Image data.
[out] width Width of the loaded image.
[out] height Height of the loaded image.
See also:
R_FindImage

Definition at line 141 of file r_image.c.

References Com_Error(), Com_StripExtension(), ERR_FATAL, Img_LoadImage(), MAX_QPATH, Mem_PoolAlloc, and vid_imagePool.

Referenced by MAP_Init().

image_t* R_LoadImageData ( const char *  name,
byte pic,
int  width,
int  height,
imagetype_t  type 
)

Creates a new image from RGBA data. Stores it in the gltextures array and also uploads it.

Note:
This is also used as an entry point for the generated r_noTexture
Parameters:
[in] name The name of the newly created image
[in] pic The RGBA data of the image
[in] width The width of the image (power of two, please)
[in] height The height of the image (power of two, please)
[in] type The image type
See also:
imagetype_t

Definition at line 486 of file r_image.c.

Referenced by CP_InitOverlay(), R_FindImage(), and R_InitMiscTexture().

void R_ScaleTexture ( unsigned *  in,
int  inwidth,
int  inheight,
unsigned *  out,
int  outwidth,
int  outheight 
)

Definition at line 161 of file r_image.c.

References byte, i, int(), and MAX_TEXTURE_SIZE.

Referenced by R_UploadData(), and R_UploadTexture().

void R_ShutdownImages ( void   ) 
See also:
R_FreeWorldImages

Definition at line 692 of file r_image.c.

References i, R_CheckError, R_DeleteImage(), r_numImages, and image_s::texnum.

Referenced by R_Shutdown().

void R_SoftenTexture ( byte in,
int  width,
int  height,
int  bpp 
)

Applies blurring to a texture.

See also:
R_BuildLightMap

Definition at line 391 of file r_image.c.

References byte, Com_Error(), dest, ERR_FATAL, i, Mem_Free, Mem_PoolAllocExt, qfalse, and vid_imagePool.

Referenced by CP_UploadRadarCoverage(), and R_BuildLightmap().

void R_TextureAlphaMode ( const char *  string  ) 
void R_TextureMode ( const char *  string  ) 
void R_TextureSolidMode ( const char *  string  ) 
void R_UploadAlpha ( const image_t image,
const byte alphaData 
)
void R_UploadTexture ( unsigned *  data,
int  width,
int  height,
image_t image 
)

Variable Documentation

const gltmode_t gl_alpha_modes[] [static]
Initial value:
 {
    {"GL_RGBA", GL_RGBA},
    {"GL_RGBA8", GL_RGBA8},
    {"GL_RGB5_A1", GL_RGB5_A1},
    {"GL_RGBA4", GL_RGBA4},
    {"GL_RGBA2", GL_RGBA2},
    {"GL_LUMINANCE4_ALPHA4", GL_LUMINANCE4_ALPHA4},
    {"GL_LUMINANCE6_ALPHA2", GL_LUMINANCE6_ALPHA2},
    {"GL_LUMINANCE8_ALPHA8", GL_LUMINANCE8_ALPHA8},
    {"GL_LUMINANCE12_ALPHA4", GL_LUMINANCE12_ALPHA4},
    {"GL_LUMINANCE12_ALPHA12", GL_LUMINANCE12_ALPHA12},
    {"GL_LUMINANCE16_ALPHA16", GL_LUMINANCE16_ALPHA16}
}

Definition at line 757 of file r_image.c.

const gltmode_t gl_solid_modes[] [static]
Initial value:
 {
    {"GL_RGB", GL_RGB},
    {"GL_RGB8", GL_RGB8},
    {"GL_RGB5", GL_RGB5},
    {"GL_RGB4", GL_RGB4},
    {"GL_R3_G3_B2", GL_R3_G3_B2},
    {"GL_RGB2", GL_RGB2_EXT},
    {"GL_RGB4", GL_RGB4_EXT},
    {"GL_RGB5", GL_RGB5_EXT},
    {"GL_RGB8", GL_RGB8_EXT},
    {"GL_RGB10", GL_RGB10_EXT},
    {"GL_RGB12", GL_RGB12_EXT},
    {"GL_RGB16", GL_RGB16_EXT},
    {"GL_LUMINANCE", GL_LUMINANCE},
    {"GL_LUMINANCE4", GL_LUMINANCE4},
    {"GL_LUMINANCE8", GL_LUMINANCE8},
    {"GL_LUMINANCE12", GL_LUMINANCE12},
    {"GL_LUMINANCE16", GL_LUMINANCE16}
}

Definition at line 788 of file r_image.c.

Initial value:
 {
    {"GL_NEAREST", GL_NEAREST, GL_NEAREST}, 
    {"GL_LINEAR", GL_LINEAR, GL_LINEAR}, 
    {"GL_NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, 
    {"GL_LINEAR_MIPMAP_NEAREST", GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR}, 
    {"GL_NEAREST_MIPMAP_LINEAR", GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST}, 
    {"GL_LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR} 
}

Definition at line 712 of file r_image.c.

image_t* imageHash[MAX_IMAGEHASH] [static]

Definition at line 31 of file r_image.c.

image_t* r_envmaptextures[MAX_ENVMAPTEXTURES]

Definition at line 37 of file r_image.c.

Referenced by R_DrawMeshModelShell(), and R_ParseStage().

image_t* r_flaretextures[NUM_FLARETEXTURES]

Definition at line 40 of file r_image.c.

Referenced by R_DrawFlareSurfaces(), and R_ParseStage().

image_t r_images[MAX_GL_TEXTURES]

Generated by  doxygen 1.6.2