UFO: Alien Invasion
Loading...
Searching...
No Matches
r_image.h File Reference
#include "r_gl.h"
#include "r_material.h"
Include dependency graph for r_image.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  image_t

Macros

#define MAX_GL_TEXTURES   1024
#define MAX_GL_LIGHTMAPS   256
#define MAX_GL_DELUXEMAPS   256
#define MAX_GL_FRAMEBUFFERS   256
#define MAX_ENVMAPTEXTURES   2
#define NUM_FLARETEXTURES   10

Enumerations

enum  imagetype_t {
  it_chars , it_effect , it_static , it_pic ,
  it_wrappic , it_skin , it_normalmap , it_glowmap ,
  it_specularmap , it_roughnessmap , it_world , it_lightmap ,
  it_deluxemap , it_material , it_worldrelated
}

Functions

void R_UploadTexture (const 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_GetScaledTextureSize (int width, int height, int *scaledWidth, int *scaledHeight)
 Calculates the texture size that should be used to upload the texture data.
void R_ScaleTexture (const unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight)
image_tR_RenderToTexture (const char *name, int x, int y, int w, int h)
void R_ImageList_f (void)
 Shows all loaded images.
void R_InitImages (void)
void R_ShutdownImages (void)
void R_ReloadImages (void)
void R_FreeWorldImages (void)
 Any image that is a mesh or world texture will be removed here.
void R_ImageClearMaterials (void)
 Free previously loaded materials and their stages.
void R_UploadAlpha (const image_t *image, const byte *alphaData)
void R_TextureMode (const char *string)
void R_TextureAlphaMode (const char *string)
void R_TextureSolidMode (const char *string)
void R_FreeImage (image_t *image)
 Free the image and its assigned maps (roughness, normal, specular, glow - if there are any).
image_tR_LoadImageData (const char *name, const 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_GetImage (const char *name)
image_tR_FindImage (const char *pname, imagetype_t type)
 Finds or loads the given image.
const image_tR_FindPics (const char *name)
 Searches for an image in the image array.
bool R_ImageExists (const char *pname,...) __attribute__((format(__printf__
bool image_tR_GetImageAtIndex (int i)
 Returns an image pointer from the r_images linked list, as if r_images would be a plain contiguous array.
int R_GetImageIndex (image_t *image)
 Returns an index of the image pointer in the r_images linked list, as if r_images would be a plain contiguous array.

Variables

int r_numImages
image_tr_envmaptextures [MAX_ENVMAPTEXTURES]
image_tr_flaretextures [NUM_FLARETEXTURES]
image_tshadow
image_tr_noTexture
image_tr_warpTexture
image_tr_dummyTexture

Macro Definition Documentation

◆ MAX_ENVMAPTEXTURES

#define MAX_ENVMAPTEXTURES   2

Definition at line 111 of file r_image.h.

Referenced by R_InitImages(), and R_ParseStage().

◆ MAX_GL_DELUXEMAPS

#define MAX_GL_DELUXEMAPS   256

Definition at line 78 of file r_image.h.

Referenced by R_UploadLightmapPage().

◆ MAX_GL_FRAMEBUFFERS

#define MAX_GL_FRAMEBUFFERS   256

Definition at line 79 of file r_image.h.

Referenced by R_FreeFBOTexture(), and R_GetFreeFBOTexture().

◆ MAX_GL_LIGHTMAPS

#define MAX_GL_LIGHTMAPS   256

Definition at line 77 of file r_image.h.

Referenced by R_UploadLightmapPage().

◆ MAX_GL_TEXTURES

#define MAX_GL_TEXTURES   1024

Definition at line 76 of file r_image.h.

Referenced by R_ImageList_f(), and R_SortSurfacesArrays_().

◆ NUM_FLARETEXTURES

#define NUM_FLARETEXTURES   10

Definition at line 114 of file r_image.h.

Referenced by R_InitImages(), and R_ParseStage().

Enumeration Type Documentation

◆ imagetype_t

Enumerator
it_chars 
it_effect 
it_static 
it_pic 
it_wrappic 
it_skin 
it_normalmap 
it_glowmap 
it_specularmap 
it_roughnessmap 
it_world 

the following are freed with every mapchange

it_lightmap 
it_deluxemap 
it_material 
it_worldrelated 

Definition at line 41 of file r_image.h.

Function Documentation

◆ R_FindImage()

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

Finds or loads the given image.

See also
R_RegisterImage
Parameters
[in]pnameImage name Path relative to the game dir (e.g. textures/tex_common/nodraw)
[in]typeThe 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
Todo
should also check the mipmapping

Definition at line 603 of file r_image.cpp.

References Com_Error(), Com_Printf(), Com_Printf(), Com_StripExtension(), ERR_FATAL, image_t::glowmap, Img_LoadImage(), it_glowmap, it_normalmap, it_roughnessmap, it_specularmap, it_world, MAX_QPATH, image_t::name, image_t::normalmap, R_ChangeImageType(), R_FindImage(), R_GetImage(), R_IsClampedImageType(), R_LoadImageData(), r_noTexture, image_t::roughnessmap, image_t::specularmap, image_t::type, type, and va().

Referenced by CL_AddActor(), Con_DrawConsole(), HUD_UpdateCursor(), R_AliasModelGetSkin(), R_Draw3DGlobe(), R_DrawEntityEffects(), R_DrawFlatGeoscape(), R_DrawFloor(), R_DrawGrass(), R_DrawImageCentered(), R_DrawInitLocal(), R_FindImage(), R_FindPics(), R_InitImages(), R_LoadAnimImages(), R_LoadMaterials(), R_ModLoadTexinfo(), R_ParseStage(), R_UploadData(), SCR_DrawCursor(), SCR_DrawLoadingScreen(), SCR_TouchPics(), SEQ_Render2D(), UI_InitRadar(), UI_LoadImage(), and UI_LoadWrappedImage().

◆ R_FindPics()

const image_t * R_FindPics ( const char * name)

Searches for an image in the image array.

Parameters
[in]nameThe name of the image relative to pics/
Note
name may not be null and has to be longer than 4 chars
Returns
nullptr on error or image_t pointer on success
See also
R_FindImage

Definition at line 673 of file r_image.cpp.

References it_pic, name, R_FindImage(), r_noTexture, and va().

Referenced by CL_ParticleLoadArt(), LE_BrushModelAction(), and SEQ_ExecutePrecache().

◆ R_FreeImage()

void R_FreeImage ( image_t * image)

Free the image and its assigned maps (roughness, normal, specular, glow - if there are any).

Parameters
imageThe image that should be freed

Definition at line 735 of file r_image.cpp.

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

Referenced by R_Draw3DGlobe(), and R_FreeWorldImages().

◆ 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 757 of file r_image.cpp.

References FOR_EACH_IMAGE, i, it_world, R_CheckError, R_FreeImage(), and image_t::type.

Referenced by CL_Disconnect().

◆ R_GetImage()

image_t * R_GetImage ( const char * name)

◆ R_GetImageAtIndex()

bool image_t * R_GetImageAtIndex ( int i)

◆ R_GetImageIndex()

int R_GetImageIndex ( image_t * imagePtr)

Returns an index of the image pointer in the r_images linked list, as if r_images would be a plain contiguous array.

Parameters
imagePtrThe image pointer

Definition at line 702 of file r_image.cpp.

References IMAGE_ARRAY_SIZE, imageArray_t::images, imageArray_t::next, and r_images.

Referenced by R_ImageExists(), R_SortSurfacesArrays(), and R_SortSurfacesArrays_().

◆ R_GetScaledTextureSize()

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]widthThe width of the source texture data
[in]heightThe heigt of the source texture data
[out]scaledWidthThe resulting width - can be the same as the given width
[out]scaledHeightThe resulting height - can be the same as the given height

Definition at line 220 of file r_image.cpp.

References MAX_TEXTURE_SIZE, and r_config.

Referenced by R_UploadData(), and R_UploadTexture().

◆ R_ImageClearMaterials()

void R_ImageClearMaterials ( void )

Free previously loaded materials and their stages.

See also
R_LoadMaterials

Definition at line 61 of file r_image.cpp.

References defaultMaterial, FOR_EACH_IMAGE, i, m, image_t::material, Mem_Free, and materialStage_t::next.

Referenced by R_LoadMaterials().

◆ R_ImageExists()

bool R_ImageExists ( const char * pname,
... )

◆ R_ImageList_f()

◆ R_InitImages()

◆ R_LoadImageData()

image_t * R_LoadImageData ( const char * name,
const 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]nameThe name of the newly created image
[in]picThe RGBA data of the image
[in]widthThe width of the image (power of two, please)
[in]heightThe height of the image (power of two, please)
[in]typeThe image type
See also
imagetype_t
Todo
Instead of this hack, unit tests' build should link to the dummy GL driver

Definition at line 475 of file r_image.cpp.

References Com_Error(), Com_HashKey(), Com_Printf(), Com_Printf(), defaultMaterial, ERR_DROP, FOR_EACH_IMAGE, glGenTextures(), image_t::has_alpha, hash, HASH_Add, image_t::height, i, IMAGE_ARRAY_SIZE, imageHash, len, image_t::material, MAX_IMAGEHASH, Mem_AllocType, Mem_PoolAllocType, image_t::name, name, imageArray_t::next, OBJZERO, Q_strncpyz(), R_BindTexture, R_GetImage(), r_images, r_numImages, R_UploadTexture(), image_t::texnum, image_t::type, type, vid_imagePool, and image_t::width.

Referenced by uiGeoscapeNode::onLoading(), R_FindImage(), R_InitMiscTexture(), and R_RenderToTexture().

◆ R_ReloadImages()

◆ R_RenderToTexture()

◆ R_ScaleTexture()

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

Definition at line 172 of file r_image.cpp.

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

Referenced by R_UploadData(), and R_UploadTexture().

◆ R_ShutdownImages()

void R_ShutdownImages ( void )

◆ R_SoftenTexture()

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

Applies blurring to a texture.

Definition at line 391 of file r_image.cpp.

References Com_Error(), dest, ERR_FATAL, i, Mem_Free, Mem_PoolAllocTypeN, and vid_imagePool.

Referenced by GAME_GetImportData().

◆ R_TextureAlphaMode()

void R_TextureAlphaMode ( const char * string)

Definition at line 931 of file r_image.cpp.

References Com_Printf(), gl_alpha_modes, i, lengthof, Q_strcasecmp, and r_config.

Referenced by R_BeginFrame().

◆ R_TextureMode()

◆ R_TextureSolidMode()

void R_TextureSolidMode ( const char * string)

Definition at line 966 of file r_image.cpp.

References Com_Printf(), gl_solid_modes, i, lengthof, Q_strcasecmp, and r_config.

Referenced by R_BeginFrame().

◆ R_UploadAlpha()

◆ R_UploadTexture()

void R_UploadTexture ( const unsigned * data,
int width,
int height,
image_t * image )

Uploads the opengl texture to the server.

Parameters
[in]dataMust be in RGBA format
widthWidth of the image
heightHeight of the image
[in,out]imagePointer to the image structure to initialize

Definition at line 262 of file r_image.cpp.

References count, data, GLenum, GLint, glTexImage2D(), glTexParameterf(), image_t::has_alpha, i, it_chars, it_pic, it_worldrelated, Mem_Free, Mem_PoolAllocTypeN, R_CheckError, r_config, R_GetScaledTextureSize(), R_IsClampedImageType(), R_ScaleTexture(), r_texture_lod, image_t::type, image_t::upload_height, image_t::upload_width, and vid_imagePool.

Referenced by R_LoadImageData(), and R_ReloadImageData().

Variable Documentation

◆ r_dummyTexture

image_t* r_dummyTexture
extern

1x1 pixel white texture to be used when texturing is required, but texture is not available

Definition at line 53 of file r_main.cpp.

Referenced by R_InitMiscTexture(), and R_TexOverride().

◆ r_envmaptextures

image_t* r_envmaptextures[MAX_ENVMAPTEXTURES]
extern

Definition at line 50 of file r_image.cpp.

Referenced by R_DrawMeshModelShell(), R_InitImages(), and R_ParseStage().

◆ r_flaretextures

image_t* r_flaretextures[NUM_FLARETEXTURES]
extern

Definition at line 53 of file r_image.cpp.

Referenced by R_DrawFlareSurfaces(), R_InitImages(), and R_ParseStage().

◆ r_noTexture

◆ r_numImages

◆ r_warpTexture

image_t* r_warpTexture
extern

Definition at line 52 of file r_main.cpp.

Referenced by R_EnableWarp(), and R_InitMiscTexture().

◆ shadow

image_t* shadow
extern

draw this when actor is alive

Definition at line 35 of file r_draw.cpp.

Referenced by R_DrawEntityEffects(), and R_DrawInitLocal().