#include "r_local.h"
#include "r_error.h"
#include "r_geoscape.h"
#include "../../shared/images.h"
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_t * | R_GetImage (const char *name) |
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. | |
image_t * | R_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_t * | imageHash [MAX_IMAGEHASH] |
image_t | r_images [MAX_GL_TEXTURES] |
int | r_numImages |
image_t * | r_envmaptextures [MAX_ENVMAPTEXTURES] |
image_t * | r_flaretextures [NUM_FLARETEXTURES] |
static const glTextureMode_t | gl_texture_modes [] |
static const gltmode_t | gl_alpha_modes [] |
static const gltmode_t | gl_solid_modes [] |
Definition in file r_image.c.
#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().
static void R_DeleteImage | ( | image_t * | image | ) | [inline, static] |
Definition at line 438 of file r_image.c.
References Com_HashKey(), hash(), image_s::hashNext, image_s::hashPrev, MAX_IMAGEHASH, image_s::name, next, R_CheckError, and image_s::texnum.
Referenced by R_FreeImage(), and R_ShutdownImages().
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.
[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 |
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).
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.
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 | ) |
Definition at line 463 of file r_image.c.
References Com_HashKey(), hash(), image_s::hashNext, MAX_IMAGEHASH, and image_s::name.
Referenced by R_FindImage(), R_LoadImageData(), and R_LoadMaterials().
void R_GetScaledTextureSize | ( | int | width, | |
int | height, | |||
int * | scaledWidth, | |||
int * | scaledHeight | |||
) |
Calculates the texture size that should be used to upload the texture data.
[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 | ) |
Free previously loaded materials and their stages.
Definition at line 48 of file r_image.c.
References material_s::bump, DEFAULT_BUMP, DEFAULT_GLOWSCALE, DEFAULT_HARDNESS, DEFAULT_PARALLAX, DEFAULT_SPECULAR, material_s::glowscale, material_s::hardness, i, lengthof, m, image_s::material, Mem_Free, materialStage_s::next, material_s::parallax, material_s::specular, and material_s::stages.
Referenced by R_LoadMaterials().
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 | ) |
Shows all loaded images.
Definition at line 78 of file r_image.c.
References Com_Printf(), i, it_chars, it_effect, it_lightmap, it_material, it_normalmap, it_pic, it_skin, it_static, it_world, it_wrappic, MAX_GL_TEXTURES, image_s::name, r_numImages, image_s::texnum, image_s::type, image_s::upload_height, and image_s::upload_width.
void R_InitImages | ( | void | ) |
Definition at line 661 of file r_image.c.
References Com_Error(), Com_Printf(), ERR_FATAL, i, it_effect, MAX_ENVMAPTEXTURES, NUM_FLARETEXTURES, R_FindImage(), r_noTexture, r_numImages, and va().
Referenced by R_Init().
void R_LoadImage | ( | const char * | name, | |
byte ** | pic, | |||
int * | width, | |||
int * | height | |||
) |
Generic image-data loading fucntion.
[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. |
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.
[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 |
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 | ) |
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.
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 | ) |
Definition at line 772 of file r_image.c.
References Com_Printf(), rconfig_t::gl_alpha_format, i, lengthof, gltmode_t::mode, gltmode_t::name, Q_strcasecmp, and r_config.
Referenced by R_BeginFrame().
void R_TextureMode | ( | const char * | string | ) |
Definition at line 721 of file r_image.c.
References Com_Printf(), i, it_chars, it_pic, it_wrappic, lengthof, rconfig_t::maxAnisotropic, glTextureMode_t::maximize, glTextureMode_t::minimize, glTextureMode_t::name, Q_strcasecmp, R_BindTexture, R_CheckError, r_config, r_numImages, image_s::texnum, and image_s::type.
Referenced by R_BeginFrame().
void R_TextureSolidMode | ( | const char * | string | ) |
Definition at line 808 of file r_image.c.
References Com_Printf(), rconfig_t::gl_solid_format, i, lengthof, gltmode_t::mode, gltmode_t::name, Q_strcasecmp, and r_config.
Referenced by R_BeginFrame().
Definition at line 425 of file r_image.c.
References rconfig_t::gl_filter_max, image_s::height, it_wrappic, R_BindTexture, r_config, image_s::texnum, image_s::type, and image_s::width.
Referenced by CP_CalcAndUploadDayAndNightTexture(), CP_DecreaseXVILevelEverywhere(), CP_IncreaseXVILevel(), CP_InitializeXVIOverlay(), and CP_UploadRadarCoverage().
void R_UploadTexture | ( | unsigned * | data, | |
int | width, | |||
int | height, | |||
image_t * | image | |||
) |
Uploads the opengl texture to the server.
[in] | data | Must be in RGBA format |
Definition at line 304 of file r_image.c.
References rconfig_t::anisotropic, byte, rconfig_t::gl_alpha_format, rconfig_t::gl_compressed_alpha_format, rconfig_t::gl_compressed_solid_format, rconfig_t::gl_filter_max, rconfig_t::gl_filter_min, rconfig_t::gl_solid_format, image_s::has_alpha, i, cvar_s::integer, it_chars, it_effect, it_material, it_pic, it_skin, it_world, rconfig_t::lod_bias, rconfig_t::maxAnisotropic, Mem_Free, Mem_PoolAllocExt, qfalse, R_CheckError, r_config, R_FilterTexture(), R_GetScaledTextureSize(), R_ScaleTexture(), r_texture_lod, image_s::type, image_s::upload_height, image_s::upload_width, cvar_s::value, and vid_imagePool.
Referenced by R_LoadImageData().
const gltmode_t gl_alpha_modes[] [static] |
{ {"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} }
const gltmode_t gl_solid_modes[] [static] |
{ {"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} }
const glTextureMode_t gl_texture_modes[] [static] |
{ {"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} }
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().
Definition at line 33 of file r_image.c.
Referenced by R_SortSurfacesArrays(), R_SortSurfacesArrays_(), UI_MaterialEditorChangeValue_f(), UI_MaterialEditorMouseDown(), UI_MaterialEditorNewStage_f(), UI_MaterialEditorNodeDraw(), UI_MaterialEditorNodeGetImageAtPosition(), UI_MaterialEditorNodeGetImageCount(), UI_MaterialEditorRemoveStage_f(), and UI_MaterialEditorSelectStage_f().
int r_numImages |
Definition at line 34 of file r_image.c.
Referenced by R_FreeWorldImages(), R_ImageList_f(), R_InitImages(), R_LoadImageData(), R_ShutdownImages(), R_SortSurfacesArrays(), R_SortSurfacesArrays_(), R_TextureMode(), UI_MaterialEditorChangeValue_f(), UI_MaterialEditorNewStage_f(), UI_MaterialEditorNodeDraw(), UI_MaterialEditorNodeGetImageAtPosition(), UI_MaterialEditorNodeGetImageCount(), UI_MaterialEditorRemoveStage_f(), and UI_MaterialEditorSelectStage_f().