DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
gl_rmain.c File Reference
#include "quakedef.h"
#include "r_shadow.h"
#include "polygon.h"
#include "image.h"
#include "ft2.h"
#include "csprogs.h"
#include "cl_video.h"
#include "cl_collision.h"
#include "shader_glsl.h"
+ Include dependency graph for gl_rmain.c:

Go to the source code of this file.

Data Structures

struct  cubemapinfo_t
 
struct  r_bufferdata_buffer_t
 
struct  r_decalsystem_splatqueue_t
 
struct  r_framedata_mem_t
 
struct  r_glsl_permutation_t
 
struct  r_qwskincache_t
 
struct  r_skinframe_t
 
struct  shadermodeinfo_t
 
struct  shaderpermutationinfo_t
 
struct  suffixinfo_t
 

Macros

#define BBOXEDGES   13
 
#define BLENDFUNC_ALLOWS_ANYFOG   (BLENDFUNC_ALLOWS_FOG | BLENDFUNC_ALLOWS_FOG_HACK0 | BLENDFUNC_ALLOWS_FOG_HACKALPHA)
 
#define BLENDFUNC_ALLOWS_COLORMOD   1
 
#define BLENDFUNC_ALLOWS_FOG   2
 
#define BLENDFUNC_ALLOWS_FOG_HACK0   4
 
#define BLENDFUNC_ALLOWS_FOG_HACKALPHA   8
 
#define FOGWIDTH   256
 
#define NORMSIZE   64
 
#define R_BUFFERDATA_CYCLE   3
 
#define R_COMPILESHADER_STATICPARM_EMIT(p, n)
 
#define R_COMPILESHADER_STATICPARM_ENABLE(p)
 
#define R_MESH_PLANE_DIST_EPSILON   (1.0 / 32.0)
 
#define R_SKINFRAME_LOAD_AVERAGE_COLORS(cnt, getpixel)
 
#define RAMPWIDTH   256
 
#define SHADERPERMUTATION_HASHSIZE   256
 
#define SHADERSTATICPARMS_COUNT   15
 
#define SKINFRAME_HASH   1024
 

Enumerations

enum  {
  SHADERSTATICPARM_SATURATION_REDCOMPENSATE = 0 , SHADERSTATICPARM_EXACTSPECULARMATH = 1 , SHADERSTATICPARM_POSTPROCESS_USERVEC1 = 2 , SHADERSTATICPARM_POSTPROCESS_USERVEC2 = 3 ,
  SHADERSTATICPARM_POSTPROCESS_USERVEC3 = 4 , SHADERSTATICPARM_POSTPROCESS_USERVEC4 = 5 , SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS = 6 , SHADERSTATICPARM_OFFSETMAPPING_USELOD = 7 ,
  SHADERSTATICPARM_SHADOWMAPPCF_1 = 8 , SHADERSTATICPARM_SHADOWMAPPCF_2 = 9 , SHADERSTATICPARM_SHADOWSAMPLER = 10 , SHADERSTATICPARM_CELSHADING = 11 ,
  SHADERSTATICPARM_CELOUTLINES = 12 , SHADERSTATICPARM_FXAA = 13 , SHADERSTATICPARM_COLORFRINGE = 14
}
 

Functions

static qbool _R_CullBox (const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes, int ignore)
 
void FOG_clear (void)
 
void GL_Main_Init (void)
 
static void gl_main_newmap (void)
 
static void gl_main_shutdown (void)
 
static void gl_main_start (void)
 
void R_AnimCache_CacheVisibleEntities (void)
 generate animcache data for all entities marked visible
 
void R_AnimCache_ClearCache (void)
 clear the animcache pointers on all known render entities
 
void R_AnimCache_Free (void)
 Animation cache prevents re-generating mesh data for an animated model multiple times in one frame for lighting, shadowing, reflections, etc.
 
qbool R_AnimCache_GetEntity (entity_render_t *ent, qbool wantnormals, qbool wanttangents)
 get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangents)
 
static int R_BlendFuncFlags (int src, int dst)
 
static void R_BlendView (rtexture_t *viewcolortexture, int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int x, int y, int width, int height)
 
static qbool R_BlendView_IsTrivial (int viewwidth, int viewheight, int width, int height)
 
static void R_Bloom_MakeTexture (void)
 
static void R_Bloom_StartFrame (void)
 
void R_BufferData_NewFrame (void)
 begin a new frame (recycle old buffers)
 
void R_BufferData_Reset (void)
 frees all dynamic buffers
 
static void R_BufferData_Resize (r_bufferdata_type_t type, qbool mustgrow, size_t minsize)
 
r_meshbuffer_tR_BufferData_Store (size_t datasize, const void *data, r_bufferdata_type_t type, int *returnbufferoffset)
 request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and offset, always successful
 
static void R_BuildBlankTextures (void)
 
static void R_BuildFogHeightTexture (void)
 
static void R_BuildFogTexture (void)
 
static void R_BuildNormalizationCube (void)
 
static void R_BuildNoTexture (void)
 
static void R_BuildWhiteCube (void)
 
void R_CalcBeam_Vertex3f (float *vert, const float *org1, const float *org2, float width)
 
void R_CalcSprite_Vertex3f (float *vertex3f, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2)
 
static void R_CalcTexCoordsForView (float x, float y, float w, float h, float tw, float th, float *texcoord2f)
 
qbool R_CanSeeBox (int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t entboxexpand, vec_t pad, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs)
 
static void R_CompileShader_AddStaticParms (unsigned int mode, uint64_t permutation)
 
qbool R_CompileShader_CheckStaticParms (void)
 
qbool R_CullBox (const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes)
 
qbool R_CullFrustum (const vec3_t mins, const vec3_t maxs)
 
void R_DebugLine (vec3_t start, vec3_t end)
 
static void R_DecalSystem_ApplySplatEntities (const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize, unsigned int decalsequence)
 
static void R_DecalSystem_ApplySplatEntitiesQueue (void)
 
void R_DecalSystem_Reset (decalsystem_t *decalsystem)
 
static void R_DecalSystem_SpawnTriangle (decalsystem_t *decalsystem, const float *v0, const float *v1, const float *v2, const float *t0, const float *t1, const float *t2, const float *c0, const float *c1, const float *c2, int triangleindex, int surfaceindex, unsigned int decalsequence)
 
void R_DecalSystem_SplatEntities (const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize)
 
static void R_DecalSystem_SplatEntity (entity_render_t *ent, const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize, unsigned int decalsequence)
 
static void R_DecalSystem_SplatTriangle (decalsystem_t *decalsystem, float r, float g, float b, float a, float s1, float t1, float s2, float t2, unsigned int decalsequence, qbool dynamic, float(*planes)[4], matrix4x4_t *projection, int triangleindex, int surfaceindex)
 
static void R_DrawBBoxMesh (vec3_t mins, vec3_t maxs, float cr, float cg, float cb, float ca)
 
static int R_DrawBrushModelsSky (void)
 only used if skyrendermasked, and normally returns false
 
void R_DrawCustomSurface (skinframe_t *skinframe, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui)
 
void R_DrawCustomSurface_Texture (texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui)
 
static void R_DrawDebugModel (void)
 
static void R_DrawEntityBBoxes (prvm_prog_t *prog)
 
static void R_DrawEntityBBoxes_Callback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
static void R_DrawLoc_Callback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
static void R_DrawLocs (void)
 
static void R_DrawModelDecals (void)
 
static void R_DrawModelDecals_Entity (entity_render_t *ent)
 
static void R_DrawModelDecals_FadeEntity (entity_render_t *ent)
 
static void R_DrawModels (void)
 
static void R_DrawModelsAddWaterPlanes (void)
 
static void R_DrawModelsDebug (void)
 
static void R_DrawModelsDepth (void)
 
void R_DrawModelSurfaces (entity_render_t *ent, qbool skysurfaces, qbool writedepth, qbool depthonly, qbool debug, qbool prepass, qbool ui)
 
static void R_DrawModelTextureSurfaceList (int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool prepass, qbool ui)
 
static void R_DrawNoModel (entity_render_t *ent)
 
static void R_DrawNoModel_TransparentCallback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
static void R_DrawSurface_TransparentCallback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
static void R_DrawTextureSurfaceList_DepthOnly (int texturenumsurfaces, const msurface_t **texturesurfacelist)
 
static void R_DrawTextureSurfaceList_GL20 (int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool prepass, qbool ui)
 
static void R_DrawTextureSurfaceList_ShowSurfaces (int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth)
 
static void R_DrawTextureSurfaceList_Sky (int texturenumsurfaces, const msurface_t **texturesurfacelist)
 
void R_EntityMatrix (const matrix4x4_t *matrix)
 
static float R_EvaluateQ3WaveFunc (q3wavefunc_t func, const float *parms)
 
void R_FillColors (float *out, int verts, float r, float g, float b, float a)
 
voidR_FrameData_Alloc (size_t size)
 allocate some temporary memory for your purposes
 
void R_FrameData_NewFrame (void)
 prepare for a new frame, recycles old buffers if a resize occurred previously
 
void R_FrameData_Reset (void)
 free all R_FrameData memory
 
static void R_FrameData_Resize (qbool mustgrow)
 
void R_FrameData_ReturnToMark (void)
 discard recent memory allocations (rewind to marker)
 
void R_FrameData_SetMark (void)
 set a marker that allows you to discard the following temporary memory allocations
 
voidR_FrameData_Store (size_t size, void *data)
 allocate some temporary memory and copy this data into it
 
static void R_GetCornerOfBox (vec3_t out, const vec3_t mins, const vec3_t maxs, int signbits)
 
rtexture_tR_GetCubemap (const char *basename)
 
texture_tR_GetCurrentTexture (texture_t *t)
 
r_refdef_scene_tR_GetScenePointer (r_refdef_scene_type_t scenetype)
 
static void R_GLSL_CompilePermutation (r_glsl_permutation_t *p, unsigned int mode, uint64_t permutation)
 
static void R_GLSL_DumpShader_f (cmd_state_t *cmd)
 
static r_glsl_permutation_tR_GLSL_FindPermutation (unsigned int mode, uint64_t permutation)
 
void R_GLSL_Restart_f (cmd_state_t *cmd)
 
void R_HDR_UpdateIrisAdaptation (const vec3_t point)
 
static void R_InitShaderModeInfo (void)
 
static rtexture_tR_LoadCubemap (const char *basename)
 
static void R_LoadQWSkin (r_qwskincache_t *cache, const char *skinname)
 
static void R_Main_FreeViewCache (void)
 
static void R_Main_ResizeViewCache (void)
 
void R_Mesh_AddBrushMeshFromPlanes (rmesh_t *mesh, int numplanes, mplane_t *planes)
 
static void R_Mesh_AddPolygon3d (rmesh_t *mesh, int numvertices, double *vertex3d)
 
void R_Mesh_AddPolygon3f (rmesh_t *mesh, int numvertices, float *vertex3f)
 
static int R_Mesh_AddVertex (rmesh_t *mesh, float x, float y, float z)
 
void R_ModulateColors (float *in, float *out, int verts, float r, float g, float b)
 
static void R_MotionBlurView (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
static void R_ProcessModelTextureSurfaceList (int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool depthonly, qbool prepass, qbool ui)
 
static void R_ProcessTransparentTextureSurfaceList (int texturenumsurfaces, const msurface_t **texturesurfacelist)
 
static void R_QueueModelSurfaceList (entity_render_t *ent, int numsurfaces, const msurface_t **surfacelist, int flagsmask, qbool writedepth, qbool depthonly, qbool prepass, qbool ui)
 
void R_RenderScene (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
void R_RenderTarget_FreeUnused (qbool force)
 
r_rendertarget_tR_RenderTarget_Get (int texturewidth, int textureheight, textype_t depthtextype, qbool depthisrenderbuffer, textype_t colortextype0, textype_t colortextype1, textype_t colortextype2, textype_t colortextype3)
 
void R_RenderView (int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int x, int y, int width, int height)
 
void R_RenderView_UpdateViewVectors (void)
 
void R_RenderWaterPlanes (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
void R_ResetViewRendering2D (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
void R_ResetViewRendering2D_Common (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight, float x2, float y2)
 
void R_ResetViewRendering3D (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
void R_SelectScene (r_refdef_scene_type_t scenetype)
 
void R_SetupShader_DeferredLight (const rtlight_t *rtlight)
 
void R_SetupShader_DepthOrShadow (qbool notrippy, qbool depthrgb, qbool skeletal)
 
void R_SetupShader_Generic (rtexture_t *t, qbool usegamma, qbool notrippy, qbool suppresstexalpha)
 
void R_SetupShader_Generic_NoTexture (qbool usegamma, qbool notrippy)
 
static void R_SetupShader_SetPermutationGLSL (unsigned int mode, uint64_t permutation)
 
void R_SetupShader_Surface (const float rtlightambient[3], const float rtlightdiffuse[3], const float rtlightspecular[3], rsurfacepass_t rsurfacepass, int texturenumsurfaces, const msurface_t **texturesurfacelist, void *surfacewaterplane, qbool notrippy, qbool ui)
 
void R_SetupView (qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
static char * R_ShaderStrCat (const char **strings)
 
skinframe_tR_SkinFrame_Find (const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qbool add)
 
skinframe_tR_SkinFrame_FindNextByName (skinframe_t *last, const char *name)
 
static void R_SkinFrame_GenerateTexturesFromQPixels (skinframe_t *skinframe, qbool colormapped)
 
skinframe_tR_SkinFrame_LoadExternal (const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
 
skinframe_tR_SkinFrame_LoadExternal_SkinFrame (skinframe_t *skinframe, const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
 
skinframe_tR_SkinFrame_LoadInternal8bit (const char *name, int textureflags, const unsigned char *skindata, int width, int height, const unsigned int *palette, const unsigned int *alphapalette)
 
skinframe_tR_SkinFrame_LoadInternalBGRA (const char *name, int textureflags, const unsigned char *skindata, int width, int height, int comparewidth, int compareheight, int comparecrc, qbool sRGB)
 
skinframe_tR_SkinFrame_LoadInternalQuake (const char *name, int textureflags, int loadpantsandshirt, int loadglowtexture, const unsigned char *skindata, int width, int height)
 
skinframe_tR_SkinFrame_LoadInternalUsingTexture (const char *name, int textureflags, rtexture_t *tex, int width, int height, qbool sRGB)
 
skinframe_tR_SkinFrame_LoadMissing (void)
 
skinframe_tR_SkinFrame_LoadNoTexture (void)
 
void R_SkinFrame_MarkUsed (skinframe_t *skinframe)
 
void R_SkinFrame_PrepareForPurge (void)
 
void R_SkinFrame_Purge (void)
 
void R_SkinFrame_PurgeSkinFrame (skinframe_t *s)
 
static void R_SortEntities (void)
 
static int R_SortEntities_Compare (const void *ap, const void *bp)
 
static void R_tcMod_ApplyToMatrix (matrix4x4_t *texmatrix, q3shaderinfo_layer_tcmod_t *tcmod, int currentmaterialflags)
 
static qbool R_TestQ3WaveFunc (q3wavefunc_t func, const float *parms)
 
void R_UpdateFog (void)
 
void R_UpdateVariables (void)
 
static void R_View_SetFrustum (const int *scissor)
 
static void R_View_Update (const int *myscissor)
 
static void R_View_UpdateEntityVisible (void)
 
void R_Water_AddWaterPlane (msurface_t *surface, int entno)
 
static void R_Water_ProcessPlanes (int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int viewx, int viewy, int viewwidth, int viewheight)
 
static void R_Water_StartFrame (int viewwidth, int viewheight)
 
void Render_Init (void)
 
void RSurf_ActiveCustomEntity (const matrix4x4_t *matrix, const matrix4x4_t *inversematrix, int entflags, double shadertime, float r, float g, float b, float a, int numvertices, const float *vertex3f, const float *texcoord2f, const float *normal3f, const float *svector3f, const float *tvector3f, const float *color4f, int numtriangles, const int *element3i, const unsigned short *element3s, qbool wantnormals, qbool wanttangents)
 
void RSurf_ActiveModelEntity (const entity_render_t *ent, qbool wantnormals, qbool wanttangents, qbool prepass)
 
void RSurf_DrawBatch (void)
 
static int RSurf_FindWaterPlaneForSurface (const msurface_t *surface)
 
float RSurf_FogPoint (const float *v)
 
float RSurf_FogVertex (const float *v)
 
void RSurf_PrepareVerticesForBatch (int batchneed, int texturenumsurfaces, const msurface_t **texturesurfacelist)
 
static void RSurf_RenumberElements (const int *inelement3i, int *outelement3i, int numelements, int adjust)
 
void RSurf_SetupDepthAndCulling (bool ui)
 
void RSurf_UploadBuffersForBatch (void)
 
static char * ShaderModeInfo_GetShaderText (shadermodeinfo_t *modeinfo, qbool printfromdisknotice, qbool builtinonly)
 
void V_MakeViewIsometric (void)
 

Variables

static const float bboxedges [BBOXEDGES][6]
 
static const unsigned short bboxelements [36]
 
static const char * builtinshaderstrings []
 
cvar_t cl_decals_bias
 
cvar_t cl_decals_max
 
cvar_t cl_decals_models
 
cvar_t cl_decals_newsystem_intensitymultiplier
 
cvar_t cl_locs_show
 
static int componentorder [4] = {0, 1, 2, 3}
 
skinframe_tdecalskinframe
 
cvar_t developer_texturelogging = {CF_CLIENT, "developer_texturelogging", "0", "produces a textures.log file containing names of skins and map textures the engine tried to load"}
 
cvar_t gl_fogblue = {CF_CLIENT, "gl_fogblue","0.3", "nehahra fog color blue value (for Nehahra compatibility only)"}
 
cvar_t gl_fogdensity = {CF_CLIENT, "gl_fogdensity", "0.25", "nehahra fog density (recommend values below 0.1) (for Nehahra compatibility only)"}
 
cvar_t gl_fogenable = {CF_CLIENT, "gl_fogenable", "0", "nehahra fog enable (for Nehahra compatibility only)"}
 
cvar_t gl_fogend = {CF_CLIENT, "gl_fogend","0", "nehahra fog end distance (for Nehahra compatibility only)"}
 
cvar_t gl_foggreen = {CF_CLIENT, "gl_foggreen","0.3", "nehahra fog color green value (for Nehahra compatibility only)"}
 
cvar_t gl_fogred = {CF_CLIENT, "gl_fogred","0.3", "nehahra fog color red value (for Nehahra compatibility only)"}
 
cvar_t gl_fogstart = {CF_CLIENT, "gl_fogstart", "0", "nehahra fog start distance (for Nehahra compatibility only)"}
 
cvar_t gl_lightmaps = {CF_CLIENT, "gl_lightmaps", "0", "draws only lightmaps, no texture (for level designers), a value of 2 keeps normalmap shading"}
 
cvar_t gl_picmip
 
cvar_t gl_skyclip = {CF_CLIENT, "gl_skyclip", "4608", "nehahra farclip distance - the real fog end (for Nehahra compatibility only)"}
 
static float irisvecs [7][3] = {{0, 0, 0}, {-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}}
 
rtexture_tloadingscreentexture
 
unsigned short locboxelements [6 *2 *3]
 
float locboxvertex3f [6 *4 *3]
 
static const float nomodelcolor4f [6 *4]
 
static const int nomodelelement3i [24]
 
static const unsigned short nomodelelement3s [24]
 
static const float nomodelvertex3f [6 *3]
 
static const int quadedges [6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}}
 
cvar_t r_batch_debugdynamicvertexpath = {CF_CLIENT | CF_ARCHIVE, "r_batch_debugdynamicvertexpath", "0", "force the dynamic batching code path for debugging purposes"}
 
cvar_t r_batch_dynamicbuffer = {CF_CLIENT | CF_ARCHIVE, "r_batch_dynamicbuffer", "0", "use vertex/index buffers for drawing dynamic and copytriangles batches"}
 
cvar_t r_batch_multidraw = {CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw", "1", "issue multiple glDrawElements calls when rendering a batch of surfaces with the same texture (otherwise the index data is copied to make it one draw)"}
 
cvar_t r_batch_multidraw_mintriangles = {CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw_mintriangles", "0", "minimum number of triangles to activate multidraw path (copying small groups of triangles may be faster)"}
 
cvar_t r_bloom = {CF_CLIENT | CF_ARCHIVE, "r_bloom", "0", "enables bloom effect (makes bright pixels affect neighboring pixels)"}
 
cvar_t r_bloom_blur = {CF_CLIENT | CF_ARCHIVE, "r_bloom_blur", "4", "how large the glow is"}
 
cvar_t r_bloom_brighten = {CF_CLIENT | CF_ARCHIVE, "r_bloom_brighten", "1", "how bright the glow is, after subtract/power"}
 
cvar_t r_bloom_colorexponent = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorexponent", "1", "how exaggerated the glow is"}
 
cvar_t r_bloom_colorscale = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorscale", "1", "how bright the glow is"}
 
cvar_t r_bloom_colorsubtract = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorsubtract", "0.1", "reduces bloom colors by a certain amount"}
 
cvar_t r_bloom_resolution = {CF_CLIENT | CF_ARCHIVE, "r_bloom_resolution", "320", "what resolution to perform the bloom effect at (independent of screen resolution)"}
 
cvar_t r_bloom_scenebrightness = {CF_CLIENT | CF_ARCHIVE, "r_bloom_scenebrightness", "1", "global rendering brightness when bloom is enabled"}
 
static r_bufferdata_buffer_tr_bufferdata_buffer [R_BUFFERDATA_CYCLE][R_BUFFERDATA_COUNT]
 
static int r_bufferdata_cycle = 0
 
cvar_t r_buffermegs [R_BUFFERDATA_COUNT]
 
cvar_t r_celoutlines = {CF_CLIENT | CF_ARCHIVE, "r_celoutlines", "0", "cartoon-style outlines (requires r_shadow_deferred)"}
 
cvar_t r_celshading = {CF_CLIENT | CF_ARCHIVE, "r_celshading", "0", "cartoon-style light shading (OpenGL 2.x only)"}
 
cvar_t r_colorfringe = {CF_CLIENT | CF_ARCHIVE, "r_colorfringe", "0", "Chromatic aberration. Values higher than 0.025 will noticeably distort the image"}
 
static unsigned int r_compileshader_staticparms [(SHADERSTATICPARMS_COUNT+0x1F) > > 5] = {0}
 
cvar_t r_cullentities_trace = {CF_CLIENT, "r_cullentities_trace", "1", "probabistically cull invisible entities"}
 
cvar_t r_cullentities_trace_delay = {CF_CLIENT, "r_cullentities_trace_delay", "1", "number of seconds until the entity gets actually culled"}
 
cvar_t r_cullentities_trace_enlarge = {CF_CLIENT, "r_cullentities_trace_enlarge", "0", "box enlargement for entity culling"}
 
cvar_t r_cullentities_trace_entityocclusion = {CF_CLIENT, "r_cullentities_trace_entityocclusion", "1", "check for occluding entities such as doors, not just world hull"}
 
cvar_t r_cullentities_trace_expand = {CF_CLIENT, "r_cullentities_trace_expand", "0", "box expanded by this many units for entity culling"}
 
cvar_t r_cullentities_trace_eyejitter = {CF_CLIENT, "r_cullentities_trace_eyejitter", "16", "randomly offset rays from the eye by this much to reduce the odds of flickering"}
 
cvar_t r_cullentities_trace_pad = {CF_CLIENT, "r_cullentities_trace_pad", "8", "accept traces that hit within this many units of the box"}
 
cvar_t r_cullentities_trace_samples = {CF_CLIENT, "r_cullentities_trace_samples", "2", "number of samples to test for entity culling (in addition to center sample)"}
 
cvar_t r_cullentities_trace_tempentitysamples = {CF_CLIENT, "r_cullentities_trace_tempentitysamples", "-1", "number of samples to test for entity culling of temp entities (including all CSQC entities), -1 disables trace culling on these entities to prevent flicker (pvs still applies)"}
 
static r_refdef_scene_type_t r_currentscenetype = RST_CLIENT
 
cvar_t r_damageblur = {CF_CLIENT | CF_ARCHIVE, "r_damageblur", "0", "screen motionblur based on damage - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"}
 
int r_decalsystem_numqueued = 0
 
r_decalsystem_splatqueue_t r_decalsystem_queue [MAX_DECALSYSTEM_QUEUE]
 
cvar_t r_deformvertexes = {CF_CLIENT, "r_deformvertexes", "1", "allows use of deformvertexes in shader files (can be turned off to check performance impact)"}
 
cvar_t r_depthfirst = {CF_CLIENT | CF_ARCHIVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"}
 
cvar_t r_draw2d = {CF_CLIENT, "r_draw2d","1", "draw 2D stuff (dangerous to turn off)"}
 
cvar_t r_drawdecals
 
cvar_t r_drawentities = {CF_CLIENT, "r_drawentities","1", "draw entities (doors, players, projectiles, etc)"}
 
cvar_t r_drawexteriormodel = {CF_CLIENT, "r_drawexteriormodel","1", "draw your player model (e.g. in chase cam, reflections)"}
 
cvar_t r_drawfog = {CF_CLIENT | CF_ARCHIVE, "r_drawfog", "1", "allows one to disable fog rendering"}
 
cvar_t r_drawparticles
 
cvar_t r_drawportals = {CF_CLIENT, "r_drawportals", "0", "shows portals (separating polygons) in world interior in quake1 maps"}
 
cvar_t r_drawviewmodel = {CF_CLIENT, "r_drawviewmodel","1", "draw your weapon model"}
 
cvar_t r_drawworld = {CF_CLIENT, "r_drawworld","1", "draw world (most static stuff)"}
 
cvar_t r_dynamic = {CF_CLIENT | CF_ARCHIVE, "r_dynamic","1", "enables dynamic lights (rocket glow and such)"}
 
cvar_t r_farclip_base = {CF_CLIENT, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"}
 
cvar_t r_farclip_world = {CF_CLIENT, "r_farclip_world", "2", "adds map size to farclip multiplied by this value"}
 
r_framebufferstate_t r_fb
 
cvar_t r_fog_clear = {CF_CLIENT, "r_fog_clear", "1", "clears renderbuffer with fog color before render starts"}
 
cvar_t r_fog_exp2 = {CF_CLIENT, "r_fog_exp2", "0", "uses GL_EXP2 fog (as in Nehahra) rather than realistic GL_EXP fog"}
 
static r_framedata_mem_tr_framedata_mem
 
cvar_t r_framedatasize = {CF_CLIENT | CF_ARCHIVE, "r_framedatasize", "0.5", "size of renderer data cache used during one frame (for skeletal animation caching, light processing, etc)"}
 
cvar_t r_fullbright = {CF_CLIENT, "r_fullbright","0", "makes map very bright and renders faster"}
 
cvar_t r_fullbright_directed = {CF_CLIENT, "r_fullbright_directed", "0", "render fullbright things (unlit worldmodel and EF_FULLBRIGHT entities, but not fullbright shaders) using a constant light direction instead to add more depth while keeping uniform brightness"}
 
cvar_t r_fullbright_directed_ambient = {CF_CLIENT, "r_fullbright_directed_ambient", "0.5", "ambient light multiplier for directed fullbright"}
 
cvar_t r_fullbright_directed_diffuse = {CF_CLIENT, "r_fullbright_directed_diffuse", "0.75", "diffuse light multiplier for directed fullbright"}
 
cvar_t r_fullbright_directed_pitch = {CF_CLIENT, "r_fullbright_directed_pitch", "20", "constant pitch direction ('height') of the fake light source to use for fullbright"}
 
cvar_t r_fullbright_directed_pitch_relative = {CF_CLIENT, "r_fullbright_directed_pitch_relative", "0", "whether r_fullbright_directed_pitch is interpreted as absolute (0) or relative (1) pitch"}
 
cvar_t r_fullbrights = {CF_CLIENT | CF_ARCHIVE, "r_fullbrights", "1", "enables glowing pixels in quake textures (changes need r_restart to take effect)"}
 
cvar_t r_fxaa = {CF_CLIENT | CF_ARCHIVE, "r_fxaa", "0", "fast approximate anti aliasing"}
 
cvar_t r_glsl_deluxemapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"}
 
cvar_t r_glsl_offsetmapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"}
 
cvar_t r_glsl_offsetmapping_lod = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod", "0", "apply distance-based level-of-detail correction to number of offsetmappig steps, effectively making it render faster on large open-area maps"}
 
cvar_t r_glsl_offsetmapping_lod_distance = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod_distance", "32", "first LOD level distance, second level (-50% steps) is 2x of this, third (33%) - 3x etc."}
 
cvar_t r_glsl_offsetmapping_reliefmapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping", "0", "relief mapping effect (higher quality)"}
 
cvar_t r_glsl_offsetmapping_reliefmapping_refinesteps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_refinesteps", "5", "relief mapping refine steps (these are a binary search executed as the last step as given by r_glsl_offsetmapping_reliefmapping_steps)"}
 
cvar_t r_glsl_offsetmapping_reliefmapping_steps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_steps", "10", "relief mapping steps (note: too high values may be not supported by your GPU)"}
 
cvar_t r_glsl_offsetmapping_scale = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_scale", "0.04", "how deep the offset mapping effect is"}
 
cvar_t r_glsl_offsetmapping_steps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_steps", "2", "offset mapping steps (note: too high values may be not supported by your GPU)"}
 
r_glsl_permutation_tr_glsl_permutation
 currently selected permutation
 
memexpandablearray_t r_glsl_permutationarray
 storage for permutations linked in the hash table
 
r_glsl_permutation_tr_glsl_permutationhash [SHADERMODE_COUNT][SHADERPERMUTATION_HASHSIZE]
 information about each possible shader permutation
 
cvar_t r_glsl_postprocess = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess", "0", "use a GLSL postprocessing shader"}
 
cvar_t r_glsl_postprocess_uservec1 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1", "0 0 0 0", "a 4-component vector to pass as uservec1 to the postprocessing shader (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec1_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1_enable", "1", "enables postprocessing uservec1 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec2 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2", "0 0 0 0", "a 4-component vector to pass as uservec2 to the postprocessing shader (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec2_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2_enable", "1", "enables postprocessing uservec2 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec3 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3", "0 0 0 0", "a 4-component vector to pass as uservec3 to the postprocessing shader (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec3_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3_enable", "1", "enables postprocessing uservec3 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec4 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4", "0 0 0 0", "a 4-component vector to pass as uservec4 to the postprocessing shader (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_postprocess_uservec4_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4_enable", "1", "enables postprocessing uservec4 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}
 
cvar_t r_glsl_saturation = {CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation", "1", "saturation multiplier (only working in glsl!)"}
 
cvar_t r_glsl_saturation_redcompensate = {CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation_redcompensate", "0", "a 'vampire sight' addition to desaturation effect, does compensation for red color, r_glsl_restart is required"}
 
cvar_t r_glsl_skeletal = {CF_CLIENT | CF_ARCHIVE, "r_glsl_skeletal", "1", "render skeletal models faster using a gpu-skinning technique"}
 
cvar_t r_glsl_vertextextureblend_usebothalphas = {CF_CLIENT | CF_ARCHIVE, "r_glsl_vertextextureblend_usebothalphas", "0", "use both alpha layers on vertex blended surfaces, each alpha layer sets amount of 'blend leak' on another layer, requires mod_q3shader_force_terrain_alphaflag on."}
 
static qbool r_gpuskeletal
 
cvar_t r_hdr_glowintensity = {CF_CLIENT | CF_ARCHIVE, "r_hdr_glowintensity", "1", "how bright light emitting textures should appear"}
 
cvar_t r_hdr_irisadaptation = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation", "0", "adjust scene brightness according to light intensity at player location"}
 
cvar_t r_hdr_irisadaptation_fade_down = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_down", "0.5", "fade rate at which value adjusts to brightness"}
 
cvar_t r_hdr_irisadaptation_fade_up = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_up", "0.1", "fade rate at which value adjusts to darkness"}
 
cvar_t r_hdr_irisadaptation_maxvalue = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_maxvalue", "4", "maximum value that can result from multiplier / brightness"}
 
cvar_t r_hdr_irisadaptation_minvalue = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_minvalue", "0.5", "minimum value that can result from multiplier / brightness"}
 
cvar_t r_hdr_irisadaptation_multiplier = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_multiplier", "2", "brightness at which value will be 1.0"}
 
cvar_t r_hdr_irisadaptation_radius = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_radius", "15", "lighting within this many units of the eye is averaged"}
 
cvar_t r_hdr_irisadaptation_value = {CF_CLIENT, "r_hdr_irisadaptation_value", "1", "current value as scenebrightness multiplier, changes continuously when irisadaptation is active"}
 
cvar_t r_hdr_scenebrightness = {CF_CLIENT | CF_ARCHIVE, "r_hdr_scenebrightness", "1", "global rendering brightness"}
 
cvar_t r_lerplightstyles = {CF_CLIENT | CF_ARCHIVE, "r_lerplightstyles", "0", "enable animation smoothing on flickering lights"}
 
cvar_t r_lerpmodels = {CF_CLIENT | CF_ARCHIVE, "r_lerpmodels", "1", "enables animation smoothing on models"}
 
cvar_t r_lerpsprites = {CF_CLIENT | CF_ARCHIVE, "r_lerpsprites", "0", "enables animation smoothing on sprites"}
 
static qbool r_loaddds
 
qbool r_loadfog
 
static qbool r_loadgloss
 
static qbool r_loadnormalmap
 
cvar_t r_lockpvs
 
cvar_t r_lockvisibility
 
mempool_tr_main_mempool
 
rtexturepool_tr_main_texturepool
 
unsigned int r_maxqueries
 
int r_maxsurfacelist = 0
 
cvar_t r_motionblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur", "0", "screen motionblur - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"}
 
cvar_t r_motionblur_averaging = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_averaging", "0.1", "sliding average reaction time for velocity (higher = slower adaption to change)"}
 
cvar_t r_motionblur_maxblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_maxblur", "0.9", "maxmimum amount of blur"}
 
cvar_t r_motionblur_minblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_minblur", "0.5", "factor of blur to apply at all times (always have this amount of blur no matter what the other factors are)"}
 
cvar_t r_motionblur_mousefactor = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor", "2", "factoring in of mouse acceleration to the blur equation - the faster the player turns their mouse, the more blur they get"}
 
cvar_t r_motionblur_mousefactor_maxspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_maxspeed", "50", "upper value of mouse acceleration when it reaches the peak factor into blur equation"}
 
cvar_t r_motionblur_mousefactor_minspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_minspeed", "0", "lower value of mouse acceleration when it starts to factor into blur equation"}
 
cvar_t r_motionblur_randomize = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_randomize", "0.1", "randomizing coefficient to workaround ghosting"}
 
cvar_t r_motionblur_velocityfactor = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor", "1", "factoring in of player velocity to the blur equation - the faster the player moves around the map, the more blur they get"}
 
cvar_t r_motionblur_velocityfactor_maxspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_maxspeed", "800", "upper value of velocity when it reaches the peak factor into blur equation"}
 
cvar_t r_motionblur_velocityfactor_minspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_minspeed", "400", "lower value of velocity when it starts to factor into blur equation"}
 
cvar_t r_nearclip = {CF_CLIENT, "r_nearclip", "1", "distance from camera of nearclip plane" }
 
cvar_t r_nolerp_list = {CF_CLIENT | CF_ARCHIVE, "r_nolerp_list", "progs/v_nail.mdl,progs/v_nail2.mdl,progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl", "comma separated list of models that will not have their animations smoothed"}
 
unsigned int r_numqueries
 
cvar_t r_polygonoffset_decals_factor = {CF_CLIENT, "r_polygonoffset_decals_factor", "0", "biases depth values of decals to prevent z-fighting artifacts"}
 
cvar_t r_polygonoffset_decals_offset = {CF_CLIENT, "r_polygonoffset_decals_offset", "-14", "biases depth values of decals to prevent z-fighting artifacts"}
 
cvar_t r_polygonoffset_submodel_factor = {CF_CLIENT, "r_polygonoffset_submodel_factor", "0", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"}
 
cvar_t r_polygonoffset_submodel_offset = {CF_CLIENT, "r_polygonoffset_submodel_offset", "14", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"}
 
cvar_t r_q1bsp_lightmap_updates_combine = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_combine", "2", "combine lightmap texture updates to make fewer glTexSubImage2D calls, modes: 0 = immediately upload lightmaps (may be thousands of small 3x3 updates), 1 = combine to one call, 2 = combine to one full texture update (glTexImage2D) which tells the driver it does not need to lock the resource (faster on most drivers)"}
 
cvar_t r_q1bsp_lightmap_updates_enabled = {CF_CLIENT, "r_q1bsp_lightmap_updates_enabled", "1", "allow lightmaps to be updated on Q1BSP maps (don't turn this off except for debugging)"}
 
cvar_t r_q1bsp_lightmap_updates_hidden_surfaces = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_hidden_surfaces", "0", "update lightmaps on surfaces that are not visible, so that updates only occur on frames where lightstyles changed value (animation or light switches), only makes sense with combine = 2"}
 
cvar_t r_q1bsp_skymasking = {CF_CLIENT, "r_q1bsp_skymasking", "1", "allows sky polygons in quake1 maps to obscure other geometry"}
 
unsigned int r_queries [MAX_OCCLUSION_QUERIES]
 
static r_qwskincache_tr_qwskincache
 
static int r_qwskincache_size
 
r_refdef_t r_refdef
 
cvar_t r_rendertarget_debug = {CF_CLIENT, "r_rendertarget_debug", "-1", "replaces the view with the contents of the specified render target (by number - note that these can fluctuate depending on scene)"}
 
static qbool r_savedds
 
static r_refdef_scene_t r_scenes_store [RST_COUNT]
 
const float r_screenvertex3f [12]
 vertex coordinates for a quad that covers the screen exactly
 
cvar_t r_shadow_bouncegrid
 
unsigned int r_shadow_occlusion_buf
 
rtexture_tr_shadow_prepasslightingdiffusetexture
 
rtexture_tr_shadow_prepasslightingspeculartexture
 
int r_shadow_shadowmapatlas_modelshadows_size
 
int r_shadow_shadowmappcf
 
qbool r_shadow_shadowmapsampler
 
qbool r_shadow_usingdeferredprepass
 
cvar_t r_shadows = {CF_CLIENT | CF_ARCHIVE, "r_shadows", "0", "casts fake stencil shadows from models onto the world (rtlights are unaffected by this); when set to 2, always cast the shadows in the direction set by r_shadows_throwdirection, otherwise use the model lighting."}
 
cvar_t r_shadows_castfrombmodels = {CF_CLIENT | CF_ARCHIVE, "r_shadows_castfrombmodels", "0", "do cast shadows from bmodels"}
 
cvar_t r_shadows_darken = {CF_CLIENT | CF_ARCHIVE, "r_shadows_darken", "0.5", "how much shadowed areas will be darkened"}
 
cvar_t r_shadows_drawafterrtlighting = {CF_CLIENT | CF_ARCHIVE, "r_shadows_drawafterrtlighting", "0", "draw fake shadows AFTER realtime lightning is drawn. May be useful for simulating fast sunlight on large outdoor maps with only one noshadow rtlight. The price is less realistic appearance of dynamic light shadows."}
 
cvar_t r_shadows_focus = {CF_CLIENT | CF_ARCHIVE, "r_shadows_focus", "0 0 0", "offset the shadowed area focus"}
 
cvar_t r_shadows_shadowmapbias = {CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapbias", "-1", "sets shadowmap bias for fake shadows. -1 sets the value of r_shadow_shadowmapping_bias. Needs shadowmapping ON."}
 
cvar_t r_shadows_shadowmapscale = {CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapscale", "0.25", "higher values increase shadowmap quality at a cost of area covered (multiply global shadowmap precision) for fake shadows. Needs shadowmapping ON."}
 
cvar_t r_shadows_throwdirection = {CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdirection", "0 0 -1", "override throwing direction for r_shadows 2"}
 
cvar_t r_shadows_throwdistance = {CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdistance", "500", "how far to cast shadows from models"}
 
cvar_t r_showbboxes = {CF_CLIENT, "r_showbboxes", "0", "shows bounding boxes of server entities, value controls opacity scaling (1 = 10%, 10 = 100%)"}
 
cvar_t r_showbboxes_client = {CF_CLIENT, "r_showbboxes_client", "0", "shows bounding boxes of clientside qc entities, value controls opacity scaling (1 = 10%, 10 = 100%)"}
 
cvar_t r_showcollisionbrushes = {CF_CLIENT, "r_showcollisionbrushes", "0", "draws collision brushes in quake3 maps (mode 1), mode 2 disables rendering of world (trippy!)"}
 
cvar_t r_showcollisionbrushes_polygonfactor = {CF_CLIENT, "r_showcollisionbrushes_polygonfactor", "-1", "expands outward the brush polygons a little bit, used to make collision brushes appear infront of walls"}
 
cvar_t r_showcollisionbrushes_polygonoffset = {CF_CLIENT, "r_showcollisionbrushes_polygonoffset", "0", "nudges brush polygon depth in hardware depth units, used to make collision brushes appear infront of walls"}
 
cvar_t r_showdisabledepthtest = {CF_CLIENT, "r_showdisabledepthtest", "0", "disables depth testing on r_show* cvars, allowing you to see what hidden geometry the graphics card is processing"}
 
cvar_t r_showlighting = {CF_CLIENT, "r_showlighting", "0", "shows areas lit by lights, useful for finding out why some areas of a map render slowly (bright orange = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"}
 
cvar_t r_shownormals = {CF_CLIENT, "r_shownormals", "0", "shows per-vertex surface normals and tangent vectors for bumpmapped lighting"}
 
cvar_t r_showoverdraw = {CF_CLIENT, "r_showoverdraw", "0", "shows overlapping geometry"}
 
cvar_t r_showparticleedges = {CF_CLIENT, "r_showparticleedges", "0", "renders a debug outline to show the polygon shape of each particle, for debugging rendering bugs with specific view types"}
 
cvar_t r_showspriteedges = {CF_CLIENT, "r_showspriteedges", "0", "renders a debug outline to show the polygon shape of each sprite frame rendered (may be 2 or more in case of interpolated animations), for debugging rendering bugs with specific view types"}
 
cvar_t r_showsurfaces = {CF_CLIENT, "r_showsurfaces", "0", "1 shows surfaces as different colors, or a value of 3 shows an approximation to vertex or object color (for a very approximate view of the game)"}
 
cvar_t r_showtris = {CF_CLIENT, "r_showtris", "0", "shows triangle outlines, value controls brightness (can be above 1)"}
 
r_skinframe_t r_skinframe
 
cvar_t r_smoothnormals_areaweighting = {CF_CLIENT, "r_smoothnormals_areaweighting", "1", "uses significantly faster (and supposedly higher quality) area-weighted vertex normals and tangent vectors rather than summing normalized triangle normals and tangents"}
 
cvar_t r_sortentities = {CF_CLIENT, "r_sortentities", "0", "sort entities before drawing (might be faster)"}
 
cvar_t r_speeds = {CF_CLIENT, "r_speeds","0", "displays rendering statistics and per-subsystem timings"}
 
const msurface_t ** r_surfacelist = NULL
 
svbsp_t r_svbsp
 shadow volume bsp struct with automatically growing nodes buffer
 
cvar_t r_test = {CF_CLIENT, "r_test", "0", "internal development use only, leave it alone (usually does nothing anyway)"}
 
rtexture_tr_texture_black
 
rtexture_tr_texture_blanknormalmap
 
cubemapinfo_tr_texture_cubemaps [MAX_CUBEMAPS]
 
cvar_t r_texture_dds_load = {CF_CLIENT | CF_ARCHIVE, "r_texture_dds_load", "0", "load compressed dds/filename.dds texture instead of filename.tga, if the file exists (requires driver support)"}
 
cvar_t r_texture_dds_save = {CF_CLIENT | CF_ARCHIVE, "r_texture_dds_save", "0", "save compressed dds/filename.dds texture when filename.tga is loaded, so that it can be loaded instead next time"}
 
rtexture_tr_texture_fogattenuation
 
rtexture_tr_texture_fogheighttexture
 
rtexture_tr_texture_gammaramps
 
unsigned int r_texture_gammaramps_serial
 
rtexture_tr_texture_grey128
 
rtexture_tr_texture_normalizationcube
 
rtexture_tr_texture_notexture
 
int r_texture_numcubemaps
 
rtexture_tr_texture_reflectcube
 
rtexture_tr_texture_white
 
rtexture_tr_texture_whitecube
 
int r_textureframe = 0
 used only by R_GetCurrentTexture, incremented per view and per UI render
 
cvar_t r_transparent = {CF_CLIENT, "r_transparent", "1", "allows use of transparent surfaces (can be turned off to check performance impact)"}
 
cvar_t r_transparent_alphatocoverage = {CF_CLIENT, "r_transparent_alphatocoverage", "1", "enables GL_ALPHA_TO_COVERAGE antialiasing technique on alphablend and alphatest surfaces when using vid_samples 2 or higher"}
 
cvar_t r_transparent_sortarraysize = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortarraysize", "4096", "number of distance-sorting layers"}
 
cvar_t r_transparent_sortmaxdist = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmaxdist", "32768", "upper distance limit for transparent sorting"}
 
cvar_t r_transparent_sortmindist = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmindist", "0", "lower distance limit for transparent sorting"}
 
cvar_t r_transparent_sortsurfacesbynearest = {CF_CLIENT, "r_transparent_sortsurfacesbynearest", "1", "sort entity and world surfaces by nearest point on bounding box instead of using the center of the bounding box, usually reduces sorting artifacts"}
 
cvar_t r_transparent_useplanardistance = {CF_CLIENT, "r_transparent_useplanardistance", "0", "sort transparent meshes by distance from view plane rather than spherical distance to the chosen point"}
 
cvar_t r_transparentdepthmasking = {CF_CLIENT | CF_ARCHIVE, "r_transparentdepthmasking", "0", "enables depth writes on transparent meshes whose materially is normally opaque, this prevents seeing the inside of a transparent mesh"}
 
int r_uniformbufferalignment = 32
 
cvar_t r_usedepthtextures = {CF_CLIENT | CF_ARCHIVE, "r_usedepthtextures", "1", "use depth texture instead of depth renderbuffer where possible, uses less video memory but may render slower (or faster) depending on hardware"}
 
cvar_t r_useinfinitefarclip = {CF_CLIENT | CF_ARCHIVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"}
 
cvar_t r_viewfbo = {CF_CLIENT | CF_ARCHIVE, "r_viewfbo", "0", "enables use of an 8bit (1) or 16bit (2) or 32bit (3) per component float framebuffer render, which may be at a different resolution than the video mode; the default setting of 0 uses a framebuffer render when required, and renders directly to the screen otherwise"}
 
cvar_t r_viewscale = {CF_CLIENT | CF_ARCHIVE, "r_viewscale", "1", "scaling factor for resolution of the fbo rendering method, must be > 0, can be above 1 for a costly antialiasing behavior, typical values are 0.5 for 1/4th as many pixels rendered, or 1 for normal rendering"}
 
cvar_t r_viewscale_fpsscaling = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling", "0", "change resolution based on framerate"}
 
cvar_t r_viewscale_fpsscaling_min = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_min", "0.0625", "worst acceptable quality"}
 
cvar_t r_viewscale_fpsscaling_multiply = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_multiply", "5", "adjust quality up or down by the frametime difference from 1.0/target, multiplied by this factor"}
 
cvar_t r_viewscale_fpsscaling_stepmax = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepmax", "1.00", "largest adjustment to hit the target framerate (this value prevents wild overshooting of the estimate)"}
 
cvar_t r_viewscale_fpsscaling_stepsize = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepsize", "0.01", "smallest adjustment to hit the target framerate (this value prevents minute oscillations)"}
 
cvar_t r_viewscale_fpsscaling_target = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_target", "70", "desired framerate"}
 
cvar_t r_water = {CF_CLIENT | CF_ARCHIVE, "r_water", "0", "whether to use reflections and refraction on water surfaces (note: r_wateralpha must be set below 1)"}
 
cvar_t r_water_cameraentitiesonly = {CF_CLIENT | CF_ARCHIVE, "r_water_cameraentitiesonly", "0", "whether to only show QC-defined reflections/refractions (typically used for camera- or portal-like effects)"}
 
cvar_t r_water_clippingplanebias = {CF_CLIENT | CF_ARCHIVE, "r_water_clippingplanebias", "1", "a rather technical setting which avoids black pixels around water edges"}
 
cvar_t r_water_hideplayer = {CF_CLIENT | CF_ARCHIVE, "r_water_hideplayer", "0", "if set to 1 then player will be hidden in refraction views, if set to 2 then player will also be hidden in reflection views, player is always visible in camera views"}
 
cvar_t r_water_lowquality = {CF_CLIENT, "r_water_lowquality", "0", "special option to accelerate water rendering: 1 disables all dynamic lights, 2 disables particles too"}
 
cvar_t r_water_reflectdistort = {CF_CLIENT | CF_ARCHIVE, "r_water_reflectdistort", "0.01", "how much water reflections shimmer"}
 
cvar_t r_water_refractdistort = {CF_CLIENT | CF_ARCHIVE, "r_water_refractdistort", "0.01", "how much water refractions shimmer"}
 
cvar_t r_water_resolutionmultiplier = {CF_CLIENT | CF_ARCHIVE, "r_water_resolutionmultiplier", "0.5", "multiplier for screen resolution when rendering refracted/reflected scenes, 1 is full quality, lower values are faster"}
 
cvar_t r_water_scissormode = {CF_CLIENT, "r_water_scissormode", "3", "scissor (1) or cull (2) or both (3) water renders"}
 
cvar_t r_wateralpha = {CF_CLIENT | CF_ARCHIVE, "r_wateralpha","1", "opacity of water polygons"}
 
cvar_t r_waterscroll = {CF_CLIENT | CF_ARCHIVE, "r_waterscroll", "1", "makes water scroll around, value controls how much"}
 
matrix4x4_t r_waterscrollmatrix
 
rsurfacestate_t rsurface
 
shadermodeinfo_t shadermodeinfo [SHADERLANGUAGE_COUNT][SHADERMODE_COUNT]
 
shaderpermutationinfo_t shaderpermutationinfo [SHADERPERMUTATION_COUNT]
 
static int shaderstaticparms_count = 0
 
static const char * shaderstaticparmstrings_list [SHADERSTATICPARMS_COUNT]
 
static suffixinfo_t suffix [3][6]
 
qbool v_flipped_state
 
cvar_t v_glslgamma_2d
 
cvar_t v_isometric
 
float viewscalefpsadjusted = 1.0f
 

Macro Definition Documentation

◆ BBOXEDGES

#define BBOXEDGES   13

Definition at line 6012 of file gl_rmain.c.

Referenced by R_DrawBBoxMesh().

◆ BLENDFUNC_ALLOWS_ANYFOG

Definition at line 1521 of file gl_rmain.c.

Referenced by R_SetupShader_Surface().

◆ BLENDFUNC_ALLOWS_COLORMOD

#define BLENDFUNC_ALLOWS_COLORMOD   1

Definition at line 1517 of file gl_rmain.c.

Referenced by R_BlendFuncFlags(), and R_GetCurrentTexture().

◆ BLENDFUNC_ALLOWS_FOG

#define BLENDFUNC_ALLOWS_FOG   2

Definition at line 1518 of file gl_rmain.c.

Referenced by R_BlendFuncFlags().

◆ BLENDFUNC_ALLOWS_FOG_HACK0

#define BLENDFUNC_ALLOWS_FOG_HACK0   4

Definition at line 1519 of file gl_rmain.c.

Referenced by R_BlendFuncFlags(), and R_SetupShader_Surface().

◆ BLENDFUNC_ALLOWS_FOG_HACKALPHA

#define BLENDFUNC_ALLOWS_FOG_HACKALPHA   8

Definition at line 1520 of file gl_rmain.c.

Referenced by R_BlendFuncFlags(), and R_SetupShader_Surface().

◆ FOGWIDTH

#define FOGWIDTH   256

Referenced by R_BuildFogTexture().

◆ NORMSIZE

#define NORMSIZE   64

◆ R_BUFFERDATA_CYCLE

#define R_BUFFERDATA_CYCLE   3

Definition at line 3598 of file gl_rmain.c.

Referenced by R_BufferData_NewFrame(), and R_BufferData_Reset().

◆ R_COMPILESHADER_STATICPARM_EMIT

#define R_COMPILESHADER_STATICPARM_EMIT ( p,
n )
Value:
if(r_compileshader_staticparms[(p) >> 5] & (1 << ((p) & 0x1F))) \
else \
shaderstaticparmstrings_list[shaderstaticparms_count++] = "\n"
#define n(x, y)
static const char * shaderstaticparmstrings_list[SHADERSTATICPARMS_COUNT]
Definition gl_rmain.c:853
static unsigned int r_compileshader_staticparms[(SHADERSTATICPARMS_COUNT+0x1F) > > 5]
Definition gl_rmain.c:856
static int shaderstaticparms_count
Definition gl_rmain.c:854

Definition at line 906 of file gl_rmain.c.

906#define R_COMPILESHADER_STATICPARM_EMIT(p, n) \
907 if(r_compileshader_staticparms[(p) >> 5] & (1 << ((p) & 0x1F))) \
908 shaderstaticparmstrings_list[shaderstaticparms_count++] = "#define " n "\n"; \
909 else \
910 shaderstaticparmstrings_list[shaderstaticparms_count++] = "\n"

Referenced by R_CompileShader_AddStaticParms().

◆ R_COMPILESHADER_STATICPARM_ENABLE

#define R_COMPILESHADER_STATICPARM_ENABLE ( p)
Value:
r_compileshader_staticparms[(p) >> 5] |= (1 << ((p) & 0x1F))

Definition at line 857 of file gl_rmain.c.

Referenced by R_CompileShader_CheckStaticParms().

◆ R_MESH_PLANE_DIST_EPSILON

#define R_MESH_PLANE_DIST_EPSILON   (1.0 / 32.0)

Definition at line 6363 of file gl_rmain.c.

Referenced by R_Mesh_AddBrushMeshFromPlanes().

◆ R_SKINFRAME_LOAD_AVERAGE_COLORS

#define R_SKINFRAME_LOAD_AVERAGE_COLORS ( cnt,
getpixel )

Definition at line 2279 of file gl_rmain.c.

2279#define R_SKINFRAME_LOAD_AVERAGE_COLORS(cnt, getpixel) \
2280 { \
2281 unsigned long long avgcolor[5], wsum; \
2282 int pix, comp, w; \
2283 avgcolor[0] = 0; \
2284 avgcolor[1] = 0; \
2285 avgcolor[2] = 0; \
2286 avgcolor[3] = 0; \
2287 avgcolor[4] = 0; \
2288 wsum = 0; \
2289 for(pix = 0; pix < cnt; ++pix) \
2290 { \
2291 w = 0; \
2292 for(comp = 0; comp < 3; ++comp) \
2293 w += getpixel; \
2294 if(w) /* ignore perfectly black pixels because that is better for model skins */ \
2295 { \
2296 ++wsum; \
2297 /* comp = 3; -- not needed, comp is always 3 when we get here */ \
2298 w = getpixel; \
2299 for(comp = 0; comp < 3; ++comp) \
2300 avgcolor[comp] += getpixel * w; \
2301 avgcolor[3] += w; \
2302 } \
2303 /* comp = 3; -- not needed, comp is always 3 when we get here */ \
2304 avgcolor[4] += getpixel; \
2305 } \
2306 if(avgcolor[3] == 0) /* no pixels seen? even worse */ \
2307 avgcolor[3] = 1; \
2308 skinframe->avgcolor[0] = avgcolor[2] / (255.0 * avgcolor[3]); \
2309 skinframe->avgcolor[1] = avgcolor[1] / (255.0 * avgcolor[3]); \
2310 skinframe->avgcolor[2] = avgcolor[0] / (255.0 * avgcolor[3]); \
2311 skinframe->avgcolor[3] = avgcolor[4] / (255.0 * cnt); \
2312 }

Referenced by R_SkinFrame_LoadExternal_SkinFrame(), R_SkinFrame_LoadInternal8bit(), R_SkinFrame_LoadInternalBGRA(), and R_SkinFrame_LoadInternalQuake().

◆ RAMPWIDTH

#define RAMPWIDTH   256

Referenced by R_UpdateVariables().

◆ SHADERPERMUTATION_HASHSIZE

#define SHADERPERMUTATION_HASHSIZE   256

Definition at line 828 of file gl_rmain.c.

Referenced by R_GLSL_FindPermutation().

◆ SHADERSTATICPARMS_COUNT

#define SHADERSTATICPARMS_COUNT   15

Definition at line 851 of file gl_rmain.c.

Referenced by R_CompileShader_CheckStaticParms(), and R_GLSL_CompilePermutation().

◆ SKINFRAME_HASH

#define SKINFRAME_HASH   1024

Definition at line 2157 of file gl_rmain.c.

Referenced by R_SkinFrame_Find(), R_SkinFrame_FindNextByName(), and R_SkinFrame_Purge().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SHADERSTATICPARM_SATURATION_REDCOMPENSATE 

red compensation filter for saturation

SHADERSTATICPARM_EXACTSPECULARMATH 

(lightsource or deluxemapping) use exact reflection map for specular effects, as opposed to the usual OpenGL approximation

SHADERSTATICPARM_POSTPROCESS_USERVEC1 

postprocess uservec1 is enabled

SHADERSTATICPARM_POSTPROCESS_USERVEC2 

postprocess uservec2 is enabled

SHADERSTATICPARM_POSTPROCESS_USERVEC3 

postprocess uservec3 is enabled

SHADERSTATICPARM_POSTPROCESS_USERVEC4 

postprocess uservec4 is enabled

SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS 
SHADERSTATICPARM_OFFSETMAPPING_USELOD 

LOD for offsetmapping.

SHADERSTATICPARM_SHADOWMAPPCF_1 

PCF 1.

SHADERSTATICPARM_SHADOWMAPPCF_2 

PCF 2.

SHADERSTATICPARM_SHADOWSAMPLER 

sampler

SHADERSTATICPARM_CELSHADING 

celshading (alternative diffuse and specular math)

SHADERSTATICPARM_CELOUTLINES 

celoutline (depth buffer analysis to produce outlines)

SHADERSTATICPARM_FXAA 

fast approximate anti aliasing

SHADERSTATICPARM_COLORFRINGE 

colorfringe (chromatic aberration)

Definition at line 833 of file gl_rmain.c.

834{
841 SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS = 6, // use both alpha layers while blending materials, allows more advanced microblending
850};
@ SHADERSTATICPARM_POSTPROCESS_USERVEC4
postprocess uservec4 is enabled
Definition gl_rmain.c:840
@ SHADERSTATICPARM_SHADOWSAMPLER
sampler
Definition gl_rmain.c:845
@ SHADERSTATICPARM_EXACTSPECULARMATH
(lightsource or deluxemapping) use exact reflection map for specular effects, as opposed to the usual...
Definition gl_rmain.c:836
@ SHADERSTATICPARM_CELOUTLINES
celoutline (depth buffer analysis to produce outlines)
Definition gl_rmain.c:847
@ SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS
Definition gl_rmain.c:841
@ SHADERSTATICPARM_SHADOWMAPPCF_1
PCF 1.
Definition gl_rmain.c:843
@ SHADERSTATICPARM_CELSHADING
celshading (alternative diffuse and specular math)
Definition gl_rmain.c:846
@ SHADERSTATICPARM_COLORFRINGE
colorfringe (chromatic aberration)
Definition gl_rmain.c:849
@ SHADERSTATICPARM_POSTPROCESS_USERVEC2
postprocess uservec2 is enabled
Definition gl_rmain.c:838
@ SHADERSTATICPARM_OFFSETMAPPING_USELOD
LOD for offsetmapping.
Definition gl_rmain.c:842
@ SHADERSTATICPARM_FXAA
fast approximate anti aliasing
Definition gl_rmain.c:848
@ SHADERSTATICPARM_POSTPROCESS_USERVEC1
postprocess uservec1 is enabled
Definition gl_rmain.c:837
@ SHADERSTATICPARM_SATURATION_REDCOMPENSATE
red compensation filter for saturation
Definition gl_rmain.c:835
@ SHADERSTATICPARM_SHADOWMAPPCF_2
PCF 2.
Definition gl_rmain.c:844
@ SHADERSTATICPARM_POSTPROCESS_USERVEC3
postprocess uservec3 is enabled
Definition gl_rmain.c:839

Function Documentation

◆ _R_CullBox()

static qbool _R_CullBox ( const vec3_t mins,
const vec3_t maxs,
int numplanes,
const mplane_t * planes,
int ignore )
static

Definition at line 3445 of file gl_rmain.c.

3446{
3447 int i;
3448 const mplane_t *p;
3449 vec3_t corner;
3450 if (r_trippy.integer)
3451 return false;
3452 for (i = 0;i < numplanes;i++)
3453 {
3454 if(i == ignore)
3455 continue;
3456 p = planes + i;
3457 R_GetCornerOfBox(corner, mins, maxs, p->signbits);
3458 if (DotProduct(p->normal, corner) < p->dist)
3459 return true;
3460 }
3461 return false;
3462}
vector mins
vector maxs
static void R_GetCornerOfBox(vec3_t out, const vec3_t mins, const vec3_t maxs, int signbits)
Definition gl_rmain.c:3438
#define DotProduct(a, b)
Definition mathlib.h:98
cvar_t r_trippy
Definition model_brush.c:29
int i
vec_t vec3_t[3]
Definition qtypes.h:71
int integer
Definition cvar.h:73
vec3_t normal
Definition model_brush.h:59
vec_t dist
Definition model_brush.h:60
int signbits
Definition model_brush.h:66

References mplane_t::dist, DotProduct, i, cvar_t::integer, maxs, mins, mplane_t::normal, R_GetCornerOfBox(), r_trippy, and mplane_t::signbits.

Referenced by R_CullBox(), and R_CullFrustum().

◆ FOG_clear()

void FOG_clear ( void )

Definition at line 349 of file gl_rmain.c.

350{
351 if (gamemode == GAME_NEHAHRA)
352 {
355 Cvar_SetQuick(&gl_fogred, "0.3");
356 Cvar_SetQuick(&gl_foggreen, "0.3");
357 Cvar_SetQuick(&gl_fogblue, "0.3");
358 }
360 r_refdef.fog_red = 0;
362 r_refdef.fog_blue = 0;
365 r_refdef.fog_end = 16384;
366 r_refdef.fog_height = 1<<30;
369}
gamemode_t gamemode
Definition com_game.c:26
@ GAME_NEHAHRA
Definition com_game.h:32
void Cvar_SetQuick(cvar_t *var, const char *value)
Definition cvar.c:436
cvar_t gl_fogdensity
Definition gl_rmain.c:148
cvar_t gl_fogblue
Definition gl_rmain.c:151
cvar_t gl_fogenable
Definition gl_rmain.c:147
cvar_t gl_fogred
Definition gl_rmain.c:149
r_refdef_t r_refdef
Definition gl_rmain.c:57
cvar_t gl_foggreen
Definition gl_rmain.c:150
char fog_height_texturename[64]
Definition render.h:444
float fog_start
Definition render.h:436
float fog_density
Definition render.h:431
float fog_height
Definition render.h:438
float fog_green
Definition render.h:433
float fog_alpha
Definition render.h:435
float fog_fadedepth
Definition render.h:439
float fog_end
Definition render.h:437
float fog_blue
Definition render.h:434
float fog_red
Definition render.h:432

References Cvar_SetQuick(), r_refdef_t::fog_alpha, r_refdef_t::fog_blue, r_refdef_t::fog_density, r_refdef_t::fog_end, r_refdef_t::fog_fadedepth, r_refdef_t::fog_green, r_refdef_t::fog_height, r_refdef_t::fog_height_texturename, r_refdef_t::fog_red, r_refdef_t::fog_start, GAME_NEHAHRA, gamemode, gl_fogblue, gl_fogdensity, gl_fogenable, gl_foggreen, gl_fogred, and r_refdef.

Referenced by CL_Fog_f(), CL_Fog_HeightTexture_f(), and CL_ParseEntityLump().

◆ GL_Main_Init()

void GL_Main_Init ( void )

Definition at line 3220 of file gl_rmain.c.

3221{
3222 int i;
3223 r_main_mempool = Mem_AllocPool("Renderer", 0, NULL);
3225
3226 Cmd_AddCommand(CF_CLIENT, "r_glsl_restart", R_GLSL_Restart_f, "unloads GLSL shaders, they will then be reloaded as needed");
3227 Cmd_AddCommand(CF_CLIENT, "r_glsl_dumpshader", R_GLSL_DumpShader_f, "dumps the engine internal default.glsl shader into glsl/default.glsl");
3228 // FIXME: the client should set up r_refdef.fog stuff including the fogmasktable
3229 if (gamemode == GAME_NEHAHRA)
3230 {
3239 }
3355
3365
3402 for (i = 0;i < R_BUFFERDATA_COUNT;i++)
3410#ifdef DP_MOBILETOUCH
3411 // GLES devices have terrible depth precision in general, so...
3416#endif
3418}
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
@ GAME_TENEBRAE
full of evil hackery
Definition com_game.h:41
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
cvar_t r_shadows_castfrombmodels
Definition gl_rmain.c:128
cvar_t r_buffermegs[R_BUFFERDATA_COUNT]
Definition gl_rmain.c:249
cvar_t r_showlighting
Definition gl_rmain.c:88
cvar_t r_shadows_shadowmapbias
Definition gl_rmain.c:131
void R_GLSL_Restart_f(cmd_state_t *cmd)
Definition gl_rmain.c:1394
cvar_t r_motionblur_velocityfactor
Definition gl_rmain.c:65
cvar_t r_motionblur_minblur
Definition gl_rmain.c:63
cvar_t r_shadows_drawafterrtlighting
Definition gl_rmain.c:127
cvar_t r_showspriteedges
Definition gl_rmain.c:93
cvar_t r_water_hideplayer
Definition gl_rmain.c:200
cvar_t r_hdr_irisadaptation_fade_up
Definition gl_rmain.c:225
cvar_t r_glsl_offsetmapping_reliefmapping_steps
Definition gl_rmain.c:175
cvar_t r_q1bsp_lightmap_updates_enabled
Definition gl_rmain.c:257
cvar_t r_batch_dynamicbuffer
Definition gl_rmain.c:240
cvar_t r_hdr_irisadaptation_value
Definition gl_rmain.c:224
cvar_t r_hdr_irisadaptation_minvalue
Definition gl_rmain.c:222
cvar_t r_hdr_irisadaptation_fade_down
Definition gl_rmain.c:226
cvar_t r_drawfog
Definition gl_rmain.c:139
cvar_t r_motionblur
Definition gl_rmain.c:59
cvar_t r_bloom_colorsubtract
Definition gl_rmain.c:215
cvar_t r_shadows_focus
Definition gl_rmain.c:129
cvar_t r_fullbrights
Definition gl_rmain.c:122
cvar_t r_viewscale_fpsscaling_stepsize
Definition gl_rmain.c:166
cvar_t r_fullbright_directed_pitch_relative
Definition gl_rmain.c:118
cvar_t r_nolerp_list
Definition gl_rmain.c:204
cvar_t r_usedepthtextures
Definition gl_rmain.c:159
cvar_t r_bloom_colorexponent
Definition gl_rmain.c:214
cvar_t r_shadows_darken
Definition gl_rmain.c:124
cvar_t r_glsl_postprocess_uservec1_enable
Definition gl_rmain.c:185
cvar_t r_water_clippingplanebias
Definition gl_rmain.c:194
cvar_t r_q1bsp_skymasking
Definition gl_rmain.c:132
cvar_t r_draw2d
Definition gl_rmain.c:97
cvar_t r_transparent_sortmaxdist
Definition gl_rmain.c:142
cvar_t r_smoothnormals_areaweighting
Definition gl_rmain.c:229
cvar_t r_fullbright_directed_diffuse
Definition gl_rmain.c:116
cvar_t r_test
Definition gl_rmain.c:235
cvar_t r_bloom
Definition gl_rmain.c:208
cvar_t r_shadows_throwdirection
Definition gl_rmain.c:126
cvar_t r_transparent_useplanardistance
Definition gl_rmain.c:81
cvar_t r_motionblur_velocityfactor_minspeed
Definition gl_rmain.c:66
cvar_t r_celoutlines
Definition gl_rmain.c:145
cvar_t r_glsl_deluxemapping
Definition gl_rmain.c:171
static void gl_main_start(void)
Definition gl_rmain.c:3041
cvar_t r_q1bsp_lightmap_updates_hidden_surfaces
Definition gl_rmain.c:259
cvar_t r_showtris
Definition gl_rmain.c:86
cvar_t r_viewscale_fpsscaling_stepmax
Definition gl_rmain.c:167
cvar_t r_viewscale
Definition gl_rmain.c:162
cvar_t r_shadows
Definition gl_rmain.c:123
cvar_t r_showcollisionbrushes_polygonfactor
Definition gl_rmain.c:90
cvar_t r_motionblur_velocityfactor_maxspeed
Definition gl_rmain.c:67
cvar_t r_cullentities_trace
Definition gl_rmain.c:101
cvar_t r_colorfringe
Definition gl_rmain.c:189
cvar_t r_water_scissormode
Definition gl_rmain.c:198
cvar_t r_polygonoffset_decals_factor
Definition gl_rmain.c:135
cvar_t r_hdr_irisadaptation_maxvalue
Definition gl_rmain.c:223
cvar_t r_viewscale_fpsscaling_target
Definition gl_rmain.c:168
cvar_t r_viewscale_fpsscaling_min
Definition gl_rmain.c:164
cvar_t r_water_resolutionmultiplier
Definition gl_rmain.c:195
cvar_t r_glsl_offsetmapping_reliefmapping_refinesteps
Definition gl_rmain.c:176
cvar_t r_water_refractdistort
Definition gl_rmain.c:196
cvar_t r_glsl_vertextextureblend_usebothalphas
Definition gl_rmain.c:245
cvar_t r_farclip_world
Definition gl_rmain.c:75
cvar_t r_drawportals
Definition gl_rmain.c:95
cvar_t r_waterscroll
Definition gl_rmain.c:206
cvar_t r_cullentities_trace_eyejitter
Definition gl_rmain.c:109
cvar_t r_glsl_postprocess_uservec3_enable
Definition gl_rmain.c:187
cvar_t r_polygonoffset_decals_offset
Definition gl_rmain.c:136
static void gl_main_newmap(void)
Definition gl_rmain.c:3194
cvar_t r_bloom_scenebrightness
Definition gl_rmain.c:216
cvar_t r_celshading
Definition gl_rmain.c:144
mempool_t * r_main_mempool
Definition gl_rmain.c:42
cvar_t r_fullbright
Definition gl_rmain.c:112
cvar_t r_bloom_colorscale
Definition gl_rmain.c:209
cvar_t r_motionblur_mousefactor
Definition gl_rmain.c:68
cvar_t r_transparent_sortsurfacesbynearest
Definition gl_rmain.c:80
cvar_t r_showoverdraw
Definition gl_rmain.c:82
cvar_t r_glsl_offsetmapping
Definition gl_rmain.c:172
cvar_t r_batch_multidraw_mintriangles
Definition gl_rmain.c:238
cvar_t r_water_lowquality
Definition gl_rmain.c:199
cvar_t r_cullentities_trace_tempentitysamples
Definition gl_rmain.c:104
cvar_t r_cullentities_trace_delay
Definition gl_rmain.c:108
cvar_t r_bloom_resolution
Definition gl_rmain.c:213
cvar_t r_hdr_irisadaptation
Definition gl_rmain.c:220
cvar_t r_fullbright_directed
Definition gl_rmain.c:114
cvar_t r_drawentities
Definition gl_rmain.c:96
cvar_t r_dynamic
Definition gl_rmain.c:121
cvar_t r_useinfinitefarclip
Definition gl_rmain.c:73
cvar_t r_bloom_brighten
Definition gl_rmain.c:211
cvar_t r_shadows_shadowmapscale
Definition gl_rmain.c:130
cvar_t r_batch_multidraw
Definition gl_rmain.c:237
cvar_t r_hdr_scenebrightness
Definition gl_rmain.c:218
cvar_t r_motionblur_maxblur
Definition gl_rmain.c:64
cvar_t r_motionblur_averaging
Definition gl_rmain.c:61
cvar_t r_fxaa
Definition gl_rmain.c:190
cvar_t r_fullbright_directed_ambient
Definition gl_rmain.c:115
cvar_t r_transparent_sortarraysize
Definition gl_rmain.c:143
cvar_t r_motionblur_mousefactor_maxspeed
Definition gl_rmain.c:70
cvar_t r_showparticleedges
Definition gl_rmain.c:94
cvar_t r_fullbright_directed_pitch
Definition gl_rmain.c:117
cvar_t r_water_reflectdistort
Definition gl_rmain.c:197
cvar_t r_showsurfaces
Definition gl_rmain.c:85
cvar_t r_motionblur_mousefactor_minspeed
Definition gl_rmain.c:69
cvar_t gl_fogstart
Definition gl_rmain.c:152
cvar_t r_hdr_irisadaptation_radius
Definition gl_rmain.c:227
cvar_t r_polygonoffset_submodel_factor
Definition gl_rmain.c:133
cvar_t r_drawexteriormodel
Definition gl_rmain.c:100
cvar_t developer_texturelogging
Definition gl_rmain.c:231
cvar_t r_viewscale_fpsscaling_multiply
Definition gl_rmain.c:165
cvar_t r_water
Definition gl_rmain.c:192
cvar_t r_glsl_offsetmapping_lod
Definition gl_rmain.c:178
cvar_t r_glsl_offsetmapping_scale
Definition gl_rmain.c:177
cvar_t r_showbboxes
Definition gl_rmain.c:83
cvar_t r_batch_debugdynamicvertexpath
Definition gl_rmain.c:239
static void R_InitShaderModeInfo(void)
Definition gl_rmain.c:987
cvar_t r_shadows_throwdistance
Definition gl_rmain.c:125
cvar_t gl_lightmaps
Definition gl_rmain.c:233
cvar_t r_transparent_sortmindist
Definition gl_rmain.c:141
cvar_t r_cullentities_trace_samples
Definition gl_rmain.c:103
cvar_t r_showbboxes_client
Definition gl_rmain.c:84
cvar_t r_framedatasize
Definition gl_rmain.c:248
cvar_t r_wateralpha
Definition gl_rmain.c:120
cvar_t r_glsl_postprocess_uservec2_enable
Definition gl_rmain.c:186
cvar_t r_showcollisionbrushes
Definition gl_rmain.c:89
cvar_t r_fog_clear
Definition gl_rmain.c:138
cvar_t r_damageblur
Definition gl_rmain.c:60
cvar_t r_fog_exp2
Definition gl_rmain.c:137
cvar_t r_glsl_postprocess_uservec4
Definition gl_rmain.c:184
cvar_t r_cullentities_trace_expand
Definition gl_rmain.c:106
cvar_t r_shownormals
Definition gl_rmain.c:87
cvar_t r_transparent
Definition gl_rmain.c:78
cvar_t r_bloom_blur
Definition gl_rmain.c:212
cvar_t r_sortentities
Definition gl_rmain.c:110
cvar_t r_transparent_alphatocoverage
Definition gl_rmain.c:79
cvar_t r_glsl_saturation_redcompensate
Definition gl_rmain.c:243
cvar_t r_glsl_offsetmapping_reliefmapping
Definition gl_rmain.c:174
cvar_t r_speeds
Definition gl_rmain.c:111
cvar_t r_polygonoffset_submodel_offset
Definition gl_rmain.c:134
static void gl_main_shutdown(void)
Definition gl_rmain.c:3138
cvar_t r_showcollisionbrushes_polygonoffset
Definition gl_rmain.c:91
cvar_t r_showdisabledepthtest
Definition gl_rmain.c:92
cvar_t r_drawworld
Definition gl_rmain.c:98
cvar_t r_motionblur_randomize
Definition gl_rmain.c:62
cvar_t r_drawviewmodel
Definition gl_rmain.c:99
cvar_t r_nearclip
Definition gl_rmain.c:76
cvar_t r_cullentities_trace_pad
Definition gl_rmain.c:107
cvar_t gl_fogend
Definition gl_rmain.c:153
cvar_t r_cullentities_trace_enlarge
Definition gl_rmain.c:105
cvar_t r_glsl_postprocess_uservec4_enable
Definition gl_rmain.c:188
cvar_t r_hdr_irisadaptation_multiplier
Definition gl_rmain.c:221
cvar_t r_glsl_postprocess_uservec1
Definition gl_rmain.c:181
cvar_t r_lerpsprites
Definition gl_rmain.c:202
cvar_t r_water_cameraentitiesonly
Definition gl_rmain.c:193
cvar_t r_rendertarget_debug
Definition gl_rmain.c:161
cvar_t r_glsl_offsetmapping_steps
Definition gl_rmain.c:173
cvar_t r_q1bsp_lightmap_updates_combine
Definition gl_rmain.c:258
cvar_t r_texture_dds_load
Definition gl_rmain.c:156
cvar_t r_lerplightstyles
Definition gl_rmain.c:205
cvar_t r_depthfirst
Definition gl_rmain.c:72
cvar_t r_deformvertexes
Definition gl_rmain.c:77
cvar_t r_glsl_saturation
Definition gl_rmain.c:242
cvar_t gl_skyclip
Definition gl_rmain.c:154
cvar_t r_viewfbo
Definition gl_rmain.c:160
cvar_t r_lerpmodels
Definition gl_rmain.c:203
static void R_GLSL_DumpShader_f(cmd_state_t *cmd)
Definition gl_rmain.c:1419
cvar_t r_farclip_base
Definition gl_rmain.c:74
cvar_t r_glsl_postprocess_uservec2
Definition gl_rmain.c:182
cvar_t r_glsl_postprocess
Definition gl_rmain.c:180
cvar_t r_hdr_glowintensity
Definition gl_rmain.c:219
cvar_t r_cullentities_trace_entityocclusion
Definition gl_rmain.c:102
cvar_t r_transparentdepthmasking
Definition gl_rmain.c:140
cvar_t r_glsl_postprocess_uservec3
Definition gl_rmain.c:183
cvar_t r_glsl_offsetmapping_lod_distance
Definition gl_rmain.c:179
cvar_t r_glsl_skeletal
Definition gl_rmain.c:170
cvar_t r_viewscale_fpsscaling
Definition gl_rmain.c:163
cvar_t r_texture_dds_save
Definition gl_rmain.c:157
#define NULL
Definition qtypes.h:12
void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
Definition r_modules.c:25
@ R_BUFFERDATA_COUNT
uniform buffer
Definition render.h:529
#define Mem_AllocPool(name, flags, parent)
Definition zone.h:104

References CF_CLIENT, Cmd_AddCommand(), Cvar_RegisterVariable(), Cvar_SetQuick(), Cvar_SetValueQuick(), developer_texturelogging, GAME_NEHAHRA, GAME_TENEBRAE, gamemode, gl_fogblue, gl_fogdensity, gl_fogenable, gl_fogend, gl_foggreen, gl_fogred, gl_fogstart, gl_lightmaps, gl_main_newmap(), gl_main_shutdown(), gl_main_start(), gl_skyclip, i, Mem_AllocPool, NULL, r_batch_debugdynamicvertexpath, r_batch_dynamicbuffer, r_batch_multidraw, r_batch_multidraw_mintriangles, r_bloom, r_bloom_blur, r_bloom_brighten, r_bloom_colorexponent, r_bloom_colorscale, r_bloom_colorsubtract, r_bloom_resolution, r_bloom_scenebrightness, R_BUFFERDATA_COUNT, r_buffermegs, r_celoutlines, r_celshading, r_colorfringe, r_cullentities_trace, r_cullentities_trace_delay, r_cullentities_trace_enlarge, r_cullentities_trace_entityocclusion, r_cullentities_trace_expand, r_cullentities_trace_eyejitter, r_cullentities_trace_pad, r_cullentities_trace_samples, r_cullentities_trace_tempentitysamples, r_damageblur, r_deformvertexes, r_depthfirst, r_draw2d, r_drawentities, r_drawexteriormodel, r_drawfog, r_drawportals, r_drawviewmodel, r_drawworld, r_dynamic, r_farclip_base, r_farclip_world, r_fog_clear, r_fog_exp2, r_framedatasize, r_fullbright, r_fullbright_directed, r_fullbright_directed_ambient, r_fullbright_directed_diffuse, r_fullbright_directed_pitch, r_fullbright_directed_pitch_relative, r_fullbrights, r_fxaa, r_glsl_deluxemapping, R_GLSL_DumpShader_f(), r_glsl_offsetmapping, r_glsl_offsetmapping_lod, r_glsl_offsetmapping_lod_distance, r_glsl_offsetmapping_reliefmapping, r_glsl_offsetmapping_reliefmapping_refinesteps, r_glsl_offsetmapping_reliefmapping_steps, r_glsl_offsetmapping_scale, r_glsl_offsetmapping_steps, r_glsl_postprocess, r_glsl_postprocess_uservec1, r_glsl_postprocess_uservec1_enable, r_glsl_postprocess_uservec2, r_glsl_postprocess_uservec2_enable, r_glsl_postprocess_uservec3, r_glsl_postprocess_uservec3_enable, r_glsl_postprocess_uservec4, r_glsl_postprocess_uservec4_enable, R_GLSL_Restart_f(), r_glsl_saturation, r_glsl_saturation_redcompensate, r_glsl_skeletal, r_glsl_vertextextureblend_usebothalphas, r_hdr_glowintensity, r_hdr_irisadaptation, r_hdr_irisadaptation_fade_down, r_hdr_irisadaptation_fade_up, r_hdr_irisadaptation_maxvalue, r_hdr_irisadaptation_minvalue, r_hdr_irisadaptation_multiplier, r_hdr_irisadaptation_radius, r_hdr_irisadaptation_value, r_hdr_scenebrightness, R_InitShaderModeInfo(), r_lerplightstyles, r_lerpmodels, r_lerpsprites, r_main_mempool, r_motionblur, r_motionblur_averaging, r_motionblur_maxblur, r_motionblur_minblur, r_motionblur_mousefactor, r_motionblur_mousefactor_maxspeed, r_motionblur_mousefactor_minspeed, r_motionblur_randomize, r_motionblur_velocityfactor, r_motionblur_velocityfactor_maxspeed, r_motionblur_velocityfactor_minspeed, r_nearclip, r_nolerp_list, r_polygonoffset_decals_factor, r_polygonoffset_decals_offset, r_polygonoffset_submodel_factor, r_polygonoffset_submodel_offset, r_q1bsp_lightmap_updates_combine, r_q1bsp_lightmap_updates_enabled, r_q1bsp_lightmap_updates_hidden_surfaces, r_q1bsp_skymasking, R_RegisterModule(), r_rendertarget_debug, r_shadows, r_shadows_castfrombmodels, r_shadows_darken, r_shadows_drawafterrtlighting, r_shadows_focus, r_shadows_shadowmapbias, r_shadows_shadowmapscale, r_shadows_throwdirection, r_shadows_throwdistance, r_showbboxes, r_showbboxes_client, r_showcollisionbrushes, r_showcollisionbrushes_polygonfactor, r_showcollisionbrushes_polygonoffset, r_showdisabledepthtest, r_showlighting, r_shownormals, r_showoverdraw, r_showparticleedges, r_showspriteedges, r_showsurfaces, r_showtris, r_smoothnormals_areaweighting, r_sortentities, r_speeds, r_test, r_texture_dds_load, r_texture_dds_save, r_transparent, r_transparent_alphatocoverage, r_transparent_sortarraysize, r_transparent_sortmaxdist, r_transparent_sortmindist, r_transparent_sortsurfacesbynearest, r_transparent_useplanardistance, r_transparentdepthmasking, r_usedepthtextures, r_useinfinitefarclip, r_viewfbo, r_viewscale, r_viewscale_fpsscaling, r_viewscale_fpsscaling_min, r_viewscale_fpsscaling_multiply, r_viewscale_fpsscaling_stepmax, r_viewscale_fpsscaling_stepsize, r_viewscale_fpsscaling_target, r_water, r_water_cameraentitiesonly, r_water_clippingplanebias, r_water_hideplayer, r_water_lowquality, r_water_reflectdistort, r_water_refractdistort, r_water_resolutionmultiplier, r_water_scissormode, r_wateralpha, and r_waterscroll.

Referenced by Render_Init().

◆ gl_main_newmap()

static void gl_main_newmap ( void )
static

Definition at line 3194 of file gl_rmain.c.

3195{
3196 // FIXME: move this code to client
3197 char *entities, entname[MAX_QPATH];
3198 if (r_qwskincache)
3202 if (cl.worldmodel)
3203 {
3204 dpsnprintf(entname, sizeof(entname), "%s.ent", cl.worldnamenoextension);
3205 if ((entities = (char *)FS_LoadFile(entname, tempmempool, true, NULL)))
3206 {
3207 CL_ParseEntityLump(entities);
3208 Mem_Free(entities);
3209 return;
3210 }
3211 if (cl.worldmodel->brush.entities)
3212 CL_ParseEntityLump(cl.worldmodel->brush.entities);
3213 }
3215
3218}
client_state_t cl
Definition cl_main.c:117
void CL_ParseEntityLump(char *entdata)
Definition cl_parse.c:384
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:997
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
Definition fs.c:3540
static void R_Main_FreeViewCache(void)
Definition gl_rmain.c:2998
void R_FrameData_Reset(void)
free all R_FrameData memory
Definition gl_rmain.c:3493
static r_qwskincache_t * r_qwskincache
Definition gl_rmain.c:308
void R_BufferData_Reset(void)
frees all dynamic buffers
Definition gl_rmain.c:3613
static int r_qwskincache_size
Definition gl_rmain.c:309
#define MAX_QPATH
max length of a quake game pathname
Definition qdefs.h:169
struct model_s * worldmodel
Definition client.h:934
char worldnamenoextension[MAX_QPATH]
Definition client.h:900
mempool_t * tempmempool
Definition zone.c:794
#define Mem_Free(mem)
Definition zone.h:96

References cl, CL_ParseEntityLump(), dpsnprintf(), FS_LoadFile(), MAX_QPATH, Mem_Free, NULL, R_BufferData_Reset(), R_FrameData_Reset(), R_Main_FreeViewCache(), r_qwskincache, r_qwskincache_size, tempmempool, client_state_t::worldmodel, and client_state_t::worldnamenoextension.

Referenced by GL_Main_Init().

◆ gl_main_shutdown()

static void gl_main_shutdown ( void )
static

Definition at line 3138 of file gl_rmain.c.

3139{
3145
3147
3148 switch(vid.renderpath)
3149 {
3150 case RENDERPATH_GL32:
3151 case RENDERPATH_GLES2:
3152#if defined(GL_SAMPLES_PASSED) && !defined(USE_GLES2)
3153 if (r_maxqueries)
3154 qglDeleteQueries(r_maxqueries, r_queries);
3155#endif
3156 break;
3157 }
3159 r_numqueries = 0;
3160 r_maxqueries = 0;
3161 memset(r_queries, 0, sizeof(r_queries));
3162
3165
3166 // clear out the r_skinframe state
3168 memset(&r_skinframe, 0, sizeof(r_skinframe));
3169
3170 if (r_svbsp.nodes)
3172 memset(&r_svbsp, 0, sizeof (r_svbsp));
3185 //r_texture_fogintensity = NULL;
3186 memset(&r_fb, 0, sizeof(r_fb));
3188
3192}
cmd_state_t * cmd_local
command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code uses...
Definition cmd.c:25
rtexture_t * r_texture_whitecube
Definition gl_rmain.c:277
rtexturepool_t * r_main_texturepool
Definition gl_rmain.c:43
unsigned int r_maxqueries
Definition gl_rmain.c:299
rtexture_t * r_texture_grey128
Definition gl_rmain.c:274
memexpandablearray_t r_glsl_permutationarray
storage for permutations linked in the hash table
Definition gl_rmain.c:938
rtexture_t * r_texture_fogattenuation
Definition gl_rmain.c:279
r_skinframe_t r_skinframe
Definition gl_rmain.c:2166
rtexture_t * r_texture_black
Definition gl_rmain.c:275
r_glsl_permutation_t * r_glsl_permutation
currently selected permutation
Definition gl_rmain.c:936
int r_texture_numcubemaps
Definition gl_rmain.c:294
r_framebufferstate_t r_fb
Definition gl_rmain.c:265
void R_RenderTarget_FreeUnused(qbool force)
Definition gl_rmain.c:4523
unsigned int r_numqueries
Definition gl_rmain.c:298
rtexture_t * r_texture_blanknormalmap
Definition gl_rmain.c:272
rtexture_t * r_texture_fogheighttexture
Definition gl_rmain.c:280
void R_AnimCache_Free(void)
Animation cache prevents re-generating mesh data for an animated model multiple times in one frame fo...
Definition gl_rmain.c:3758
svbsp_t r_svbsp
shadow volume bsp struct with automatically growing nodes buffer
Definition gl_rmain.c:268
r_glsl_permutation_t * r_glsl_permutationhash[SHADERMODE_COUNT][SHADERPERMUTATION_HASHSIZE]
information about each possible shader permutation
Definition gl_rmain.c:934
rtexture_t * loadingscreentexture
Definition cl_screen.c:1567
rtexture_t * r_texture_gammaramps
Definition gl_rmain.c:281
rtexture_t * r_texture_white
Definition gl_rmain.c:273
rtexture_t * r_texture_normalizationcube
Definition gl_rmain.c:278
unsigned int r_shadow_occlusion_buf
Definition r_shadow.c:136
unsigned int r_queries[MAX_OCCLUSION_QUERIES]
Definition gl_rmain.c:297
void R_FreeTexturePool(rtexturepool_t **rtexturepool)
memexpandablearray_t rendertargets
Definition render.h:904
memexpandablearray_t array
Definition gl_rmain.c:2162
svbsp_node_t * nodes
Definition svbsp.h:30
renderpath_t renderpath
Definition vid.h:80
@ RENDERPATH_GLES2
Definition vid.h:38
@ RENDERPATH_GL32
Definition vid.h:37
viddef_t vid
global video state
Definition vid_shared.c:64
void Mem_ExpandableArray_FreeArray(memexpandablearray_t *l)
Definition zone.c:683

References r_skinframe_t::array, cmd_local, loadingscreentexture, Mem_ExpandableArray_FreeArray(), Mem_Free, svbsp_t::nodes, NULL, R_AnimCache_Free(), R_BufferData_Reset(), r_fb, R_FrameData_Reset(), R_FreeTexturePool(), r_glsl_permutation, r_glsl_permutationarray, r_glsl_permutationhash, R_GLSL_Restart_f(), R_Main_FreeViewCache(), r_main_texturepool, r_maxqueries, r_numqueries, r_queries, r_qwskincache, r_qwskincache_size, R_RenderTarget_FreeUnused(), r_shadow_occlusion_buf, r_skinframe, r_svbsp, r_texture_black, r_texture_blanknormalmap, r_texture_fogattenuation, r_texture_fogheighttexture, r_texture_gammaramps, r_texture_grey128, r_texture_normalizationcube, r_texture_numcubemaps, r_texture_white, r_texture_whitecube, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, r_framebufferstate_t::rendertargets, and vid.

Referenced by GL_Main_Init().

◆ gl_main_start()

static void gl_main_start ( void )
static

Definition at line 3041 of file gl_rmain.c.

3042{
3055
3058
3059 switch(vid.renderpath)
3060 {
3061 case RENDERPATH_GL32:
3062 case RENDERPATH_GLES2:
3063 r_loadnormalmap = true;
3064 r_loadgloss = true;
3065 r_loadfog = false;
3066#ifdef GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT
3068#endif
3069 break;
3070 }
3071
3075
3076 r_numqueries = 0;
3077 r_maxqueries = 0;
3078 memset(r_queries, 0, sizeof(r_queries));
3079
3082
3083 // due to caching of texture_t references, the collision cache must be reset
3085
3086 // set up r_skinframe loading system for textures
3087 memset(&r_skinframe, 0, sizeof(r_skinframe));
3090
3095#ifndef USE_GLES2
3097#endif //USE_GLES2
3101 //r_texture_fogintensity = NULL;
3102 memset(&r_fb, 0, sizeof(r_fb));
3107 memset(&r_svbsp, 0, sizeof (r_svbsp));
3108
3109 memset(r_texture_cubemaps, 0, sizeof(r_texture_cubemaps));
3111
3113
3114#ifdef __ANDROID__
3115 // For Steelstorm Android
3116 // FIXME CACHE the program and reload
3117 // FIXME see possible combinations for SS:BR android
3118 Con_DPrintf("Compiling most used shaders for SS:BR android... START\n");
3132 Con_DPrintf("Compiling most used shaders for SS:BR android... END\n");
3133#endif
3134}
void Collision_Cache_Reset(qbool resetlimits)
Definition collision.c:1480
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
static void R_BuildWhiteCube(void)
Definition gl_rmain.c:401
static qbool r_savedds
Definition gl_rmain.c:51
static void R_BuildBlankTextures(void)
Definition gl_rmain.c:371
qbool r_loadfog
Definition gl_rmain.c:49
static void R_BuildNormalizationCube(void)
Definition gl_rmain.c:408
static void R_SetupShader_SetPermutationGLSL(unsigned int mode, uint64_t permutation)
Definition gl_rmain.c:1346
int r_uniformbufferalignment
Definition gl_rmain.c:270
static qbool r_loadnormalmap
Definition gl_rmain.c:47
cubemapinfo_t * r_texture_cubemaps[MAX_CUBEMAPS]
Definition gl_rmain.c:295
static void R_BuildNoTexture(void)
Definition gl_rmain.c:396
static qbool r_loadgloss
Definition gl_rmain.c:48
static qbool r_loaddds
Definition gl_rmain.c:50
rtexturepool_t * R_AllocTexturePool(void)
#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT
Definition glquake.h:426
float fogmasktable_density
Definition render.h:430
unsigned int loadsequence
Definition gl_rmain.c:2161
qbool ext_texture_compression_s3tc
Definition vid.h:48
viddef_support_t support
Definition vid.h:89
void Mem_ExpandableArray_NewArray(memexpandablearray_t *l, mempool_t *mempool, size_t recordsize, int numrecordsperarray)
Definition zone.c:675

References r_skinframe_t::array, Collision_Cache_Reset(), Con_DPrintf(), viddef_support_t::ext_texture_compression_s3tc, r_refdef_t::fogmasktable_density, GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, cvar_t::integer, loadingscreentexture, r_skinframe_t::loadsequence, Mem_ExpandableArray_NewArray(), NULL, R_AllocTexturePool(), R_AnimCache_Free(), R_BufferData_Reset(), R_BuildBlankTextures(), R_BuildNormalizationCube(), R_BuildNoTexture(), R_BuildWhiteCube(), r_fb, R_FrameData_Reset(), r_glsl_permutation, r_glsl_permutationarray, r_glsl_permutationhash, r_loaddds, r_loadfog, r_loadgloss, r_loadnormalmap, r_main_mempool, r_main_texturepool, r_maxqueries, r_numqueries, r_queries, r_qwskincache, r_qwskincache_size, r_refdef, r_savedds, R_SetupShader_SetPermutationGLSL(), r_skinframe, r_svbsp, r_texture_black, r_texture_blanknormalmap, r_texture_cubemaps, r_texture_dds_load, r_texture_dds_save, r_texture_fogattenuation, r_texture_fogheighttexture, r_texture_gammaramps, r_texture_grey128, r_texture_normalizationcube, r_texture_numcubemaps, r_texture_white, r_texture_whitecube, r_uniformbufferalignment, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, r_framebufferstate_t::rendertargets, viddef_t::support, and vid.

Referenced by GL_Main_Init().

◆ R_AnimCache_CacheVisibleEntities()

void R_AnimCache_CacheVisibleEntities ( void )

generate animcache data for all entities marked visible

Definition at line 3874 of file gl_rmain.c.

3875{
3876 int i;
3877
3878 // TODO: thread this
3879 // NOTE: R_PrepareRTLights() also caches entities
3880
3881 for (i = 0;i < r_refdef.scene.numentities;i++)
3884}
qbool R_AnimCache_GetEntity(entity_render_t *ent, qbool wantnormals, qbool wanttangents)
get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangent...
Definition gl_rmain.c:3789
entity_render_t ** entities
renderable entities (excluding world)
Definition render.h:361
r_refdef_viewcache_t viewcache
Definition render.h:407
r_refdef_scene_t scene
Definition render.h:418
unsigned char * entityvisible
which entities are currently visible for this viewpoint (the used range is 0...r_refdef....
Definition render.h:336

References r_refdef_scene_t::entities, r_refdef_viewcache_t::entityvisible, i, r_refdef_scene_t::numentities, R_AnimCache_GetEntity(), r_refdef, r_refdef_t::scene, and r_refdef_t::viewcache.

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_AnimCache_ClearCache()

void R_AnimCache_ClearCache ( void )

clear the animcache pointers on all known render entities

Definition at line 3762 of file gl_rmain.c.

3763{
3764 int i;
3765 entity_render_t *ent;
3766
3767 for (i = 0;i < r_refdef.scene.numentities;i++)
3768 {
3769 ent = r_refdef.scene.entities[i];
3770 ent->animcache_vertex3f = NULL;
3773 ent->animcache_normal3f = NULL;
3786 }
3787}
float * animcache_skeletaltransform3x4
Definition client.h:395
r_meshbuffer_t * animcache_vertex3f_vertexbuffer
Definition client.h:380
float * animcache_normal3f
Definition client.h:382
int animcache_skeletaltransform3x4size
Definition client.h:398
int animcache_vertex3f_bufferoffset
Definition client.h:381
r_meshbuffer_t * animcache_svector3f_vertexbuffer
Definition client.h:386
r_meshbuffer_t * animcache_tvector3f_vertexbuffer
Definition client.h:389
float * animcache_vertex3f
Definition client.h:379
int animcache_svector3f_bufferoffset
Definition client.h:387
r_meshbuffer_t * animcache_skeletaltransform3x4buffer
Definition client.h:396
r_meshbuffer_t * animcache_normal3f_vertexbuffer
Definition client.h:383
float * animcache_svector3f
Definition client.h:385
int animcache_tvector3f_bufferoffset
Definition client.h:390
float * animcache_tvector3f
Definition client.h:388
int animcache_skeletaltransform3x4offset
Definition client.h:397
int animcache_normal3f_bufferoffset
Definition client.h:384

References entity_render_t::animcache_normal3f, entity_render_t::animcache_normal3f_bufferoffset, entity_render_t::animcache_normal3f_vertexbuffer, entity_render_t::animcache_skeletaltransform3x4, entity_render_t::animcache_skeletaltransform3x4buffer, entity_render_t::animcache_skeletaltransform3x4offset, entity_render_t::animcache_skeletaltransform3x4size, entity_render_t::animcache_svector3f, entity_render_t::animcache_svector3f_bufferoffset, entity_render_t::animcache_svector3f_vertexbuffer, entity_render_t::animcache_tvector3f, entity_render_t::animcache_tvector3f_bufferoffset, entity_render_t::animcache_tvector3f_vertexbuffer, entity_render_t::animcache_vertex3f, entity_render_t::animcache_vertex3f_bufferoffset, entity_render_t::animcache_vertex3f_vertexbuffer, r_refdef_scene_t::entities, i, NULL, r_refdef_scene_t::numentities, r_refdef, and r_refdef_t::scene.

Referenced by R_RenderView().

◆ R_AnimCache_Free()

void R_AnimCache_Free ( void )

Animation cache prevents re-generating mesh data for an animated model multiple times in one frame for lighting, shadowing, reflections, etc.

free all R_AnimCache memory

Definition at line 3758 of file gl_rmain.c.

3759{
3760}

Referenced by gl_main_shutdown(), and gl_main_start().

◆ R_AnimCache_GetEntity()

qbool R_AnimCache_GetEntity ( entity_render_t * ent,
qbool wantnormals,
qbool wanttangents )

get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangents)

Definition at line 3789 of file gl_rmain.c.

3790{
3791 model_t *model = ent->model;
3792 int numvertices;
3793
3794 // see if this ent is worth caching
3795 if (!model || !model->Draw || !model->AnimateVertices)
3796 return false;
3797 // nothing to cache if it contains no animations and has no skeleton
3798 if (!model->surfmesh.isanimated && !(model->num_bones && ent->skeleton && ent->skeleton->relativetransforms))
3799 return false;
3800 // see if it is already cached for gpuskeletal
3802 return false;
3803 // see if it is already cached as a mesh
3804 if (ent->animcache_vertex3f)
3805 {
3806 // check if we need to add normals or tangents
3807 if (ent->animcache_normal3f)
3808 wantnormals = false;
3809 if (ent->animcache_svector3f)
3810 wanttangents = false;
3811 if (!wantnormals && !wanttangents)
3812 return false;
3813 }
3814
3815 // check which kind of cache we need to generate
3816 if (r_gpuskeletal && model->num_bones > 0 && model->surfmesh.data_skeletalindex4ub)
3817 {
3818 // cache the skeleton so the vertex shader can use it
3822 ent->animcache_skeletaltransform3x4 = (float *)R_FrameData_Alloc(sizeof(float[3][4]) * model->num_bones);
3824 // note: this can fail if the buffer is at the grow limit
3825 ent->animcache_skeletaltransform3x4size = sizeof(float[3][4]) * model->num_bones;
3827 }
3828 else if (ent->animcache_vertex3f)
3829 {
3830 // mesh was already cached but we may need to add normals/tangents
3831 // (this only happens with multiple views, reflections, cameras, etc)
3832 if (wantnormals || wanttangents)
3833 {
3834 numvertices = model->surfmesh.num_vertices;
3835 if (wantnormals)
3836 ent->animcache_normal3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3837 if (wanttangents)
3838 {
3839 ent->animcache_svector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3840 ent->animcache_tvector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3841 }
3842 model->AnimateVertices(model, ent->frameblend, ent->skeleton, NULL, wantnormals ? ent->animcache_normal3f : NULL, wanttangents ? ent->animcache_svector3f : NULL, wanttangents ? ent->animcache_tvector3f : NULL);
3846 }
3847 }
3848 else
3849 {
3850 // generate mesh cache
3851 numvertices = model->surfmesh.num_vertices;
3852 ent->animcache_vertex3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3853 if (wantnormals)
3854 ent->animcache_normal3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3855 if (wanttangents)
3856 {
3857 ent->animcache_svector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3858 ent->animcache_tvector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3859 }
3860 model->AnimateVertices(model, ent->frameblend, ent->skeleton, ent->animcache_vertex3f, ent->animcache_normal3f, ent->animcache_svector3f, ent->animcache_tvector3f);
3861 if (wantnormals || wanttangents)
3862 {
3866 }
3870 }
3871 return true;
3872}
string model
static qbool r_gpuskeletal
Definition gl_rmain.c:52
void * R_FrameData_Alloc(size_t size)
allocate some temporary memory for your purposes
Definition gl_rmain.c:3539
r_meshbuffer_t * R_BufferData_Store(size_t datasize, const void *data, r_bufferdata_type_t type, int *returnbufferoffset)
request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and of...
Definition gl_rmain.c:3707
#define max(A, B)
Definition mathlib.h:38
void Mod_Skeletal_BuildTransforms(const model_t *RESTRICT model, const frameblend_t *RESTRICT frameblend, const skeleton_t *skeleton, float *RESTRICT bonepose, float *RESTRICT boneposerelative)
Definition model_alias.c:65
@ r_stat_animcache_shape_count
Definition r_stats.h:67
@ r_stat_animcache_skeletal_bones
Definition r_stats.h:62
@ r_stat_animcache_shape_maxvertices
Definition r_stats.h:69
@ r_stat_animcache_skeletal_maxbones
Definition r_stats.h:63
@ r_stat_animcache_skeletal_count
Definition r_stats.h:61
@ r_stat_animcache_shade_count
Definition r_stats.h:64
@ r_stat_animcache_shape_vertices
Definition r_stats.h:68
@ r_stat_animcache_shade_vertices
Definition r_stats.h:65
@ r_stat_animcache_shade_maxvertices
Definition r_stats.h:66
@ R_BUFFERDATA_UNIFORM
index buffer - 32bit (because D3D cares)
Definition render.h:528
frameblend_t frameblend[MAX_FRAMEBLENDS]
Definition client.h:373
model_t * model
Definition client.h:343
skeleton_t * skeleton
Definition client.h:375
int stats[r_stat_count]
Definition render.h:466
struct matrix4x4_s * relativetransforms
Definition protocol.h:426

References entity_render_t::animcache_normal3f, entity_render_t::animcache_skeletaltransform3x4, entity_render_t::animcache_skeletaltransform3x4buffer, entity_render_t::animcache_skeletaltransform3x4offset, entity_render_t::animcache_skeletaltransform3x4size, entity_render_t::animcache_svector3f, entity_render_t::animcache_tvector3f, entity_render_t::animcache_vertex3f, entity_render_t::frameblend, max, Mod_Skeletal_BuildTransforms(), entity_render_t::model, model, NULL, R_BufferData_Store(), R_BUFFERDATA_UNIFORM, R_FrameData_Alloc(), r_gpuskeletal, r_refdef, r_stat_animcache_shade_count, r_stat_animcache_shade_maxvertices, r_stat_animcache_shade_vertices, r_stat_animcache_shape_count, r_stat_animcache_shape_maxvertices, r_stat_animcache_shape_vertices, r_stat_animcache_skeletal_bones, r_stat_animcache_skeletal_count, r_stat_animcache_skeletal_maxbones, skeleton_t::relativetransforms, entity_render_t::skeleton, and r_refdef_t::stats.

Referenced by R_AnimCache_CacheVisibleEntities(), R_Shadow_PrepareLight(), and R_Shadow_PrepareModelShadows().

◆ R_BlendFuncFlags()

static int R_BlendFuncFlags ( int src,
int dst )
static

Definition at line 1522 of file gl_rmain.c.

1523{
1524 int r = 0;
1525
1526 // a blendfunc allows colormod if:
1527 // a) it can never keep the destination pixel invariant, or
1528 // b) it can keep the destination pixel invariant, and still can do so if colormodded
1529 // this is to prevent unintended side effects from colormod
1530
1531 // a blendfunc allows fog if:
1532 // blend(fog(src), fog(dst)) == fog(blend(src, dst))
1533 // this is to prevent unintended side effects from fog
1534
1535 // these checks are the output of fogeval.pl
1536
1540 if(src == GL_DST_COLOR && dst == GL_ONE_MINUS_SRC_ALPHA) r &= ~BLENDFUNC_ALLOWS_COLORMOD;
1542 if(src == GL_DST_COLOR && dst == GL_SRC_ALPHA) r &= ~BLENDFUNC_ALLOWS_COLORMOD;
1543 if(src == GL_DST_COLOR && dst == GL_SRC_COLOR) r &= ~BLENDFUNC_ALLOWS_COLORMOD;
1544 if(src == GL_DST_COLOR && dst == GL_ZERO) r &= ~BLENDFUNC_ALLOWS_COLORMOD;
1545 if(src == GL_ONE && dst == GL_ONE) r |= BLENDFUNC_ALLOWS_FOG_HACK0;
1547 if(src == GL_ONE && dst == GL_ZERO) r |= BLENDFUNC_ALLOWS_FOG;
1553 if(src == GL_ONE_MINUS_SRC_ALPHA && dst == GL_SRC_COLOR) r &= ~BLENDFUNC_ALLOWS_COLORMOD;
1554 if(src == GL_ONE_MINUS_SRC_COLOR && dst == GL_SRC_COLOR) r &= ~BLENDFUNC_ALLOWS_COLORMOD;
1557 if(src == GL_ZERO && dst == GL_ONE) r |= BLENDFUNC_ALLOWS_FOG;
1558 if(src == GL_ZERO && dst == GL_SRC_COLOR) r &= ~BLENDFUNC_ALLOWS_COLORMOD;
1559
1560 return r;
1561}
#define BLENDFUNC_ALLOWS_FOG_HACK0
Definition gl_rmain.c:1519
#define BLENDFUNC_ALLOWS_FOG_HACKALPHA
Definition gl_rmain.c:1520
#define BLENDFUNC_ALLOWS_FOG
Definition gl_rmain.c:1518
#define BLENDFUNC_ALLOWS_COLORMOD
Definition gl_rmain.c:1517
#define GL_ONE_MINUS_DST_ALPHA
Definition glquake.h:82
#define GL_ONE_MINUS_DST_COLOR
Definition glquake.h:78
#define GL_SRC_ALPHA
Definition glquake.h:79
#define GL_SRC_COLOR
Definition glquake.h:75
#define GL_ZERO
Definition glquake.h:73
#define GL_ONE_MINUS_SRC_ALPHA
Definition glquake.h:80
#define GL_ONE
Definition glquake.h:74
#define GL_DST_ALPHA
Definition glquake.h:81
#define GL_DST_COLOR
Definition glquake.h:77
#define GL_ONE_MINUS_SRC_COLOR
Definition glquake.h:76
prvm_eval_t * src
dp_FragColor r

References BLENDFUNC_ALLOWS_COLORMOD, BLENDFUNC_ALLOWS_FOG, BLENDFUNC_ALLOWS_FOG_HACK0, BLENDFUNC_ALLOWS_FOG_HACKALPHA, GL_DST_ALPHA, GL_DST_COLOR, GL_ONE, GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_SRC_COLOR, GL_ZERO, r, and src.

Referenced by R_GetCurrentTexture(), and R_SetupShader_Surface().

◆ R_BlendView()

static void R_BlendView ( rtexture_t * viewcolortexture,
int fbo,
rtexture_t * depthtexture,
rtexture_t * colortexture,
int x,
int y,
int width,
int height )
static

Definition at line 5317 of file gl_rmain.c.

5318{
5319 uint64_t permutation;
5320 float uservecs[4][4];
5321 rtexture_t *viewtexture;
5322 rtexture_t *bloomtexture;
5323
5325
5326 if (r_fb.bloomwidth)
5327 {
5328 // make the bloom texture
5330 }
5331
5332#if _MSC_VER >= 1400
5333#define sscanf sscanf_s
5334#endif
5335 memset(uservecs, 0, sizeof(uservecs));
5337 sscanf(r_glsl_postprocess_uservec1.string, "%f %f %f %f", &uservecs[0][0], &uservecs[0][1], &uservecs[0][2], &uservecs[0][3]);
5339 sscanf(r_glsl_postprocess_uservec2.string, "%f %f %f %f", &uservecs[1][0], &uservecs[1][1], &uservecs[1][2], &uservecs[1][3]);
5341 sscanf(r_glsl_postprocess_uservec3.string, "%f %f %f %f", &uservecs[2][0], &uservecs[2][1], &uservecs[2][2], &uservecs[2][3]);
5343 sscanf(r_glsl_postprocess_uservec4.string, "%f %f %f %f", &uservecs[3][0], &uservecs[3][1], &uservecs[3][2], &uservecs[3][3]);
5344
5345 // render to the screen fbo
5346 R_ResetViewRendering2D(fbo, depthtexture, colortexture, x, y, width, height);
5347 GL_Color(1, 1, 1, 1);
5349
5350 viewtexture = viewcolortexture;
5351 bloomtexture = r_fb.rt_bloom ? r_fb.rt_bloom->colortexture[0] : NULL;
5352
5354 {
5356 if (rt && rt->colortexture[0])
5357 {
5358 viewtexture = rt->colortexture[0];
5359 bloomtexture = NULL;
5360 }
5361 }
5362
5364 switch(vid.renderpath)
5365 {
5366 case RENDERPATH_GL32:
5367 case RENDERPATH_GLES2:
5368 permutation =
5380 if (r_glsl_permutation->loc_UserVec1 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec1 , uservecs[0][0], uservecs[0][1], uservecs[0][2], uservecs[0][3]);
5381 if (r_glsl_permutation->loc_UserVec2 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec2 , uservecs[1][0], uservecs[1][1], uservecs[1][2], uservecs[1][3]);
5382 if (r_glsl_permutation->loc_UserVec3 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec3 , uservecs[2][0], uservecs[2][1], uservecs[2][2], uservecs[2][3]);
5383 if (r_glsl_permutation->loc_UserVec4 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec4 , uservecs[3][0], uservecs[3][1], uservecs[3][2], uservecs[3][3]);
5388 break;
5389 }
5392}
qbool R_Stereo_ColorMasking(void)
Definition cl_screen.c:2072
unsigned short polygonelement3s[(POLYGONELEMENTS_MAXPOINTS-2) *3]
Definition gl_backend.c:241
int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2) *3]
Definition gl_backend.c:240
void R_Mesh_TexBind(unsigned int unitnum, rtexture_t *tex)
void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtriangles, const int *element3i, const r_meshbuffer_t *element3i_indexbuffer, int element3i_bufferoffset, const unsigned short *element3s, const r_meshbuffer_t *element3s_indexbuffer, int element3s_bufferoffset)
void GL_Color(float cr, float cg, float cb, float ca)
void R_Mesh_PrepareVertices_Mesh_Arrays(int numvertices, const float *vertex3f, const float *svector3f, const float *tvector3f, const float *normal3f, const float *color4f, const float *texcoordtexture2f, const float *texcoordlightmap2f)
void GL_BlendFunc(int blendfunc1, int blendfunc2)
void R_ResetViewRendering2D(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4477
void R_EntityMatrix(const matrix4x4_t *matrix)
Definition gl_rmain.c:4417
const float r_screenvertex3f[12]
vertex coordinates for a quad that covers the screen exactly
Definition gl_rmain.c:313
static void R_Bloom_MakeTexture(void)
Definition gl_rmain.c:5113
GLenum GLsizei width
Definition glquake.h:622
GLenum GLsizei GLsizei height
Definition glquake.h:622
GLint GLenum GLint GLint y
Definition glquake.h:651
GLint GLenum GLint x
Definition glquake.h:651
const matrix4x4_t identitymatrix
Definition matrixlib.c:9
@ r_stat_bloom_drawpixels
Definition r_stats.h:44
#define SHADERPERMUTATION_POSTPROCESSING
user defined postprocessing (postprocessing only)
Definition render.h:87
#define SHADERPERMUTATION_BLOOM
bloom (postprocessing only)
Definition render.h:85
@ SHADERMODE_POSTPROCESS
postprocessing shader (r_glsl_postprocess)
Definition render.h:53
#define SHADERPERMUTATION_VIEWTINT
view tint (postprocessing only), use vertex colors (generic only)
Definition render.h:75
#define SHADERPERMUTATION_SATURATION
saturation (postprocessing only)
Definition render.h:77
#define SHADERPERMUTATION_GAMMARAMPS
gamma (postprocessing only)
Definition render.h:82
float value
Definition cvar.h:74
const char * string
Definition cvar.h:71
r_rendertarget_t * rt_bloom
Definition render.h:888
r_rendertarget_t * rt_screen
Definition render.h:887
float viewblend[4]
Definition render.h:416
r_refdef_view_t view
Definition render.h:406
float texcoord2f[8]
Definition render.h:819
rtexture_t * colortexture[4]
Definition render.h:834
qbool vid_gammatables_trivial
this is set to true if all color control values are at default setting, and it therefore would make n...
void * Mem_ExpandableArray_RecordAtIndex(const memexpandablearray_t *l, size_t index)
Definition zone.c:780

References r_framebufferstate_t::bloomwidth, r_rendertarget_t::colortexture, GL_BlendFunc(), GL_Color(), GL_ONE, GL_ZERO, height, r_refdef_view_t::height, identitymatrix, cvar_t::integer, r_glsl_permutation_t::loc_BloomColorSubtract, r_glsl_permutation_t::loc_ColorFringe, r_glsl_permutation_t::loc_PixelSize, r_glsl_permutation_t::loc_PixelToScreenTexCoord, r_glsl_permutation_t::loc_Saturation, r_glsl_permutation_t::loc_UserVec1, r_glsl_permutation_t::loc_UserVec2, r_glsl_permutation_t::loc_UserVec3, r_glsl_permutation_t::loc_UserVec4, r_glsl_permutation_t::loc_ViewTintColor, Mem_ExpandableArray_RecordAtIndex(), NULL, polygonelement3i, polygonelement3s, r_bloom_colorsubtract, R_Bloom_MakeTexture(), r_colorfringe, R_EntityMatrix(), r_fb, r_glsl_permutation, r_glsl_postprocess, r_glsl_postprocess_uservec1, r_glsl_postprocess_uservec1_enable, r_glsl_postprocess_uservec2, r_glsl_postprocess_uservec2_enable, r_glsl_postprocess_uservec3, r_glsl_postprocess_uservec3_enable, r_glsl_postprocess_uservec4, r_glsl_postprocess_uservec4_enable, r_glsl_saturation, R_Mesh_Draw(), R_Mesh_PrepareVertices_Mesh_Arrays(), R_Mesh_TexBind(), r_refdef, r_rendertarget_debug, R_ResetViewRendering2D(), r_screenvertex3f, R_SetupShader_SetPermutationGLSL(), r_stat_bloom_drawpixels, R_Stereo_ColorMasking(), r_texture_gammaramps, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, r_framebufferstate_t::rendertargets, r_framebufferstate_t::rt_bloom, r_framebufferstate_t::rt_screen, r_framebufferstate_t::screentextureheight, r_framebufferstate_t::screentexturewidth, SHADERMODE_POSTPROCESS, SHADERPERMUTATION_BLOOM, SHADERPERMUTATION_GAMMARAMPS, SHADERPERMUTATION_POSTPROCESSING, SHADERPERMUTATION_SATURATION, SHADERPERMUTATION_VIEWTINT, r_refdef_t::stats, cvar_t::string, r_glsl_permutation_t::tex_Texture_First, r_glsl_permutation_t::tex_Texture_GammaRamps, r_glsl_permutation_t::tex_Texture_Second, r_rendertarget_t::texcoord2f, cvar_t::value, vid, vid_gammatables_trivial, r_refdef_t::view, r_refdef_t::viewblend, r_refdef_view_t::width, width, x, and y.

Referenced by R_RenderView().

◆ R_BlendView_IsTrivial()

static qbool R_BlendView_IsTrivial ( int viewwidth,
int viewheight,
int width,
int height )
static

Definition at line 5224 of file gl_rmain.c.

5225{
5226 // Scaling requested?
5227 if (viewwidth != width || viewheight != height)
5228 return false;
5229 // Higher bit depth or explicit FBO requested?
5230 if (r_viewfbo.integer)
5231 return false;
5232 // Non-trivial postprocessing shader permutation?
5233 if (r_fb.bloomwidth
5234 || r_refdef.viewblend[3] > 0
5238 return false;
5239 // Other reasons for a non-trivial default postprocessing shader?
5240 // (See R_CompileShader_CheckStaticParms but only those relevant for MODE_POSTPROCESS in shader_glsl.h)
5241 // Skip: if (r_glsl_saturation_redcompensate.integer) (already covered by saturation above).
5242 // Skip: if (r_glsl_postprocess.integer) (already covered by r_glsl_postprocess above).
5243 // Skip: if (r_glsl_postprocess_uservec1_enable.integer) (already covered by r_glsl_postprocessing above).
5244 if (r_fxaa.integer)
5245 return false;
5246 if (r_colorfringe.value)
5247 return false;
5248 return true;
5249}

References r_framebufferstate_t::bloomwidth, height, cvar_t::integer, r_colorfringe, r_fb, r_fxaa, r_glsl_postprocess, r_glsl_saturation, r_refdef, R_Stereo_ColorMasking(), r_viewfbo, cvar_t::value, vid_gammatables_trivial, r_refdef_t::viewblend, and width.

Referenced by R_RenderView().

◆ R_Bloom_MakeTexture()

static void R_Bloom_MakeTexture ( void )
static

Definition at line 5113 of file gl_rmain.c.

5114{
5115 int x, range, dir;
5116 float xoffset, yoffset, r, brighten;
5117 float colorscale = r_bloom_colorscale.value;
5118 r_viewport_t bloomviewport;
5119 r_rendertarget_t *prev, *cur;
5120 textype_t textype = r_fb.rt_screen->colortextype[0];
5121
5123
5124 R_Viewport_InitOrtho(&bloomviewport, &identitymatrix, 0, 0, r_fb.bloomwidth, r_fb.bloomheight, 0, 0, 1, 1, -10, 100, NULL);
5125
5126 // scale down screen texture to the bloom texture size
5128 prev = r_fb.rt_screen;
5131 R_SetViewport(&bloomviewport);
5133 GL_DepthTest(false);
5135 GL_Color(colorscale, colorscale, colorscale, 1);
5137 // TODO: do boxfilter scale-down in shader?
5138 R_SetupShader_Generic(prev->colortexture[0], false, true, true);
5141 // we now have a properly scaled bloom image
5142
5143 // multiply bloom image by itself as many times as desired to darken it
5144 // TODO: if people actually use this it could be done more quickly in the previous shader pass
5145 for (x = 1;x < min(r_bloom_colorexponent.value, 32);)
5146 {
5147 prev = cur;
5150 x *= 2;
5151 r = bound(0, r_bloom_colorexponent.value / x, 1); // always 0.5 to 1
5152 if(x <= 2)
5154 GL_BlendFunc(GL_SRC_COLOR, GL_ZERO); // square it
5155 GL_Color(1,1,1,1); // no fix factor supported here
5157 R_SetupShader_Generic(prev->colortexture[0], false, true, false);
5160 }
5162
5163 range = r_bloom_blur.integer * r_fb.bloomwidth / 320;
5164 brighten = r_bloom_brighten.value;
5165 brighten = sqrt(brighten);
5166 if(range >= 1)
5167 brighten *= (3 * range) / (2 * range - 1); // compensate for the "dot particle"
5168
5169 for (dir = 0;dir < 2;dir++)
5170 {
5171 prev = cur;
5174 // blend on at multiple vertical offsets to achieve a vertical blur
5175 // TODO: do offset blends using GLSL
5176 // TODO instead of changing the texcoords, change the target positions to prevent artifacts at edges
5180 R_SetupShader_Generic(prev->colortexture[0], false, true, false);
5182 for (x = -range;x <= range;x++)
5183 {
5184 if (!dir){xoffset = 0;yoffset = x;}
5185 else {xoffset = x;yoffset = 0;}
5186 xoffset /= (float)prev->texturewidth;
5187 yoffset /= (float)prev->textureheight;
5188 // compute a texcoord array with the specified x and y offset
5197 // this r value looks like a 'dot' particle, fading sharply to
5198 // black at the edges
5199 // (probably not realistic but looks good enough)
5200 //r = ((range*range+1)/((float)(x*x+1)))/(range*2+1);
5201 //r = brighten/(range*2+1);
5202 r = brighten / (range * 2 + 1);
5203 if(range >= 1)
5204 r *= (1 - x*x/(float)((range+1)*(range+1)));
5205 if (r <= 0)
5206 continue;
5208 GL_Color(r, r, r, 1);
5217 }
5218 }
5219
5220 // now we have the bloom image, so keep track of it
5221 r_fb.rt_bloom = cur;
5222}
void GL_Clear(int mask, const float *colorvalue, float depthvalue, int stencilvalue)
void GL_CullFace(int state)
void GL_DepthTest(int state)
void R_Mesh_SetRenderTargets(int fbo)
void R_SetViewport(const r_viewport_t *v)
Definition gl_backend.c:897
void R_Viewport_InitOrtho(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float x1, float y1, float x2, float y2, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:587
void R_Mesh_PrepareVertices_Generic_Arrays(int numvertices, const float *vertex3f, const float *color4f, const float *texcoord2f)
r_rendertarget_t * R_RenderTarget_Get(int texturewidth, int textureheight, textype_t depthtextype, qbool depthisrenderbuffer, textype_t colortextype0, textype_t colortextype1, textype_t colortextype2, textype_t colortextype3)
Definition gl_rmain.c:4564
void R_SetupShader_Generic(rtexture_t *t, qbool usegamma, qbool notrippy, qbool suppresstexalpha)
Definition gl_rmain.c:1461
#define GL_NONE
Definition glquake.h:127
#define CHECKGLERROR
Definition glquake.h:1059
GLint GLint GLint yoffset
Definition glquake.h:649
GLint GLint xoffset
Definition glquake.h:649
#define GL_COLOR_BUFFER_BIT
Definition glquake.h:171
#define min(A, B)
Definition mathlib.h:37
#define bound(min, num, max)
Definition mathlib.h:34
float sqrt(float f)
@ r_stat_bloom
Definition r_stats.h:42
textype_t
Definition r_textures.h:44
@ TEXTYPE_UNUSED
Definition r_textures.h:46
vec2 dir
precision highp float
Definition shader_glsl.h:53
float offsettexcoord2f[8]
Definition render.h:896
textype_t colortextype[4]
Definition render.h:824

References r_framebufferstate_t::bloomheight, r_framebufferstate_t::bloomwidth, bound, CHECKGLERROR, r_rendertarget_t::colortexture, r_rendertarget_t::colortextype, dir, r_rendertarget_t::fbo, float, GL_BlendFunc(), GL_Clear(), GL_Color(), GL_COLOR_BUFFER_BIT, GL_CullFace(), GL_DepthTest(), GL_NONE, GL_ONE, GL_SRC_COLOR, GL_ZERO, identitymatrix, cvar_t::integer, min, NULL, r_framebufferstate_t::offsettexcoord2f, polygonelement3i, polygonelement3s, r, r_bloom_blur, r_bloom_brighten, r_bloom_colorexponent, r_bloom_colorscale, r_fb, R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), R_Mesh_SetRenderTargets(), r_refdef, R_RenderTarget_Get(), r_screenvertex3f, R_SetupShader_Generic(), R_SetViewport(), r_stat_bloom, r_stat_bloom_drawpixels, R_Viewport_InitOrtho(), r_framebufferstate_t::rt_bloom, r_framebufferstate_t::rt_screen, sqrt(), r_refdef_t::stats, r_rendertarget_t::texcoord2f, r_rendertarget_t::textureheight, r_rendertarget_t::texturewidth, TEXTYPE_UNUSED, cvar_t::value, x, xoffset, and yoffset.

Referenced by R_BlendView().

◆ R_Bloom_StartFrame()

static void R_Bloom_StartFrame ( void )
static

Definition at line 5019 of file gl_rmain.c.

5020{
5021 int screentexturewidth, screentextureheight;
5023 double scale;
5024
5025 // clear the pointers to rendertargets from last frame as they're stale
5027 r_fb.rt_bloom = NULL;
5028
5029 switch (vid.renderpath)
5030 {
5031 case RENDERPATH_GL32:
5033 if (r_viewfbo.integer == 2) textype = TEXTYPE_COLORBUFFER16F;
5034 if (r_viewfbo.integer == 3) textype = TEXTYPE_COLORBUFFER32F;
5035 break;
5036 case RENDERPATH_GLES2:
5037 r_fb.usedepthtextures = false;
5038 break;
5039 }
5040
5042 {
5043 double actualframetime;
5044 double targetframetime;
5045 double adjust;
5046 actualframetime = r_refdef.lastdrawscreentime;
5047 targetframetime = (1.0 / r_viewscale_fpsscaling_target.value);
5048 adjust = (targetframetime - actualframetime) * r_viewscale_fpsscaling_multiply.value;
5051 {
5052 if (adjust > 0)
5054 else
5056 }
5057 viewscalefpsadjusted += adjust;
5059 }
5060 else
5061 viewscalefpsadjusted = 1.0f;
5062
5064 if (vid.mode.samples)
5065 scale *= sqrt(vid.mode.samples); // supersampling
5066 scale = bound(0.03125f, scale, 4.0f);
5067 screentexturewidth = (int)ceil(r_refdef.view.width * scale);
5068 screentextureheight = (int)ceil(r_refdef.view.height * scale);
5069 screentexturewidth = bound(1, screentexturewidth, (int)vid.maxtexturesize_2d);
5070 screentextureheight = bound(1, screentextureheight, (int)vid.maxtexturesize_2d);
5071
5072 // set bloomwidth and bloomheight to the bloom resolution that will be
5073 // used (often less than the screen resolution for faster rendering)
5074 r_fb.bloomheight = bound(1, r_bloom_resolution.value * 0.75f, screentextureheight);
5075 r_fb.bloomwidth = r_fb.bloomheight * screentexturewidth / screentextureheight;
5076 r_fb.bloomwidth = bound(1, r_fb.bloomwidth, screentexturewidth);
5079
5081 {
5085 }
5086 if (!r_bloom.integer)
5088
5089 // allocate motionblur ghost texture if needed - this is the only persistent texture and is only useful on the main view
5090 if (r_refdef.view.ismain && (r_fb.screentexturewidth != screentexturewidth || r_fb.screentextureheight != screentextureheight || r_fb.textype != textype))
5091 {
5092 if (r_fb.ghosttexture)
5095
5096 r_fb.screentexturewidth = screentexturewidth;
5097 r_fb.screentextureheight = screentextureheight;
5098 r_fb.textype = textype;
5099
5101 {
5102 if (r_motionblur.value > 0 || r_damageblur.value > 0)
5104 r_fb.ghosttexture_valid = false;
5105 }
5106 }
5107
5108 r_fb.rt_screen = R_RenderTarget_Get(screentexturewidth, screentextureheight, TEXTYPE_DEPTHBUFFER24STENCIL8, true, textype, TEXTYPE_UNUSED, TEXTYPE_UNUSED, TEXTYPE_UNUSED);
5109
5110 r_refdef.view.clear = true;
5111}
qbool R_Stereo_Active(void)
Definition cl_screen.c:2077
float scale
static int(ZEXPORT *qz_inflate)(z_stream *strm
float viewscalefpsadjusted
Definition gl_rmain.c:4382
void R_FreeTexture(rtexture_t *rt)
rtexture_t * R_LoadTexture2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, const unsigned char *data, textype_t textype, int flags, int miplevel, const unsigned int *palette)
float ceil(float f)
float floor(float f)
#define TEXF_FORCELINEAR
Definition r_textures.h:19
@ TEXTYPE_COLORBUFFER
Definition r_textures.h:84
@ TEXTYPE_COLORBUFFER32F
Definition r_textures.h:88
@ TEXTYPE_DEPTHBUFFER24STENCIL8
Definition r_textures.h:94
@ TEXTYPE_COLORBUFFER16F
Definition r_textures.h:86
#define TEXF_CLAMP
Definition r_textures.h:15
#define TEXF_RENDERTARGET
Definition r_textures.h:37
qbool ghosttexture_valid
Definition render.h:900
rtexture_t * ghosttexture
Definition render.h:890
textype_t textype
Definition render.h:883
double lastdrawscreentime
Definition render.h:462
qbool clear
whether to call R_ClearScreen before rendering stuff
Definition render.h:305
qbool ismain
if true, this is the MAIN view (which is, after CSQC, copied into the scene for use e....
Definition render.h:309
int samples
Definition vid.h:65
unsigned int maxtexturesize_2d
Definition vid.h:83
viddef_mode_t mode
currently active video mode
Definition vid.h:73

References r_framebufferstate_t::bloomheight, r_framebufferstate_t::bloomwidth, bound, ceil(), r_refdef_view_t::clear, Cvar_SetValueQuick(), floor(), r_framebufferstate_t::ghosttexture, r_framebufferstate_t::ghosttexture_valid, r_refdef_view_t::height, int(), cvar_t::integer, r_refdef_view_t::ismain, r_refdef_t::lastdrawscreentime, viddef_t::maxtexturesize_2d, viddef_t::mode, NULL, r_bloom, r_bloom_blur, r_bloom_resolution, r_damageblur, r_fb, R_FreeTexture(), R_LoadTexture2D(), r_main_texturepool, r_motionblur, r_refdef, R_RenderTarget_Get(), R_Stereo_Active(), r_usedepthtextures, r_viewfbo, r_viewscale, r_viewscale_fpsscaling, r_viewscale_fpsscaling_min, r_viewscale_fpsscaling_multiply, r_viewscale_fpsscaling_stepmax, r_viewscale_fpsscaling_stepsize, r_viewscale_fpsscaling_target, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, r_framebufferstate_t::rt_bloom, r_framebufferstate_t::rt_screen, viddef_mode_t::samples, scale, r_framebufferstate_t::screentextureheight, r_framebufferstate_t::screentexturewidth, sqrt(), TEXF_CLAMP, TEXF_FORCELINEAR, TEXF_RENDERTARGET, r_framebufferstate_t::textype, TEXTYPE_COLORBUFFER, TEXTYPE_COLORBUFFER16F, TEXTYPE_COLORBUFFER32F, TEXTYPE_DEPTHBUFFER24STENCIL8, TEXTYPE_UNUSED, r_framebufferstate_t::usedepthtextures, cvar_t::value, vid, r_refdef_t::view, viewscalefpsadjusted, and r_refdef_view_t::width.

Referenced by R_RenderView().

◆ R_BufferData_NewFrame()

void R_BufferData_NewFrame ( void )

begin a new frame (recycle old buffers)

Definition at line 3678 of file gl_rmain.c.

3679{
3680 int type;
3681 r_bufferdata_buffer_t **p, *mem;
3682 // cycle to the next frame's buffers
3684 // if we ran out of space on the last time we used these buffers, free the old memory now
3685 for (type = 0;type < R_BUFFERDATA_COUNT;type++)
3686 {
3688 {
3690 // free all but the head buffer, this is how we recycle obsolete
3691 // buffers after they are no longer in use
3693 while (*p)
3694 {
3695 mem = *p;
3696 *p = (*p)->purge;
3697 if (mem->buffer)
3699 Mem_Free(mem);
3700 }
3701 // reset the current offset
3703 }
3704 }
3705}
void R_Mesh_DestroyMeshBuffer(r_meshbuffer_t *buffer)
#define R_BUFFERDATA_CYCLE
Definition gl_rmain.c:3598
static r_bufferdata_buffer_t * r_bufferdata_buffer[R_BUFFERDATA_CYCLE][R_BUFFERDATA_COUNT]
Definition gl_rmain.c:3610
static void R_BufferData_Resize(r_bufferdata_type_t type, qbool mustgrow, size_t minsize)
Definition gl_rmain.c:3636
static int r_bufferdata_cycle
Definition gl_rmain.c:3609
GLenum type
Definition glquake.h:656
r_bufferdata_type_t
enum of the various types of hardware buffer object used in rendering note that the r_buffermegs[] ar...
Definition render.h:524
struct r_bufferdata_buffer_s * purge
Definition gl_rmain.c:3602
r_meshbuffer_t * buffer
Definition gl_rmain.c:3605

References r_bufferdata_buffer_t::buffer, r_bufferdata_buffer_t::current, Mem_Free, r_bufferdata_buffer_t::purge, r_bufferdata_buffer, R_BUFFERDATA_COUNT, R_BUFFERDATA_CYCLE, r_bufferdata_cycle, R_BufferData_Resize(), R_Mesh_DestroyMeshBuffer(), and type.

Referenced by CL_UpdateScreen().

◆ R_BufferData_Reset()

void R_BufferData_Reset ( void )

frees all dynamic buffers

free all dynamic vertex/index/uniform buffers

Definition at line 3613 of file gl_rmain.c.

3614{
3615 int cycle, type;
3616 r_bufferdata_buffer_t **p, *mem;
3617 for (cycle = 0;cycle < R_BUFFERDATA_CYCLE;cycle++)
3618 {
3619 for (type = 0;type < R_BUFFERDATA_COUNT;type++)
3620 {
3621 // free all buffers
3622 p = &r_bufferdata_buffer[cycle][type];
3623 while (*p)
3624 {
3625 mem = *p;
3626 *p = (*p)->purge;
3627 if (mem->buffer)
3629 Mem_Free(mem);
3630 }
3631 }
3632 }
3633}

References r_bufferdata_buffer_t::buffer, Mem_Free, r_bufferdata_buffer_t::purge, r_bufferdata_buffer, R_BUFFERDATA_COUNT, R_BUFFERDATA_CYCLE, R_Mesh_DestroyMeshBuffer(), and type.

Referenced by gl_main_newmap(), gl_main_shutdown(), and gl_main_start().

◆ R_BufferData_Resize()

static void R_BufferData_Resize ( r_bufferdata_type_t type,
qbool mustgrow,
size_t minsize )
static

Definition at line 3636 of file gl_rmain.c.

3637{
3639 size_t size;
3640 float newvalue = r_buffermegs[type].value;
3641
3642 // increase the cvar if we have to (but only if we already have a mem)
3643 if (mustgrow && mem)
3644 newvalue *= 2.0f;
3645 newvalue = bound(0.25f, newvalue, 256.0f);
3646 while (newvalue * 1024*1024 < minsize)
3647 newvalue *= 2.0f;
3648
3649 // clamp the cvar to valid range
3650 newvalue = bound(0.25f, newvalue, 256.0f);
3651 if (r_buffermegs[type].value != newvalue)
3653
3654 // calculate size in bytes
3655 size = (size_t)(newvalue * 1024*1024);
3656 size = bound(131072, size, 256*1024*1024);
3657
3658 // allocate a new buffer if the size is different (purge old one later)
3659 // or if we were told we must grow the buffer
3660 if (!mem || mem->size != size || mustgrow)
3661 {
3662 mem = (r_bufferdata_buffer_t *)Mem_Alloc(r_main_mempool, sizeof(*mem));
3663 mem->size = size;
3664 mem->current = 0;
3666 mem->buffer = R_Mesh_CreateMeshBuffer(NULL, mem->size, "dynamicbuffervertex", false, false, true, false);
3667 else if (type == R_BUFFERDATA_INDEX16)
3668 mem->buffer = R_Mesh_CreateMeshBuffer(NULL, mem->size, "dynamicbufferindex16", true, false, true, true);
3669 else if (type == R_BUFFERDATA_INDEX32)
3670 mem->buffer = R_Mesh_CreateMeshBuffer(NULL, mem->size, "dynamicbufferindex32", true, false, true, false);
3671 else if (type == R_BUFFERDATA_UNIFORM)
3672 mem->buffer = R_Mesh_CreateMeshBuffer(NULL, mem->size, "dynamicbufferuniform", false, true, true, false);
3675 }
3676}
vector size
r_meshbuffer_t * R_Mesh_CreateMeshBuffer(const void *data, size_t size, const char *name, qbool isindexbuffer, qbool isuniformbuffer, qbool isdynamic, qbool isindex16)
GLsizei const GLfloat * value
Definition glquake.h:740
@ R_BUFFERDATA_VERTEX
Definition render.h:525
@ R_BUFFERDATA_INDEX32
index buffer - 16bit (because D3D cares)
Definition render.h:527
@ R_BUFFERDATA_INDEX16
vertex buffer
Definition render.h:526
#define Mem_Alloc(pool, size)
Definition zone.h:92

References bound, r_bufferdata_buffer_t::buffer, r_bufferdata_buffer_t::current, Cvar_SetValueQuick(), Mem_Alloc, NULL, r_bufferdata_buffer_t::purge, r_bufferdata_buffer, r_bufferdata_cycle, R_BUFFERDATA_INDEX16, R_BUFFERDATA_INDEX32, R_BUFFERDATA_UNIFORM, R_BUFFERDATA_VERTEX, r_buffermegs, r_main_mempool, R_Mesh_CreateMeshBuffer(), r_bufferdata_buffer_t::size, size, type, cvar_t::value, and value.

Referenced by R_BufferData_NewFrame(), and R_BufferData_Store().

◆ R_BufferData_Store()

r_meshbuffer_t * R_BufferData_Store ( size_t datasize,
const void * data,
r_bufferdata_type_t type,
int * returnbufferoffset )

request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and offset, always successful

Definition at line 3707 of file gl_rmain.c.

3708{
3710 int offset = 0;
3711 int padsize;
3712
3713 *returnbufferoffset = 0;
3714
3715 // align size to a byte boundary appropriate for the buffer type, this
3716 // makes all allocations have aligned start offsets
3718 padsize = (datasize + r_uniformbufferalignment - 1) & ~(r_uniformbufferalignment - 1);
3719 else
3720 padsize = (datasize + 15) & ~15;
3721
3722 // if we ran out of space in this buffer we must allocate a new one
3724 R_BufferData_Resize(type, true, padsize);
3725
3726 // if the resize did not give us enough memory, fail
3728 Sys_Error("R_BufferData_Store: failed to create a new buffer of sufficient size\n");
3729
3731 offset = (int)mem->current;
3732 mem->current += padsize;
3733
3734 // upload the data to the buffer at the chosen offset
3735 if (offset == 0)
3736 R_Mesh_UpdateMeshBuffer(mem->buffer, NULL, mem->size, false, 0);
3737 R_Mesh_UpdateMeshBuffer(mem->buffer, data, datasize, true, offset);
3738
3739 // count the usage for stats
3742
3743 // return the buffer offset
3744 *returnbufferoffset = offset;
3745
3746 return mem->buffer;
3747}
void R_Mesh_UpdateMeshBuffer(r_meshbuffer_t *buffer, const void *data, size_t size, qbool subdata, size_t offset)
GLsizeiptr const GLvoid * data
Definition glquake.h:639
GLuint GLuint GLintptr offset
Definition glquake.h:632
@ r_stat_bufferdatasize_vertex
Definition r_stats.h:57
@ r_stat_bufferdatacurrent_vertex
Definition r_stats.h:53
void Sys_Error(const char *error,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
Causes the entire program to exit ASAP.
Definition sys_shared.c:724

References r_bufferdata_buffer_t::buffer, r_bufferdata_buffer_t::current, data, int(), max, NULL, offset, r_bufferdata_buffer, r_bufferdata_cycle, R_BufferData_Resize(), R_BUFFERDATA_UNIFORM, R_Mesh_UpdateMeshBuffer(), r_refdef, r_stat_bufferdatacurrent_vertex, r_stat_bufferdatasize_vertex, r_uniformbufferalignment, r_bufferdata_buffer_t::size, size, r_refdef_t::stats, Sys_Error(), and type.

Referenced by Mod_Mesh_UploadDynamicBuffers(), R_AnimCache_GetEntity(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), R_Mesh_PrepareVertices_Mesh_Arrays(), R_Mesh_PrepareVertices_Vertex3f(), and RSurf_UploadBuffersForBatch().

◆ R_BuildBlankTextures()

static void R_BuildBlankTextures ( void )
static

Definition at line 371 of file gl_rmain.c.

372{
373 unsigned char data[4];
374 data[2] = 128; // normal X
375 data[1] = 128; // normal Y
376 data[0] = 255; // normal Z
377 data[3] = 255; // height
379 data[0] = 255;
380 data[1] = 255;
381 data[2] = 255;
382 data[3] = 255;
384 data[0] = 128;
385 data[1] = 128;
386 data[2] = 128;
387 data[3] = 255;
389 data[0] = 0;
390 data[1] = 0;
391 data[2] = 0;
392 data[3] = 255;
394}
@ TEXTYPE_BGRA
Definition r_textures.h:53
#define TEXF_PERSISTENT
Definition r_textures.h:25

References data, NULL, R_LoadTexture2D(), r_main_texturepool, r_texture_black, r_texture_blanknormalmap, r_texture_grey128, r_texture_white, TEXF_PERSISTENT, and TEXTYPE_BGRA.

Referenced by gl_main_start().

◆ R_BuildFogHeightTexture()

static void R_BuildFogHeightTexture ( void )
static

Definition at line 526 of file gl_rmain.c.

527{
528 unsigned char *inpixels;
529 int size;
530 int x;
531 int y;
532 int j;
533 float c[4];
534 float f;
535 inpixels = NULL;
538 inpixels = loadimagepixelsbgra(r_refdef.fogheighttexturename, true, false, false, NULL);
539 if (!inpixels)
540 {
551 return;
552 }
556 r_refdef.fog_height_table2d = (unsigned char *)Mem_Alloc(r_main_mempool, size * size * 4);
557 memcpy(r_refdef.fog_height_table1d, inpixels, size * 4);
558 Mem_Free(inpixels);
559 // LadyHavoc: now the magic - what is that table2d for? it is a cooked
560 // average fog color table accounting for every fog layer between a point
561 // and the camera. (Note: attenuation is handled separately!)
562 for (y = 0;y < size;y++)
563 {
564 for (x = 0;x < size;x++)
565 {
566 Vector4Clear(c);
567 f = 0;
568 if (x < y)
569 {
570 for (j = x;j <= y;j++)
571 {
573 f++;
574 }
575 }
576 else
577 {
578 for (j = x;j >= y;j--)
579 {
581 f++;
582 }
583 }
584 f = 1.0f / f;
585 r_refdef.fog_height_table2d[(y*size+x)*4+0] = (unsigned char)(c[0] * f);
586 r_refdef.fog_height_table2d[(y*size+x)*4+1] = (unsigned char)(c[1] * f);
587 r_refdef.fog_height_table2d[(y*size+x)*4+2] = (unsigned char)(c[2] * f);
588 r_refdef.fog_height_table2d[(y*size+x)*4+3] = (unsigned char)(c[3] * f);
589 }
590 }
592}
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
unsigned char * loadimagepixelsbgra(const char *filename, qbool complain, qbool allowFixtrans, qbool convertsRGB, int *miplevel)
Definition image.c:1043
int image_width
Definition image.c:9
#define Vector4Clear(a)
Definition mathlib.h:82
#define Vector4Add(a, b, out)
Definition mathlib.h:89
#define TEXF_ALPHA
Definition r_textures.h:9
float f
unsigned char * fog_height_table1d
Definition render.h:445
unsigned char * fog_height_table2d
Definition render.h:446
char fogheighttexturename[64]
Definition render.h:450
int fog_height_tablesize
Definition render.h:447

References dp_strlcpy, f, r_refdef_t::fog_height_table1d, r_refdef_t::fog_height_table2d, r_refdef_t::fog_height_tablesize, r_refdef_t::fog_height_texturename, r_refdef_t::fogheighttexturename, image_width, loadimagepixelsbgra(), Mem_Alloc, Mem_Free, NULL, R_FreeTexture(), R_LoadTexture2D(), r_main_mempool, r_main_texturepool, r_refdef, r_texture_fogheighttexture, size, TEXF_ALPHA, TEXF_CLAMP, TEXTYPE_BGRA, Vector4Add, Vector4Clear, x, and y.

Referenced by R_UpdateFog().

◆ R_BuildFogTexture()

static void R_BuildFogTexture ( void )
static

Definition at line 470 of file gl_rmain.c.

471{
472 int x, b;
473#define FOGWIDTH 256
474 unsigned char data1[FOGWIDTH][4];
475 //unsigned char data2[FOGWIDTH][4];
476 double d, r, alpha;
477
482
484 for (x = 0;x < FOGMASKTABLEWIDTH;x++)
485 {
486 d = (x * r - r_refdef.fogmasktable_start);
488 Con_DPrintf("%f ", d);
489 d = max(0, d);
492 else
493 alpha = exp(-r_refdef.fogmasktable_density * 0.004 * d);
495 Con_DPrintf(" : %f ", alpha);
498 Con_DPrintf(" = %f\n", alpha);
500 }
501
502 for (x = 0;x < FOGWIDTH;x++)
503 {
504 b = (int)(r_refdef.fogmasktable[x * (FOGMASKTABLEWIDTH - 1) / (FOGWIDTH - 1)] * 255);
505 data1[x][0] = b;
506 data1[x][1] = b;
507 data1[x][2] = b;
508 data1[x][3] = 255;
509 //data2[x][0] = 255 - b;
510 //data2[x][1] = 255 - b;
511 //data2[x][2] = 255 - b;
512 //data2[x][3] = 255;
513 }
515 {
516 R_UpdateTexture(r_texture_fogattenuation, &data1[0][0], 0, 0, 0, FOGWIDTH, 1, 1, 0);
517 //R_UpdateTexture(r_texture_fogattenuation, &data2[0][0], 0, 0, 0, FOGWIDTH, 1, 1, 0);
518 }
519 else
520 {
522 //r_texture_fogintensity = R_LoadTexture2D(r_main_texturepool, "fogintensity", FOGWIDTH, 1, &data2[0][0], TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_CLAMP, NULL);
523 }
524}
float alpha
#define FOGWIDTH
void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, int z, int width, int height, int depth, int combine)
cvar_t developer_extra
Definition host.c:49
#define FOGMASKTABLEWIDTH
Definition render.h:428
dp_FragColor b
float fogmasktable[FOGMASKTABLEWIDTH]
Definition render.h:429
float fogmasktable_start
Definition render.h:430
float fogrange
Definition render.h:425
float fogmasktable_alpha
Definition render.h:430
float fogmasktable_range
Definition render.h:430

References alpha, b, bound, Con_DPrintf(), developer_extra, r_refdef_t::fog_alpha, r_refdef_t::fog_density, r_refdef_t::fog_start, r_refdef_t::fogmasktable, r_refdef_t::fogmasktable_alpha, r_refdef_t::fogmasktable_density, r_refdef_t::fogmasktable_range, r_refdef_t::fogmasktable_start, FOGMASKTABLEWIDTH, r_refdef_t::fogrange, FOGWIDTH, int(), cvar_t::integer, max, NULL, r, r_fog_exp2, R_LoadTexture2D(), r_main_texturepool, r_refdef, r_texture_fogattenuation, R_UpdateTexture(), TEXF_CLAMP, TEXF_FORCELINEAR, TEXF_PERSISTENT, TEXTYPE_BGRA, and x.

Referenced by R_UpdateFog().

◆ R_BuildNormalizationCube()

static void R_BuildNormalizationCube ( void )
static

Definition at line 408 of file gl_rmain.c.

409{
410 int x, y, side;
411 vec3_t v;
412 vec_t s, t, intensity;
413#define NORMSIZE 64
414 unsigned char *data;
415 data = (unsigned char *)Mem_Alloc(tempmempool, 6*NORMSIZE*NORMSIZE*4);
416 for (side = 0;side < 6;side++)
417 {
418 for (y = 0;y < NORMSIZE;y++)
419 {
420 for (x = 0;x < NORMSIZE;x++)
421 {
422 s = (x + 0.5f) * (2.0f / NORMSIZE) - 1.0f;
423 t = (y + 0.5f) * (2.0f / NORMSIZE) - 1.0f;
424 switch(side)
425 {
426 default:
427 case 0:
428 v[0] = 1;
429 v[1] = -t;
430 v[2] = -s;
431 break;
432 case 1:
433 v[0] = -1;
434 v[1] = -t;
435 v[2] = s;
436 break;
437 case 2:
438 v[0] = s;
439 v[1] = 1;
440 v[2] = t;
441 break;
442 case 3:
443 v[0] = s;
444 v[1] = -1;
445 v[2] = -t;
446 break;
447 case 4:
448 v[0] = s;
449 v[1] = -t;
450 v[2] = 1;
451 break;
452 case 5:
453 v[0] = -s;
454 v[1] = -t;
455 v[2] = -1;
456 break;
457 }
458 intensity = 127.0f / sqrt(DotProduct(v, v));
459 data[((side*64+y)*64+x)*4+2] = (unsigned char)(128.0f + intensity * v[0]);
460 data[((side*64+y)*64+x)*4+1] = (unsigned char)(128.0f + intensity * v[1]);
461 data[((side*64+y)*64+x)*4+0] = (unsigned char)(128.0f + intensity * v[2]);
462 data[((side*64+y)*64+x)*4+3] = 255;
463 }
464 }
465 }
467 Mem_Free(data);
468}
#define NORMSIZE
rtexture_t * R_LoadTextureCubeMap(rtexturepool_t *rtexturepool, const char *identifier, int width, const unsigned char *data, textype_t textype, int flags, int miplevel, const unsigned int *palette)
const GLdouble * v
Definition glquake.h:762
float vec_t
Definition qtypes.h:68
float intensity
Definition snd_mix.c:314

References data, DotProduct, intensity, Mem_Alloc, Mem_Free, NORMSIZE, NULL, R_LoadTextureCubeMap(), r_main_texturepool, r_texture_normalizationcube, sqrt(), tempmempool, TEXF_CLAMP, TEXF_PERSISTENT, TEXTYPE_BGRA, v, x, and y.

Referenced by gl_main_start().

◆ R_BuildNoTexture()

static void R_BuildNoTexture ( void )
static

Definition at line 396 of file gl_rmain.c.

397{
399}
rtexture_t * r_texture_notexture
Definition gl_rmain.c:276
unsigned char * Image_GenerateNoTexture(void)
Definition image.c:1887
#define TEXF_MIPMAP
Definition r_textures.h:11

References Image_GenerateNoTexture(), NULL, R_LoadTexture2D(), r_main_texturepool, r_texture_notexture, TEXF_MIPMAP, TEXF_PERSISTENT, and TEXTYPE_BGRA.

Referenced by gl_main_start().

◆ R_BuildWhiteCube()

static void R_BuildWhiteCube ( void )
static

Definition at line 401 of file gl_rmain.c.

402{
403 unsigned char data[6*1*1*4];
404 memset(data, 255, sizeof(data));
406}

References data, NULL, R_LoadTextureCubeMap(), r_main_texturepool, r_texture_whitecube, TEXF_CLAMP, TEXF_PERSISTENT, and TEXTYPE_BGRA.

Referenced by gl_main_start().

◆ R_CalcBeam_Vertex3f()

void R_CalcBeam_Vertex3f ( float * vert,
const float * org1,
const float * org2,
float width )

Definition at line 6253 of file gl_rmain.c.

6254{
6255 vec3_t right1, right2, diff, normal;
6256
6257 VectorSubtract (org2, org1, normal);
6258
6259 // calculate 'right' vector for start
6260 VectorSubtract (r_refdef.view.origin, org1, diff);
6261 CrossProduct (normal, diff, right1);
6262 VectorNormalize (right1);
6263
6264 // calculate 'right' vector for end
6265 VectorSubtract (r_refdef.view.origin, org2, diff);
6266 CrossProduct (normal, diff, right2);
6267 VectorNormalize (right2);
6268
6269 vert[ 0] = org1[0] + width * right1[0];
6270 vert[ 1] = org1[1] + width * right1[1];
6271 vert[ 2] = org1[2] + width * right1[2];
6272 vert[ 3] = org1[0] - width * right1[0];
6273 vert[ 4] = org1[1] - width * right1[1];
6274 vert[ 5] = org1[2] - width * right1[2];
6275 vert[ 6] = org2[0] - width * right2[0];
6276 vert[ 7] = org2[1] - width * right2[1];
6277 vert[ 8] = org2[2] - width * right2[2];
6278 vert[ 9] = org2[0] + width * right2[0];
6279 vert[10] = org2[1] + width * right2[1];
6280 vert[11] = org2[2] + width * right2[2];
6281}
#define VectorNormalize(v)
Definition mathlib.h:104
#define VectorSubtract(a, b, out)
Definition mathlib.h:99
#define CrossProduct(a, b, out)
Definition mathlib.h:103
vec3 normal
vec3_t origin
Definition render.h:267

References CrossProduct, normal, r_refdef_view_t::origin, r_refdef, VectorNormalize, VectorSubtract, r_refdef_t::view, and width.

Referenced by R_DrawParticle_TransparentCallback().

◆ R_CalcSprite_Vertex3f()

void R_CalcSprite_Vertex3f ( float * vertex3f,
const vec3_t origin,
const vec3_t left,
const vec3_t up,
float scalex1,
float scalex2,
float scaley1,
float scaley2 )

Definition at line 6283 of file gl_rmain.c.

6284{
6285 vertex3f[ 0] = origin[0] + left[0] * scalex2 + up[0] * scaley1;
6286 vertex3f[ 1] = origin[1] + left[1] * scalex2 + up[1] * scaley1;
6287 vertex3f[ 2] = origin[2] + left[2] * scalex2 + up[2] * scaley1;
6288 vertex3f[ 3] = origin[0] + left[0] * scalex2 + up[0] * scaley2;
6289 vertex3f[ 4] = origin[1] + left[1] * scalex2 + up[1] * scaley2;
6290 vertex3f[ 5] = origin[2] + left[2] * scalex2 + up[2] * scaley2;
6291 vertex3f[ 6] = origin[0] + left[0] * scalex1 + up[0] * scaley2;
6292 vertex3f[ 7] = origin[1] + left[1] * scalex1 + up[1] * scaley2;
6293 vertex3f[ 8] = origin[2] + left[2] * scalex1 + up[2] * scaley2;
6294 vertex3f[ 9] = origin[0] + left[0] * scalex1 + up[0] * scaley1;
6295 vertex3f[10] = origin[1] + left[1] * scalex1 + up[1] * scaley1;
6296 vertex3f[11] = origin[2] + left[2] * scalex1 + up[2] * scaley1;
6297}
vector origin
static vec3_t up
Definition sv_user.c:305

References origin, and up.

Referenced by R_BeginCoronaQuery(), R_DrawCorona(), R_Model_Sprite_Draw_TransparentCallback(), R_Shadow_DrawCursor_TransparentCallback(), and R_Shadow_DrawLightSprite_TransparentCallback().

◆ R_CalcTexCoordsForView()

static void R_CalcTexCoordsForView ( float x,
float y,
float w,
float h,
float tw,
float th,
float * texcoord2f )
static

Definition at line 4547 of file gl_rmain.c.

4548{
4549 float iw = 1.0f / tw, ih = 1.0f / th, x1, y1, x2, y2;
4550 x1 = x * iw;
4551 x2 = (x + w) * iw;
4552 y1 = (th - y) * ih;
4553 y2 = (th - y - h) * ih;
4554 texcoord2f[0] = x1;
4555 texcoord2f[2] = x2;
4556 texcoord2f[4] = x2;
4557 texcoord2f[6] = x1;
4558 texcoord2f[1] = y1;
4559 texcoord2f[3] = y1;
4560 texcoord2f[5] = y2;
4561 texcoord2f[7] = y2;
4562}
GLubyte GLubyte GLubyte GLubyte w
Definition glquake.h:782
vec3 y2
vec3 x2
vec3 x1

References w, x, x1, x2, y, and y2.

Referenced by R_MotionBlurView(), and R_RenderTarget_Get().

◆ R_CanSeeBox()

qbool R_CanSeeBox ( int numsamples,
vec_t eyejitter,
vec_t entboxenlarge,
vec_t entboxexpand,
vec_t pad,
vec3_t eye,
vec3_t entboxmins,
vec3_t entboxmaxs )

Definition at line 3888 of file gl_rmain.c.

3889{
3890 long unsigned int i;
3891 int j;
3892 vec3_t eyemins, eyemaxs;
3893 vec3_t boxmins, boxmaxs;
3894 vec3_t padmins, padmaxs;
3895 vec3_t start;
3896 vec3_t end;
3898 static vec3_t positions[] = {
3899 { 0.5f, 0.5f, 0.5f },
3900 { 0.0f, 0.0f, 0.0f },
3901 { 0.0f, 0.0f, 1.0f },
3902 { 0.0f, 1.0f, 0.0f },
3903 { 0.0f, 1.0f, 1.0f },
3904 { 1.0f, 0.0f, 0.0f },
3905 { 1.0f, 0.0f, 1.0f },
3906 { 1.0f, 1.0f, 0.0f },
3907 { 1.0f, 1.0f, 1.0f },
3908 };
3909
3910 // sample count can be set to -1 to skip this logic, for flicker-prone objects
3911 if (numsamples < 0)
3912 return true;
3913
3914 // view origin is not used for culling in portal/reflection/refraction renders or isometric views
3916 return true;
3917
3918 if (!r_cullentities_trace_entityocclusion.integer && (!model || !model->brush.TraceLineOfSight))
3919 return true;
3920
3921 // expand the eye box a little
3922 eyemins[0] = eye[0] - eyejitter;
3923 eyemaxs[0] = eye[0] + eyejitter;
3924 eyemins[1] = eye[1] - eyejitter;
3925 eyemaxs[1] = eye[1] + eyejitter;
3926 eyemins[2] = eye[2] - eyejitter;
3927 eyemaxs[2] = eye[2] + eyejitter;
3928 // expand the box a little
3929 boxmins[0] = (entboxenlarge + 1) * entboxmins[0] - entboxenlarge * entboxmaxs[0] - entboxexpand;
3930 boxmaxs[0] = (entboxenlarge + 1) * entboxmaxs[0] - entboxenlarge * entboxmins[0] + entboxexpand;
3931 boxmins[1] = (entboxenlarge + 1) * entboxmins[1] - entboxenlarge * entboxmaxs[1] - entboxexpand;
3932 boxmaxs[1] = (entboxenlarge + 1) * entboxmaxs[1] - entboxenlarge * entboxmins[1] + entboxexpand;
3933 boxmins[2] = (entboxenlarge + 1) * entboxmins[2] - entboxenlarge * entboxmaxs[2] - entboxexpand;
3934 boxmaxs[2] = (entboxenlarge + 1) * entboxmaxs[2] - entboxenlarge * entboxmins[2] + entboxexpand;
3935 // make an even larger box for the acceptable area
3936 padmins[0] = boxmins[0] - pad;
3937 padmaxs[0] = boxmaxs[0] + pad;
3938 padmins[1] = boxmins[1] - pad;
3939 padmaxs[1] = boxmaxs[1] + pad;
3940 padmins[2] = boxmins[2] - pad;
3941 padmaxs[2] = boxmaxs[2] + pad;
3942
3943 // return true if eye overlaps enlarged box
3944 if (BoxesOverlap(boxmins, boxmaxs, eyemins, eyemaxs))
3945 return true;
3946
3947 VectorCopy(eye, start);
3948 // try specific positions in the box first - note that these can be cached
3950 {
3951 for (i = 0; i < sizeof(positions) / sizeof(positions[0]); i++)
3952 {
3953 trace_t trace;
3954 end[0] = boxmins[0] + (boxmaxs[0] - boxmins[0]) * positions[i][0];
3955 end[1] = boxmins[1] + (boxmaxs[1] - boxmins[1]) * positions[i][1];
3956 end[2] = boxmins[2] + (boxmaxs[2] - boxmins[2]) * positions[i][2];
3957 //trace_t trace = CL_TraceLine(start, end, MOVE_NORMAL, NULL, SUPERCONTENTS_SOLID, SUPERCONTENTS_SKY, MATERIALFLAGMASK_TRANSLUCENT, 0.0f, true, false, NULL, true, true);
3959 // not picky - if the trace ended anywhere in the box we're good
3960 if (BoxesOverlap(trace.endpos, trace.endpos, padmins, padmaxs))
3961 return true;
3962 }
3963 }
3964 else
3965 {
3966 // try center
3967 VectorMAM(0.5f, boxmins, 0.5f, boxmaxs, end);
3968 if (model->brush.TraceLineOfSight(model, start, end, padmins, padmaxs))
3969 return true;
3970 }
3971
3972 // try various random positions
3973 for (j = 0; j < numsamples; j++)
3974 {
3975 VectorSet(start, lhrandom(eyemins[0], eyemaxs[0]), lhrandom(eyemins[1], eyemaxs[1]), lhrandom(eyemins[2], eyemaxs[2]));
3976 VectorSet(end, lhrandom(boxmins[0], boxmaxs[0]), lhrandom(boxmins[1], boxmaxs[1]), lhrandom(boxmins[2], boxmaxs[2]));
3978 {
3979 trace_t trace = CL_TraceLine(start, end, MOVE_NORMAL, NULL, SUPERCONTENTS_SOLID, SUPERCONTENTS_SKY, MATERIALFLAGMASK_TRANSLUCENT, 0.0f, true, false, NULL, true, true);
3980 // not picky - if the trace ended anywhere in the box we're good
3981 if (BoxesOverlap(trace.endpos, trace.endpos, padmins, padmaxs))
3982 return true;
3983 }
3984 else if (model->brush.TraceLineOfSight(model, start, end, padmins, padmaxs))
3985 return true;
3986 }
3987
3988 return false;
3989}
#define SUPERCONTENTS_SKY
Definition bspfile.h:200
#define SUPERCONTENTS_SOLID
Definition bspfile.h:196
trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities, qbool hitsurfaces)
trace_t CL_Cache_TraceLineSurfaces(const vec3_t start, const vec3_t end, int type, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask)
#define BoxesOverlap(a, b, c, d)
Definition mathlib.h:122
#define lhrandom(MIN, MAX)
LadyHavoc: this function never returns exactly MIN or exactly MAX, because of a QuakeC bug in id1 whe...
Definition mathlib.h:48
#define VectorSet(vec, x, y, z)
Definition mathlib.h:96
#define VectorCopy(in, out)
Definition mathlib.h:101
#define VectorMAM(scale1, b1, scale2, b2, out)
Definition mathlib.h:116
#define MATERIALFLAGMASK_TRANSLUCENT
model_t * worldmodel
same as worldentity->model
Definition render.h:358
int usevieworiginculling
allows visibility culling based on the view origin (e.g.
Definition render.h:286
double endpos[3]
Definition collision.h:42
#define MOVE_NORMAL
Definition world.h:28

References BoxesOverlap, CL_Cache_TraceLineSurfaces(), CL_TraceLine(), trace_t::endpos, i, cvar_t::integer, lhrandom, MATERIALFLAGMASK_TRANSLUCENT, model, MOVE_NORMAL, NULL, r_cullentities_trace_entityocclusion, r_refdef, r_refdef_t::scene, SUPERCONTENTS_SKY, SUPERCONTENTS_SOLID, r_refdef_view_t::usevieworiginculling, VectorCopy, VectorMAM, VectorSet, r_refdef_t::view, and r_refdef_scene_t::worldmodel.

Referenced by R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_PrepareLight(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ R_CompileShader_AddStaticParms()

static void R_CompileShader_AddStaticParms ( unsigned int mode,
uint64_t permutation )
static

Definition at line 911 of file gl_rmain.c.

912{
914
915 // emit all
931}
#define R_COMPILESHADER_STATICPARM_EMIT(p, n)
Definition gl_rmain.c:906

References R_COMPILESHADER_STATICPARM_EMIT, SHADERSTATICPARM_CELOUTLINES, SHADERSTATICPARM_CELSHADING, SHADERSTATICPARM_COLORFRINGE, SHADERSTATICPARM_EXACTSPECULARMATH, SHADERSTATICPARM_FXAA, SHADERSTATICPARM_OFFSETMAPPING_USELOD, SHADERSTATICPARM_POSTPROCESS_USERVEC1, SHADERSTATICPARM_POSTPROCESS_USERVEC2, SHADERSTATICPARM_POSTPROCESS_USERVEC3, SHADERSTATICPARM_POSTPROCESS_USERVEC4, SHADERSTATICPARM_SATURATION_REDCOMPENSATE, SHADERSTATICPARM_SHADOWMAPPCF_1, SHADERSTATICPARM_SHADOWMAPPCF_2, SHADERSTATICPARM_SHADOWSAMPLER, SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS, and shaderstaticparms_count.

Referenced by R_GLSL_CompilePermutation().

◆ R_CompileShader_CheckStaticParms()

qbool R_CompileShader_CheckStaticParms ( void )

Definition at line 861 of file gl_rmain.c.

862{
863 static int r_compileshader_staticparms_save[(SHADERSTATICPARMS_COUNT + 0x1F) >> 5];
864 memcpy(r_compileshader_staticparms_save, r_compileshader_staticparms, sizeof(r_compileshader_staticparms));
866
867 // detect all
875 {
884 }
885 if (r_fxaa.integer)
889
892 if (r_shadow_shadowmappcf > 1)
894 else if (r_shadow_shadowmappcf)
902
903 return memcmp(r_compileshader_staticparms, r_compileshader_staticparms_save, sizeof(r_compileshader_staticparms)) != 0;
904}
int r_shadow_shadowmappcf
Definition r_shadow.c:60
#define R_COMPILESHADER_STATICPARM_ENABLE(p)
Definition gl_rmain.c:857
qbool r_shadow_shadowmapsampler
Definition r_shadow.c:58
#define SHADERSTATICPARMS_COUNT
Definition gl_rmain.c:851
cvar_t r_shadow_glossexact
Definition r_shadow.c:152

References cvar_t::integer, r_celoutlines, r_celshading, r_colorfringe, R_COMPILESHADER_STATICPARM_ENABLE, r_compileshader_staticparms, r_fxaa, r_glsl_offsetmapping_lod, r_glsl_offsetmapping_lod_distance, r_glsl_postprocess, r_glsl_postprocess_uservec1_enable, r_glsl_postprocess_uservec2_enable, r_glsl_postprocess_uservec3_enable, r_glsl_postprocess_uservec4_enable, r_glsl_saturation_redcompensate, r_glsl_vertextextureblend_usebothalphas, r_shadow_glossexact, r_shadow_shadowmappcf, r_shadow_shadowmapsampler, SHADERSTATICPARM_CELOUTLINES, SHADERSTATICPARM_CELSHADING, SHADERSTATICPARM_COLORFRINGE, SHADERSTATICPARM_EXACTSPECULARMATH, SHADERSTATICPARM_FXAA, SHADERSTATICPARM_OFFSETMAPPING_USELOD, SHADERSTATICPARM_POSTPROCESS_USERVEC1, SHADERSTATICPARM_POSTPROCESS_USERVEC2, SHADERSTATICPARM_POSTPROCESS_USERVEC3, SHADERSTATICPARM_POSTPROCESS_USERVEC4, SHADERSTATICPARM_SATURATION_REDCOMPENSATE, SHADERSTATICPARM_SHADOWMAPPCF_1, SHADERSTATICPARM_SHADOWMAPPCF_2, SHADERSTATICPARM_SHADOWSAMPLER, SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS, SHADERSTATICPARMS_COUNT, and cvar_t::value.

Referenced by R_RenderView(), and R_Shadow_SetShadowMode().

◆ R_CullBox()

qbool R_CullBox ( const vec3_t mins,
const vec3_t maxs,
int numplanes,
const mplane_t * planes )

Definition at line 3470 of file gl_rmain.c.

3471{
3472 // nothing to ignore
3473 return _R_CullBox(mins, maxs, numplanes, planes, -1);
3474}
static qbool _R_CullBox(const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes, int ignore)
Definition gl_rmain.c:3445

References _R_CullBox(), maxs, and mins.

Referenced by R_Q1BSP_RecursiveGetLightInfo_BIH(), R_Q1BSP_RecursiveGetLightInfo_BSP(), and R_Shadow_PrepareLight().

◆ R_CullFrustum()

qbool R_CullFrustum ( const vec3_t mins,
const vec3_t maxs )

◆ R_DebugLine()

void R_DebugLine ( vec3_t start,
vec3_t end )

Definition at line 10107 of file gl_rmain.c.

10108{
10109 model_t *mod = CL_Mesh_UI();
10110 msurface_t *surf;
10111 int e0, e1, e2, e3;
10112 float offsetx, offsety, x1, y1, x2, y2, width = 1.0f;
10113 float r1 = 1.0f, g1 = 0.0f, b1 = 0.0f, alpha1 = 0.25f;
10114 float r2 = 1.0f, g2 = 1.0f, b2 = 0.0f, alpha2 = 0.25f;
10115 vec4_t w[2], s[2];
10116
10117 // transform to screen coords first
10118 Vector4Set(w[0], start[0], start[1], start[2], 1);
10119 Vector4Set(w[1], end[0], end[1], end[2], 1);
10122 x1 = s[0][0] * vid_conwidth.value / vid.mode.width;
10123 y1 = (vid.mode.height - s[0][1]) * vid_conheight.value / vid.mode.height;
10124 x2 = s[1][0] * vid_conwidth.value / vid.mode.width;
10125 y2 = (vid.mode.height - s[1][1]) * vid_conheight.value / vid.mode.height;
10126 //Con_DPrintf("R_DebugLine: %.0f,%.0f to %.0f,%.0f\n", x1, y1, x2, y2);
10127
10128 // add the line to the UI mesh for drawing later
10129
10130 // width is measured in real pixels
10131 if (fabs(x2 - x1) > fabs(y2 - y1))
10132 {
10133 offsetx = 0;
10134 offsety = 0.5f * width * vid_conheight.value / vid.mode.height;
10135 }
10136 else
10137 {
10138 offsetx = 0.5f * width * vid_conwidth.value / vid.mode.width;
10139 offsety = 0;
10140 }
10142 e0 = Mod_Mesh_IndexForVertex(mod, surf, x1 - offsetx, y1 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r1, g1, b1, alpha1);
10143 e1 = Mod_Mesh_IndexForVertex(mod, surf, x2 - offsetx, y2 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r2, g2, b2, alpha2);
10144 e2 = Mod_Mesh_IndexForVertex(mod, surf, x2 + offsetx, y2 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r2, g2, b2, alpha2);
10145 e3 = Mod_Mesh_IndexForVertex(mod, surf, x1 + offsetx, y1 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r1, g1, b1, alpha1);
10146 Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
10147 Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
10148
10149}
cvar_t vid_conheight
Definition cl_screen.c:57
cvar_t vid_conwidth
Definition cl_screen.c:56
#define CL_Mesh_UI()
Definition client.h:1372
float mod(float dividend, float divisor)
void R_Viewport_TransformToScreen(const r_viewport_t *v, const vec4_t in, vec4_t out)
Definition gl_backend.c:383
#define Vector4Set(vec, r, g, b, a)
Definition mathlib.h:86
float fabs(float f)
#define MATERIALFLAG_VERTEXCOLOR
#define MATERIALFLAG_ALPHA
Definition model_brush.h:79
#define MATERIALFLAG_BLENDED
#define MATERIALFLAG_ALPHAGEN_VERTEX
#define MATERIALFLAG_WALL
Definition model_brush.h:89
#define MATERIALFLAG_NOSHADOW
msurface_t * Mod_Mesh_AddSurface(model_t *mod, texture_t *tex, qbool batchwithprevioussurface)
int Mod_Mesh_IndexForVertex(model_t *mod, msurface_t *surf, float x, float y, float z, float nx, float ny, float nz, float s, float t, float u, float v, float r, float g, float b, float a)
texture_t * Mod_Mesh_GetTexture(model_t *mod, const char *name, int defaultdrawflags, int defaulttexflags, int defaultmaterialflags)
void Mod_Mesh_AddTriangle(model_t *mod, msurface_t *surf, int e0, int e1, int e2)
vec_t vec4_t[4]
Definition qtypes.h:72
describes the textures to use on a range of triangles in the model, and mins/maxs (AABB) for culling.
r_viewport_t viewport
note: if r_viewscale is used, the viewport.width and viewport.height may be less than width and heigh...
Definition render.h:296
int width
Definition vid.h:60
int height
Definition vid.h:61

References CL_Mesh_UI, fabs(), viddef_mode_t::height, MATERIALFLAG_ALPHA, MATERIALFLAG_ALPHAGEN_VERTEX, MATERIALFLAG_BLENDED, MATERIALFLAG_NOSHADOW, MATERIALFLAG_VERTEXCOLOR, MATERIALFLAG_WALL, mod(), Mod_Mesh_AddSurface(), Mod_Mesh_AddTriangle(), Mod_Mesh_GetTexture(), Mod_Mesh_IndexForVertex(), viddef_t::mode, r_refdef, R_Viewport_TransformToScreen(), cvar_t::value, Vector4Set, vid, vid_conheight, vid_conwidth, r_refdef_t::view, r_refdef_view_t::viewport, w, viddef_mode_t::width, width, x1, x2, and y2.

Referenced by R_DrawParticle_TransparentCallback(), and R_Model_Sprite_Draw_TransparentCallback().

◆ R_DecalSystem_ApplySplatEntities()

static void R_DecalSystem_ApplySplatEntities ( const vec3_t worldorigin,
const vec3_t worldnormal,
float r,
float g,
float b,
float a,
float s1,
float t1,
float s2,
float t2,
float worldsize,
unsigned int decalsequence )
static

Definition at line 9466 of file gl_rmain.c.

9467{
9468 int renderentityindex;
9469 float worldmins[3];
9470 float worldmaxs[3];
9471 entity_render_t *ent;
9472
9473 worldmins[0] = worldorigin[0] - worldsize;
9474 worldmins[1] = worldorigin[1] - worldsize;
9475 worldmins[2] = worldorigin[2] - worldsize;
9476 worldmaxs[0] = worldorigin[0] + worldsize;
9477 worldmaxs[1] = worldorigin[1] + worldsize;
9478 worldmaxs[2] = worldorigin[2] + worldsize;
9479
9480 R_DecalSystem_SplatEntity(r_refdef.scene.worldentity, worldorigin, worldnormal, r, g, b, a, s1, t1, s2, t2, worldsize, decalsequence);
9481
9482 for (renderentityindex = 0;renderentityindex < r_refdef.scene.numentities;renderentityindex++)
9483 {
9484 ent = r_refdef.scene.entities[renderentityindex];
9485 if (!BoxesOverlap(ent->mins, ent->maxs, worldmins, worldmaxs))
9486 continue;
9487
9488 R_DecalSystem_SplatEntity(ent, worldorigin, worldnormal, r, g, b, a, s1, t1, s2, t2, worldsize, decalsequence);
9489 }
9490}
static void R_DecalSystem_SplatEntity(entity_render_t *ent, const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize, unsigned int decalsequence)
Definition gl_rmain.c:9307
dp_FragColor g
ret a
vec3_t mins
Definition client.h:371
vec3_t maxs
Definition client.h:371
entity_render_t * worldentity
the world
Definition render.h:355

References a, b, BoxesOverlap, r_refdef_scene_t::entities, g, entity_render_t::maxs, entity_render_t::mins, r_refdef_scene_t::numentities, r, R_DecalSystem_SplatEntity(), r_refdef, r_refdef_t::scene, and r_refdef_scene_t::worldentity.

Referenced by R_DecalSystem_ApplySplatEntitiesQueue().

◆ R_DecalSystem_ApplySplatEntitiesQueue()

static void R_DecalSystem_ApplySplatEntitiesQueue ( void )
static

Definition at line 9522 of file gl_rmain.c.

9523{
9524 int i;
9526
9527 for (i = 0, queue = r_decalsystem_queue;i < r_decalsystem_numqueued;i++, queue++)
9528 R_DecalSystem_ApplySplatEntities(queue->worldorigin, queue->worldnormal, queue->color[0], queue->color[1], queue->color[2], queue->color[3], queue->tcrange[0], queue->tcrange[1], queue->tcrange[2], queue->tcrange[3], queue->worldsize, queue->decalsequence);
9530}
int r_decalsystem_numqueued
Definition gl_rmain.c:9503
r_decalsystem_splatqueue_t r_decalsystem_queue[MAX_DECALSYSTEM_QUEUE]
Definition gl_rmain.c:9504
static void R_DecalSystem_ApplySplatEntities(const vec3_t worldorigin, const vec3_t worldnormal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float worldsize, unsigned int decalsequence)
Definition gl_rmain.c:9466

References r_decalsystem_splatqueue_t::color, r_decalsystem_splatqueue_t::decalsequence, i, R_DecalSystem_ApplySplatEntities(), r_decalsystem_numqueued, r_decalsystem_queue, r_decalsystem_splatqueue_t::tcrange, r_decalsystem_splatqueue_t::worldnormal, r_decalsystem_splatqueue_t::worldorigin, and r_decalsystem_splatqueue_t::worldsize.

Referenced by R_DrawModelDecals().

◆ R_DecalSystem_Reset()

void R_DecalSystem_Reset ( decalsystem_t * decalsystem)

Definition at line 9134 of file gl_rmain.c.

9135{
9136 if (decalsystem->decals)
9137 Mem_Free(decalsystem->decals);
9138 memset(decalsystem, 0, sizeof(*decalsystem));
9139}
tridecal_t * decals
Definition client.h:61

References decalsystem_t::decals, and Mem_Free.

Referenced by CL_UpdateNetworkEntities(), CLVM_free_edict(), R_DecalSystem_SplatEntity(), R_DrawModelDecals_Entity(), and R_DrawModelDecals_FadeEntity().

◆ R_DecalSystem_SpawnTriangle()

static void R_DecalSystem_SpawnTriangle ( decalsystem_t * decalsystem,
const float * v0,
const float * v1,
const float * v2,
const float * t0,
const float * t1,
const float * t2,
const float * c0,
const float * c1,
const float * c2,
int triangleindex,
int surfaceindex,
unsigned int decalsequence )
static

Definition at line 9141 of file gl_rmain.c.

9142{
9143 tridecal_t *decal;
9144 int i;
9145
9146 // expand or initialize the system
9147 if (decalsystem->maxdecals <= decalsystem->numdecals)
9148 {
9149 decalsystem_t old = *decalsystem;
9150 qbool useshortelements;
9151 decalsystem->maxdecals = max(16, decalsystem->maxdecals * 2);
9152 useshortelements = decalsystem->maxdecals * 3 <= 65536;
9153 decalsystem->decals = (tridecal_t *)Mem_Alloc(cls.levelmempool, decalsystem->maxdecals * (sizeof(tridecal_t) + sizeof(float[3][3]) + sizeof(float[3][2]) + sizeof(float[3][4]) + sizeof(int[3]) + (useshortelements ? sizeof(unsigned short[3]) : 0)));
9154 decalsystem->color4f = (float *)(decalsystem->decals + decalsystem->maxdecals);
9155 decalsystem->texcoord2f = (float *)(decalsystem->color4f + decalsystem->maxdecals*12);
9156 decalsystem->vertex3f = (float *)(decalsystem->texcoord2f + decalsystem->maxdecals*6);
9157 decalsystem->element3i = (int *)(decalsystem->vertex3f + decalsystem->maxdecals*9);
9158 decalsystem->element3s = (useshortelements ? ((unsigned short *)(decalsystem->element3i + decalsystem->maxdecals*3)) : NULL);
9159 if (decalsystem->numdecals)
9160 memcpy(decalsystem->decals, old.decals, decalsystem->numdecals * sizeof(tridecal_t));
9161 if (old.decals)
9162 Mem_Free(old.decals);
9163 for (i = 0;i < decalsystem->maxdecals*3;i++)
9164 decalsystem->element3i[i] = i;
9165 if (useshortelements)
9166 for (i = 0;i < decalsystem->maxdecals*3;i++)
9167 decalsystem->element3s[i] = i;
9168 }
9169
9170 // grab a decal and search for another free slot for the next one
9171 decal = &decalsystem->decals[decalsystem->numdecals++];
9172
9173 // initialize the decal
9174 decal->lived = 0;
9175 decal->triangleindex = triangleindex;
9176 decal->surfaceindex = surfaceindex;
9177 decal->decalsequence = decalsequence;
9178 decal->color4f[0][0] = c0[0];
9179 decal->color4f[0][1] = c0[1];
9180 decal->color4f[0][2] = c0[2];
9181 decal->color4f[0][3] = 1;
9182 decal->color4f[1][0] = c1[0];
9183 decal->color4f[1][1] = c1[1];
9184 decal->color4f[1][2] = c1[2];
9185 decal->color4f[1][3] = 1;
9186 decal->color4f[2][0] = c2[0];
9187 decal->color4f[2][1] = c2[1];
9188 decal->color4f[2][2] = c2[2];
9189 decal->color4f[2][3] = 1;
9190 decal->vertex3f[0][0] = v0[0];
9191 decal->vertex3f[0][1] = v0[1];
9192 decal->vertex3f[0][2] = v0[2];
9193 decal->vertex3f[1][0] = v1[0];
9194 decal->vertex3f[1][1] = v1[1];
9195 decal->vertex3f[1][2] = v1[2];
9196 decal->vertex3f[2][0] = v2[0];
9197 decal->vertex3f[2][1] = v2[1];
9198 decal->vertex3f[2][2] = v2[2];
9199 decal->texcoord2f[0][0] = t0[0];
9200 decal->texcoord2f[0][1] = t0[1];
9201 decal->texcoord2f[1][0] = t1[0];
9202 decal->texcoord2f[1][1] = t1[1];
9203 decal->texcoord2f[2][0] = t2[0];
9204 decal->texcoord2f[2][1] = t2[1];
9205 TriangleNormal(v0, v1, v2, decal->plane);
9206 VectorNormalize(decal->plane);
9207 decal->plane[3] = DotProduct(v0, decal->plane);
9208}
client_static_t cls
Definition cl_main.c:116
GLfloat GLfloat GLfloat v2
Definition glquake.h:747
GLfloat v0
Definition glquake.h:739
GLfloat GLfloat v1
Definition glquake.h:743
#define TriangleNormal(a, b, c, n)
Definition mathlib.h:126
bool qbool
Definition qtypes.h:9
mempool_t * levelmempool
Definition client.h:571
int maxdecals
Definition client.h:59
int * element3i
Definition client.h:65
int numdecals
Definition client.h:60
unsigned short * element3s
Definition client.h:66
float * color4f
Definition client.h:64
float * texcoord2f
Definition client.h:63
float * vertex3f
Definition client.h:62
float vertex3f[3][3]
Definition client.h:41
int surfaceindex
Definition client.h:49
float lived
Definition client.h:45
float color4f[3][4]
Definition client.h:42
int triangleindex
Definition client.h:47
float texcoord2f[3][2]
Definition client.h:40
unsigned int decalsequence
Definition client.h:51
float plane[4]
Definition client.h:43

References cls, decalsystem_t::color4f, tridecal_t::color4f, decalsystem_t::decals, tridecal_t::decalsequence, DotProduct, decalsystem_t::element3i, decalsystem_t::element3s, i, client_static_t::levelmempool, tridecal_t::lived, max, decalsystem_t::maxdecals, Mem_Alloc, Mem_Free, NULL, decalsystem_t::numdecals, tridecal_t::plane, tridecal_t::surfaceindex, decalsystem_t::texcoord2f, tridecal_t::texcoord2f, tridecal_t::triangleindex, TriangleNormal, v0, v1, v2, VectorNormalize, decalsystem_t::vertex3f, and tridecal_t::vertex3f.

Referenced by R_DecalSystem_SplatTriangle().

◆ R_DecalSystem_SplatEntities()

void R_DecalSystem_SplatEntities ( const vec3_t worldorigin,
const vec3_t worldnormal,
float r,
float g,
float b,
float a,
float s1,
float t1,
float s2,
float t2,
float worldsize )

◆ R_DecalSystem_SplatEntity()

static void R_DecalSystem_SplatEntity ( entity_render_t * ent,
const vec3_t worldorigin,
const vec3_t worldnormal,
float r,
float g,
float b,
float a,
float s1,
float t1,
float s2,
float t2,
float worldsize,
unsigned int decalsequence )
static

Definition at line 9307 of file gl_rmain.c.

9308{
9309 matrix4x4_t projection;
9310 decalsystem_t *decalsystem;
9311 qbool dynamic;
9312 model_t *model;
9313 const msurface_t *surface;
9314 const msurface_t *surfaces;
9315 const texture_t *texture;
9316 int numtriangles;
9317 int surfaceindex;
9318 int triangleindex;
9319 float localorigin[3];
9320 float localnormal[3];
9321 float localmins[3];
9322 float localmaxs[3];
9323 float localsize;
9324 //float normal[3];
9325 float planes[6][4];
9326 float angles[3];
9327 bih_t *bih;
9328 int bih_triangles_count;
9329 int bih_triangles[256];
9330 int bih_surfaces[256];
9331
9332 decalsystem = &ent->decalsystem;
9333 model = ent->model;
9334 if (!model || !ent->allowdecals || ent->alpha < 1 || (ent->flags & (RENDER_ADDITIVE | RENDER_NODEPTHTEST)))
9335 {
9337 return;
9338 }
9339
9340 if (!model->brush.data_leafs && !cl_decals_models.integer)
9341 {
9342 if (decalsystem->model)
9343 R_DecalSystem_Reset(decalsystem);
9344 return;
9345 }
9346
9347 if (decalsystem->model != model)
9348 R_DecalSystem_Reset(decalsystem);
9349 decalsystem->model = model;
9350
9351 RSurf_ActiveModelEntity(ent, true, false, false);
9352
9353 Matrix4x4_Transform(&rsurface.inversematrix, worldorigin, localorigin);
9354 Matrix4x4_Transform3x3(&rsurface.inversematrix, worldnormal, localnormal);
9355 VectorNormalize(localnormal);
9356 localsize = worldsize*rsurface.inversematrixscale;
9357 localmins[0] = localorigin[0] - localsize;
9358 localmins[1] = localorigin[1] - localsize;
9359 localmins[2] = localorigin[2] - localsize;
9360 localmaxs[0] = localorigin[0] + localsize;
9361 localmaxs[1] = localorigin[1] + localsize;
9362 localmaxs[2] = localorigin[2] + localsize;
9363
9364 //VectorCopy(localnormal, planes[4]);
9365 //VectorVectors(planes[4], planes[2], planes[0]);
9366 AnglesFromVectors(angles, localnormal, NULL, false);
9367 AngleVectors(angles, planes[0], planes[2], planes[4]);
9368 VectorNegate(planes[0], planes[1]);
9369 VectorNegate(planes[2], planes[3]);
9370 VectorNegate(planes[4], planes[5]);
9371 planes[0][3] = DotProduct(planes[0], localorigin) - localsize;
9372 planes[1][3] = DotProduct(planes[1], localorigin) - localsize;
9373 planes[2][3] = DotProduct(planes[2], localorigin) - localsize;
9374 planes[3][3] = DotProduct(planes[3], localorigin) - localsize;
9375 planes[4][3] = DotProduct(planes[4], localorigin) - localsize;
9376 planes[5][3] = DotProduct(planes[5], localorigin) - localsize;
9377
9378#if 1
9379// works
9380{
9381 matrix4x4_t forwardprojection;
9382 Matrix4x4_CreateFromQuakeEntity(&forwardprojection, localorigin[0], localorigin[1], localorigin[2], angles[0], angles[1], angles[2], localsize);
9383 Matrix4x4_Invert_Simple(&projection, &forwardprojection);
9384}
9385#else
9386// broken
9387{
9388 float projectionvector[4][3];
9389 VectorScale(planes[0], ilocalsize, projectionvector[0]);
9390 VectorScale(planes[2], ilocalsize, projectionvector[1]);
9391 VectorScale(planes[4], ilocalsize, projectionvector[2]);
9392 projectionvector[0][0] = planes[0][0] * ilocalsize;
9393 projectionvector[0][1] = planes[1][0] * ilocalsize;
9394 projectionvector[0][2] = planes[2][0] * ilocalsize;
9395 projectionvector[1][0] = planes[0][1] * ilocalsize;
9396 projectionvector[1][1] = planes[1][1] * ilocalsize;
9397 projectionvector[1][2] = planes[2][1] * ilocalsize;
9398 projectionvector[2][0] = planes[0][2] * ilocalsize;
9399 projectionvector[2][1] = planes[1][2] * ilocalsize;
9400 projectionvector[2][2] = planes[2][2] * ilocalsize;
9401 projectionvector[3][0] = -(localorigin[0]*projectionvector[0][0]+localorigin[1]*projectionvector[1][0]+localorigin[2]*projectionvector[2][0]);
9402 projectionvector[3][1] = -(localorigin[0]*projectionvector[0][1]+localorigin[1]*projectionvector[1][1]+localorigin[2]*projectionvector[2][1]);
9403 projectionvector[3][2] = -(localorigin[0]*projectionvector[0][2]+localorigin[1]*projectionvector[1][2]+localorigin[2]*projectionvector[2][2]);
9404 Matrix4x4_FromVectors(&projection, projectionvector[0], projectionvector[1], projectionvector[2], projectionvector[3]);
9405}
9406#endif
9407
9408 dynamic = model->surfmesh.isanimated;
9409 surfaces = model->data_surfaces;
9410
9411 bih = NULL;
9412 bih_triangles_count = -1;
9413 if(!dynamic)
9414 {
9415 if(model->render_bih.numleafs)
9416 bih = &model->render_bih;
9417 else if(model->collision_bih.numleafs)
9418 bih = &model->collision_bih;
9419 }
9420 if(bih)
9421 bih_triangles_count = BIH_GetTriangleListForBox(bih, sizeof(bih_triangles) / sizeof(*bih_triangles), bih_triangles, bih_surfaces, localmins, localmaxs);
9422 if(bih_triangles_count == 0)
9423 return;
9424 if(bih_triangles_count > (int) (sizeof(bih_triangles) / sizeof(*bih_triangles))) // hit too many, likely bad anyway
9425 return;
9426 if(bih_triangles_count > 0)
9427 {
9428 for (triangleindex = 0; triangleindex < bih_triangles_count; ++triangleindex)
9429 {
9430 surfaceindex = bih_surfaces[triangleindex];
9431 surface = surfaces + surfaceindex;
9432 texture = surface->texture;
9433 if (!texture)
9434 continue;
9436 continue;
9437 if (texture->surfaceflags & Q3SURFACEFLAG_NOMARKS)
9438 continue;
9439 R_DecalSystem_SplatTriangle(decalsystem, r, g, b, a, s1, t1, s2, t2, decalsequence, dynamic, planes, &projection, bih_triangles[triangleindex], surfaceindex);
9440 }
9441 }
9442 else
9443 {
9444 for (surfaceindex = model->submodelsurfaces_start;surfaceindex < model->submodelsurfaces_end;surfaceindex++)
9445 {
9446 surface = surfaces + surfaceindex;
9447 // check cull box first because it rejects more than any other check
9448 if (!dynamic && !BoxesOverlap(surface->mins, surface->maxs, localmins, localmaxs))
9449 continue;
9450 // skip transparent surfaces
9451 texture = surface->texture;
9452 if (!texture)
9453 continue;
9455 continue;
9456 if (texture->surfaceflags & Q3SURFACEFLAG_NOMARKS)
9457 continue;
9458 numtriangles = surface->num_triangles;
9459 for (triangleindex = 0; triangleindex < numtriangles; triangleindex++)
9460 R_DecalSystem_SplatTriangle(decalsystem, r, g, b, a, s1, t1, s2, t2, decalsequence, dynamic, planes, &projection, triangleindex + surface->num_firsttriangle, surfaceindex);
9461 }
9462 }
9463}
int BIH_GetTriangleListForBox(const bih_t *bih, int maxtriangles, int *trianglelist_idx, int *trianglelist_surf, const float *mins, const float *maxs)
Definition bih.c:211
vector angles
void R_DecalSystem_Reset(decalsystem_t *decalsystem)
Definition gl_rmain.c:9134
static void R_DecalSystem_SplatTriangle(decalsystem_t *decalsystem, float r, float g, float b, float a, float s1, float t1, float s2, float t2, unsigned int decalsequence, qbool dynamic, float(*planes)[4], matrix4x4_t *projection, int triangleindex, int surfaceindex)
Definition gl_rmain.c:9214
rsurfacestate_t rsurface
Definition gl_rmain.c:6919
cvar_t cl_decals_models
void RSurf_ActiveModelEntity(const entity_render_t *ent, qbool wantnormals, qbool wanttangents, qbool prepass)
Definition gl_rmain.c:6921
GLenum GLenum GLuint texture
Definition glquake.h:613
void AnglesFromVectors(vec3_t angles, const vec3_t forward, const vec3_t up, qbool flippitch)
LadyHavoc: calculates pitch/yaw/roll angles from forward and up vectors.
Definition mathlib.c:650
void AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition mathlib.c:444
#define VectorNegate(a, b)
Definition mathlib.h:95
#define VectorScale(in, scale, out)
Definition mathlib.h:111
void Matrix4x4_Transform(const matrix4x4_t *in, const float v[3], float out[3])
Definition matrixlib.c:1657
void Matrix4x4_Transform3x3(const matrix4x4_t *in, const float v[3], float out[3])
Definition matrixlib.c:1685
void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, double x, double y, double z, double pitch, double yaw, double roll, double scale)
Definition matrixlib.c:715
void Matrix4x4_Invert_Simple(matrix4x4_t *out, const matrix4x4_t *in1)
Definition matrixlib.c:422
void Matrix4x4_FromVectors(matrix4x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3])
Definition matrixlib.c:970
#define MATERIALFLAG_SKY
Definition model_brush.h:92
#define MATERIALFLAG_REFRACTION
#define MATERIALFLAG_WATERSHADER
#define MATERIALFLAG_NODEPTHTEST
Definition model_brush.h:83
#define MATERIALFLAG_SHORTDEPTHRANGE
#define Q3SURFACEFLAG_NOMARKS
#define RENDER_ADDITIVE
Definition protocol.h:370
#define RENDER_NODEPTHTEST
Definition protocol.h:369
Definition bih.h:70
model_t * model
Definition client.h:57
decalsystem_t decalsystem
Definition client.h:438
int num_firsttriangle
int num_triangles
range of triangles and vertices in model->surfmesh
texture_t * texture
the texture to use on the surface
vec3_t mins
bounding box for onscreen checks
float inversematrixscale
Definition render.h:723
matrix4x4_t inversematrix
Definition render.h:720

References a, entity_render_t::allowdecals, entity_render_t::alpha, angles, AnglesFromVectors(), AngleVectors(), b, BIH_GetTriangleListForBox(), BoxesOverlap, cl_decals_models, entity_render_t::decalsystem, DotProduct, entity_render_t::flags, g, cvar_t::integer, rsurfacestate_t::inversematrix, rsurfacestate_t::inversematrixscale, MATERIALFLAG_BLENDED, MATERIALFLAG_NODEPTHTEST, MATERIALFLAG_REFRACTION, MATERIALFLAG_SHORTDEPTHRANGE, MATERIALFLAG_SKY, MATERIALFLAG_WATERSHADER, Matrix4x4_CreateFromQuakeEntity(), Matrix4x4_FromVectors(), Matrix4x4_Invert_Simple(), Matrix4x4_Transform(), Matrix4x4_Transform3x3(), msurface_t::maxs, msurface_t::mins, decalsystem_t::model, entity_render_t::model, model, NULL, msurface_t::num_firsttriangle, msurface_t::num_triangles, Q3SURFACEFLAG_NOMARKS, r, R_DecalSystem_Reset(), R_DecalSystem_SplatTriangle(), RENDER_ADDITIVE, RENDER_NODEPTHTEST, RSurf_ActiveModelEntity(), rsurface, msurface_t::texture, texture, VectorNegate, VectorNormalize, and VectorScale.

Referenced by R_DecalSystem_ApplySplatEntities().

◆ R_DecalSystem_SplatTriangle()

static void R_DecalSystem_SplatTriangle ( decalsystem_t * decalsystem,
float r,
float g,
float b,
float a,
float s1,
float t1,
float s2,
float t2,
unsigned int decalsequence,
qbool dynamic,
float(*) planes[4],
matrix4x4_t * projection,
int triangleindex,
int surfaceindex )
static

Definition at line 9214 of file gl_rmain.c.

9215{
9216 int cornerindex;
9217 int index;
9218 float v[9][3];
9219 const float *vertex3f;
9220 const float *normal3f;
9221 int numpoints;
9222 float points[2][9][3];
9223 float temp[3];
9224 float tc[9][2];
9225 float f;
9226 float c[9][4];
9227 const int *e;
9228
9229 e = rsurface.modelelement3i + 3*triangleindex;
9230
9231 vertex3f = rsurface.modelvertex3f;
9232 normal3f = rsurface.modelnormal3f;
9233
9234 if (normal3f)
9235 {
9236 for (cornerindex = 0;cornerindex < 3;cornerindex++)
9237 {
9238 index = 3*e[cornerindex];
9239 VectorMA(vertex3f + index, cl_decals_bias.value, normal3f + index, v[cornerindex]);
9240 }
9241 }
9242 else
9243 {
9244 for (cornerindex = 0;cornerindex < 3;cornerindex++)
9245 {
9246 index = 3*e[cornerindex];
9247 VectorCopy(vertex3f + index, v[cornerindex]);
9248 }
9249 }
9250
9251 // cull backfaces
9252 //TriangleNormal(v[0], v[1], v[2], normal);
9253 //if (DotProduct(normal, localnormal) < 0.0f)
9254 // continue;
9255 // clip by each of the box planes formed from the projection matrix
9256 // if anything survives, we emit the decal
9257 numpoints = PolygonF_Clip(3 , v[0] , planes[0][0], planes[0][1], planes[0][2], planes[0][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[1][0]);
9258 if (numpoints < 3)
9259 return;
9260 numpoints = PolygonF_Clip(numpoints, points[1][0], planes[1][0], planes[1][1], planes[1][2], planes[1][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[0][0]);
9261 if (numpoints < 3)
9262 return;
9263 numpoints = PolygonF_Clip(numpoints, points[0][0], planes[2][0], planes[2][1], planes[2][2], planes[2][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[1][0]);
9264 if (numpoints < 3)
9265 return;
9266 numpoints = PolygonF_Clip(numpoints, points[1][0], planes[3][0], planes[3][1], planes[3][2], planes[3][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[0][0]);
9267 if (numpoints < 3)
9268 return;
9269 numpoints = PolygonF_Clip(numpoints, points[0][0], planes[4][0], planes[4][1], planes[4][2], planes[4][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), points[1][0]);
9270 if (numpoints < 3)
9271 return;
9272 numpoints = PolygonF_Clip(numpoints, points[1][0], planes[5][0], planes[5][1], planes[5][2], planes[5][3], 1.0f/64.0f, sizeof(points[0])/sizeof(points[0][0]), v[0]);
9273 if (numpoints < 3)
9274 return;
9275 // some part of the triangle survived, so we have to accept it...
9276 if (dynamic)
9277 {
9278 // dynamic always uses the original triangle
9279 numpoints = 3;
9280 for (cornerindex = 0;cornerindex < 3;cornerindex++)
9281 {
9282 index = 3*e[cornerindex];
9283 VectorCopy(vertex3f + index, v[cornerindex]);
9284 }
9285 }
9286 for (cornerindex = 0;cornerindex < numpoints;cornerindex++)
9287 {
9288 // convert vertex positions to texcoords
9289 Matrix4x4_Transform(projection, v[cornerindex], temp);
9290 tc[cornerindex][0] = (temp[1]+1.0f)*0.5f * (s2-s1) + s1;
9291 tc[cornerindex][1] = (temp[2]+1.0f)*0.5f * (t2-t1) + t1;
9292 // calculate distance fade from the projection origin
9294 f = bound(0.0f, f, 1.0f);
9295 c[cornerindex][0] = r * f;
9296 c[cornerindex][1] = g * f;
9297 c[cornerindex][2] = b * f;
9298 c[cornerindex][3] = 1.0f;
9299 //VectorMA(v[cornerindex], cl_decals_bias.value, localnormal, v[cornerindex]);
9300 }
9301 if (dynamic)
9302 R_DecalSystem_SpawnTriangle(decalsystem, v[0], v[1], v[2], tc[0], tc[1], tc[2], c[0], c[1], c[2], triangleindex, surfaceindex, decalsequence);
9303 else
9304 for (cornerindex = 0;cornerindex < numpoints-2;cornerindex++)
9305 R_DecalSystem_SpawnTriangle(decalsystem, v[0], v[cornerindex+1], v[cornerindex+2], tc[0], tc[cornerindex+1], tc[cornerindex+2], c[0], c[cornerindex+1], c[cornerindex+2], -1, surfaceindex, decalsequence);
9306}
static void R_DecalSystem_SpawnTriangle(decalsystem_t *decalsystem, const float *v0, const float *v1, const float *v2, const float *t0, const float *t1, const float *t2, const float *c0, const float *c1, const float *c2, int triangleindex, int surfaceindex, unsigned int decalsequence)
Definition gl_rmain.c:9141
cvar_t cl_decals_bias
cvar_t cl_decals_newsystem_intensitymultiplier
GLuint index
Definition glquake.h:629
#define VectorMA(a, scale, b, out)
Definition mathlib.h:114
int PolygonF_Clip(int innumpoints, const float *inpoints, float planenormalx, float planenormaly, float planenormalz, float planedist, float epsilon, int outfrontmaxpoints, float *outfrontpoints)
Definition polygon.c:99
void vec2 tc
int * modelelement3i
Definition render.h:649
float * modelvertex3f
Definition render.h:622
float * modelnormal3f
Definition render.h:631

References a, b, bound, cl_decals_bias, cl_decals_newsystem_intensitymultiplier, f, fabs(), g, index, Matrix4x4_Transform(), rsurfacestate_t::modelelement3i, rsurfacestate_t::modelnormal3f, rsurfacestate_t::modelvertex3f, PolygonF_Clip(), r, R_DecalSystem_SpawnTriangle(), rsurface, tc, v, cvar_t::value, VectorCopy, and VectorMA.

Referenced by R_DecalSystem_SplatEntity().

◆ R_DrawBBoxMesh()

static void R_DrawBBoxMesh ( vec3_t mins,
vec3_t maxs,
float cr,
float cg,
float cb,
float ca )
static

Definition at line 6034 of file gl_rmain.c.

6035{
6036 int numvertices = BBOXEDGES * 8;
6037 float vertex3f[BBOXEDGES * 8 * 3], color4f[BBOXEDGES * 8 * 4];
6038 int numtriangles = BBOXEDGES * 12;
6039 unsigned short elements[BBOXEDGES * 36];
6040 int i, edge;
6041 float *v, *c, f1, f2, edgemins[3], edgemaxs[3];
6042
6043 RSurf_ActiveModelEntity(r_refdef.scene.worldentity, false, false, false);
6044
6046 GL_DepthMask(false);
6047 GL_DepthRange(0, 1);
6049
6050 for (edge = 0; edge < BBOXEDGES; edge++)
6051 {
6052 for (i = 0; i < 3; i++)
6053 {
6054 edgemins[i] = mins[i] + (maxs[i] - mins[i]) * bboxedges[edge][i] - 0.25f;
6055 edgemaxs[i] = mins[i] + (maxs[i] - mins[i]) * bboxedges[edge][3 + i] + 0.25f;
6056 }
6057 vertex3f[edge * 24 + 0] = edgemins[0]; vertex3f[edge * 24 + 1] = edgemins[1]; vertex3f[edge * 24 + 2] = edgemins[2];
6058 vertex3f[edge * 24 + 3] = edgemaxs[0]; vertex3f[edge * 24 + 4] = edgemins[1]; vertex3f[edge * 24 + 5] = edgemins[2];
6059 vertex3f[edge * 24 + 6] = edgemins[0]; vertex3f[edge * 24 + 7] = edgemaxs[1]; vertex3f[edge * 24 + 8] = edgemins[2];
6060 vertex3f[edge * 24 + 9] = edgemaxs[0]; vertex3f[edge * 24 + 10] = edgemaxs[1]; vertex3f[edge * 24 + 11] = edgemins[2];
6061 vertex3f[edge * 24 + 12] = edgemins[0]; vertex3f[edge * 24 + 13] = edgemins[1]; vertex3f[edge * 24 + 14] = edgemaxs[2];
6062 vertex3f[edge * 24 + 15] = edgemaxs[0]; vertex3f[edge * 24 + 16] = edgemins[1]; vertex3f[edge * 24 + 17] = edgemaxs[2];
6063 vertex3f[edge * 24 + 18] = edgemins[0]; vertex3f[edge * 24 + 19] = edgemaxs[1]; vertex3f[edge * 24 + 20] = edgemaxs[2];
6064 vertex3f[edge * 24 + 21] = edgemaxs[0]; vertex3f[edge * 24 + 22] = edgemaxs[1]; vertex3f[edge * 24 + 23] = edgemaxs[2];
6065 for (i = 0; i < 36; i++)
6066 elements[edge * 36 + i] = edge * 8 + bboxelements[i];
6067 }
6068 R_FillColors(color4f, numvertices, cr, cg, cb, ca);
6069 if (r_refdef.fogenabled)
6070 {
6071 for (i = 0, v = vertex3f, c = color4f; i < numvertices; i++, v += 3, c += 4)
6072 {
6073 f1 = RSurf_FogVertex(v);
6074 f2 = 1 - f1;
6075 c[0] = c[0] * f1 + r_refdef.fogcolor[0] * f2;
6076 c[1] = c[1] * f1 + r_refdef.fogcolor[1] * f2;
6077 c[2] = c[2] * f1 + r_refdef.fogcolor[2] * f2;
6078 }
6079 }
6080 R_Mesh_PrepareVertices_Generic_Arrays(numvertices, vertex3f, color4f, NULL);
6082 R_SetupShader_Generic_NoTexture(false, false);
6083 R_Mesh_Draw(0, numvertices, 0, numtriangles, NULL, NULL, 0, elements, NULL, 0);
6084}
void GL_DepthMask(int state)
void GL_DepthRange(float nearfrac, float farfrac)
void GL_PolygonOffset(float planeoffset, float depthoffset)
void R_Mesh_ResetTextureState(void)
void R_SetupShader_Generic_NoTexture(qbool usegamma, qbool notrippy)
Definition gl_rmain.c:1488
float RSurf_FogVertex(const float *v)
Definition gl_rmain.c:7324
void R_FillColors(float *out, int verts, float r, float g, float b, float a)
Definition gl_rmain.c:335
static const unsigned short bboxelements[36]
Definition gl_rmain.c:6002
static const float bboxedges[BBOXEDGES][6]
Definition gl_rmain.c:6013
#define BBOXEDGES
Definition gl_rmain.c:6012
qbool fogenabled
Definition render.h:440
float polygonoffset
Definition render.h:459
float fogcolor[3]
Definition render.h:424
float polygonfactor
Definition render.h:458

References BBOXEDGES, bboxedges, bboxelements, r_refdef_t::fogcolor, r_refdef_t::fogenabled, GL_BlendFunc(), GL_DepthMask(), GL_DepthRange(), GL_ONE_MINUS_SRC_ALPHA, GL_PolygonOffset(), GL_SRC_ALPHA, i, maxs, mins, NULL, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, R_FillColors(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), R_Mesh_ResetTextureState(), r_refdef, R_SetupShader_Generic_NoTexture(), RSurf_ActiveModelEntity(), RSurf_FogVertex(), r_refdef_t::scene, v, and r_refdef_scene_t::worldentity.

Referenced by R_DrawEntityBBoxes_Callback().

◆ R_DrawBrushModelsSky()

static int R_DrawBrushModelsSky ( void )
static

only used if skyrendermasked, and normally returns false

Definition at line 4058 of file gl_rmain.c.

4059{
4060 int i, sky;
4061 entity_render_t *ent;
4062
4063 sky = false;
4064 for (i = 0;i < r_refdef.scene.numentities;i++)
4065 {
4067 continue;
4068 ent = r_refdef.scene.entities[i];
4069 if (!ent->model || !ent->model->DrawSky)
4070 continue;
4071 ent->model->DrawSky(ent);
4072 sky = true;
4073 }
4074 return sky;
4075}
void(* DrawSky)(struct entity_render_s *ent)

References model_t::DrawSky, r_refdef_scene_t::entities, r_refdef_viewcache_t::entityvisible, i, entity_render_t::model, r_refdef_scene_t::numentities, r_refdef, r_refdef_t::scene, and r_refdef_t::viewcache.

Referenced by R_RenderScene().

◆ R_DrawCustomSurface()

void R_DrawCustomSurface ( skinframe_t * skinframe,
const matrix4x4_t * texmatrix,
int materialflags,
int firstvertex,
int numvertices,
int firsttriangle,
int numtriangles,
qbool writedepth,
qbool prepass,
qbool ui )

Definition at line 10152 of file gl_rmain.c.

10153{
10154 static texture_t texture;
10155
10156 // fake enough texture and surface state to render this geometry
10157
10158 texture.update_lastrenderframe = -1; // regenerate this texture
10159 texture.basematerialflags = materialflags | MATERIALFLAG_CUSTOMSURFACE | MATERIALFLAG_WALL;
10160 texture.basealpha = 1.0f;
10161 texture.currentskinframe = skinframe;
10162 texture.currenttexmatrix = *texmatrix; // requires MATERIALFLAG_CUSTOMSURFACE
10163 texture.offsetmapping = OFFSETMAPPING_OFF;
10164 texture.offsetscale = 1;
10165 texture.specularscalemod = 1;
10166 texture.specularpowermod = 1;
10167 texture.transparentsort = TRANSPARENTSORT_DISTANCE;
10168
10169 R_DrawCustomSurface_Texture(&texture, texmatrix, materialflags, firstvertex, numvertices, firsttriangle, numtriangles, writedepth, prepass, ui);
10170}
void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui)
Definition gl_rmain.c:10172
#define MATERIALFLAG_CUSTOMSURFACE
@ TRANSPARENTSORT_DISTANCE
Definition r_qshader.h:194
@ OFFSETMAPPING_OFF
Definition r_qshader.h:185

References MATERIALFLAG_CUSTOMSURFACE, MATERIALFLAG_WALL, OFFSETMAPPING_OFF, R_DrawCustomSurface_Texture(), texture, and TRANSPARENTSORT_DISTANCE.

Referenced by R_DrawCorona(), R_Shadow_DrawCursor_TransparentCallback(), R_Shadow_DrawLightSprite_TransparentCallback(), R_SkyBox(), and R_SkySphere().

◆ R_DrawCustomSurface_Texture()

void R_DrawCustomSurface_Texture ( texture_t * texture,
const matrix4x4_t * texmatrix,
int materialflags,
int firstvertex,
int numvertices,
int firsttriangle,
int numtriangles,
qbool writedepth,
qbool prepass,
qbool ui )

Definition at line 10172 of file gl_rmain.c.

10173{
10174 static msurface_t surface;
10175 const msurface_t *surfacelist = &surface;
10176
10177 // fake enough texture and surface state to render this geometry
10178 surface.texture = texture;
10179 surface.num_triangles = numtriangles;
10180 surface.num_firsttriangle = firsttriangle;
10181 surface.num_vertices = numvertices;
10182 surface.num_firstvertex = firstvertex;
10183
10184 // now render it
10189 R_DrawModelTextureSurfaceList(1, &surfacelist, writedepth, prepass, ui);
10190}
static void R_DrawModelTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool prepass, qbool ui)
Definition gl_rmain.c:8832
texture_t * R_GetCurrentTexture(texture_t *t)
Definition gl_rmain.c:6549
int num_firstvertex
qbool uselightmaptexture
Definition render.h:738
rtexture_t * lightmaptexture
Definition render.h:734
rtexture_t * deluxemaptexture
Definition render.h:735
texture_t * texture
Definition render.h:733

References rsurfacestate_t::deluxemaptexture, rsurfacestate_t::lightmaptexture, NULL, msurface_t::num_firsttriangle, msurface_t::num_firstvertex, msurface_t::num_triangles, msurface_t::num_vertices, R_DrawModelTextureSurfaceList(), R_GetCurrentTexture(), rsurface, msurface_t::texture, rsurfacestate_t::texture, texture, and rsurfacestate_t::uselightmaptexture.

Referenced by R_DrawCustomSurface(), and R_Model_Sprite_Draw_TransparentCallback().

◆ R_DrawDebugModel()

static void R_DrawDebugModel ( void )
static

Definition at line 9747 of file gl_rmain.c.

9748{
9750 int j, flagsmask;
9751 const msurface_t *surface;
9752 model_t *model = ent->model;
9753
9754 if (!sv.active && !cls.demoplayback && ent != r_refdef.scene.worldentity)
9755 return;
9756
9757 if (r_showoverdraw.value > 0)
9758 {
9759 float c = r_refdef.view.colorscale * r_showoverdraw.value * 0.125f;
9760 flagsmask = MATERIALFLAG_SKY | MATERIALFLAG_WALL;
9761 R_SetupShader_Generic_NoTexture(false, false);
9762 GL_DepthTest(false);
9763 GL_DepthMask(false);
9764 GL_DepthRange(0, 1);
9766 for (j = model->submodelsurfaces_start;j < model->submodelsurfaces_end;j++)
9767 {
9769 continue;
9770 surface = model->data_surfaces + j;
9772 if ((rsurface.texture->currentmaterialflags & flagsmask) && surface->num_triangles)
9773 {
9777 GL_Color(c, 0, 0, 1.0f);
9778 else if (ent == r_refdef.scene.worldentity)
9779 GL_Color(c, c, c, 1.0f);
9780 else
9781 GL_Color(0, c, 0, 1.0f);
9784 }
9785 }
9787 }
9788
9789 flagsmask = MATERIALFLAG_SKY | MATERIALFLAG_WALL;
9790
9791// R_Mesh_ResetTextureState();
9792 R_SetupShader_Generic_NoTexture(false, false);
9793 GL_DepthRange(0, 1);
9795 GL_DepthMask(false);
9797
9798 if (r_showcollisionbrushes.value > 0 && model->collision_bih.numleafs)
9799 {
9800 int triangleindex;
9801 int bihleafindex;
9802 qbool cullbox = false;
9803 const q3mbrush_t *brush;
9804 const bih_t *bih = &model->collision_bih;
9805 const bih_leaf_t *bihleaf;
9806 float vertex3f[3][3];
9808 for (bihleafindex = 0, bihleaf = bih->leafs;bihleafindex < bih->numleafs;bihleafindex++, bihleaf++)
9809 {
9810 if (cullbox && R_CullFrustum(bihleaf->mins, bihleaf->maxs))
9811 continue;
9812 switch (bihleaf->type)
9813 {
9814 case BIH_BRUSH:
9815 brush = model->brush.data_brushes + bihleaf->itemindex;
9816 if (brush->colbrushf && brush->colbrushf->numtriangles)
9817 {
9818 GL_Color((bihleafindex & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 5) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 10) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, r_showcollisionbrushes.value);
9819 R_Mesh_PrepareVertices_Generic_Arrays(brush->colbrushf->numpoints, brush->colbrushf->points->v, NULL, NULL);
9820 R_Mesh_Draw(0, brush->colbrushf->numpoints, 0, brush->colbrushf->numtriangles, brush->colbrushf->elements, NULL, 0, NULL, NULL, 0);
9821 }
9822 break;
9824 triangleindex = bihleaf->itemindex;
9825 VectorCopy(model->brush.data_collisionvertex3f + 3*model->brush.data_collisionelement3i[triangleindex*3+0], vertex3f[0]);
9826 VectorCopy(model->brush.data_collisionvertex3f + 3*model->brush.data_collisionelement3i[triangleindex*3+1], vertex3f[1]);
9827 VectorCopy(model->brush.data_collisionvertex3f + 3*model->brush.data_collisionelement3i[triangleindex*3+2], vertex3f[2]);
9828 GL_Color((bihleafindex & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 5) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 10) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, r_showcollisionbrushes.value);
9831 break;
9832 case BIH_RENDERTRIANGLE:
9833 triangleindex = bihleaf->itemindex;
9834 VectorCopy(model->surfmesh.data_vertex3f + 3*model->surfmesh.data_element3i[triangleindex*3+0], vertex3f[0]);
9835 VectorCopy(model->surfmesh.data_vertex3f + 3*model->surfmesh.data_element3i[triangleindex*3+1], vertex3f[1]);
9836 VectorCopy(model->surfmesh.data_vertex3f + 3*model->surfmesh.data_element3i[triangleindex*3+2], vertex3f[2]);
9837 GL_Color((bihleafindex & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 5) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, ((bihleafindex >> 10) & 31) * (1.0f / 32.0f) * r_refdef.view.colorscale, r_showcollisionbrushes.value);
9840 break;
9841 }
9842 }
9843 }
9844
9846
9847#ifndef USE_GLES2
9848 if (r_showtris.value > 0 && qglPolygonMode)
9849 {
9851 {
9853 GL_DepthMask(false);
9854 }
9855 else
9856 {
9858 GL_DepthMask(true);
9859 }
9860 qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE);CHECKGLERROR
9861 for (j = model->submodelsurfaces_start; j < model->submodelsurfaces_end; j++)
9862 {
9864 continue;
9865 surface = model->data_surfaces + j;
9867 if ((rsurface.texture->currentmaterialflags & flagsmask) && surface->num_triangles)
9868 {
9872 else if (ent == r_refdef.scene.worldentity)
9874 else
9878 }
9879 }
9880 qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);CHECKGLERROR
9882 }
9883
9884# if 0
9885 // FIXME! implement r_shownormals with just triangles
9886 if (r_shownormals.value != 0 && qglBegin)
9887 {
9888 int l, k;
9889 vec3_t v;
9891 {
9893 GL_DepthMask(false);
9894 }
9895 else
9896 {
9898 GL_DepthMask(true);
9899 }
9900 for (j = model->submodelsurfaces_start; j < model->submodelsurfaces_end; j++)
9901 {
9903 continue;
9904 surface = model->data_surfaces + j;
9906 if ((rsurface.texture->currentmaterialflags & flagsmask) && surface->num_triangles)
9907 {
9909 qglBegin(GL_LINES);
9911 {
9912 for (k = 0, l = rsurface.batchfirstvertex;k < rsurface.batchnumvertices;k++, l++)
9913 {
9915 GL_Color(0, 0, r_refdef.view.colorscale, 1);
9916 qglVertex3f(v[0], v[1], v[2]);
9919 qglVertex3f(v[0], v[1], v[2]);
9920 }
9921 }
9923 {
9924 for (k = 0, l = rsurface.batchfirstvertex;k < rsurface.batchnumvertices;k++, l++)
9925 {
9927 GL_Color(r_refdef.view.colorscale, 0, 0, 1);
9928 qglVertex3f(v[0], v[1], v[2]);
9931 qglVertex3f(v[0], v[1], v[2]);
9932 }
9933 }
9935 {
9936 for (k = 0, l = rsurface.batchfirstvertex;k < rsurface.batchnumvertices;k++, l++)
9937 {
9939 GL_Color(0, r_refdef.view.colorscale, 0, 1);
9940 qglVertex3f(v[0], v[1], v[2]);
9943 qglVertex3f(v[0], v[1], v[2]);
9944 }
9945 }
9947 {
9948 for (k = 0, l = rsurface.batchfirstvertex;k < rsurface.batchnumvertices;k++, l++)
9949 {
9951 GL_Color(0, 0, r_refdef.view.colorscale, 1);
9952 qglVertex3f(v[0], v[1], v[2]);
9955 qglVertex3f(v[0], v[1], v[2]);
9956 }
9957 }
9958 qglEnd();
9960 }
9961 }
9963 }
9964# endif
9965#endif
9966}
@ BIH_COLLISIONTRIANGLE
Definition bih.h:30
@ BIH_RENDERTRIANGLE
Definition bih.h:31
@ BIH_BRUSH
Definition bih.h:29
void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:7388
void RSurf_DrawBatch(void)
Definition gl_rmain.c:8477
qbool R_CullFrustum(const vec3_t mins, const vec3_t maxs)
Definition gl_rmain.c:3464
#define GL_FRONT_AND_BACK
Definition glquake.h:136
#define GL_FILL
Definition glquake.h:108
#define GL_LINE
Definition glquake.h:107
#define MATERIALFLAG_NOCULLFACE
#define BATCHNEED_NOGAPS
Definition render.h:793
#define BATCHNEED_ARRAY_NORMAL
Definition render.h:786
#define BATCHNEED_ARRAY_VECTOR
Definition render.h:787
#define BATCHNEED_ARRAY_VERTEX
Definition render.h:785
server_t sv
local server
Definition sv_main.c:223
float maxs[3]
Definition bih.h:61
bih_leaftype_t type
Definition bih.h:59
int itemindex
Definition bih.h:65
float mins[3]
Definition bih.h:60
bih_leaf_t * leafs
Definition bih.h:74
qbool demoplayback
Definition client.h:587
struct colbrushf_s * colbrushf
float colorscale
global RGB color multiplier for rendering
Definition render.h:302
int cullface_back
Definition render.h:318
unsigned char * world_surfacevisible
Definition render.h:342
float * batchsvector3f
Definition render.h:676
int batchnumvertices
Definition render.h:670
entity_render_t * entity
Definition render.h:767
float * batchtvector3f
Definition render.h:679
int batchfirstvertex
Definition render.h:669
float * batchvertex3f
Definition render.h:673
float * batchnormal3f
Definition render.h:682
qbool active
false if only a net client
Definition server.h:66
int currentmaterialflags

References server_t::active, rsurfacestate_t::batchfirstvertex, BATCHNEED_ARRAY_NORMAL, BATCHNEED_ARRAY_VECTOR, BATCHNEED_ARRAY_VERTEX, BATCHNEED_NOGAPS, rsurfacestate_t::batchnormal3f, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchsvector3f, rsurfacestate_t::batchtvector3f, rsurfacestate_t::batchvertex3f, BIH_BRUSH, BIH_COLLISIONTRIANGLE, BIH_RENDERTRIANGLE, CHECKGLERROR, cls, q3mbrush_t::colbrushf, r_refdef_view_t::colorscale, r_refdef_view_t::cullface_back, texture_t::currentmaterialflags, client_static_t::demoplayback, rsurfacestate_t::entity, GL_BlendFunc(), GL_Color(), GL_CullFace(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_FILL, GL_FRONT_AND_BACK, GL_LINE, GL_NONE, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_PolygonOffset(), GL_SRC_ALPHA, GL_ZERO, cvar_t::integer, bih_leaf_t::itemindex, bih_t::leafs, MATERIALFLAG_BLENDED, MATERIALFLAG_NOCULLFACE, MATERIALFLAG_SKY, MATERIALFLAG_WALL, bih_leaf_t::maxs, bih_leaf_t::mins, entity_render_t::model, model, NULL, msurface_t::num_triangles, polygonelement3i, polygonelement3s, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, R_CullFrustum(), R_GetCurrentTexture(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), r_refdef, R_SetupShader_Generic_NoTexture(), r_showcollisionbrushes, r_showcollisionbrushes_polygonfactor, r_showcollisionbrushes_polygonoffset, r_showdisabledepthtest, r_shownormals, r_showoverdraw, r_showtris, RSurf_DrawBatch(), RSurf_PrepareVerticesForBatch(), rsurface, r_refdef_t::scene, sv, msurface_t::texture, rsurfacestate_t::texture, bih_leaf_t::type, v, cvar_t::value, VectorCopy, VectorMA, r_refdef_t::view, r_refdef_t::viewcache, r_refdef_viewcache_t::world_surfacevisible, and r_refdef_scene_t::worldentity.

Referenced by R_DrawModelSurfaces().

◆ R_DrawEntityBBoxes()

static void R_DrawEntityBBoxes ( prvm_prog_t * prog)
static

Definition at line 6120 of file gl_rmain.c.

6121{
6122 int i;
6123 prvm_edict_t *edict;
6124 vec3_t center;
6125
6126 if (prog == NULL)
6127 return;
6128
6129 for (i = 0; i < prog->num_edicts; i++)
6130 {
6131 edict = PRVM_EDICT_NUM(i);
6132 if (edict->free)
6133 continue;
6134 // exclude the following for now, as they don't live in world coordinate space and can't be solid:
6135 if (PRVM_gameedictedict(edict, tag_entity) != 0)
6136 continue;
6137 if (prog == SVVM_prog && PRVM_serveredictedict(edict, viewmodelforclient) != 0)
6138 continue;
6139 VectorLerp(edict->priv.server->areamins, 0.5f, edict->priv.server->areamaxs, center);
6141 }
6142}
entity viewmodelforclient
entity tag_entity
static void R_DrawEntityBBoxes_Callback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rmain.c:6086
#define VectorLerp(v1, lerp, v2, out)
Definition mathlib.h:120
void R_MeshQueue_AddTransparent(dptransparentsortcategory_t category, const vec3_t center, void(*callback)(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist), const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)
Definition meshqueue.c:33
#define PRVM_serveredictedict(ed, fieldname)
Definition progsvm.h:175
#define PRVM_gameedictedict(ed, fieldname)
Definition progsvm.h:163
#define PRVM_EDICT_NUM(n)
Definition progsvm.h:867
#define SVVM_prog
Definition progsvm.h:766
qbool free
true if this edict is unused
Definition progsvm.h:93
union prvm_edict_t::@29 priv
struct edict_engineprivate_s * server
FIXME: this server pointer really means world, not server (it is used by both server qc and client qc...
Definition progsvm.h:106
int num_edicts
copies of some vars that were former read from sv
Definition progsvm.h:671

References prvm_edict_t::free, i, NULL, prvm_prog_t::num_edicts, prvm_edict_t::priv, PRVM_EDICT_NUM, PRVM_gameedictedict, PRVM_serveredictedict, R_DrawEntityBBoxes_Callback(), R_MeshQueue_AddTransparent(), prvm_edict_t::server, SVVM_prog, tag_entity, TRANSPARENTSORT_DISTANCE, VectorLerp, and viewmodelforclient.

Referenced by R_RenderScene().

◆ R_DrawEntityBBoxes_Callback()

static void R_DrawEntityBBoxes_Callback ( const entity_render_t * ent,
const rtlight_t * rtlight,
int numsurfaces,
int * surfacelist )
static

Definition at line 6086 of file gl_rmain.c.

6087{
6088 // hacky overloading of the parameters
6089 prvm_prog_t *prog = (prvm_prog_t *)rtlight;
6090 int i;
6091 float color[4];
6092 prvm_edict_t *edict;
6093
6095 R_SetupShader_Generic_NoTexture(false, false);
6096
6097 for (i = 0;i < numsurfaces;i++)
6098 {
6099 edict = PRVM_EDICT_NUM(surfacelist[i]);
6100 switch ((int)PRVM_serveredictfloat(edict, solid))
6101 {
6102 case SOLID_NOT: Vector4Set(color, 1, 1, 1, 0.05);break;
6103 case SOLID_TRIGGER: Vector4Set(color, 1, 0, 1, 0.10);break;
6104 case SOLID_BBOX: Vector4Set(color, 0, 1, 0, 0.10);break;
6105 case SOLID_SLIDEBOX: Vector4Set(color, 1, 0, 0, 0.10);break;
6106 case SOLID_BSP: Vector4Set(color, 0, 0, 1, 0.05);break;
6107 case SOLID_CORPSE: Vector4Set(color, 1, 0.5, 0, 0.05);break;
6108 default: Vector4Set(color, 0, 0, 0, 0.50);break;
6109 }
6110 if (prog == CLVM_prog)
6112 else
6113 color[3] *= r_showbboxes.value;
6114 color[3] = bound(0, color[3], 1);
6116 R_DrawBBoxMesh(edict->priv.server->areamins, edict->priv.server->areamaxs, color[0], color[1], color[2], color[3]);
6117 }
6118}
float solid
vector color
static void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, float ca)
Definition gl_rmain.c:6034
#define CLVM_prog
Definition progsvm.h:767
#define PRVM_serveredictfloat(ed, fieldname)
Definition progsvm.h:172
#define SOLID_BBOX
touch on edge, block
Definition server.h:334
#define SOLID_SLIDEBOX
touch on edge, but not an onground
Definition server.h:335
#define SOLID_CORPSE
same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
Definition server.h:338
#define SOLID_NOT
no interaction with other objects
Definition server.h:332
#define SOLID_TRIGGER
touch on edge, but not blocking
Definition server.h:333
#define SOLID_BSP
bsp clip, touch on edge, block
Definition server.h:336

References bound, CLVM_prog, color, GL_CullFace(), GL_DepthTest(), GL_NONE, i, cvar_t::integer, prvm_edict_t::priv, PRVM_EDICT_NUM, PRVM_serveredictfloat, R_DrawBBoxMesh(), R_SetupShader_Generic_NoTexture(), r_showbboxes, r_showbboxes_client, r_showdisabledepthtest, prvm_edict_t::server, solid, SOLID_BBOX, SOLID_BSP, SOLID_CORPSE, SOLID_NOT, SOLID_SLIDEBOX, SOLID_TRIGGER, cvar_t::value, and Vector4Set.

Referenced by R_DrawEntityBBoxes().

◆ R_DrawLoc_Callback()

static void R_DrawLoc_Callback ( const entity_render_t * ent,
const rtlight_t * rtlight,
int numsurfaces,
int * surfacelist )
static

Definition at line 9078 of file gl_rmain.c.

9079{
9080 int i, j;
9081 cl_locnode_t *loc = (cl_locnode_t *)ent;
9082 vec3_t mins, size;
9083 float vertex3f[6*4*3];
9086 GL_DepthMask(false);
9087 GL_DepthRange(0, 1);
9089 GL_DepthTest(true);
9092
9093// R_Mesh_ResetTextureState();
9094
9095 i = surfacelist[0];
9096 GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_refdef.view.colorscale,
9097 ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_refdef.view.colorscale,
9098 ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_refdef.view.colorscale,
9099 surfacelist[0] < 0 ? 0.5f : 0.125f);
9100
9101 if (VectorCompare(loc->mins, loc->maxs))
9102 {
9103 VectorSet(size, 2, 2, 2);
9104 VectorMA(loc->mins, -0.5f, size, mins);
9105 }
9106 else
9107 {
9108 VectorCopy(loc->mins, mins);
9109 VectorSubtract(loc->maxs, loc->mins, size);
9110 }
9111
9112 for (i = 0;i < 6*4*3;)
9113 for (j = 0;j < 3;j++, i++)
9114 vertex3f[i] = mins[j] + size[j] * locboxvertex3f[i];
9115
9117 R_SetupShader_Generic_NoTexture(false, false);
9118 R_Mesh_Draw(0, 6*4, 0, 6*2, NULL, NULL, 0, locboxelements, NULL, 0);
9119}
unsigned short locboxelements[6 *2 *3]
Definition gl_rmain.c:9068
float locboxvertex3f[6 *4 *3]
Definition gl_rmain.c:9058
#define VectorCompare(a, b)
Definition mathlib.h:113
vec3_t mins
Definition client.h:725
vec3_t maxs
Definition client.h:725

References CHECKGLERROR, r_refdef_view_t::colorscale, GL_BlendFunc(), GL_Color(), GL_CullFace(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_NONE, GL_ONE_MINUS_SRC_ALPHA, GL_PolygonOffset(), GL_SRC_ALPHA, i, identitymatrix, locboxelements, locboxvertex3f, cl_locnode_t::maxs, cl_locnode_t::mins, mins, NULL, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, R_EntityMatrix(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), r_refdef, R_SetupShader_Generic_NoTexture(), size, VectorCompare, VectorCopy, VectorMA, VectorSet, VectorSubtract, and r_refdef_t::view.

Referenced by R_DrawLocs().

◆ R_DrawLocs()

void R_DrawLocs ( void )
static

Definition at line 9121 of file gl_rmain.c.

9122{
9123 int index;
9124 cl_locnode_t *loc, *nearestloc;
9125 vec3_t center;
9127 for (loc = cl.locnodes, index = 0;loc;loc = loc->next, index++)
9128 {
9129 VectorLerp(loc->mins, 0.5f, loc->maxs, center);
9131 }
9132}
cl_locnode_t * CL_Locs_FindNearest(const vec3_t point)
Definition cl_main.c:2193
static void R_DrawLoc_Callback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rmain.c:9078
struct cl_locnode_s * next
Definition client.h:723
vec3_t movement_origin
Definition client.h:809
cl_locnode_t * locnodes
Definition client.h:1125

References cl, CL_Locs_FindNearest(), index, client_state_t::locnodes, cl_locnode_t::maxs, cl_locnode_t::mins, client_state_t::movement_origin, cl_locnode_t::next, NULL, R_DrawLoc_Callback(), R_MeshQueue_AddTransparent(), TRANSPARENTSORT_DISTANCE, and VectorLerp.

Referenced by R_RenderScene().

◆ R_DrawModelDecals()

static void R_DrawModelDecals ( void )
static

Definition at line 9711 of file gl_rmain.c.

9712{
9713 int i, numdecals;
9714
9715 // fade faster when there are too many decals
9717 for (i = 0;i < r_refdef.scene.numentities;i++)
9719
9721 for (i = 0;i < r_refdef.scene.numentities;i++)
9724
9726
9728 for (i = 0;i < r_refdef.scene.numentities;i++)
9730
9731 r_refdef.stats[r_stat_totaldecals] += numdecals;
9732
9734 return;
9735
9737
9738 for (i = 0;i < r_refdef.scene.numentities;i++)
9739 {
9741 continue;
9744 }
9745}
static void R_DecalSystem_ApplySplatEntitiesQueue(void)
Definition gl_rmain.c:9522
static void R_DrawModelDecals_Entity(entity_render_t *ent)
Definition gl_rmain.c:9581
cvar_t r_drawdecals
static void R_DrawModelDecals_FadeEntity(entity_render_t *ent)
Definition gl_rmain.c:9533
@ r_stat_totaldecals
Definition r_stats.h:23

References entity_render_t::decalsystem, r_refdef_scene_t::entities, r_refdef_viewcache_t::entityvisible, i, cvar_t::integer, decalsystem_t::numdecals, r_refdef_scene_t::numentities, R_DecalSystem_ApplySplatEntitiesQueue(), r_drawdecals, R_DrawModelDecals_Entity(), R_DrawModelDecals_FadeEntity(), r_refdef, r_showsurfaces, r_stat_totaldecals, r_refdef_t::scene, r_refdef_t::stats, r_refdef_t::viewcache, and r_refdef_scene_t::worldentity.

Referenced by R_RenderScene().

◆ R_DrawModelDecals_Entity()

static void R_DrawModelDecals_Entity ( entity_render_t * ent)
static

Definition at line 9581 of file gl_rmain.c.

9582{
9583 int i;
9584 decalsystem_t *decalsystem = &ent->decalsystem;
9585 int numdecals;
9586 tridecal_t *decal;
9587 float faderate;
9588 float alpha;
9589 float *v3f;
9590 float *c4f;
9591 float *t2f;
9592 const int *e;
9593 const unsigned char *surfacevisible = ent == r_refdef.scene.worldentity ? r_refdef.viewcache.world_surfacevisible : NULL;
9594 int numtris = 0;
9595
9596 numdecals = decalsystem->numdecals;
9597 if (!numdecals)
9598 return;
9599
9601 return;
9602
9603 if (ent->model != decalsystem->model || ent->alpha < 1 || (ent->flags & RENDER_ADDITIVE))
9604 {
9605 R_DecalSystem_Reset(decalsystem);
9606 return;
9607 }
9608
9609 // if the model is static it doesn't matter what value we give for
9610 // wantnormals and wanttangents, so this logic uses only rules applicable
9611 // to a model, knowing that they are meaningless otherwise
9612 RSurf_ActiveModelEntity(ent, false, false, false);
9613
9614 decalsystem->lastupdatetime = r_refdef.scene.time;
9615
9616 faderate = 1.0f / max(0.001f, cl_decals_fadetime.value);
9617
9618 // update vertex positions for animated models
9619 v3f = decalsystem->vertex3f;
9620 c4f = decalsystem->color4f;
9621 t2f = decalsystem->texcoord2f;
9622 for (i = 0, decal = decalsystem->decals;i < numdecals;i++, decal++)
9623 {
9624 if (!decal->color4f[0][3])
9625 continue;
9626
9627 if (surfacevisible && !surfacevisible[decal->surfaceindex])
9628 continue;
9629
9630 // skip backfaces
9631 if (decal->triangleindex < 0 && DotProduct(r_refdef.view.origin, decal->plane) < decal->plane[3])
9632 continue;
9633
9634 // update color values for fading decals
9635 if (decal->lived >= cl_decals_time.value)
9636 alpha = 1 - faderate * (decal->lived - cl_decals_time.value);
9637 else
9638 alpha = 1.0f;
9639
9640 c4f[ 0] = decal->color4f[0][0] * alpha;
9641 c4f[ 1] = decal->color4f[0][1] * alpha;
9642 c4f[ 2] = decal->color4f[0][2] * alpha;
9643 c4f[ 3] = 1;
9644 c4f[ 4] = decal->color4f[1][0] * alpha;
9645 c4f[ 5] = decal->color4f[1][1] * alpha;
9646 c4f[ 6] = decal->color4f[1][2] * alpha;
9647 c4f[ 7] = 1;
9648 c4f[ 8] = decal->color4f[2][0] * alpha;
9649 c4f[ 9] = decal->color4f[2][1] * alpha;
9650 c4f[10] = decal->color4f[2][2] * alpha;
9651 c4f[11] = 1;
9652
9653 t2f[0] = decal->texcoord2f[0][0];
9654 t2f[1] = decal->texcoord2f[0][1];
9655 t2f[2] = decal->texcoord2f[1][0];
9656 t2f[3] = decal->texcoord2f[1][1];
9657 t2f[4] = decal->texcoord2f[2][0];
9658 t2f[5] = decal->texcoord2f[2][1];
9659
9660 // update vertex positions for animated models
9661 if (decal->triangleindex >= 0 && decal->triangleindex < rsurface.modelnumtriangles)
9662 {
9663 e = rsurface.modelelement3i + 3*decal->triangleindex;
9664 VectorCopy(rsurface.modelvertex3f + 3*e[0], v3f);
9665 VectorCopy(rsurface.modelvertex3f + 3*e[1], v3f + 3);
9666 VectorCopy(rsurface.modelvertex3f + 3*e[2], v3f + 6);
9667 }
9668 else
9669 {
9670 VectorCopy(decal->vertex3f[0], v3f);
9671 VectorCopy(decal->vertex3f[1], v3f + 3);
9672 VectorCopy(decal->vertex3f[2], v3f + 6);
9673 }
9674
9675 if (r_refdef.fogenabled)
9676 {
9677 alpha = RSurf_FogVertex(v3f);
9678 VectorScale(c4f, alpha, c4f);
9679 alpha = RSurf_FogVertex(v3f + 3);
9680 VectorScale(c4f + 4, alpha, c4f + 4);
9681 alpha = RSurf_FogVertex(v3f + 6);
9682 VectorScale(c4f + 8, alpha, c4f + 8);
9683 }
9684
9685 v3f += 9;
9686 c4f += 12;
9687 t2f += 6;
9688 numtris++;
9689 }
9690
9691 if (numtris > 0)
9692 {
9693 r_refdef.stats[r_stat_drawndecals] += numtris;
9694
9695 // now render the decals all at once
9696 // (this assumes they all use one particle font texture!)
9697 RSurf_ActiveCustomEntity(&rsurface.matrix, &rsurface.inversematrix, rsurface.ent_flags, ent->shadertime, 1, 1, 1, 1, numdecals*3, decalsystem->vertex3f, decalsystem->texcoord2f, NULL, NULL, NULL, decalsystem->color4f, numtris, decalsystem->element3i, decalsystem->element3s, false, false);
9698// R_Mesh_ResetTextureState();
9699 R_Mesh_PrepareVertices_Generic_Arrays(numtris * 3, decalsystem->vertex3f, decalsystem->color4f, decalsystem->texcoord2f);
9700 GL_DepthMask(false);
9701 GL_DepthRange(0, 1);
9703 GL_DepthTest(true);
9706 R_SetupShader_Generic(decalskinframe->base, false, false, false);
9707 R_Mesh_Draw(0, numtris * 3, 0, numtris, decalsystem->element3i, NULL, 0, decalsystem->element3s, NULL, 0);
9708 }
9709}
cvar_t cl_decals_fadetime
cvar_t cl_decals_time
skinframe_t * decalskinframe
void RSurf_ActiveCustomEntity(const matrix4x4_t *matrix, const matrix4x4_t *inversematrix, int entflags, double shadertime, float r, float g, float b, float a, int numvertices, const float *vertex3f, const float *texcoord2f, const float *normal3f, const float *svector3f, const float *tvector3f, const float *color4f, int numtriangles, const int *element3i, const unsigned short *element3s, qbool wantnormals, qbool wanttangents)
Definition gl_rmain.c:7146
@ r_stat_drawndecals
Definition r_stats.h:22
double lastupdatetime
Definition client.h:58
double shadertime
Definition client.h:366
double time
(client gameworld) time for rendering time based effects
Definition render.h:352
float basepolygonfactor
Definition render.h:730
matrix4x4_t matrix
Definition render.h:719
int modelnumtriangles
Definition render.h:657
float basepolygonoffset
Definition render.h:731
struct rtexture_s * base
Definition r_textures.h:129

References alpha, entity_render_t::alpha, skinframe_t::base, rsurfacestate_t::basepolygonfactor, rsurfacestate_t::basepolygonoffset, cl_decals_fadetime, cl_decals_time, decalsystem_t::color4f, tridecal_t::color4f, decalsystem_t::decals, decalskinframe, entity_render_t::decalsystem, DotProduct, decalsystem_t::element3i, decalsystem_t::element3s, rsurfacestate_t::ent_flags, entity_render_t::flags, r_refdef_t::fogenabled, GL_BlendFunc(), GL_CullFace(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_NONE, GL_ONE_MINUS_SRC_COLOR, GL_PolygonOffset(), GL_ZERO, i, cvar_t::integer, rsurfacestate_t::inversematrix, decalsystem_t::lastupdatetime, tridecal_t::lived, rsurfacestate_t::matrix, max, decalsystem_t::model, entity_render_t::model, rsurfacestate_t::modelelement3i, rsurfacestate_t::modelnumtriangles, rsurfacestate_t::modelvertex3f, NULL, decalsystem_t::numdecals, r_refdef_view_t::origin, tridecal_t::plane, R_DecalSystem_Reset(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), r_polygonoffset_decals_factor, r_polygonoffset_decals_offset, r_refdef, R_SetupShader_Generic(), r_showsurfaces, r_stat_drawndecals, RENDER_ADDITIVE, RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), RSurf_FogVertex(), rsurface, r_refdef_t::scene, entity_render_t::shadertime, r_refdef_t::stats, tridecal_t::surfaceindex, decalsystem_t::texcoord2f, tridecal_t::texcoord2f, r_refdef_scene_t::time, tridecal_t::triangleindex, cvar_t::value, VectorCopy, VectorScale, decalsystem_t::vertex3f, tridecal_t::vertex3f, r_refdef_t::view, r_refdef_t::viewcache, r_refdef_viewcache_t::world_surfacevisible, and r_refdef_scene_t::worldentity.

Referenced by R_DrawModelDecals().

◆ R_DrawModelDecals_FadeEntity()

static void R_DrawModelDecals_FadeEntity ( entity_render_t * ent)
static

Definition at line 9533 of file gl_rmain.c.

9534{
9535 int i;
9536 decalsystem_t *decalsystem = &ent->decalsystem;
9537 unsigned int killsequence;
9538 tridecal_t *decal;
9539 float frametime;
9540 float lifetime;
9541
9542 if (!decalsystem->numdecals)
9543 return;
9544
9546 return;
9547
9548 if (ent->model != decalsystem->model || ent->alpha < 1 || (ent->flags & RENDER_ADDITIVE))
9549 {
9550 R_DecalSystem_Reset(decalsystem);
9551 return;
9552 }
9553
9554 killsequence = cl.decalsequence - bound(1, (unsigned int) cl_decals_max.integer, cl.decalsequence);
9556
9557 if (decalsystem->lastupdatetime)
9558 frametime = (r_refdef.scene.time - decalsystem->lastupdatetime);
9559 else
9560 frametime = 0;
9561 decalsystem->lastupdatetime = r_refdef.scene.time;
9562
9563 for (i = 0, decal = decalsystem->decals;i < decalsystem->numdecals;i++, decal++)
9564 {
9565 decal->lived += frametime;
9566 if (killsequence > decal->decalsequence || decal->lived >= lifetime)
9567 {
9568 *decal = decalsystem->decals[--decalsystem->numdecals];
9569 --i, --decal; // Consider the just moved decal next.
9570 }
9571 }
9572
9573 if (decalsystem->numdecals <= 0)
9574 {
9575 // if there are no decals left, reset decalsystem
9576 R_DecalSystem_Reset(decalsystem);
9577 }
9578}
float frametime
cvar_t cl_decals_max

References entity_render_t::alpha, bound, cl, cl_decals_fadetime, cl_decals_max, cl_decals_time, decalsystem_t::decals, client_state_t::decalsequence, tridecal_t::decalsequence, entity_render_t::decalsystem, entity_render_t::flags, frametime, i, cvar_t::integer, decalsystem_t::lastupdatetime, tridecal_t::lived, decalsystem_t::model, entity_render_t::model, decalsystem_t::numdecals, R_DecalSystem_Reset(), r_refdef, r_showsurfaces, RENDER_ADDITIVE, r_refdef_t::scene, r_refdef_scene_t::time, and cvar_t::value.

Referenced by R_DrawModelDecals().

◆ R_DrawModels()

static void R_DrawModels ( void )
static

Definition at line 4078 of file gl_rmain.c.

4079{
4080 int i;
4081 entity_render_t *ent;
4082
4083 for (i = 0;i < r_refdef.scene.numentities;i++)
4084 {
4086 continue;
4087 ent = r_refdef.scene.entities[i];
4089
4090 if (ent->model && ent->model->Draw != NULL)
4091 ent->model->Draw(ent);
4092 else
4093 R_DrawNoModel(ent);
4094 }
4095}
static void R_DrawNoModel(entity_render_t *ent)
Definition gl_rmain.c:6243
@ r_stat_entities
Definition r_stats.h:12
void(* Draw)(struct entity_render_s *ent)

References model_t::Draw, r_refdef_scene_t::entities, r_refdef_viewcache_t::entityvisible, i, entity_render_t::model, NULL, r_refdef_scene_t::numentities, R_DrawNoModel(), r_refdef, r_stat_entities, r_refdef_t::scene, r_refdef_t::stats, and r_refdef_t::viewcache.

Referenced by R_RenderScene().

◆ R_DrawModelsAddWaterPlanes()

static void R_DrawModelsAddWaterPlanes ( void )
static

Definition at line 4127 of file gl_rmain.c.

4128{
4129 int i;
4130 entity_render_t *ent;
4131
4132 for (i = 0;i < r_refdef.scene.numentities;i++)
4133 {
4135 continue;
4136 ent = r_refdef.scene.entities[i];
4137 if (ent->model && ent->model->DrawAddWaterPlanes != NULL)
4138 ent->model->DrawAddWaterPlanes(ent);
4139 }
4140}
void(* DrawAddWaterPlanes)(struct entity_render_s *ent)

References model_t::DrawAddWaterPlanes, r_refdef_scene_t::entities, r_refdef_viewcache_t::entityvisible, i, entity_render_t::model, NULL, r_refdef_scene_t::numentities, r_refdef, r_refdef_t::scene, and r_refdef_t::viewcache.

Referenced by R_RenderWaterPlanes().

◆ R_DrawModelsDebug()

static void R_DrawModelsDebug ( void )
static

Definition at line 4112 of file gl_rmain.c.

4113{
4114 int i;
4115 entity_render_t *ent;
4116
4117 for (i = 0;i < r_refdef.scene.numentities;i++)
4118 {
4120 continue;
4121 ent = r_refdef.scene.entities[i];
4122 if (ent->model && ent->model->DrawDebug != NULL)
4123 ent->model->DrawDebug(ent);
4124 }
4125}
void(* DrawDebug)(struct entity_render_s *ent)

References model_t::DrawDebug, r_refdef_scene_t::entities, r_refdef_viewcache_t::entityvisible, i, entity_render_t::model, NULL, r_refdef_scene_t::numentities, r_refdef, r_refdef_t::scene, and r_refdef_t::viewcache.

Referenced by R_RenderScene().

◆ R_DrawModelsDepth()

static void R_DrawModelsDepth ( void )
static

Definition at line 4097 of file gl_rmain.c.

4098{
4099 int i;
4100 entity_render_t *ent;
4101
4102 for (i = 0;i < r_refdef.scene.numentities;i++)
4103 {
4105 continue;
4106 ent = r_refdef.scene.entities[i];
4107 if (ent->model && ent->model->DrawDepth != NULL)
4108 ent->model->DrawDepth(ent);
4109 }
4110}
void(* DrawDepth)(struct entity_render_s *ent)

References model_t::DrawDepth, r_refdef_scene_t::entities, r_refdef_viewcache_t::entityvisible, i, entity_render_t::model, NULL, r_refdef_scene_t::numentities, r_refdef, r_refdef_t::scene, and r_refdef_t::viewcache.

Referenced by R_RenderScene().

◆ R_DrawModelSurfaces()

void R_DrawModelSurfaces ( entity_render_t * ent,
qbool skysurfaces,
qbool writedepth,
qbool depthonly,
qbool debug,
qbool prepass,
qbool ui )

Definition at line 9970 of file gl_rmain.c.

9971{
9972 int i, j, flagsmask;
9973 model_t *model = ent->model;
9974 msurface_t *surfaces;
9975 unsigned char *update;
9976 int numsurfacelist = 0;
9977 if (model == NULL)
9978 return;
9979
9980 if (r_maxsurfacelist < model->num_surfaces)
9981 {
9982 r_maxsurfacelist = model->num_surfaces;
9983 if (r_surfacelist)
9986 }
9987
9989 RSurf_ActiveModelEntity(ent, false, false, false);
9990 else if (prepass)
9991 RSurf_ActiveModelEntity(ent, true, true, true);
9992 else if (depthonly)
9993 RSurf_ActiveModelEntity(ent, model->wantnormals, model->wanttangents, false);
9994 else
9995 RSurf_ActiveModelEntity(ent, true, true, false);
9996
9997 surfaces = model->data_surfaces;
9998 update = model->brushq1.lightmapupdateflags;
9999
10000 flagsmask = skysurfaces ? MATERIALFLAG_SKY : MATERIALFLAG_WALL;
10001
10002 if (debug)
10003 {
10005 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
10006 return;
10007 }
10008
10009 // check if this is an empty model
10010 if (model->submodelsurfaces_start >= model->submodelsurfaces_end)
10011 return;
10012
10018 numsurfacelist = 0;
10019
10020 // add visible surfaces to draw list
10021 if (ent == r_refdef.scene.worldentity)
10022 {
10023 // for the world entity, check surfacevisible
10024 for (i = model->submodelsurfaces_start;i < model->submodelsurfaces_end;i++)
10025 {
10026 j = model->modelsurfaces_sorted[i];
10028 r_surfacelist[numsurfacelist++] = surfaces + j;
10029 }
10030
10031 // don't do anything if there were no surfaces added (none of the world entity is visible)
10032 if (!numsurfacelist)
10033 {
10034 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
10035 return;
10036 }
10037 }
10038 else if (ui)
10039 {
10040 // for ui we have to preserve the order of surfaces (not using modelsurfaces_sorted)
10041 for (i = model->submodelsurfaces_start; i < model->submodelsurfaces_end; i++)
10042 r_surfacelist[numsurfacelist++] = surfaces + i;
10043 }
10044 else
10045 {
10046 // add all surfaces
10047 for (i = model->submodelsurfaces_start; i < model->submodelsurfaces_end; i++)
10048 r_surfacelist[numsurfacelist++] = surfaces + model->modelsurfaces_sorted[i];
10049 }
10050
10051 /*
10052 * Mark lightmaps as dirty if their lightstyle's value changed. We do this by
10053 * using style chains because most styles do not change on most frames, and most
10054 * surfaces do not have styles on them. Mods like Arcane Dimensions (e.g. ad_necrokeep)
10055 * break this rule and animate most surfaces.
10056 */
10057 if (update && !skysurfaces && !depthonly && !prepass && model->brushq1.num_lightstyles && r_refdef.scene.lightmapintensity > 0 && r_q1bsp_lightmap_updates_enabled.integer)
10058 {
10060
10061 // For each lightstyle, check if its value changed and mark the lightmaps as dirty if so
10062 for (i = 0, style = model->brushq1.data_lightstyleinfo; i < model->brushq1.num_lightstyles; i++, style++)
10063 {
10064 if (style->value != r_refdef.scene.lightstylevalue[style->style])
10065 {
10066 int* list = style->surfacelist;
10067 style->value = r_refdef.scene.lightstylevalue[style->style];
10068 // Value changed - mark the surfaces belonging to this style chain as dirty
10069 for (j = 0; j < style->numsurfaces; j++)
10070 update[list[j]] = true;
10071 }
10072 }
10073 // Now check if update flags are set on any surfaces that are visible
10075 {
10076 /*
10077 * We can do less frequent texture uploads (approximately 10hz for animated
10078 * lightstyles) by rebuilding lightmaps on surfaces that are not currently visible.
10079 * For optimal efficiency, this includes the submodels of the worldmodel, so we
10080 * use model->num_surfaces, not nummodelsurfaces.
10081 */
10082 for (i = 0; i < model->num_surfaces;i++)
10083 if (update[i])
10085 }
10086 else
10087 {
10088 for (i = 0; i < numsurfacelist; i++)
10089 if (update[r_surfacelist[i] - surfaces])
10091 }
10092 }
10093
10094 R_QueueModelSurfaceList(ent, numsurfacelist, r_surfacelist, flagsmask, writedepth, depthonly, prepass, ui);
10095
10096 // add to stats if desired
10097 if (r_speeds.integer && !skysurfaces && !depthonly)
10098 {
10099 r_refdef.stats[r_stat_entities_surfaces] += numsurfacelist;
10100 for (j = 0;j < numsurfacelist;j++)
10102 }
10103
10104 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
10105}
float style
int r_maxsurfacelist
Definition gl_rmain.c:9968
static void R_QueueModelSurfaceList(entity_render_t *ent, int numsurfaces, const msurface_t **surfacelist, int flagsmask, qbool writedepth, qbool depthonly, qbool prepass, qbool ui)
Definition gl_rmain.c:9012
const msurface_t ** r_surfacelist
Definition gl_rmain.c:9969
static void R_DrawDebugModel(void)
Definition gl_rmain.c:9747
void R_BuildLightMap(const entity_render_t *ent, msurface_t *surface, int combine)
Definition gl_rsurf.c:50
@ r_stat_entities_triangles
Definition r_stats.h:14
@ r_stat_entities_surfaces
Definition r_stats.h:13
float lightmapintensity
Definition render.h:387
unsigned short lightstylevalue[MAX_LIGHTSTYLES]
8.8 fraction of base light value
Definition render.h:380
const rtlight_t * rtlight
Definition render.h:748

References rsurfacestate_t::deluxemaptexture, rsurfacestate_t::entity, i, cvar_t::integer, r_refdef_scene_t::lightmapintensity, rsurfacestate_t::lightmaptexture, r_refdef_scene_t::lightstylevalue, MATERIALFLAG_SKY, MATERIALFLAG_WALL, Mem_Alloc, Mem_Free, entity_render_t::model, model, NULL, msurface_t::num_triangles, R_BuildLightMap(), R_DrawDebugModel(), r_main_mempool, r_maxsurfacelist, r_q1bsp_lightmap_updates_combine, r_q1bsp_lightmap_updates_enabled, r_q1bsp_lightmap_updates_hidden_surfaces, R_QueueModelSurfaceList(), r_refdef, r_showsurfaces, r_speeds, r_stat_entities_surfaces, r_stat_entities_triangles, r_surfacelist, RSurf_ActiveModelEntity(), rsurface, rsurfacestate_t::rtlight, r_refdef_t::scene, r_refdef_t::stats, style, rsurfacestate_t::texture, rsurfacestate_t::uselightmaptexture, r_refdef_t::viewcache, r_refdef_viewcache_t::world_surfacevisible, and r_refdef_scene_t::worldentity.

Referenced by DrawQ_FlushUI(), R_Mod_Draw(), R_Mod_DrawDebug(), R_Mod_DrawDepth(), R_Mod_DrawPrepass(), and R_Mod_DrawSky().

◆ R_DrawModelTextureSurfaceList()

static void R_DrawModelTextureSurfaceList ( int texturenumsurfaces,
const msurface_t ** texturesurfacelist,
qbool writedepth,
qbool prepass,
qbool ui )
static

Definition at line 8832 of file gl_rmain.c.

8833{
8837 {
8838 R_DrawTextureSurfaceList_ShowSurfaces(texturenumsurfaces, texturesurfacelist, writedepth);
8839 return;
8840 }
8841 switch (vid.renderpath)
8842 {
8843 case RENDERPATH_GL32:
8844 case RENDERPATH_GLES2:
8845 R_DrawTextureSurfaceList_GL20(texturenumsurfaces, texturesurfacelist, writedepth, prepass, ui);
8846 break;
8847 }
8849}
static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool prepass, qbool ui)
Definition gl_rmain.c:8686
void RSurf_SetupDepthAndCulling(bool ui)
Definition gl_rmain.c:8576
static void R_DrawTextureSurfaceList_ShowSurfaces(int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth)
Definition gl_rmain.c:8746
qbool showdebug
Definition render.h:314

References CHECKGLERROR, cvar_t::integer, R_DrawTextureSurfaceList_GL20(), R_DrawTextureSurfaceList_ShowSurfaces(), r_refdef, r_showsurfaces, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, RSurf_SetupDepthAndCulling(), r_refdef_view_t::showdebug, vid, and r_refdef_t::view.

Referenced by R_DrawCustomSurface_Texture(), R_DrawSurface_TransparentCallback(), and R_ProcessModelTextureSurfaceList().

◆ R_DrawNoModel()

void R_DrawNoModel ( entity_render_t * ent)
static

Definition at line 6243 of file gl_rmain.c.

6244{
6245 vec3_t org;
6247 if ((ent->flags & RENDER_ADDITIVE) || (ent->alpha < 1))
6249 else
6251}
static void R_DrawNoModel_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rmain.c:6188
void Matrix4x4_OriginFromMatrix(const matrix4x4_t *in, float *out)
Definition matrixlib.c:1792
@ TRANSPARENTSORT_HUD
Definition r_qshader.h:195
matrix4x4_t matrix
Definition client.h:332

References entity_render_t::alpha, entity_render_t::flags, entity_render_t::matrix, Matrix4x4_OriginFromMatrix(), NULL, R_DrawNoModel_TransparentCallback(), R_MeshQueue_AddTransparent(), RENDER_ADDITIVE, RENDER_NODEPTHTEST, rsurface, rsurfacestate_t::rtlight, TRANSPARENTSORT_DISTANCE, and TRANSPARENTSORT_HUD.

Referenced by R_DrawModels().

◆ R_DrawNoModel_TransparentCallback()

static void R_DrawNoModel_TransparentCallback ( const entity_render_t * ent,
const rtlight_t * rtlight,
int numsurfaces,
int * surfacelist )
static

Definition at line 6188 of file gl_rmain.c.

6189{
6190 int i;
6191 float f1, f2, *c;
6192 float color4f[6*4];
6193
6194 RSurf_ActiveCustomEntity(&ent->matrix, &ent->inversematrix, ent->flags, ent->shadertime, ent->colormod[0], ent->colormod[1], ent->colormod[2], ent->alpha, 6, nomodelvertex3f, NULL, NULL, NULL, NULL, nomodelcolor4f, 8, nomodelelement3i, nomodelelement3s, false, false);
6195
6196 // this is only called once per entity so numsurfaces is always 1, and
6197 // surfacelist is always {0}, so this code does not handle batches
6198
6200 {
6202 GL_DepthMask(false);
6203 }
6204 else if (ent->alpha < 1)
6205 {
6207 GL_DepthMask(false);
6208 }
6209 else
6210 {
6212 GL_DepthMask(true);
6213 }
6214 GL_DepthRange(0, (rsurface.ent_flags & RENDER_VIEWMODEL) ? 0.0625 : 1);
6218 memcpy(color4f, nomodelcolor4f, sizeof(float[6*4]));
6219 for (i = 0, c = color4f;i < 6;i++, c += 4)
6220 {
6221 c[0] *= ent->render_fullbright[0] * r_refdef.view.colorscale;
6222 c[1] *= ent->render_fullbright[1] * r_refdef.view.colorscale;
6223 c[2] *= ent->render_fullbright[2] * r_refdef.view.colorscale;
6224 c[3] *= ent->alpha;
6225 }
6226 if (r_refdef.fogenabled)
6227 {
6228 for (i = 0, c = color4f;i < 6;i++, c += 4)
6229 {
6231 f2 = 1 - f1;
6232 c[0] = (c[0] * f1 + r_refdef.fogcolor[0] * f2);
6233 c[1] = (c[1] * f1 + r_refdef.fogcolor[1] * f2);
6234 c[2] = (c[2] * f1 + r_refdef.fogcolor[2] * f2);
6235 }
6236 }
6237// R_Mesh_ResetTextureState();
6238 R_SetupShader_Generic_NoTexture(false, false);
6241}
static const int nomodelelement3i[24]
Definition gl_rmain.c:6144
static const float nomodelvertex3f[6 *3]
Definition gl_rmain.c:6168
static const unsigned short nomodelelement3s[24]
Definition gl_rmain.c:6156
static const float nomodelcolor4f[6 *4]
Definition gl_rmain.c:6178
#define RENDER_VIEWMODEL
Definition protocol.h:358
#define RENDER_DOUBLESIDED
Definition protocol.h:371
float render_fullbright[3]
Definition client.h:412
matrix4x4_t inversematrix
Definition client.h:334
float colormod[3]
Definition client.h:359

References entity_render_t::alpha, rsurfacestate_t::basepolygonfactor, rsurfacestate_t::basepolygonoffset, entity_render_t::colormod, r_refdef_view_t::colorscale, r_refdef_view_t::cullface_back, rsurfacestate_t::ent_flags, entity_render_t::flags, r_refdef_t::fogcolor, r_refdef_t::fogenabled, GL_BlendFunc(), GL_CullFace(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_NONE, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_PolygonOffset(), GL_SRC_ALPHA, GL_ZERO, i, entity_render_t::inversematrix, entity_render_t::matrix, nomodelcolor4f, nomodelelement3i, nomodelelement3s, nomodelvertex3f, NULL, R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), r_refdef, R_SetupShader_Generic_NoTexture(), RENDER_ADDITIVE, RENDER_DOUBLESIDED, entity_render_t::render_fullbright, RENDER_NODEPTHTEST, RENDER_VIEWMODEL, RSurf_ActiveCustomEntity(), RSurf_FogVertex(), rsurface, entity_render_t::shadertime, and r_refdef_t::view.

Referenced by R_DrawNoModel().

◆ R_DrawSurface_TransparentCallback()

static void R_DrawSurface_TransparentCallback ( const entity_render_t * ent,
const rtlight_t * rtlight,
int numsurfaces,
int * surfacelist )
static

Definition at line 8851 of file gl_rmain.c.

8852{
8853 int i, j;
8854 int texturenumsurfaces, endsurface;
8856 const msurface_t *surface;
8857 const msurface_t *texturesurfacelist[MESHQUEUE_TRANSPARENT_BATCHSIZE];
8858
8859 RSurf_ActiveModelEntity(ent, true, true, false);
8860
8862 {
8863 qbool setup = false;
8864 for (i = 0;i < numsurfaces;i = j)
8865 {
8866 j = i + 1;
8867 surface = rsurface.modelsurfaces + surfacelist[i];
8868 texture = surface->texture;
8873 // scan ahead until we find a different texture
8874 endsurface = min(i + 1024, numsurfaces);
8875 texturenumsurfaces = 0;
8876 texturesurfacelist[texturenumsurfaces++] = surface;
8877 for (;j < endsurface;j++)
8878 {
8879 surface = rsurface.modelsurfaces + surfacelist[j];
8880 if (texture != surface->texture)
8881 break;
8882 texturesurfacelist[texturenumsurfaces++] = surface;
8883 }
8885 continue;
8886 // render the range of surfaces as depth
8887 if (!setup)
8888 {
8889 setup = true;
8890 GL_ColorMask(0,0,0,0);
8891 GL_Color(1,1,1,1);
8892 GL_DepthTest(true);
8894 GL_DepthMask(true);
8895// R_Mesh_ResetTextureState();
8896 }
8898 RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX | BATCHNEED_ALLOWMULTIDRAW, texturenumsurfaces, texturesurfacelist);
8902 }
8903 if (setup)
8905 }
8906
8907 for (i = 0;i < numsurfaces;i = j)
8908 {
8909 j = i + 1;
8910 surface = rsurface.modelsurfaces + surfacelist[i];
8911 texture = surface->texture;
8913 // scan ahead until we find a different texture
8914 endsurface = min(i + MESHQUEUE_TRANSPARENT_BATCHSIZE, numsurfaces);
8915 texturenumsurfaces = 0;
8916 texturesurfacelist[texturenumsurfaces++] = surface;
8920 for (;j < endsurface;j++)
8921 {
8922 surface = rsurface.modelsurfaces + surfacelist[j];
8923 if (texture != surface->texture || rsurface.lightmaptexture != surface->lightmaptexture)
8924 break;
8925 texturesurfacelist[texturenumsurfaces++] = surface;
8926 }
8927 // render the range of surfaces
8928 R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, false, false, false);
8929 }
8930 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
8931}
void R_Mesh_PrepareVertices_Vertex3f(int numvertices, const float *vertex3f, const r_meshbuffer_t *vertexbuffer, int bufferoffset)
void GL_ColorMask(int r, int g, int b, int a)
void R_SetupShader_DepthOrShadow(qbool notrippy, qbool depthrgb, qbool skeletal)
Definition gl_rmain.c:1493
#define MESHQUEUE_TRANSPARENT_BATCHSIZE
Definition meshqueue.h:6
#define MATERIALFLAG_TRANSDEPTH
#define BATCHNEED_ALLOWMULTIDRAW
Definition render.h:795
struct rtexture_s * deluxemaptexture
the lighting direction texture fragment to use on the rendering mesh
struct rtexture_s * lightmaptexture
the lightmap texture fragment to use on the rendering mesh
int colormask[4]
which color components to allow (for anaglyph glasses)
Definition render.h:299
int batchvertex3f_bufferoffset
Definition render.h:675
const msurface_t * modelsurfaces
Definition render.h:658
const r_meshbuffer_t * batchvertex3f_vertexbuffer
Definition render.h:674
float * batchskeletaltransform3x4
Definition render.h:707

References BATCHNEED_ALLOWMULTIDRAW, BATCHNEED_ARRAY_VERTEX, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchskeletaltransform3x4, rsurfacestate_t::batchvertex3f, rsurfacestate_t::batchvertex3f_bufferoffset, rsurfacestate_t::batchvertex3f_vertexbuffer, r_refdef_view_t::colormask, texture_t::currentmaterialflags, msurface_t::deluxemaptexture, rsurfacestate_t::deluxemaptexture, rsurfacestate_t::entity, GL_BlendFunc(), GL_Color(), GL_ColorMask(), GL_DepthMask(), GL_DepthTest(), GL_ONE, GL_ZERO, i, cvar_t::integer, msurface_t::lightmaptexture, rsurfacestate_t::lightmaptexture, MATERIALFLAG_TRANSDEPTH, MESHQUEUE_TRANSPARENT_BATCHSIZE, min, rsurfacestate_t::modelsurfaces, NULL, R_DrawModelTextureSurfaceList(), R_GetCurrentTexture(), R_Mesh_PrepareVertices_Vertex3f(), r_refdef, R_SetupShader_DepthOrShadow(), r_transparentdepthmasking, RSurf_ActiveModelEntity(), RSurf_DrawBatch(), RSurf_PrepareVerticesForBatch(), RSurf_SetupDepthAndCulling(), rsurface, msurface_t::texture, rsurfacestate_t::texture, texture, rsurfacestate_t::uselightmaptexture, and r_refdef_t::view.

Referenced by R_ProcessTransparentTextureSurfaceList().

◆ R_DrawTextureSurfaceList_DepthOnly()

static void R_DrawTextureSurfaceList_DepthOnly ( int texturenumsurfaces,
const msurface_t ** texturesurfacelist )
static

Definition at line 8965 of file gl_rmain.c.

References BATCHNEED_ALLOWMULTIDRAW, BATCHNEED_ARRAY_VERTEX, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchskeletaltransform3x4, rsurfacestate_t::batchvertex3f, rsurfacestate_t::batchvertex3f_bufferoffset, rsurfacestate_t::batchvertex3f_vertexbuffer, texture_t::currentmaterialflags, MATERIALFLAG_ALPHATEST, MATERIALFLAG_BLENDED, MATERIALFLAG_NODEPTHTEST, MATERIALFLAG_REFLECTION, MATERIALFLAG_WATERSHADER, r_fb, R_Mesh_PrepareVertices_Vertex3f(), R_SetupShader_DepthOrShadow(), r_waterstate_t::renderingscene, RSurf_DrawBatch(), RSurf_PrepareVerticesForBatch(), RSurf_SetupDepthAndCulling(), rsurface, rsurfacestate_t::texture, and r_framebufferstate_t::water.

Referenced by R_ProcessModelTextureSurfaceList().

◆ R_DrawTextureSurfaceList_GL20()

static void R_DrawTextureSurfaceList_GL20 ( int texturenumsurfaces,
const msurface_t ** texturesurfacelist,
qbool writedepth,
qbool prepass,
qbool ui )
static

Definition at line 8686 of file gl_rmain.c.

8687{
8689 return;
8690 if (prepass)
8691 {
8692 // render screenspace normalmap to texture
8693 GL_DepthMask(true);
8694 R_SetupShader_Surface(vec3_origin, vec3_origin, vec3_origin, RSURFPASS_DEFERREDGEOMETRY, texturenumsurfaces, texturesurfacelist, NULL, false, false);
8696 return;
8697 }
8698
8699 // bind lightmap texture
8700
8701 // water/refraction/reflection/camera surfaces have to be handled specially
8703 {
8704 int start, end, startplaneindex;
8705 for (start = 0;start < texturenumsurfaces;start = end)
8706 {
8707 startplaneindex = RSurf_FindWaterPlaneForSurface(texturesurfacelist[start]);
8708 if(startplaneindex < 0)
8709 {
8710 // this happens if the plane e.g. got backface culled and thus didn't get a water plane. We can just ignore this.
8711 // Con_Printf("No matching water plane for surface with material flags 0x%08x - PLEASE DEBUG THIS\n", rsurface.texture->currentmaterialflags);
8712 end = start + 1;
8713 continue;
8714 }
8715 for (end = start + 1;end < texturenumsurfaces && startplaneindex == RSurf_FindWaterPlaneForSurface(texturesurfacelist[end]);end++)
8716 ;
8717 // now that we have a batch using the same planeindex, render it
8719 {
8720 // render water or distortion background
8721 GL_DepthMask(true);
8722 R_SetupShader_Surface(vec3_origin, vec3_origin, vec3_origin, RSURFPASS_BACKGROUND, end-start, texturesurfacelist + start, (void *)(r_fb.water.waterplanes + startplaneindex), false, false);
8724 // blend surface on top
8725 GL_DepthMask(false);
8726 R_SetupShader_Surface(vec3_origin, vec3_origin, vec3_origin, RSURFPASS_BASE, end-start, texturesurfacelist + start, NULL, false, false);
8728 }
8730 {
8731 // render surface with reflection texture as input
8733 R_SetupShader_Surface(vec3_origin, vec3_origin, vec3_origin, RSURFPASS_BASE, end-start, texturesurfacelist + start, (void *)(r_fb.water.waterplanes + startplaneindex), false, false);
8735 }
8736 }
8737 return;
8738 }
8739
8740 // render surface batch normally
8742 R_SetupShader_Surface(vec3_origin, vec3_origin, vec3_origin, RSURFPASS_BASE, texturenumsurfaces, texturesurfacelist, NULL, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SKY) != 0 || ui, ui);
8744}
static int RSurf_FindWaterPlaneForSurface(const msurface_t *surface)
Definition gl_rmain.c:8536
void R_SetupShader_Surface(const float rtlightambient[3], const float rtlightdiffuse[3], const float rtlightspecular[3], rsurfacepass_t rsurfacepass, int texturenumsurfaces, const msurface_t **texturesurfacelist, void *surfacewaterplane, qbool notrippy, qbool ui)
Definition gl_rmain.c:1563
vec3_t vec3_origin
Definition mathlib.c:26
#define MATERIALFLAG_CAMERA
@ RSURFPASS_BACKGROUND
Definition render.h:805
@ RSURFPASS_BASE
Definition render.h:804
@ RSURFPASS_DEFERREDGEOMETRY
Definition render.h:807
r_waterstate_waterplane_t waterplanes[MAX_WATERPLANES]
Definition render.h:869

References texture_t::currentmaterialflags, GL_DepthMask(), MATERIALFLAG_BLENDED, MATERIALFLAG_CAMERA, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_SKY, MATERIALFLAG_WATERSHADER, NULL, r_fb, R_SetupShader_Surface(), r_waterstate_t::renderingscene, RSurf_DrawBatch(), RSurf_FindWaterPlaneForSurface(), rsurface, RSURFPASS_BACKGROUND, RSURFPASS_BASE, RSURFPASS_DEFERREDGEOMETRY, rsurfacestate_t::texture, vec3_origin, r_framebufferstate_t::water, and r_waterstate_t::waterplanes.

Referenced by R_DrawModelTextureSurfaceList().

◆ R_DrawTextureSurfaceList_ShowSurfaces()

static void R_DrawTextureSurfaceList_ShowSurfaces ( int texturenumsurfaces,
const msurface_t ** texturesurfacelist,
qbool writedepth )
static

Definition at line 8746 of file gl_rmain.c.

8747{
8748 int vi;
8749 int j;
8750 int texturesurfaceindex;
8751 int k;
8752 const msurface_t *surface;
8753 float surfacecolor4f[4];
8754 float c[4];
8756
8757// R_Mesh_ResetTextureState();
8758 R_SetupShader_Generic_NoTexture(false, false);
8759
8761 GL_DepthMask(writedepth);
8762
8763 switch (r_showsurfaces.integer)
8764 {
8765 case 1:
8766 default:
8768 vi = 0;
8769 for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
8770 {
8771 surface = texturesurfacelist[texturesurfaceindex];
8772 k = (int)(((size_t)surface) / sizeof(msurface_t));
8773 Vector4Set(surfacecolor4f, (k & 0xF) * (1.0f / 16.0f), (k & 0xF0) * (1.0f / 256.0f), (k & 0xF00) * (1.0f / 4096.0f), 1);
8774 for (j = 0;j < surface->num_vertices;j++)
8775 {
8776 Vector4Copy(surfacecolor4f, rsurface.batchlightmapcolor4f + 4 * vi);
8777 vi++;
8778 }
8779 }
8780 break;
8781 case 3:
8782 if(t && t->currentskinframe)
8783 {
8784 Vector4Copy(t->currentskinframe->avgcolor, c);
8785 c[3] *= t->currentalpha;
8786 }
8787 else
8788 {
8789 Vector4Set(c, 1, 0, 1, 1);
8790 }
8791 if (t && (t->pantstexture || t->shirttexture))
8792 {
8794 }
8797 c[3] *= r_wateralpha.value;
8799 vi = 0;
8801 {
8802 for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
8803 {
8804 surface = texturesurfacelist[texturesurfaceindex];
8805 for (j = 0;j < surface->num_vertices;j++)
8806 {
8807 float *ptr = rsurface.batchlightmapcolor4f + 4 * vi;
8808 Vector4Multiply(ptr, c, ptr);
8809 vi++;
8810 }
8811 }
8812 }
8813 else
8814 {
8815 for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
8816 {
8817 surface = texturesurfacelist[texturesurfaceindex];
8818 for (j = 0;j < surface->num_vertices;j++)
8819 {
8820 float *ptr = rsurface.batchlightmapcolor4f + 4 * vi;
8821 Vector4Copy(c, ptr);
8822 vi++;
8823 }
8824 }
8825 }
8826 break;
8827 }
8830}
#define Vector4Multiply(a, b, out)
Definition mathlib.h:91
#define Vector4Copy(in, out)
Definition mathlib.h:84
#define MATERIALFLAG_WATERALPHA
Definition model_brush.h:85
#define BATCHNEED_ARRAY_VERTEXCOLOR
Definition render.h:789
#define BATCHNEED_ALWAYSCOPY
Definition render.h:794
float * modellightmapcolor4f
Definition render.h:634
float * batchtexcoordtexture2f
Definition render.h:688
float * batchlightmapcolor4f
Definition render.h:685
float render_colormap_pants[3]
float render_colormap_shirt[3]
struct rtexture_s * shirttexture
struct rtexture_s * pantstexture
float currentalpha
struct skinframe_s * currentskinframe

References rsurfacestate_t::batchlightmapcolor4f, BATCHNEED_ALWAYSCOPY, BATCHNEED_ARRAY_VERTEX, BATCHNEED_ARRAY_VERTEXCOLOR, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchtexcoordtexture2f, rsurfacestate_t::batchvertex3f, r_refdef_view_t::colorscale, texture_t::currentalpha, texture_t::currentmaterialflags, texture_t::currentskinframe, GL_BlendFunc(), GL_DepthMask(), GL_ONE, GL_ZERO, int(), cvar_t::integer, MATERIALFLAG_WATERALPHA, rsurfacestate_t::modellightmapcolor4f, msurface_t::num_vertices, texture_t::pantstexture, R_Mesh_PrepareVertices_Generic_Arrays(), r_refdef, R_SetupShader_Generic_NoTexture(), r_showsurfaces, r_wateralpha, texture_t::render_colormap_pants, texture_t::render_colormap_shirt, RSurf_DrawBatch(), RSurf_PrepareVerticesForBatch(), rsurface, texture_t::shirttexture, rsurfacestate_t::texture, cvar_t::value, Vector4Copy, Vector4Multiply, Vector4Set, VectorMAM, VectorScale, and r_refdef_t::view.

Referenced by R_DrawModelTextureSurfaceList().

◆ R_DrawTextureSurfaceList_Sky()

static void R_DrawTextureSurfaceList_Sky ( int texturenumsurfaces,
const msurface_t ** texturesurfacelist )
static

Definition at line 8587 of file gl_rmain.c.

8588{
8589 int j;
8590 const float *v;
8591 float p[3], mins[3], maxs[3];
8592 int scissor[4];
8593 // transparent sky would be ridiculous
8595 return;
8596 R_SetupShader_Generic_NoTexture(false, false);
8597 skyrenderlater = true;
8599 GL_DepthMask(true);
8600
8601 // add the vertices of the surfaces to a world bounding box so we can scissor the sky render later
8603 {
8604 RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX | BATCHNEED_NOGAPS, texturenumsurfaces, texturesurfacelist);
8605 for (j = 0, v = rsurface.batchvertex3f + 3 * rsurface.batchfirstvertex; j < rsurface.batchnumvertices; j++, v += 3)
8606 {
8608 if (j > 0)
8609 {
8610 if (mins[0] > p[0]) mins[0] = p[0];
8611 if (mins[1] > p[1]) mins[1] = p[1];
8612 if (mins[2] > p[2]) mins[2] = p[2];
8613 if (maxs[0] < p[0]) maxs[0] = p[0];
8614 if (maxs[1] < p[1]) maxs[1] = p[1];
8615 if (maxs[2] < p[2]) maxs[2] = p[2];
8616 }
8617 else
8618 {
8619 VectorCopy(p, mins);
8620 VectorCopy(p, maxs);
8621 }
8622 }
8623 if (!R_ScissorForBBox(mins, maxs, scissor))
8624 {
8625 if (skyscissor[2])
8626 {
8627 if (skyscissor[0] > scissor[0])
8628 {
8629 skyscissor[2] += skyscissor[0] - scissor[0];
8630 skyscissor[0] = scissor[0];
8631 }
8632 if (skyscissor[1] > scissor[1])
8633 {
8634 skyscissor[3] += skyscissor[1] - scissor[1];
8635 skyscissor[1] = scissor[1];
8636 }
8637 if (skyscissor[0] + skyscissor[2] < scissor[0] + scissor[2])
8638 skyscissor[2] = scissor[0] + scissor[2] - skyscissor[0];
8639 if (skyscissor[1] + skyscissor[3] < scissor[1] + scissor[3])
8640 skyscissor[3] = scissor[1] + scissor[3] - skyscissor[1];
8641 }
8642 else
8643 Vector4Copy(scissor, skyscissor);
8644 }
8645 }
8646
8647 // LadyHavoc: HalfLife maps have freaky skypolys so don't use
8648 // skymasking on them, and Quake3 never did sky masking (unlike
8649 // software Quake and software Quake2), so disable the sky masking
8650 // in Quake3 maps as it causes problems with q3map2 sky tricks,
8651 // and skymasking also looks very bad when noclipping outside the
8652 // level, so don't use it then either.
8654 {
8656 if (skyrendermasked)
8657 {
8658 R_SetupShader_DepthOrShadow(false, false, false);
8659 // depth-only (masking)
8660 GL_ColorMask(0, 0, 0, 0);
8661 // just to make sure that braindead drivers don't draw
8662 // anything despite that colormask...
8664 RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX | BATCHNEED_ALLOWMULTIDRAW, texturenumsurfaces, texturesurfacelist);
8666 }
8667 else
8668 {
8669 R_SetupShader_Generic_NoTexture(false, false);
8670 // fog sky
8672 RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX | BATCHNEED_NOGAPS, texturenumsurfaces, texturesurfacelist);
8675 }
8677 if (skyrendermasked)
8679 }
8681 GL_Color(1, 1, 1, 1);
8682}
qbool R_ScissorForBBox(const float *mins, const float *maxs, int *scissor)
Definition gl_backend.c:430
cvar_t r_q3bsp_renderskydepth
Definition gl_rsurf.c:41
#define MATERIALFLAGMASK_DEPTHSORTED
cvar_t r_sky_scissor
Definition r_sky.c:9
int skyrendermasked
Definition r_sky.c:11
int skyrenderlater
Definition r_sky.c:10
int skyscissor[4]
Definition r_sky.c:12
model_brush_t brush
qbool world_novis
if true, the view is currently in a leaf without pvs data
Definition render.h:344

References rsurfacestate_t::batchfirstvertex, BATCHNEED_ALLOWMULTIDRAW, BATCHNEED_ARRAY_VERTEX, BATCHNEED_NOGAPS, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchvertex3f, rsurfacestate_t::batchvertex3f_bufferoffset, rsurfacestate_t::batchvertex3f_vertexbuffer, model_t::brush, r_refdef_view_t::colormask, texture_t::currentmaterialflags, r_refdef_t::fogcolor, GL_BlendFunc(), GL_Color(), GL_ColorMask(), GL_DepthMask(), GL_ONE, GL_ZERO, cvar_t::integer, model_brush_t::isq3bsp, MATERIALFLAGMASK_DEPTHSORTED, rsurfacestate_t::matrix, Matrix4x4_Transform(), maxs, mins, NULL, R_Mesh_PrepareVertices_Generic_Arrays(), R_Mesh_PrepareVertices_Vertex3f(), R_Mesh_ResetTextureState(), r_q1bsp_skymasking, r_q3bsp_renderskydepth, r_refdef, R_ScissorForBBox(), R_SetupShader_DepthOrShadow(), R_SetupShader_Generic_NoTexture(), r_sky_scissor, r_trippy, RSurf_DrawBatch(), RSurf_PrepareVerticesForBatch(), RSurf_SetupDepthAndCulling(), rsurface, r_refdef_t::scene, model_brush_t::skymasking, skyrenderlater, skyrendermasked, skyscissor, rsurfacestate_t::texture, v, Vector4Copy, VectorCopy, r_refdef_t::view, r_refdef_t::viewcache, r_refdef_viewcache_t::world_novis, and r_refdef_scene_t::worldmodel.

Referenced by R_ProcessModelTextureSurfaceList().

◆ R_EntityMatrix()

void R_EntityMatrix ( const matrix4x4_t * matrix)

Definition at line 4417 of file gl_rmain.c.

4418{
4419 if (gl_modelmatrixchanged || memcmp(matrix, &gl_modelmatrix, sizeof(matrix4x4_t)))
4420 {
4421 gl_modelmatrixchanged = false;
4422 gl_modelmatrix = *matrix;
4428 switch(vid.renderpath)
4429 {
4430 case RENDERPATH_GL32:
4431 case RENDERPATH_GLES2:
4434 break;
4435 }
4436 }
4437}
float gl_modelviewprojection16f[16]
Definition gl_backend.c:30
matrix4x4_t gl_modelmatrix
Definition gl_backend.c:24
matrix4x4_t gl_modelviewprojectionmatrix
Definition gl_backend.c:28
matrix4x4_t gl_modelviewmatrix
Definition gl_backend.c:26
matrix4x4_t gl_projectionmatrix
Definition gl_backend.c:27
float gl_modelview16f[16]
Definition gl_backend.c:29
qbool gl_modelmatrixchanged
Definition gl_backend.c:31
matrix4x4_t gl_viewmatrix
Definition gl_backend.c:25
void Matrix4x4_Concat(matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2)
Definition matrixlib.c:83
void Matrix4x4_ToArrayFloatGL(const matrix4x4_t *in, float out[16])
Definition matrixlib.c:1165
int loc_ModelViewProjectionMatrix
Definition gl_rmain.c:812

References CHECKGLERROR, gl_modelmatrix, gl_modelmatrixchanged, gl_modelview16f, gl_modelviewmatrix, gl_modelviewprojection16f, gl_modelviewprojectionmatrix, gl_projectionmatrix, gl_viewmatrix, r_glsl_permutation_t::loc_ModelViewMatrix, r_glsl_permutation_t::loc_ModelViewProjectionMatrix, Matrix4x4_Concat(), Matrix4x4_ToArrayFloatGL(), r_glsl_permutation, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, and vid.

Referenced by R_BlendView(), R_DrawExplosion_TransparentCallback(), R_DrawLoc_Callback(), R_DrawPortal_Callback(), R_MotionBlurView(), R_ResetViewRendering2D_Common(), R_ResetViewRendering3D(), R_SetViewport(), R_Shadow_DrawCoronas(), R_Shadow_RenderMode_DrawDeferredLight(), RSurf_ActiveCustomEntity(), and RSurf_ActiveModelEntity().

◆ R_EvaluateQ3WaveFunc()

static float R_EvaluateQ3WaveFunc ( q3wavefunc_t func,
const float * parms )
static

Definition at line 6407 of file gl_rmain.c.

6408{
6409 double index, f;
6410 index = parms[2] + rsurface.shadertime * parms[3];
6411 index -= floor(index);
6412 switch (func & ((1 << Q3WAVEFUNC_USER_SHIFT) - 1))
6413 {
6414 default:
6415 case Q3WAVEFUNC_NONE:
6416 case Q3WAVEFUNC_NOISE:
6417 case Q3WAVEFUNC_COUNT:
6418 f = 0;
6419 break;
6420 case Q3WAVEFUNC_SIN: f = sin(index * M_PI * 2);break;
6421 case Q3WAVEFUNC_SQUARE: f = index < 0.5 ? 1 : -1;break;
6422 case Q3WAVEFUNC_SAWTOOTH: f = index;break;
6423 case Q3WAVEFUNC_INVERSESAWTOOTH: f = 1 - index;break;
6425 index *= 4;
6426 f = index - floor(index);
6427 if (index < 1)
6428 {
6429 // f = f;
6430 }
6431 else if (index < 2)
6432 f = 1 - f;
6433 else if (index < 3)
6434 f = -f;
6435 else
6436 f = -(1 - f);
6437 break;
6438 }
6439 f = parms[0] + parms[1] * f;
6440 if(func >> Q3WAVEFUNC_USER_SHIFT) // assumes rsurface to be set!
6442 return (float) f;
6443}
#define M_PI
Definition mathlib.h:28
float sin(float f)
#define Q3WAVEFUNC_USER_COUNT
Definition r_qshader.h:42
#define Q3WAVEFUNC_USER_SHIFT
Definition r_qshader.h:43
@ Q3WAVEFUNC_INVERSESAWTOOTH
Definition r_qshader.h:32
@ Q3WAVEFUNC_SAWTOOTH
Definition r_qshader.h:34
@ Q3WAVEFUNC_TRIANGLE
Definition r_qshader.h:37
@ Q3WAVEFUNC_NOISE
Definition r_qshader.h:33
@ Q3WAVEFUNC_COUNT
Definition r_qshader.h:38
@ Q3WAVEFUNC_NONE
Definition r_qshader.h:31
@ Q3WAVEFUNC_SIN
Definition r_qshader.h:35
@ Q3WAVEFUNC_SQUARE
Definition r_qshader.h:36
float userwavefunc_param[Q3WAVEFUNC_USER_COUNT]
Definition render.h:762
double shadertime
Definition render.h:717

References bound, f, floor(), index, M_PI, Q3WAVEFUNC_COUNT, Q3WAVEFUNC_INVERSESAWTOOTH, Q3WAVEFUNC_NOISE, Q3WAVEFUNC_NONE, Q3WAVEFUNC_SAWTOOTH, Q3WAVEFUNC_SIN, Q3WAVEFUNC_SQUARE, Q3WAVEFUNC_TRIANGLE, Q3WAVEFUNC_USER_COUNT, Q3WAVEFUNC_USER_SHIFT, rsurface, rsurfacestate_t::shadertime, sin(), and rsurfacestate_t::userwavefunc_param.

Referenced by R_tcMod_ApplyToMatrix(), and RSurf_PrepareVerticesForBatch().

◆ R_FillColors()

void R_FillColors ( float * out,
int verts,
float r,
float g,
float b,
float a )

Definition at line 335 of file gl_rmain.c.

336{
337 int i;
338 for (i = 0;i < verts;i++)
339 {
340 out[0] = r;
341 out[1] = g;
342 out[2] = b;
343 out[3] = a;
344 out += 4;
345 }
346}

References a, b, g, i, and r.

Referenced by R_DrawBBoxMesh().

◆ R_FrameData_Alloc()

void * R_FrameData_Alloc ( size_t size)

allocate some temporary memory for your purposes

Definition at line 3539 of file gl_rmain.c.

3540{
3541 void *data;
3542 float newvalue;
3543
3544 // align to 16 byte boundary - the data pointer is already aligned, so we
3545 // only need to ensure the size of every allocation is also aligned
3546 size = (size + 15) & ~15;
3547
3549 {
3550 // emergency - we ran out of space, allocate more memory
3551 // note: this has no upper-bound, we'll fail to allocate memory eventually and just die
3552 newvalue = r_framedatasize.value * 2.0f;
3553 // upper bound based on architecture - if we try to allocate more than this we could overflow, better to loop until we error out on allocation failure
3554 if (sizeof(size_t) >= 8)
3555 newvalue = bound(0.25f, newvalue, (float)(1ll << 42));
3556 else
3557 newvalue = bound(0.25f, newvalue, (float)(1 << 10));
3558 // this might not be a growing it, but we'll allocate another buffer every time
3560 R_FrameData_Resize(true);
3561 }
3562
3565
3566 // count the usage for stats
3569
3570 return (void *)data;
3571}
static void R_FrameData_Resize(qbool mustgrow)
Definition gl_rmain.c:3503
static r_framedata_mem_t * r_framedata_mem
Definition gl_rmain.c:3491
@ r_stat_framedatacurrent
Definition r_stats.h:51
@ r_stat_framedatasize
Definition r_stats.h:52
unsigned char * data
Definition gl_rmain.c:3487

References bound, r_framedata_mem_t::current, Cvar_SetValueQuick(), data, r_framedata_mem_t::data, max, r_framedata_mem, R_FrameData_Resize(), r_framedatasize, r_refdef, r_stat_framedatacurrent, r_stat_framedatasize, r_framedata_mem_t::size, size, r_refdef_t::stats, and cvar_t::value.

Referenced by R_AnimCache_GetEntity(), R_FrameData_Store(), R_Q1BSP_CallRecursiveGetLightInfo(), RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), and RSurf_PrepareVerticesForBatch().

◆ R_FrameData_NewFrame()

void R_FrameData_NewFrame ( void )

prepare for a new frame, recycles old buffers if a resize occurred previously

Definition at line 3521 of file gl_rmain.c.

3522{
3523 R_FrameData_Resize(false);
3524 if (!r_framedata_mem)
3525 return;
3526 // if we ran out of space on the last frame, free the old memory now
3527 while (r_framedata_mem->purge)
3528 {
3529 // repeatedly remove the second item in the list, leaving only head
3530 r_framedata_mem_t *next = r_framedata_mem->purge->purge;
3532 r_framedata_mem->purge = next;
3533 }
3534 // reset the current mem pointer
3536 r_framedata_mem->mark = 0;
3537}
struct r_framedata_mem_s * purge
Definition gl_rmain.c:3482

References r_framedata_mem_t::current, r_framedata_mem_t::mark, Mem_Free, r_framedata_mem_t::purge, r_framedata_mem, and R_FrameData_Resize().

Referenced by CL_UpdateScreen().

◆ R_FrameData_Reset()

void R_FrameData_Reset ( void )

free all R_FrameData memory

Definition at line 3493 of file gl_rmain.c.

3494{
3495 while (r_framedata_mem)
3496 {
3499 r_framedata_mem = next;
3500 }
3501}

References Mem_Free, r_framedata_mem_t::purge, and r_framedata_mem.

Referenced by gl_main_newmap(), gl_main_shutdown(), and gl_main_start().

◆ R_FrameData_Resize()

static void R_FrameData_Resize ( qbool mustgrow)
static

Definition at line 3503 of file gl_rmain.c.

3504{
3505 size_t wantedsize;
3506 wantedsize = (size_t)(r_framedatasize.value * 1024*1024);
3507 wantedsize = bound(65536, wantedsize, 1000*1024*1024);
3508 if (!r_framedata_mem || r_framedata_mem->wantedsize != wantedsize || mustgrow)
3509 {
3511 newmem->wantedsize = wantedsize;
3512 newmem->data = (unsigned char *)(((size_t)(newmem+1) + 15) & ~15);
3513 newmem->size = (unsigned char *)newmem + wantedsize - newmem->data;
3514 newmem->current = 0;
3515 newmem->mark = 0;
3516 newmem->purge = r_framedata_mem;
3517 r_framedata_mem = newmem;
3518 }
3519}

References bound, r_framedata_mem_t::current, r_framedata_mem_t::data, r_framedata_mem_t::mark, Mem_Alloc, r_framedata_mem_t::purge, r_framedata_mem, r_framedatasize, r_main_mempool, r_framedata_mem_t::size, cvar_t::value, and r_framedata_mem_t::wantedsize.

Referenced by R_FrameData_Alloc(), and R_FrameData_NewFrame().

◆ R_FrameData_ReturnToMark()

void R_FrameData_ReturnToMark ( void )

discard recent memory allocations (rewind to marker)

Definition at line 3588 of file gl_rmain.c.

3589{
3590 if (!r_framedata_mem)
3591 return;
3593}

References r_framedata_mem_t::current, r_framedata_mem_t::mark, and r_framedata_mem.

Referenced by R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Q1BSP_DrawLight_TransparentCallback(), R_QueueModelSurfaceList(), and R_RTLight_Compile().

◆ R_FrameData_SetMark()

void R_FrameData_SetMark ( void )

set a marker that allows you to discard the following temporary memory allocations

Definition at line 3581 of file gl_rmain.c.

3582{
3583 if (!r_framedata_mem)
3584 return;
3586}

References r_framedata_mem_t::current, r_framedata_mem_t::mark, and r_framedata_mem.

Referenced by R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Q1BSP_DrawLight_TransparentCallback(), R_QueueModelSurfaceList(), and R_RTLight_Compile().

◆ R_FrameData_Store()

void * R_FrameData_Store ( size_t size,
void * data )

allocate some temporary memory and copy this data into it

Definition at line 3573 of file gl_rmain.c.

3574{
3575 void *d = R_FrameData_Alloc(size);
3576 if (d && data)
3577 memcpy(d, data, size);
3578 return d;
3579}

References data, R_FrameData_Alloc(), and size.

Referenced by R_Shadow_PrepareLight(), and RSurf_PrepareVerticesForBatch().

◆ R_GetCornerOfBox()

static void R_GetCornerOfBox ( vec3_t out,
const vec3_t mins,
const vec3_t maxs,
int signbits )
static

Definition at line 3438 of file gl_rmain.c.

3439{
3440 out[0] = ((signbits & 1) ? mins : maxs)[0];
3441 out[1] = ((signbits & 2) ? mins : maxs)[1];
3442 out[2] = ((signbits & 4) ? mins : maxs)[2];
3443}

References maxs, and mins.

Referenced by _R_CullBox().

◆ R_GetCubemap()

rtexture_t * R_GetCubemap ( const char * basename)

Definition at line 2982 of file gl_rmain.c.

2983{
2984 int i;
2985 for (i = 0;i < r_texture_numcubemaps;i++)
2986 if (r_texture_cubemaps[i] != NULL)
2987 if (!strcasecmp(r_texture_cubemaps[i]->basename, basename))
2989 if (i >= MAX_CUBEMAPS || !r_main_mempool)
2990 return r_texture_whitecube;
2993 dp_strlcpy(r_texture_cubemaps[i]->basename, basename, sizeof(r_texture_cubemaps[i]->basename));
2995 return r_texture_cubemaps[i]->texture;
2996}
static rtexture_t * R_LoadCubemap(const char *basename)
Definition gl_rmain.c:2908
#define MAX_CUBEMAPS
max number of cubemap textures loaded for light filters
Definition qdefs.h:130
rtexture_t * texture
Definition gl_rmain.c:290

References dp_strlcpy, i, MAX_CUBEMAPS, Mem_Alloc, NULL, R_LoadCubemap(), r_main_mempool, r_texture_cubemaps, r_texture_numcubemaps, r_texture_whitecube, and cubemapinfo_t::texture.

Referenced by Mod_LoadTextureFromQ3Shader(), R_Shadow_PrepareLight(), and VM_CL_loadcubemap().

◆ R_GetCurrentTexture()

texture_t * R_GetCurrentTexture ( texture_t * t)

Definition at line 6549 of file gl_rmain.c.

6550{
6551 int i, q;
6552 const entity_render_t *ent = rsurface.entity;
6553 model_t *model = ent->model; // when calling this, ent must not be NULL
6555 float specularscale = 0.0f;
6556
6558 return t->currentframe;
6560 t->update_lastrenderentity = (void *)ent;
6561
6562 if(ent->entitynumber >= MAX_EDICTS && ent->entitynumber < 2 * MAX_EDICTS)
6563 t->camera_entity = ent->entitynumber;
6564 else
6565 t->camera_entity = 0;
6566
6567 // switch to an alternate material if this is a q1bsp animated material
6568 {
6569 texture_t *texture = t;
6570 int s = rsurface.ent_skinnum;
6571 if ((unsigned int)s >= (unsigned int)model->numskins)
6572 s = 0;
6573 if (model->skinscenes)
6574 {
6575 if (model->skinscenes[s].framecount > 1)
6576 s = model->skinscenes[s].firstframe + (unsigned int) (rsurface.shadertime * model->skinscenes[s].framerate) % model->skinscenes[s].framecount;
6577 else
6578 s = model->skinscenes[s].firstframe;
6579 }
6580 if (s > 0)
6581 t = t + s * model->num_surfaces;
6582 if (t->animated)
6583 {
6584 // use an alternate animation if the entity's frame is not 0,
6585 // and only if the texture has an alternate animation
6586 if (t->animated == 2) // q2bsp
6587 t = t->anim_frames[0][ent->framegroupblend[0].frame % t->anim_total[0]];
6588 else if (rsurface.ent_alttextures && t->anim_total[1])
6589 t = t->anim_frames[1][(t->anim_total[1] >= 2) ? ((int)(rsurface.shadertime * 5.0f) % t->anim_total[1]) : 0];
6590 else
6591 t = t->anim_frames[0][(t->anim_total[0] >= 2) ? ((int)(rsurface.shadertime * 5.0f) % t->anim_total[0]) : 0];
6592 }
6593 texture->currentframe = t;
6594 }
6595
6596 // update currentskinframe to be a qw skin or animation frame
6597 if (rsurface.ent_qwskin >= 0)
6598 {
6601 {
6603 if (r_qwskincache)
6606 }
6607 if (strcmp(r_qwskincache[i].name, cl.scores[i].qw_skin))
6612 }
6613 else if (t->materialshaderpass && t->materialshaderpass->numframes >= 2)
6617
6620 if (t->basematerialflags & MATERIALFLAG_WATERALPHA && (model->brush.supportwateralpha || r_water.integer || r_novis.integer || r_trippy.integer))
6626
6627 // decide on which type of lighting to use for this surface
6635 {
6636 // some CUSTOMBLEND blendfuncs are too weird, we have to ignore colormod and view colorscale
6638 for (q = 0; q < 3; q++)
6639 {
6641 t->render_modellight_lightdir_world[q] = q == 2;
6642 t->render_modellight_lightdir_local[q] = q == 2;
6643 t->render_modellight_ambient[q] = 1;
6644 t->render_modellight_diffuse[q] = 0;
6646 t->render_lightmap_ambient[q] = 0;
6647 t->render_lightmap_diffuse[q] = 0;
6648 t->render_lightmap_specular[q] = 0;
6649 t->render_rtlight_diffuse[q] = 0;
6650 t->render_rtlight_specular[q] = 0;
6651 }
6652 }
6654 {
6655 // fullbright is basically MATERIALFLAG_MODELLIGHT but with ambient locked to 1,1,1 and no shading
6657 for (q = 0; q < 3; q++)
6658 {
6661 t->render_modellight_lightdir_world[q] = q == 2;
6662 t->render_modellight_lightdir_local[q] = q == 2;
6663 t->render_modellight_diffuse[q] = 0;
6665 t->render_lightmap_ambient[q] = 0;
6666 t->render_lightmap_diffuse[q] = 0;
6667 t->render_lightmap_specular[q] = 0;
6668 t->render_rtlight_diffuse[q] = 0;
6669 t->render_rtlight_specular[q] = 0;
6670 }
6671 }
6673 {
6674 t->currentmaterialflags &= ~MATERIALFLAG_MODELLIGHT;
6675 for (q = 0; q < 3; q++)
6676 {
6678 t->render_modellight_lightdir_world[q] = q == 2;
6679 t->render_modellight_lightdir_local[q] = q == 2;
6680 t->render_modellight_ambient[q] = 0;
6681 t->render_modellight_diffuse[q] = 0;
6688 }
6689 }
6691 {
6692 // ambient + single direction light (modellight)
6694 for (q = 0; q < 3; q++)
6695 {
6702 t->render_lightmap_ambient[q] = 0;
6703 t->render_lightmap_diffuse[q] = 0;
6704 t->render_lightmap_specular[q] = 0;
6707 }
6708 }
6709 else
6710 {
6711 // lightmap - 2x diffuse and specular brightness because bsp files have 0-2 colors as 0-1
6712 for (q = 0; q < 3; q++)
6713 {
6715 t->render_modellight_lightdir_world[q] = q == 2;
6716 t->render_modellight_lightdir_local[q] = q == 2;
6717 t->render_modellight_ambient[q] = 0;
6718 t->render_modellight_diffuse[q] = 0;
6725 }
6726 }
6727
6729 {
6730 // since MATERIALFLAG_VERTEXCOLOR uses the lightmapcolor4f vertex
6731 // attribute, we punt it to the lightmap path and hope for the best,
6732 // but lighting doesn't work.
6733 //
6734 // FIXME: this is fine for effects but CSQC polygons should be subject
6735 // to lighting.
6737 for (q = 0; q < 3; q++)
6738 {
6740 t->render_modellight_lightdir_world[q] = q == 2;
6741 t->render_modellight_lightdir_local[q] = q == 2;
6742 t->render_modellight_ambient[q] = 0;
6743 t->render_modellight_diffuse[q] = 0;
6745 t->render_lightmap_ambient[q] = 0;
6747 t->render_lightmap_specular[q] = 0;
6748 t->render_rtlight_diffuse[q] = 0;
6749 t->render_rtlight_specular[q] = 0;
6750 }
6751 }
6752
6753 for (q = 0; q < 3; q++)
6754 {
6757 }
6758
6761 else if (t->currentalpha < 1)
6763 // LadyHavoc: prevent bugs where code checks add or alpha at higher priority than customblend by clearing these flags
6770 if (t->backgroundshaderpass)
6773 {
6775 t->currentmaterialflags &= ~MATERIALFLAG_BLENDED;
6776 }
6777 else
6780 {
6781 // promote alphablend to alphatocoverage (a type of alphatest) if antialiasing is on
6783 }
6786
6787 // there is no tcmod
6789 {
6792 }
6794 {
6797 }
6798
6799 if (t->materialshaderpass)
6800 for (i = 0, tcmod = t->materialshaderpass->tcmods;i < Q3MAXTCMODS && tcmod->tcmod;i++, tcmod++)
6802
6804 if (t->currentskinframe->qpixels)
6806 t->basetexture = (!t->colormapping && t->currentskinframe->merged) ? t->currentskinframe->merged : t->currentskinframe->base;
6807 if (!t->basetexture)
6809 t->pantstexture = t->colormapping ? t->currentskinframe->pants : NULL;
6810 t->shirttexture = t->colormapping ? t->currentskinframe->shirt : NULL;
6811 t->nmaptexture = t->currentskinframe->nmap;
6812 if (!t->nmaptexture)
6815 t->glowtexture = t->currentskinframe->glow;
6816 t->fogtexture = t->currentskinframe->fog;
6817 t->reflectmasktexture = t->currentskinframe->reflect;
6818 if (t->backgroundshaderpass)
6819 {
6820 for (i = 0, tcmod = t->backgroundshaderpass->tcmods; i < Q3MAXTCMODS && tcmod->tcmod; i++, tcmod++)
6822 t->backgroundbasetexture = (!t->colormapping && t->backgroundcurrentskinframe->merged) ? t->backgroundcurrentskinframe->merged : t->backgroundcurrentskinframe->base;
6826 if (!t->backgroundnmaptexture)
6828 // make sure that if glow is going to be used, both textures are not NULL
6829 if (!t->backgroundglowtexture && t->glowtexture)
6831 if (!t->glowtexture && t->backgroundglowtexture)
6833 }
6834 else
6835 {
6840 }
6842 // TODO: store reference values for these in the texture?
6843 if (r_shadow_gloss.integer > 0)
6844 {
6846 {
6848 {
6851 specularscale = r_shadow_glossintensity.value;
6852 }
6853 }
6855 {
6858 specularscale = r_shadow_gloss2intensity.value;
6860 }
6861 }
6862 specularscale *= t->specularscalemod;
6864
6865 // lightmaps mode looks bad with dlights using actual texturing, so turn
6866 // off the colormap and glossmap, but leave the normalmap on as it still
6867 // accurately represents the shading involved
6869 {
6873 if (gl_lightmaps.integer < 2)
6876 t->glowtexture = NULL;
6877 t->fogtexture = NULL;
6880 if (gl_lightmaps.integer < 2)
6884 specularscale = 0;
6886 }
6887
6888 if (specularscale != 1.0f)
6889 {
6890 for (q = 0; q < 3; q++)
6891 {
6892 t->render_modellight_specular[q] *= specularscale;
6893 t->render_lightmap_specular[q] *= specularscale;
6894 t->render_rtlight_specular[q] *= specularscale;
6895 }
6896 }
6897
6898 t->currentblendfunc[0] = GL_ONE;
6899 t->currentblendfunc[1] = GL_ZERO;
6901 {
6903 t->currentblendfunc[1] = GL_ONE;
6904 }
6906 {
6909 }
6911 {
6912 t->currentblendfunc[0] = t->customblendfunc[0];
6913 t->currentblendfunc[1] = t->customblendfunc[1];
6914 }
6915
6916 return t;
6917}
entity_t cl_meshentities[NUM_MESHENTITIES]
Definition cl_main.c:2513
@ MESH_UI
Definition client.h:1365
static void R_LoadQWSkin(r_qwskincache_t *cache, const char *skinname)
Definition gl_rmain.c:6522
static void R_SkinFrame_GenerateTexturesFromQPixels(skinframe_t *skinframe, qbool colormapped)
Definition gl_rmain.c:2676
int r_textureframe
used only by R_GetCurrentTexture, incremented per view and per UI render
Definition gl_rmain.c:45
matrix4x4_t r_waterscrollmatrix
Definition gl_rmain.c:5394
static void R_tcMod_ApplyToMatrix(matrix4x4_t *texmatrix, q3shaderinfo_layer_tcmod_t *tcmod, int currentmaterialflags)
Definition gl_rmain.c:6445
static int R_BlendFuncFlags(int src, int dst)
Definition gl_rmain.c:1522
const GLchar * name
Definition glquake.h:601
int LoopingFrameNumberFromDouble(double t, int loopframes)
Definition mathlib.c:891
#define VectorLength2(a)
Definition mathlib.h:110
void Matrix4x4_CreateIdentity(matrix4x4_t *out)
Definition matrixlib.c:564
cvar_t r_shadow_gloss
Definition r_shadow.c:147
cvar_t r_novis
Definition model_brush.c:31
#define MATERIALFLAG_ADD
Definition model_brush.h:81
#define MATERIALFLAG_FULLBRIGHT
Definition model_brush.h:87
#define MATERIALFLAG_VERTEXTEXTUREBLEND
#define MATERIALFLAG_LIGHTGRID
#define MATERIALFLAG_MODELLIGHT
#define MATERIALFLAG_WATERSCROLL
Definition model_brush.h:94
#define MATERIALFLAG_CUSTOMBLEND
#define MATERIALFLAG_NORTLIGHT
#define RENDER_DYNAMICMODELLIGHT
Definition protocol.h:373
#define RENDER_LIGHT
Definition protocol.h:366
#define RENDER_CUSTOMIZEDMODELLIGHT
Definition protocol.h:372
#define MAX_EDICTS
max number of objects in game world at once (32768 protocol limit)
Definition qdefs.h:105
cvar_t r_shadow_glossintensity
Definition r_shadow.c:149
cvar_t r_shadow_gloss2intensity
Definition r_shadow.c:148
cvar_t r_shadow_glossexponent
Definition r_shadow.c:150
cvar_t r_shadow_gloss2exponent
Definition r_shadow.c:151
scoreboard_t * scores
Definition client.h:945
float render_rtlight_diffuse[3]
Definition client.h:426
float render_glowmod[3]
Definition client.h:414
float render_modellight_specular[3]
Definition client.h:420
qbool render_rtlight_disabled
Definition client.h:431
float render_modellight_lightdir_world[3]
Definition client.h:418
float render_lightmap_ambient[3]
Definition client.h:422
float render_modellight_lightdir_local[3]
Definition client.h:419
vec3_t colormap_shirtcolor
Definition client.h:348
qbool render_modellight_forced
Definition client.h:429
framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS]
Definition client.h:363
float render_lightmap_diffuse[3]
Definition client.h:423
float render_modellight_ambient[3]
Definition client.h:416
float render_rtlight_specular[3]
Definition client.h:427
float render_lightmap_specular[3]
Definition client.h:424
qbool render_lightgrid
Definition client.h:433
float render_modellight_diffuse[3]
Definition client.h:417
float glowmod[3]
Definition client.h:360
vec3_t colormap_pantscolor
Definition client.h:347
entity_render_t render
Definition client.h:477
skinframe_t * skinframe
Definition gl_rmain.c:304
qbool isoverlay
if true, don't clear or do any post process effects (bloom, etc)
Definition render.h:307
qbool enabled
Definition render.h:874
int ent_alttextures
Definition render.h:716
float * modeltexcoordlightmap2f
Definition render.h:640
qbool forcecurrenttextureupdate
Definition render.h:610
char qw_skin[MAX_QPATH]
Definition client.h:501
q3shaderinfo_layer_tcmod_t tcmods[Q3MAXTCMODS]
Definition r_qshader.h:270
struct skinframe_s * skinframes[TEXTURE_MAXFRAMES]
Definition r_qshader.h:265
float specularpower
struct skinframe_s * backgroundcurrentskinframe
struct rtexture_s * basetexture
int currentblendfunc[2]
float render_rtlight_specular[3]
matrix4x4_t currenttexmatrix
qbool colormapping
struct rtexture_s * glosstexture
float render_modellight_lightdir_world[3]
float render_glowmod[3]
struct rtexture_s * nmaptexture
int anim_total[2]
struct rtexture_s * backgroundglosstexture
struct rtexture_s * backgroundbasetexture
texture_shaderpass_t * backgroundshaderpass
int camera_entity
void * update_lastrenderentity
float basealpha
float render_modellight_diffuse[3]
float render_rtlight_diffuse[3]
float render_modellight_ambient[3]
float specularpowermod
int basematerialflags
struct texture_s * currentframe
struct rtexture_s * glowtexture
int update_lastrenderframe
float render_modellight_lightdir_local[3]
struct rtexture_s * backgroundglowtexture
float render_lightmap_specular[3]
struct rtexture_s * reflectmasktexture
matrix4x4_t currentbackgroundtexmatrix
struct rtexture_s * fogtexture
float render_lightmap_diffuse[3]
texture_shaderpass_t * materialshaderpass
float render_lightmap_ambient[3]
float specularscalemod
struct rtexture_s * backgroundnmaptexture
float render_modellight_specular[3]
struct texture_s * anim_frames[2][10]
int customblendfunc[2]
qbool allowalphatocoverage
indicates the GL_AlphaToCoverage function works on this renderpath and framebuffer
Definition vid.h:81

References viddef_t::allowalphatocoverage, entity_render_t::alpha, texture_t::anim_frames, texture_t::anim_total, texture_t::animated, texture_t::backgroundbasetexture, texture_t::backgroundcurrentskinframe, texture_t::backgroundglosstexture, texture_t::backgroundglowtexture, texture_t::backgroundnmaptexture, texture_t::backgroundshaderpass, texture_t::basealpha, texture_t::basematerialflags, texture_t::basetexture, BLENDFUNC_ALLOWS_COLORMOD, texture_t::camera_entity, cl, cl_meshentities, entity_render_t::colormap_pantscolor, entity_render_t::colormap_shirtcolor, texture_t::colormapping, r_refdef_view_t::colorscale, texture_t::currentalpha, texture_t::currentbackgroundtexmatrix, texture_t::currentblendfunc, texture_t::currentframe, texture_t::currentmaterialflags, texture_t::currentskinframe, texture_t::currenttexmatrix, texture_t::customblendfunc, r_waterstate_t::enabled, rsurfacestate_t::ent_alttextures, rsurfacestate_t::ent_flags, rsurfacestate_t::ent_qwskin, rsurfacestate_t::ent_skinnum, rsurfacestate_t::entity, entity_render_t::entitynumber, texture_t::fogtexture, rsurfacestate_t::forcecurrenttextureupdate, framegroupblend_t::frame, entity_render_t::framegroupblend, texture_shaderpass_t::framerate, gl_lightmaps, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ZERO, texture_t::glosstexture, entity_render_t::glowmod, texture_t::glowtexture, i, int(), cvar_t::integer, r_refdef_view_t::isoverlay, LoopingFrameNumberFromDouble(), MATERIALFLAG_ADD, MATERIALFLAG_ALPHA, MATERIALFLAG_ALPHATEST, MATERIALFLAG_BLENDED, MATERIALFLAG_CAMERA, MATERIALFLAG_CUSTOMBLEND, MATERIALFLAG_CUSTOMSURFACE, MATERIALFLAG_FULLBRIGHT, MATERIALFLAG_LIGHTGRID, MATERIALFLAG_MODELLIGHT, MATERIALFLAG_NOCULLFACE, MATERIALFLAG_NODEPTHTEST, MATERIALFLAG_NORTLIGHT, MATERIALFLAG_NOSHADOW, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_SHORTDEPTHRANGE, MATERIALFLAG_TRANSDEPTH, MATERIALFLAG_VERTEXCOLOR, MATERIALFLAG_VERTEXTEXTUREBLEND, MATERIALFLAG_WALL, MATERIALFLAG_WATERALPHA, MATERIALFLAG_WATERSCROLL, MATERIALFLAG_WATERSHADER, texture_t::materialshaderpass, Matrix4x4_CreateIdentity(), MAX_EDICTS, client_state_t::maxclients, Mem_Alloc, Mem_Free, MESH_UI, entity_render_t::model, model, rsurfacestate_t::modeltexcoordlightmap2f, name, texture_t::nmaptexture, NULL, texture_shaderpass_t::numframes, texture_t::pantstexture, scoreboard_t::qw_skin, R_BlendFuncFlags(), r_fb, R_LoadQWSkin(), r_main_mempool, r_novis, r_qwskincache, r_qwskincache_size, r_refdef, r_shadow_gloss, r_shadow_gloss2exponent, r_shadow_gloss2intensity, r_shadow_glossexponent, r_shadow_glossintensity, R_SkinFrame_GenerateTexturesFromQPixels(), R_tcMod_ApplyToMatrix(), r_texture_black, r_texture_blanknormalmap, r_texture_grey128, r_texture_notexture, r_texture_white, r_textureframe, r_transparent_alphatocoverage, r_transparentdepthmasking, r_trippy, r_water, r_wateralpha, r_waterscrollmatrix, texture_t::reflectmasktexture, entity_t::render, RENDER_ADDITIVE, texture_t::render_colormap_pants, texture_t::render_colormap_shirt, RENDER_CUSTOMIZEDMODELLIGHT, RENDER_DOUBLESIDED, RENDER_DYNAMICMODELLIGHT, entity_render_t::render_fullbright, entity_render_t::render_glowmod, texture_t::render_glowmod, RENDER_LIGHT, entity_render_t::render_lightgrid, entity_render_t::render_lightmap_ambient, texture_t::render_lightmap_ambient, entity_render_t::render_lightmap_diffuse, texture_t::render_lightmap_diffuse, entity_render_t::render_lightmap_specular, texture_t::render_lightmap_specular, entity_render_t::render_modellight_ambient, texture_t::render_modellight_ambient, entity_render_t::render_modellight_diffuse, texture_t::render_modellight_diffuse, entity_render_t::render_modellight_forced, entity_render_t::render_modellight_lightdir_local, texture_t::render_modellight_lightdir_local, entity_render_t::render_modellight_lightdir_world, texture_t::render_modellight_lightdir_world, entity_render_t::render_modellight_specular, texture_t::render_modellight_specular, RENDER_NODEPTHTEST, entity_render_t::render_rtlight_diffuse, texture_t::render_rtlight_diffuse, entity_render_t::render_rtlight_disabled, entity_render_t::render_rtlight_specular, texture_t::render_rtlight_specular, RENDER_VIEWMODEL, rsurface, client_state_t::scores, rsurfacestate_t::shadertime, texture_t::shirttexture, r_qwskincache_t::skinframe, texture_shaderpass_t::skinframes, texture_t::specularpower, texture_t::specularpowermod, texture_t::specularscalemod, texture_shaderpass_t::tcmods, texture, texture_t::update_lastrenderentity, texture_t::update_lastrenderframe, cvar_t::value, VectorLength2, vid, r_refdef_t::view, and r_framebufferstate_t::water.

Referenced by R_DrawCustomSurface_Texture(), R_DrawDebugModel(), R_DrawSurface_TransparentCallback(), R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Model_Sprite_Draw_TransparentCallback(), R_Q1BSP_DrawLight_TransparentCallback(), R_Q1BSP_RecursiveGetLightInfo_BIH(), R_Q1BSP_RecursiveGetLightInfo_BSP(), R_QueueModelSurfaceList(), and R_Water_AddWaterPlane().

◆ R_GetScenePointer()

r_refdef_scene_t * R_GetScenePointer ( r_refdef_scene_type_t scenetype)

Definition at line 5588 of file gl_rmain.c.

5589{
5590 // of course, we could also add a qbool that provides a lock state and a ReleaseScenePointer function..
5591 if( scenetype == r_currentscenetype ) {
5592 return &r_refdef.scene;
5593 } else {
5594 return &r_scenes_store[ scenetype ];
5595 }
5596}
static r_refdef_scene_type_t r_currentscenetype
Definition gl_rmain.c:5566
static r_refdef_scene_t r_scenes_store[RST_COUNT]
Definition gl_rmain.c:5567

References r_currentscenetype, r_refdef, r_scenes_store, and r_refdef_t::scene.

Referenced by MVM_init_cmd().

◆ R_GLSL_CompilePermutation()

static void R_GLSL_CompilePermutation ( r_glsl_permutation_t * p,
unsigned int mode,
uint64_t permutation )
static

Definition at line 1024 of file gl_rmain.c.

1025{
1026 unsigned i;
1027 int ubibind;
1028 int sampler;
1030 char *sourcestring;
1031 char permutationname[256];
1032 int vertstrings_count = 0;
1033 int geomstrings_count = 0;
1034 int fragstrings_count = 0;
1035 const char *vertstrings_list[32+5+SHADERSTATICPARMS_COUNT+1];
1036 const char *geomstrings_list[32+5+SHADERSTATICPARMS_COUNT+1];
1037 const char *fragstrings_list[32+5+SHADERSTATICPARMS_COUNT+1];
1038
1039 if (p->compiled)
1040 return;
1041 p->compiled = true;
1042 p->program = 0;
1043
1044 permutationname[0] = 0;
1045 sourcestring = ShaderModeInfo_GetShaderText(modeinfo, true, false);
1046
1047 dp_strlcat(permutationname, modeinfo->filename, sizeof(permutationname));
1048
1049 // we need 140 for r_glsl_skeletal (GL_ARB_uniform_buffer_object)
1050 if(vid.support.glshaderversion >= 140)
1051 {
1052 vertstrings_list[vertstrings_count++] = "#version 140\n";
1053 geomstrings_list[geomstrings_count++] = "#version 140\n";
1054 fragstrings_list[fragstrings_count++] = "#version 140\n";
1055 vertstrings_list[vertstrings_count++] = "#define GLSL140\n";
1056 geomstrings_list[geomstrings_count++] = "#define GLSL140\n";
1057 fragstrings_list[fragstrings_count++] = "#define GLSL140\n";
1058 }
1059 // if we can do #version 130, we should (this improves quality of offset/reliefmapping thanks to textureGrad)
1060 else if(vid.support.glshaderversion >= 130)
1061 {
1062 vertstrings_list[vertstrings_count++] = "#version 130\n";
1063 geomstrings_list[geomstrings_count++] = "#version 130\n";
1064 fragstrings_list[fragstrings_count++] = "#version 130\n";
1065 vertstrings_list[vertstrings_count++] = "#define GLSL130\n";
1066 geomstrings_list[geomstrings_count++] = "#define GLSL130\n";
1067 fragstrings_list[fragstrings_count++] = "#define GLSL130\n";
1068 }
1069 // if we can do #version 120, we should (this adds the invariant keyword)
1070 else if(vid.support.glshaderversion >= 120)
1071 {
1072 vertstrings_list[vertstrings_count++] = "#version 120\n";
1073 geomstrings_list[geomstrings_count++] = "#version 120\n";
1074 fragstrings_list[fragstrings_count++] = "#version 120\n";
1075 vertstrings_list[vertstrings_count++] = "#define GLSL120\n";
1076 geomstrings_list[geomstrings_count++] = "#define GLSL120\n";
1077 fragstrings_list[fragstrings_count++] = "#define GLSL120\n";
1078 }
1079 // GLES also adds several things from GLSL120
1080 switch(vid.renderpath)
1081 {
1082 case RENDERPATH_GLES2:
1083 vertstrings_list[vertstrings_count++] = "#define GLES\n";
1084 geomstrings_list[geomstrings_count++] = "#define GLES\n";
1085 fragstrings_list[fragstrings_count++] = "#define GLES\n";
1086 break;
1087 default:
1088 break;
1089 }
1090
1091 // the first pretext is which type of shader to compile as
1092 // (later these will all be bound together as a program object)
1093 vertstrings_list[vertstrings_count++] = "#define VERTEX_SHADER\n";
1094 geomstrings_list[geomstrings_count++] = "#define GEOMETRY_SHADER\n";
1095 fragstrings_list[fragstrings_count++] = "#define FRAGMENT_SHADER\n";
1096
1097 // the second pretext is the mode (for example a light source)
1098 vertstrings_list[vertstrings_count++] = modeinfo->pretext;
1099 geomstrings_list[geomstrings_count++] = modeinfo->pretext;
1100 fragstrings_list[fragstrings_count++] = modeinfo->pretext;
1101 dp_strlcat(permutationname, modeinfo->name, sizeof(permutationname));
1102
1103 // now add all the permutation pretexts
1104 for (i = 0;i < SHADERPERMUTATION_COUNT;i++)
1105 {
1106 if (permutation & (1ll<<i))
1107 {
1108 vertstrings_list[vertstrings_count++] = shaderpermutationinfo[i].pretext;
1109 geomstrings_list[geomstrings_count++] = shaderpermutationinfo[i].pretext;
1110 fragstrings_list[fragstrings_count++] = shaderpermutationinfo[i].pretext;
1111 dp_strlcat(permutationname, shaderpermutationinfo[i].name, sizeof(permutationname));
1112 }
1113 else
1114 {
1115 // keep line numbers correct
1116 vertstrings_list[vertstrings_count++] = "\n";
1117 geomstrings_list[geomstrings_count++] = "\n";
1118 fragstrings_list[fragstrings_count++] = "\n";
1119 }
1120 }
1121
1122 // add static parms
1124 memcpy((char *)(vertstrings_list + vertstrings_count), shaderstaticparmstrings_list, sizeof(*vertstrings_list) * shaderstaticparms_count);
1125 vertstrings_count += shaderstaticparms_count;
1126 memcpy((char *)(geomstrings_list + geomstrings_count), shaderstaticparmstrings_list, sizeof(*vertstrings_list) * shaderstaticparms_count);
1127 geomstrings_count += shaderstaticparms_count;
1128 memcpy((char *)(fragstrings_list + fragstrings_count), shaderstaticparmstrings_list, sizeof(*vertstrings_list) * shaderstaticparms_count);
1129 fragstrings_count += shaderstaticparms_count;
1130
1131 // now append the shader text itself
1132 vertstrings_list[vertstrings_count++] = sourcestring;
1133 geomstrings_list[geomstrings_count++] = sourcestring;
1134 fragstrings_list[fragstrings_count++] = sourcestring;
1135
1136 // we don't currently use geometry shaders for anything, so just empty the list
1137 geomstrings_count = 0;
1138
1139 // compile the shader program
1140 if (vertstrings_count + geomstrings_count + fragstrings_count)
1141 p->program = GL_Backend_CompileProgram(vertstrings_count, vertstrings_list, geomstrings_count, geomstrings_list, fragstrings_count, fragstrings_list);
1142 if (p->program)
1143 {
1145 qglUseProgram(p->program);CHECKGLERROR
1146 // look up all the uniform variable names we care about, so we don't
1147 // have to look them up every time we set them
1148
1149#if 0
1150 // debugging aid
1151 {
1152 GLint activeuniformindex = 0;
1153 GLint numactiveuniforms = 0;
1154 char uniformname[128];
1155 GLsizei uniformnamelength = 0;
1156 GLint uniformsize = 0;
1157 GLenum uniformtype = 0;
1158 memset(uniformname, 0, sizeof(uniformname));
1159 qglGetProgramiv(p->program, GL_ACTIVE_UNIFORMS, &numactiveuniforms);
1160 Con_Printf("Shader has %i uniforms\n", numactiveuniforms);
1161 for (activeuniformindex = 0;activeuniformindex < numactiveuniforms;activeuniformindex++)
1162 {
1163 qglGetActiveUniform(p->program, activeuniformindex, sizeof(uniformname) - 1, &uniformnamelength, &uniformsize, &uniformtype, uniformname);
1164 Con_Printf("Uniform %i name \"%s\" size %i type %i\n", (int)activeuniformindex, uniformname, (int)uniformsize, (int)uniformtype);
1165 }
1166 }
1167#endif
1168
1169 p->loc_Texture_First = qglGetUniformLocation(p->program, "Texture_First");
1170 p->loc_Texture_Second = qglGetUniformLocation(p->program, "Texture_Second");
1171 p->loc_Texture_GammaRamps = qglGetUniformLocation(p->program, "Texture_GammaRamps");
1172 p->loc_Texture_Normal = qglGetUniformLocation(p->program, "Texture_Normal");
1173 p->loc_Texture_Color = qglGetUniformLocation(p->program, "Texture_Color");
1174 p->loc_Texture_Gloss = qglGetUniformLocation(p->program, "Texture_Gloss");
1175 p->loc_Texture_Glow = qglGetUniformLocation(p->program, "Texture_Glow");
1176 p->loc_Texture_SecondaryNormal = qglGetUniformLocation(p->program, "Texture_SecondaryNormal");
1177 p->loc_Texture_SecondaryColor = qglGetUniformLocation(p->program, "Texture_SecondaryColor");
1178 p->loc_Texture_SecondaryGloss = qglGetUniformLocation(p->program, "Texture_SecondaryGloss");
1179 p->loc_Texture_SecondaryGlow = qglGetUniformLocation(p->program, "Texture_SecondaryGlow");
1180 p->loc_Texture_Pants = qglGetUniformLocation(p->program, "Texture_Pants");
1181 p->loc_Texture_Shirt = qglGetUniformLocation(p->program, "Texture_Shirt");
1182 p->loc_Texture_FogHeightTexture = qglGetUniformLocation(p->program, "Texture_FogHeightTexture");
1183 p->loc_Texture_FogMask = qglGetUniformLocation(p->program, "Texture_FogMask");
1184 p->loc_Texture_LightGrid = qglGetUniformLocation(p->program, "Texture_LightGrid");
1185 p->loc_Texture_Lightmap = qglGetUniformLocation(p->program, "Texture_Lightmap");
1186 p->loc_Texture_Deluxemap = qglGetUniformLocation(p->program, "Texture_Deluxemap");
1187 p->loc_Texture_Attenuation = qglGetUniformLocation(p->program, "Texture_Attenuation");
1188 p->loc_Texture_Cube = qglGetUniformLocation(p->program, "Texture_Cube");
1189 p->loc_Texture_Refraction = qglGetUniformLocation(p->program, "Texture_Refraction");
1190 p->loc_Texture_Reflection = qglGetUniformLocation(p->program, "Texture_Reflection");
1191 p->loc_Texture_ShadowMap2D = qglGetUniformLocation(p->program, "Texture_ShadowMap2D");
1192 p->loc_Texture_CubeProjection = qglGetUniformLocation(p->program, "Texture_CubeProjection");
1193 p->loc_Texture_ScreenNormalMap = qglGetUniformLocation(p->program, "Texture_ScreenNormalMap");
1194 p->loc_Texture_ScreenDiffuse = qglGetUniformLocation(p->program, "Texture_ScreenDiffuse");
1195 p->loc_Texture_ScreenSpecular = qglGetUniformLocation(p->program, "Texture_ScreenSpecular");
1196 p->loc_Texture_ReflectMask = qglGetUniformLocation(p->program, "Texture_ReflectMask");
1197 p->loc_Texture_ReflectCube = qglGetUniformLocation(p->program, "Texture_ReflectCube");
1198 p->loc_Texture_BounceGrid = qglGetUniformLocation(p->program, "Texture_BounceGrid");
1199 p->loc_Alpha = qglGetUniformLocation(p->program, "Alpha");
1200 p->loc_BloomBlur_Parameters = qglGetUniformLocation(p->program, "BloomBlur_Parameters");
1201 p->loc_ClientTime = qglGetUniformLocation(p->program, "ClientTime");
1202 p->loc_Color_Ambient = qglGetUniformLocation(p->program, "Color_Ambient");
1203 p->loc_Color_Diffuse = qglGetUniformLocation(p->program, "Color_Diffuse");
1204 p->loc_Color_Specular = qglGetUniformLocation(p->program, "Color_Specular");
1205 p->loc_Color_Glow = qglGetUniformLocation(p->program, "Color_Glow");
1206 p->loc_Color_Pants = qglGetUniformLocation(p->program, "Color_Pants");
1207 p->loc_Color_Shirt = qglGetUniformLocation(p->program, "Color_Shirt");
1208 p->loc_DeferredColor_Ambient = qglGetUniformLocation(p->program, "DeferredColor_Ambient");
1209 p->loc_DeferredColor_Diffuse = qglGetUniformLocation(p->program, "DeferredColor_Diffuse");
1210 p->loc_DeferredColor_Specular = qglGetUniformLocation(p->program, "DeferredColor_Specular");
1211 p->loc_DeferredMod_Diffuse = qglGetUniformLocation(p->program, "DeferredMod_Diffuse");
1212 p->loc_DeferredMod_Specular = qglGetUniformLocation(p->program, "DeferredMod_Specular");
1213 p->loc_DistortScaleRefractReflect = qglGetUniformLocation(p->program, "DistortScaleRefractReflect");
1214 p->loc_EyePosition = qglGetUniformLocation(p->program, "EyePosition");
1215 p->loc_FogColor = qglGetUniformLocation(p->program, "FogColor");
1216 p->loc_FogHeightFade = qglGetUniformLocation(p->program, "FogHeightFade");
1217 p->loc_FogPlane = qglGetUniformLocation(p->program, "FogPlane");
1218 p->loc_FogPlaneViewDist = qglGetUniformLocation(p->program, "FogPlaneViewDist");
1219 p->loc_FogRangeRecip = qglGetUniformLocation(p->program, "FogRangeRecip");
1220 p->loc_LightColor = qglGetUniformLocation(p->program, "LightColor");
1221 p->loc_LightGridMatrix = qglGetUniformLocation(p->program, "LightGridMatrix");
1222 p->loc_LightGridNormalMatrix = qglGetUniformLocation(p->program, "LightGridNormalMatrix");
1223 p->loc_LightDir = qglGetUniformLocation(p->program, "LightDir");
1224 p->loc_LightPosition = qglGetUniformLocation(p->program, "LightPosition");
1225 p->loc_OffsetMapping_ScaleSteps = qglGetUniformLocation(p->program, "OffsetMapping_ScaleSteps");
1226 p->loc_OffsetMapping_LodDistance = qglGetUniformLocation(p->program, "OffsetMapping_LodDistance");
1227 p->loc_OffsetMapping_Bias = qglGetUniformLocation(p->program, "OffsetMapping_Bias");
1228 p->loc_PixelSize = qglGetUniformLocation(p->program, "PixelSize");
1229 p->loc_ReflectColor = qglGetUniformLocation(p->program, "ReflectColor");
1230 p->loc_ReflectFactor = qglGetUniformLocation(p->program, "ReflectFactor");
1231 p->loc_ReflectOffset = qglGetUniformLocation(p->program, "ReflectOffset");
1232 p->loc_RefractColor = qglGetUniformLocation(p->program, "RefractColor");
1233 p->loc_Saturation = qglGetUniformLocation(p->program, "Saturation");
1234 p->loc_ScreenCenterRefractReflect = qglGetUniformLocation(p->program, "ScreenCenterRefractReflect");
1235 p->loc_ScreenScaleRefractReflect = qglGetUniformLocation(p->program, "ScreenScaleRefractReflect");
1236 p->loc_ScreenToDepth = qglGetUniformLocation(p->program, "ScreenToDepth");
1237 p->loc_ShadowMap_Parameters = qglGetUniformLocation(p->program, "ShadowMap_Parameters");
1238 p->loc_ShadowMap_TextureScale = qglGetUniformLocation(p->program, "ShadowMap_TextureScale");
1239 p->loc_SpecularPower = qglGetUniformLocation(p->program, "SpecularPower");
1240 p->loc_UserVec1 = qglGetUniformLocation(p->program, "UserVec1");
1241 p->loc_UserVec2 = qglGetUniformLocation(p->program, "UserVec2");
1242 p->loc_UserVec3 = qglGetUniformLocation(p->program, "UserVec3");
1243 p->loc_UserVec4 = qglGetUniformLocation(p->program, "UserVec4");
1244 p->loc_ColorFringe = qglGetUniformLocation(p->program, "ColorFringe");
1245 p->loc_ViewTintColor = qglGetUniformLocation(p->program, "ViewTintColor");
1246 p->loc_ViewToLight = qglGetUniformLocation(p->program, "ViewToLight");
1247 p->loc_ModelToLight = qglGetUniformLocation(p->program, "ModelToLight");
1248 p->loc_TexMatrix = qglGetUniformLocation(p->program, "TexMatrix");
1249 p->loc_BackgroundTexMatrix = qglGetUniformLocation(p->program, "BackgroundTexMatrix");
1250 p->loc_ModelViewMatrix = qglGetUniformLocation(p->program, "ModelViewMatrix");
1251 p->loc_ModelViewProjectionMatrix = qglGetUniformLocation(p->program, "ModelViewProjectionMatrix");
1252 p->loc_PixelToScreenTexCoord = qglGetUniformLocation(p->program, "PixelToScreenTexCoord");
1253 p->loc_ModelToReflectCube = qglGetUniformLocation(p->program, "ModelToReflectCube");
1254 p->loc_ShadowMapMatrix = qglGetUniformLocation(p->program, "ShadowMapMatrix");
1255 p->loc_BloomColorSubtract = qglGetUniformLocation(p->program, "BloomColorSubtract");
1256 p->loc_NormalmapScrollBlend = qglGetUniformLocation(p->program, "NormalmapScrollBlend");
1257 p->loc_BounceGridMatrix = qglGetUniformLocation(p->program, "BounceGridMatrix");
1258 p->loc_BounceGridIntensity = qglGetUniformLocation(p->program, "BounceGridIntensity");
1259 // initialize the samplers to refer to the texture units we use
1260 p->tex_Texture_First = -1;
1261 p->tex_Texture_Second = -1;
1262 p->tex_Texture_GammaRamps = -1;
1263 p->tex_Texture_Normal = -1;
1264 p->tex_Texture_Color = -1;
1265 p->tex_Texture_Gloss = -1;
1266 p->tex_Texture_Glow = -1;
1271 p->tex_Texture_Pants = -1;
1272 p->tex_Texture_Shirt = -1;
1274 p->tex_Texture_FogMask = -1;
1275 p->tex_Texture_LightGrid = -1;
1276 p->tex_Texture_Lightmap = -1;
1277 p->tex_Texture_Deluxemap = -1;
1279 p->tex_Texture_Cube = -1;
1280 p->tex_Texture_Refraction = -1;
1281 p->tex_Texture_Reflection = -1;
1289 p->tex_Texture_BounceGrid = -1;
1290 // bind the texture samplers in use
1291 sampler = 0;
1292 if (p->loc_Texture_First >= 0) {p->tex_Texture_First = sampler;qglUniform1i(p->loc_Texture_First , sampler);sampler++;}
1293 if (p->loc_Texture_Second >= 0) {p->tex_Texture_Second = sampler;qglUniform1i(p->loc_Texture_Second , sampler);sampler++;}
1294 if (p->loc_Texture_GammaRamps >= 0) {p->tex_Texture_GammaRamps = sampler;qglUniform1i(p->loc_Texture_GammaRamps , sampler);sampler++;}
1295 if (p->loc_Texture_Normal >= 0) {p->tex_Texture_Normal = sampler;qglUniform1i(p->loc_Texture_Normal , sampler);sampler++;}
1296 if (p->loc_Texture_Color >= 0) {p->tex_Texture_Color = sampler;qglUniform1i(p->loc_Texture_Color , sampler);sampler++;}
1297 if (p->loc_Texture_Gloss >= 0) {p->tex_Texture_Gloss = sampler;qglUniform1i(p->loc_Texture_Gloss , sampler);sampler++;}
1298 if (p->loc_Texture_Glow >= 0) {p->tex_Texture_Glow = sampler;qglUniform1i(p->loc_Texture_Glow , sampler);sampler++;}
1299 if (p->loc_Texture_SecondaryNormal >= 0) {p->tex_Texture_SecondaryNormal = sampler;qglUniform1i(p->loc_Texture_SecondaryNormal , sampler);sampler++;}
1300 if (p->loc_Texture_SecondaryColor >= 0) {p->tex_Texture_SecondaryColor = sampler;qglUniform1i(p->loc_Texture_SecondaryColor , sampler);sampler++;}
1301 if (p->loc_Texture_SecondaryGloss >= 0) {p->tex_Texture_SecondaryGloss = sampler;qglUniform1i(p->loc_Texture_SecondaryGloss , sampler);sampler++;}
1302 if (p->loc_Texture_SecondaryGlow >= 0) {p->tex_Texture_SecondaryGlow = sampler;qglUniform1i(p->loc_Texture_SecondaryGlow , sampler);sampler++;}
1303 if (p->loc_Texture_Pants >= 0) {p->tex_Texture_Pants = sampler;qglUniform1i(p->loc_Texture_Pants , sampler);sampler++;}
1304 if (p->loc_Texture_Shirt >= 0) {p->tex_Texture_Shirt = sampler;qglUniform1i(p->loc_Texture_Shirt , sampler);sampler++;}
1305 if (p->loc_Texture_FogHeightTexture>= 0) {p->tex_Texture_FogHeightTexture = sampler;qglUniform1i(p->loc_Texture_FogHeightTexture, sampler);sampler++;}
1306 if (p->loc_Texture_FogMask >= 0) {p->tex_Texture_FogMask = sampler;qglUniform1i(p->loc_Texture_FogMask , sampler);sampler++;}
1307 if (p->loc_Texture_LightGrid >= 0) {p->tex_Texture_LightGrid = sampler;qglUniform1i(p->loc_Texture_LightGrid , sampler);sampler++;}
1308 if (p->loc_Texture_Lightmap >= 0) {p->tex_Texture_Lightmap = sampler;qglUniform1i(p->loc_Texture_Lightmap , sampler);sampler++;}
1309 if (p->loc_Texture_Deluxemap >= 0) {p->tex_Texture_Deluxemap = sampler;qglUniform1i(p->loc_Texture_Deluxemap , sampler);sampler++;}
1310 if (p->loc_Texture_Attenuation >= 0) {p->tex_Texture_Attenuation = sampler;qglUniform1i(p->loc_Texture_Attenuation , sampler);sampler++;}
1311 if (p->loc_Texture_Cube >= 0) {p->tex_Texture_Cube = sampler;qglUniform1i(p->loc_Texture_Cube , sampler);sampler++;}
1312 if (p->loc_Texture_Refraction >= 0) {p->tex_Texture_Refraction = sampler;qglUniform1i(p->loc_Texture_Refraction , sampler);sampler++;}
1313 if (p->loc_Texture_Reflection >= 0) {p->tex_Texture_Reflection = sampler;qglUniform1i(p->loc_Texture_Reflection , sampler);sampler++;}
1314 if (p->loc_Texture_ShadowMap2D >= 0) {p->tex_Texture_ShadowMap2D = sampler;qglUniform1i(p->loc_Texture_ShadowMap2D , sampler);sampler++;}
1315 if (p->loc_Texture_CubeProjection >= 0) {p->tex_Texture_CubeProjection = sampler;qglUniform1i(p->loc_Texture_CubeProjection , sampler);sampler++;}
1316 if (p->loc_Texture_ScreenNormalMap >= 0) {p->tex_Texture_ScreenNormalMap = sampler;qglUniform1i(p->loc_Texture_ScreenNormalMap , sampler);sampler++;}
1317 if (p->loc_Texture_ScreenDiffuse >= 0) {p->tex_Texture_ScreenDiffuse = sampler;qglUniform1i(p->loc_Texture_ScreenDiffuse , sampler);sampler++;}
1318 if (p->loc_Texture_ScreenSpecular >= 0) {p->tex_Texture_ScreenSpecular = sampler;qglUniform1i(p->loc_Texture_ScreenSpecular , sampler);sampler++;}
1319 if (p->loc_Texture_ReflectMask >= 0) {p->tex_Texture_ReflectMask = sampler;qglUniform1i(p->loc_Texture_ReflectMask , sampler);sampler++;}
1320 if (p->loc_Texture_ReflectCube >= 0) {p->tex_Texture_ReflectCube = sampler;qglUniform1i(p->loc_Texture_ReflectCube , sampler);sampler++;}
1321 if (p->loc_Texture_BounceGrid >= 0) {p->tex_Texture_BounceGrid = sampler;qglUniform1i(p->loc_Texture_BounceGrid , sampler);sampler++;}
1322 // get the uniform block indices so we can bind them
1324#ifndef USE_GLES2 /* FIXME: GLES3 only */
1325 p->ubiloc_Skeletal_Transform12_UniformBlock = qglGetUniformBlockIndex(p->program, "Skeletal_Transform12_UniformBlock");
1326#endif
1327 // clear the uniform block bindings
1329 // bind the uniform blocks in use
1330 ubibind = 0;
1331#ifndef USE_GLES2 /* FIXME: GLES3 only */
1332 if (p->ubiloc_Skeletal_Transform12_UniformBlock >= 0) {p->ubibind_Skeletal_Transform12_UniformBlock = ubibind;qglUniformBlockBinding(p->program, p->ubiloc_Skeletal_Transform12_UniformBlock, ubibind);ubibind++;}
1333#endif
1334 // we're done compiling and setting up the shader, at least until it is used
1336 Con_DPrintf("^5GLSL shader %s compiled (%i textures).\n", permutationname, sampler);
1337 }
1338 else
1339 Con_Printf("^1GLSL shader %s failed! some features may not work properly.\n", permutationname);
1340
1341 // free the strings
1342 if (sourcestring)
1343 Mem_Free(sourcestring);
1344}
#define dp_strlcat(dst, src, dsize)
Definition common.h:304
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **vertexstrings_list, int geometrystrings_count, const char **geometrystrings_list, int fragmentstrings_count, const char **fragmentstrings_list)
shadermodeinfo_t shadermodeinfo[SHADERLANGUAGE_COUNT][SHADERMODE_COUNT]
Definition gl_rmain.c:662
static char * ShaderModeInfo_GetShaderText(shadermodeinfo_t *modeinfo, qbool printfromdisknotice, qbool builtinonly)
Definition gl_rmain.c:1006
shaderpermutationinfo_t shaderpermutationinfo[SHADERPERMUTATION_COUNT]
Definition gl_rmain.c:625
static void R_CompileShader_AddStaticParms(unsigned int mode, uint64_t permutation)
Definition gl_rmain.c:911
int GLint
Definition glquake.h:51
GLenum mode
Definition glquake.h:718
unsigned int GLenum
Definition glquake.h:45
int GLsizei
Definition glquake.h:55
#define GL_ACTIVE_UNIFORMS
Definition glquake.h:454
#define SHADERPERMUTATION_COUNT
size of shaderpermutationinfo array
Definition render.h:105
@ SHADERLANGUAGE_GLSL
Definition render.h:44
int loc_Texture_FogHeightTexture
Definition gl_rmain.c:743
int tex_Texture_SecondaryNormal
Definition gl_rmain.c:706
int loc_Texture_First
locations of detected uniforms in program object, or -1 if not found
Definition gl_rmain.c:730
int tex_Texture_FogHeightTexture
Definition gl_rmain.c:712
int loc_ScreenCenterRefractReflect
Definition gl_rmain.c:795
int loc_Texture_SecondaryNormal
Definition gl_rmain.c:737
int loc_Texture_ScreenNormalMap
Definition gl_rmain.c:754
int program
0 if compilation failed
Definition gl_rmain.c:697
int ubibind_Skeletal_Transform12_UniformBlock
uniform block bindings
Definition gl_rmain.c:822
qbool compiled
indicates if we have tried compiling this permutation already
Definition gl_rmain.c:695
int ubiloc_Skeletal_Transform12_UniformBlock
uniform block indices
Definition gl_rmain.c:824
int loc_ScreenScaleRefractReflect
Definition gl_rmain.c:796
int loc_OffsetMapping_ScaleSteps
Definition gl_rmain.c:786
int loc_DistortScaleRefractReflect
Definition gl_rmain.c:774
int loc_OffsetMapping_LodDistance
Definition gl_rmain.c:787
int tex_Texture_ScreenNormalMap
Definition gl_rmain.c:723
const char * name
Definition gl_rmain.c:617
const char * pretext
Definition gl_rmain.c:616
const char * pretext
Definition gl_rmain.c:606
int glshaderversion
this is at least 150 (GL 3.2)
Definition vid.h:45

References CHECKGLERROR, r_glsl_permutation_t::compiled, Con_DPrintf(), Con_Printf(), dp_strlcat, shadermodeinfo_t::filename, GL_ACTIVE_UNIFORMS, GL_Backend_CompileProgram(), viddef_support_t::glshaderversion, i, r_glsl_permutation_t::loc_Alpha, r_glsl_permutation_t::loc_BackgroundTexMatrix, r_glsl_permutation_t::loc_BloomBlur_Parameters, r_glsl_permutation_t::loc_BloomColorSubtract, r_glsl_permutation_t::loc_BounceGridIntensity, r_glsl_permutation_t::loc_BounceGridMatrix, r_glsl_permutation_t::loc_ClientTime, r_glsl_permutation_t::loc_Color_Ambient, r_glsl_permutation_t::loc_Color_Diffuse, r_glsl_permutation_t::loc_Color_Glow, r_glsl_permutation_t::loc_Color_Pants, r_glsl_permutation_t::loc_Color_Shirt, r_glsl_permutation_t::loc_Color_Specular, r_glsl_permutation_t::loc_ColorFringe, r_glsl_permutation_t::loc_DeferredColor_Ambient, r_glsl_permutation_t::loc_DeferredColor_Diffuse, r_glsl_permutation_t::loc_DeferredColor_Specular, r_glsl_permutation_t::loc_DeferredMod_Diffuse, r_glsl_permutation_t::loc_DeferredMod_Specular, r_glsl_permutation_t::loc_DistortScaleRefractReflect, r_glsl_permutation_t::loc_EyePosition, r_glsl_permutation_t::loc_FogColor, r_glsl_permutation_t::loc_FogHeightFade, r_glsl_permutation_t::loc_FogPlane, r_glsl_permutation_t::loc_FogPlaneViewDist, r_glsl_permutation_t::loc_FogRangeRecip, r_glsl_permutation_t::loc_LightColor, r_glsl_permutation_t::loc_LightDir, r_glsl_permutation_t::loc_LightGridMatrix, r_glsl_permutation_t::loc_LightGridNormalMatrix, r_glsl_permutation_t::loc_LightPosition, r_glsl_permutation_t::loc_ModelToLight, r_glsl_permutation_t::loc_ModelToReflectCube, r_glsl_permutation_t::loc_ModelViewMatrix, r_glsl_permutation_t::loc_ModelViewProjectionMatrix, r_glsl_permutation_t::loc_NormalmapScrollBlend, r_glsl_permutation_t::loc_OffsetMapping_Bias, r_glsl_permutation_t::loc_OffsetMapping_LodDistance, r_glsl_permutation_t::loc_OffsetMapping_ScaleSteps, r_glsl_permutation_t::loc_PixelSize, r_glsl_permutation_t::loc_PixelToScreenTexCoord, r_glsl_permutation_t::loc_ReflectColor, r_glsl_permutation_t::loc_ReflectFactor, r_glsl_permutation_t::loc_ReflectOffset, r_glsl_permutation_t::loc_RefractColor, r_glsl_permutation_t::loc_Saturation, r_glsl_permutation_t::loc_ScreenCenterRefractReflect, r_glsl_permutation_t::loc_ScreenScaleRefractReflect, r_glsl_permutation_t::loc_ScreenToDepth, r_glsl_permutation_t::loc_ShadowMap_Parameters, r_glsl_permutation_t::loc_ShadowMap_TextureScale, r_glsl_permutation_t::loc_ShadowMapMatrix, r_glsl_permutation_t::loc_SpecularPower, r_glsl_permutation_t::loc_TexMatrix, r_glsl_permutation_t::loc_Texture_Attenuation, r_glsl_permutation_t::loc_Texture_BounceGrid, r_glsl_permutation_t::loc_Texture_Color, r_glsl_permutation_t::loc_Texture_Cube, r_glsl_permutation_t::loc_Texture_CubeProjection, r_glsl_permutation_t::loc_Texture_Deluxemap, r_glsl_permutation_t::loc_Texture_First, r_glsl_permutation_t::loc_Texture_FogHeightTexture, r_glsl_permutation_t::loc_Texture_FogMask, r_glsl_permutation_t::loc_Texture_GammaRamps, r_glsl_permutation_t::loc_Texture_Gloss, r_glsl_permutation_t::loc_Texture_Glow, r_glsl_permutation_t::loc_Texture_LightGrid, r_glsl_permutation_t::loc_Texture_Lightmap, r_glsl_permutation_t::loc_Texture_Normal, r_glsl_permutation_t::loc_Texture_Pants, r_glsl_permutation_t::loc_Texture_ReflectCube, r_glsl_permutation_t::loc_Texture_Reflection, r_glsl_permutation_t::loc_Texture_ReflectMask, r_glsl_permutation_t::loc_Texture_Refraction, r_glsl_permutation_t::loc_Texture_ScreenDiffuse, r_glsl_permutation_t::loc_Texture_ScreenNormalMap, r_glsl_permutation_t::loc_Texture_ScreenSpecular, r_glsl_permutation_t::loc_Texture_Second, r_glsl_permutation_t::loc_Texture_SecondaryColor, r_glsl_permutation_t::loc_Texture_SecondaryGloss, r_glsl_permutation_t::loc_Texture_SecondaryGlow, r_glsl_permutation_t::loc_Texture_SecondaryNormal, r_glsl_permutation_t::loc_Texture_ShadowMap2D, r_glsl_permutation_t::loc_Texture_Shirt, r_glsl_permutation_t::loc_UserVec1, r_glsl_permutation_t::loc_UserVec2, r_glsl_permutation_t::loc_UserVec3, r_glsl_permutation_t::loc_UserVec4, r_glsl_permutation_t::loc_ViewTintColor, r_glsl_permutation_t::loc_ViewToLight, Mem_Free, mode, name, shadermodeinfo_t::name, shadermodeinfo_t::pretext, shaderpermutationinfo_t::pretext, r_glsl_permutation_t::program, R_CompileShader_AddStaticParms(), viddef_t::renderpath, RENDERPATH_GLES2, SHADERLANGUAGE_GLSL, shadermodeinfo, ShaderModeInfo_GetShaderText(), SHADERPERMUTATION_COUNT, shaderpermutationinfo, SHADERSTATICPARMS_COUNT, shaderstaticparms_count, shaderstaticparmstrings_list, viddef_t::support, r_glsl_permutation_t::tex_Texture_Attenuation, r_glsl_permutation_t::tex_Texture_BounceGrid, r_glsl_permutation_t::tex_Texture_Color, r_glsl_permutation_t::tex_Texture_Cube, r_glsl_permutation_t::tex_Texture_CubeProjection, r_glsl_permutation_t::tex_Texture_Deluxemap, r_glsl_permutation_t::tex_Texture_First, r_glsl_permutation_t::tex_Texture_FogHeightTexture, r_glsl_permutation_t::tex_Texture_FogMask, r_glsl_permutation_t::tex_Texture_GammaRamps, r_glsl_permutation_t::tex_Texture_Gloss, r_glsl_permutation_t::tex_Texture_Glow, r_glsl_permutation_t::tex_Texture_LightGrid, r_glsl_permutation_t::tex_Texture_Lightmap, r_glsl_permutation_t::tex_Texture_Normal, r_glsl_permutation_t::tex_Texture_Pants, r_glsl_permutation_t::tex_Texture_ReflectCube, r_glsl_permutation_t::tex_Texture_Reflection, r_glsl_permutation_t::tex_Texture_ReflectMask, r_glsl_permutation_t::tex_Texture_Refraction, r_glsl_permutation_t::tex_Texture_ScreenDiffuse, r_glsl_permutation_t::tex_Texture_ScreenNormalMap, r_glsl_permutation_t::tex_Texture_ScreenSpecular, r_glsl_permutation_t::tex_Texture_Second, r_glsl_permutation_t::tex_Texture_SecondaryColor, r_glsl_permutation_t::tex_Texture_SecondaryGloss, r_glsl_permutation_t::tex_Texture_SecondaryGlow, r_glsl_permutation_t::tex_Texture_SecondaryNormal, r_glsl_permutation_t::tex_Texture_ShadowMap2D, r_glsl_permutation_t::tex_Texture_Shirt, r_glsl_permutation_t::ubibind_Skeletal_Transform12_UniformBlock, r_glsl_permutation_t::ubiloc_Skeletal_Transform12_UniformBlock, and vid.

Referenced by R_SetupShader_SetPermutationGLSL().

◆ R_GLSL_DumpShader_f()

static void R_GLSL_DumpShader_f ( cmd_state_t * cmd)
static

Definition at line 1419 of file gl_rmain.c.

1420{
1421 unsigned i;
1422 int language, mode, dupe;
1423 char *text;
1424 shadermodeinfo_t *modeinfo;
1425 qfile_t *file;
1426
1427 for (language = 0;language < SHADERLANGUAGE_COUNT;language++)
1428 {
1429 modeinfo = shadermodeinfo[language];
1430 for (mode = 0;mode < SHADERMODE_COUNT;mode++)
1431 {
1432 // don't dump the same file multiple times (most or all shaders come from the same file)
1433 for (dupe = mode - 1;dupe >= 0;dupe--)
1434 if (!strcmp(modeinfo[mode].filename, modeinfo[dupe].filename))
1435 break;
1436 if (dupe >= 0)
1437 continue;
1438 text = modeinfo[mode].builtinstring;
1439 if (!text)
1440 continue;
1441 file = FS_OpenRealFile(modeinfo[mode].filename, "w", false);
1442 if (file)
1443 {
1444 FS_Print(file, "/* The engine may define the following macros:\n");
1445 FS_Print(file, "#define VERTEX_SHADER\n#define GEOMETRY_SHADER\n#define FRAGMENT_SHADER\n");
1446 for (i = 0;i < SHADERMODE_COUNT;i++)
1447 FS_Print(file, modeinfo[i].pretext);
1448 for (i = 0;i < SHADERPERMUTATION_COUNT;i++)
1449 FS_Print(file, shaderpermutationinfo[i].pretext);
1450 FS_Print(file, "*/\n");
1451 FS_Print(file, text);
1452 FS_Close(file);
1453 Con_Printf("%s written\n", modeinfo[mode].filename);
1454 }
1455 else
1456 Con_Printf(CON_ERROR "failed to write to %s\n", modeinfo[mode].filename);
1457 }
1458 }
1459}
#define CON_ERROR
Definition console.h:102
qfile_t * FS_OpenRealFile(const char *filepath, const char *mode, qbool quiet)
Definition fs.c:2901
int FS_Close(qfile_t *file)
Definition fs.c:2970
int FS_Print(qfile_t *file, const char *msg)
Definition fs.c:3261
@ SHADERMODE_COUNT
Definition render.h:69
@ SHADERLANGUAGE_COUNT
Definition render.h:45
char * builtinstring
Definition gl_rmain.c:619

References shadermodeinfo_t::builtinstring, CON_ERROR, Con_Printf(), FS_Close(), FS_OpenRealFile(), FS_Print(), i, mode, SHADERLANGUAGE_COUNT, SHADERMODE_COUNT, shadermodeinfo, SHADERPERMUTATION_COUNT, and shaderpermutationinfo.

Referenced by GL_Main_Init().

◆ R_GLSL_FindPermutation()

static r_glsl_permutation_t * R_GLSL_FindPermutation ( unsigned int mode,
uint64_t permutation )
static

Definition at line 940 of file gl_rmain.c.

941{
942 //unsigned int hashdepth = 0;
943 unsigned int hashindex = (permutation * 0x1021) & (SHADERPERMUTATION_HASHSIZE - 1);
945 for (p = r_glsl_permutationhash[mode][hashindex];p;p = p->hashnext)
946 {
947 if (p->mode == mode && p->permutation == permutation)
948 {
949 //if (hashdepth > 10)
950 // Con_Printf("R_GLSL_FindPermutation: Warning: %i:%i has hashdepth %i\n", mode, permutation, hashdepth);
951 return p;
952 }
953 //hashdepth++;
954 }
956 p->mode = mode;
957 p->permutation = permutation;
958 p->hashnext = r_glsl_permutationhash[mode][hashindex];
959 r_glsl_permutationhash[mode][hashindex] = p;
960 //if (hashdepth > 10)
961 // Con_Printf("R_GLSL_FindPermutation: Warning: %i:%i has hashdepth %i\n", mode, permutation, hashdepth);
962 return p;
963}
#define SHADERPERMUTATION_HASHSIZE
Definition gl_rmain.c:828
struct r_glsl_permutation_s * hashnext
hash lookup data
Definition gl_rmain.c:690
unsigned int mode
Definition gl_rmain.c:691
void * Mem_ExpandableArray_AllocRecord(memexpandablearray_t *l)
Definition zone.c:695

References r_glsl_permutation_t::hashnext, Mem_ExpandableArray_AllocRecord(), mode, r_glsl_permutation_t::mode, r_glsl_permutation_t::permutation, r_glsl_permutationarray, r_glsl_permutationhash, and SHADERPERMUTATION_HASHSIZE.

Referenced by R_SetupShader_SetPermutationGLSL().

◆ R_GLSL_Restart_f()

void R_GLSL_Restart_f ( cmd_state_t * cmd)

Definition at line 1394 of file gl_rmain.c.

1395{
1396 unsigned int i, limit;
1397 switch(vid.renderpath)
1398 {
1399 case RENDERPATH_GL32:
1400 case RENDERPATH_GLES2:
1401 {
1405 for (i = 0;i < limit;i++)
1406 {
1408 {
1411 }
1412 }
1414 }
1415 break;
1416 }
1417}
void GL_Backend_FreeProgram(unsigned int prog)
size_t Mem_ExpandableArray_IndexRange(const memexpandablearray_t *l)
Definition zone.c:763
void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record)
Definition zone.c:743

References GL_Backend_FreeProgram(), i, int(), Mem_ExpandableArray_FreeRecord(), Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), NULL, r_glsl_permutation_t::program, r_glsl_permutation, r_glsl_permutationarray, r_glsl_permutationhash, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, and vid.

Referenced by GL_Main_Init(), gl_main_shutdown(), R_RenderView(), and R_Shadow_SetShadowMode().

◆ R_HDR_UpdateIrisAdaptation()

void R_HDR_UpdateIrisAdaptation ( const vec3_t point)

Definition at line 4144 of file gl_rmain.c.

4145{
4147 {
4148 vec3_t p;
4149 vec3_t ambient;
4150 vec3_t diffuse;
4151 vec3_t diffusenormal;
4153 vec_t brightness = 0.0f;
4154 vec_t goal;
4155 vec_t current;
4156 vec_t d;
4157 int c;
4159 for (c = 0;c < (int)(sizeof(irisvecs)/sizeof(irisvecs[0]));c++)
4160 {
4161 p[0] = point[0] + irisvecs[c][0] * r_hdr_irisadaptation_radius.value;
4162 p[1] = point[1] + irisvecs[c][1] * r_hdr_irisadaptation_radius.value;
4163 p[2] = point[2] + irisvecs[c][2] * r_hdr_irisadaptation_radius.value;
4165 d = DotProduct(forward, diffusenormal);
4166 brightness += VectorLength(ambient);
4167 if (d > 0)
4168 brightness += d * VectorLength(diffuse);
4169 }
4170 brightness *= 1.0f / c;
4171 brightness += 0.00001f; // make sure it's never zero
4172 goal = r_hdr_irisadaptation_multiplier.value / brightness;
4175 if (current < goal)
4176 current = min(current + r_hdr_irisadaptation_fade_up.value * cl.realframetime, goal);
4177 else if (current > goal)
4178 current = max(current - r_hdr_irisadaptation_fade_down.value * cl.realframetime, goal);
4179 if (fabs(r_hdr_irisadaptation_value.value - current) > 0.0001f)
4181 }
4182 else if (r_hdr_irisadaptation_value.value != 1.0f)
4184}
static float irisvecs[7][3]
Definition gl_rmain.c:4142
#define VectorLength(a)
Definition mathlib.h:109
void R_CompleteLightPoint(float *ambient, float *diffuse, float *lightdir, const vec3_t p, const int flags, float lightmapintensity, float ambientintensity)
Definition r_shadow.c:6014
#define LP_DYNLIGHT
Definition r_shadow.h:194
#define LP_LIGHTMAP
Definition r_shadow.h:192
#define LP_RTWORLD
Definition r_shadow.h:193
double realframetime
Definition client.h:871
float ambientintensity
Definition render.h:384
vec3_t forward
Definition render.h:268
static vec3_t forward
Definition sv_user.c:305

References r_refdef_scene_t::ambientintensity, bound, cl, Cvar_SetValueQuick(), DotProduct, fabs(), forward, r_refdef_view_t::forward, int(), cvar_t::integer, irisvecs, r_refdef_scene_t::lightmapintensity, LP_DYNLIGHT, LP_LIGHTMAP, LP_RTWORLD, max, min, R_CompleteLightPoint(), r_hdr_irisadaptation, r_hdr_irisadaptation_fade_down, r_hdr_irisadaptation_fade_up, r_hdr_irisadaptation_maxvalue, r_hdr_irisadaptation_minvalue, r_hdr_irisadaptation_multiplier, r_hdr_irisadaptation_radius, r_hdr_irisadaptation_value, r_refdef, client_state_t::realframetime, r_refdef_t::scene, cvar_t::value, VectorCopy, VectorLength, and r_refdef_t::view.

Referenced by CL_UpdateScreen().

◆ R_InitShaderModeInfo()

static void R_InitShaderModeInfo ( void )
static

Definition at line 987 of file gl_rmain.c.

988{
989 int i, language;
990 shadermodeinfo_t *modeinfo;
991 // we have a bunch of things to compute that weren't calculated at engine compile time - all filenames should have a crc of the builtin strings to prevent accidental overrides (any customization must be updated to match engine)
992 for (language = 0; language < SHADERLANGUAGE_COUNT; language++)
993 {
994 for (i = 0; i < SHADERMODE_COUNT; i++)
995 {
996 char filename[MAX_QPATH];
997 modeinfo = &shadermodeinfo[language][i];
999 modeinfo->builtincrc = CRC_Block((const unsigned char *)modeinfo->builtinstring, strlen(modeinfo->builtinstring));
1000 dpsnprintf(filename, sizeof(filename), "%s/%s_crc%i.%s", modeinfo->extension, modeinfo->sourcebasename, modeinfo->builtincrc, modeinfo->extension);
1001 modeinfo->filename = Mem_strdup(r_main_mempool, filename);
1002 }
1003 }
1004}
unsigned short CRC_Block(const unsigned char *data, size_t size)
Definition com_crc16.c:75
static char * R_ShaderStrCat(const char **strings)
Definition gl_rmain.c:965
float strlen(string s)
const char ** builtinshaderstrings
Definition gl_rmain.c:615
const char * extension
Definition gl_rmain.c:614
const char * sourcebasename
Definition gl_rmain.c:613
#define Mem_strdup(pool, s)
Definition zone.h:97

References shadermodeinfo_t::builtincrc, shadermodeinfo_t::builtinshaderstrings, shadermodeinfo_t::builtinstring, CRC_Block(), dpsnprintf(), shadermodeinfo_t::extension, shadermodeinfo_t::filename, i, MAX_QPATH, Mem_strdup, r_main_mempool, R_ShaderStrCat(), SHADERLANGUAGE_COUNT, SHADERMODE_COUNT, shadermodeinfo, shadermodeinfo_t::sourcebasename, and strlen().

Referenced by GL_Main_Init().

◆ R_LoadCubemap()

static rtexture_t * R_LoadCubemap ( const char * basename)
static

Definition at line 2908 of file gl_rmain.c.

2909{
2910 int i, j, cubemapsize, forcefilter;
2911 unsigned char *cubemappixels, *image_buffer;
2912 rtexture_t *cubemaptexture;
2913 char name[256];
2914
2915 // HACK: if the cubemap name starts with a !, the cubemap is nearest-filtered
2916 forcefilter = TEXF_FORCELINEAR;
2917 if (basename && basename[0] == '!')
2918 {
2919 basename++;
2920 forcefilter = TEXF_FORCENEAREST;
2921 }
2922 // must start 0 so the first loadimagepixels has no requested width/height
2923 cubemapsize = 0;
2924 cubemappixels = NULL;
2925 cubemaptexture = NULL;
2926 // keep trying different suffix groups (posx, px, rt) until one loads
2927 for (j = 0;j < 3 && !cubemappixels;j++)
2928 {
2929 // load the 6 images in the suffix group
2930 for (i = 0;i < 6;i++)
2931 {
2932 // generate an image name based on the base and and suffix
2933 dpsnprintf(name, sizeof(name), "%s%s", basename, suffix[j][i].suffix);
2934 // load it
2935 if ((image_buffer = loadimagepixelsbgra(name, false, false, false, NULL)))
2936 {
2937 // an image loaded, make sure width and height are equal
2938 if (image_width == image_height && (!cubemappixels || image_width == cubemapsize))
2939 {
2940 // if this is the first image to load successfully, allocate the cubemap memory
2941 if (!cubemappixels && image_width >= 1)
2942 {
2943 cubemapsize = image_width;
2944 // note this clears to black, so unavailable sides are black
2945 cubemappixels = (unsigned char *)Mem_Alloc(tempmempool, 6*cubemapsize*cubemapsize*4);
2946 }
2947 // copy the image with any flipping needed by the suffix (px and posx types don't need flipping)
2948 if (cubemappixels)
2949 Image_CopyMux(cubemappixels+i*cubemapsize*cubemapsize*4, image_buffer, cubemapsize, cubemapsize, suffix[j][i].flipx, suffix[j][i].flipy, suffix[j][i].flipdiagonal, 4, 4, componentorder);
2950 }
2951 else
2952 Con_Printf("Cubemap image \"%s\" (%ix%i) is not square, OpenGL requires square cubemaps.\n", name, image_width, image_height);
2953 // free the image
2954 Mem_Free(image_buffer);
2955 }
2956 }
2957 }
2958 // if a cubemap loaded, upload it
2959 if (cubemappixels)
2960 {
2962 Con_Printf("loading cubemap \"%s\"\n", basename);
2963
2965 Mem_Free(cubemappixels);
2966 }
2967 else
2968 {
2969 Con_DPrintf("failed to load cubemap \"%s\"\n", basename);
2971 {
2972 Con_Printf("(tried tried images ");
2973 for (j = 0;j < 3;j++)
2974 for (i = 0;i < 6;i++)
2975 Con_Printf("%s\"%s%s.tga\"", j + i > 0 ? ", " : "", basename, suffix[j][i].suffix);
2976 Con_Print(" and was unable to find any of them).\n");
2977 }
2978 }
2979 return cubemaptexture;
2980}
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
static int componentorder[4]
Definition gl_rmain.c:2906
static suffixinfo_t suffix[3][6]
Definition gl_rmain.c:2878
cvar_t gl_texturecompression_lightcubemaps
Definition gl_textures.c:46
cvar_t gl_texturecompression
Definition gl_textures.c:37
cvar_t developer_loading
Definition host.c:52
int image_height
Definition image.c:10
void Image_CopyMux(unsigned char *outpixels, const unsigned char *inpixels, int inputwidth, int inputheight, qbool inputflipx, qbool inputflipy, qbool inputflipdiagonal, int numoutputcomponents, int numinputcomponents, int *outputinputcomponentindices)
Definition image.c:24
#define TEXF_FORCENEAREST
Definition r_textures.h:17
#define TEXF_COMPRESS
Definition r_textures.h:23
@ TEXTYPE_SRGB_BGRA
Definition r_textures.h:73
qbool sRGB3D
whether 3D rendering is sRGB corrected (based on sRGBcapable3D)
Definition vid.h:76

References componentorder, Con_DPrintf(), Con_Print(), Con_Printf(), developer_loading, dpsnprintf(), gl_texturecompression, gl_texturecompression_lightcubemaps, i, Image_CopyMux(), image_height, image_width, cvar_t::integer, loadimagepixelsbgra(), Mem_Alloc, Mem_Free, name, NULL, R_LoadTextureCubeMap(), r_main_texturepool, viddef_t::sRGB3D, suffix, tempmempool, TEXF_CLAMP, TEXF_COMPRESS, TEXF_FORCELINEAR, TEXF_FORCENEAREST, TEXTYPE_BGRA, TEXTYPE_SRGB_BGRA, and vid.

Referenced by R_GetCubemap().

◆ R_LoadQWSkin()

static void R_LoadQWSkin ( r_qwskincache_t * cache,
const char * skinname )
static

Definition at line 6522 of file gl_rmain.c.

6523{
6524 int textureflags = (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_PICMIP;
6525 char name[MAX_QPATH];
6526 skinframe_t *skinframe;
6527 unsigned char pixels[296*194];
6528 dp_strlcpy(cache->name, skinname, sizeof(cache->name));
6529 dpsnprintf(name, sizeof(name), "skins/%s.pcx", cache->name);
6531 Con_Printf("loading %s\n", name);
6532 skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, 0, false);
6533 if (!skinframe || !skinframe->base)
6534 {
6535 unsigned char *f;
6536 fs_offset_t filesize;
6537 skinframe = NULL;
6538 f = FS_LoadFile(name, tempmempool, true, &filesize);
6539 if (f)
6540 {
6541 if (LoadPCX_QWSkin(f, (int)filesize, pixels, 296, 194))
6543 Mem_Free(f);
6544 }
6545 }
6546 cache->skinframe = skinframe;
6547}
int64_t fs_offset_t
Definition fs.h:37
skinframe_t * R_SkinFrame_LoadInternalQuake(const char *name, int textureflags, int loadpantsandshirt, int loadglowtexture, const unsigned char *skindata, int width, int height)
Definition gl_rmain.c:2616
skinframe_t * R_SkinFrame_Find(const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qbool add)
Definition gl_rmain.c:2240
GLint GLenum GLenum GLvoid * pixels
Definition glquake.h:706
qbool LoadPCX_QWSkin(const unsigned char *f, int filesize, unsigned char *pixels, int outwidth, int outheight)
Definition image.c:286
cvar_t r_mipskins
#define TEXF_PICMIP
Definition r_textures.h:21
char name[MAX_QPATH]
Definition gl_rmain.c:303

References skinframe_t::base, Con_Printf(), developer_loading, dp_strlcpy, dpsnprintf(), f, FS_LoadFile(), image_height, image_width, cvar_t::integer, LoadPCX_QWSkin(), MAX_QPATH, Mem_Free, name, r_qwskincache_t::name, NULL, pixels, r_fullbrights, r_mipskins, R_SkinFrame_Find(), R_SkinFrame_LoadInternalQuake(), r_qwskincache_t::skinframe, tempmempool, TEXF_MIPMAP, and TEXF_PICMIP.

Referenced by R_GetCurrentTexture().

◆ R_Main_FreeViewCache()

◆ R_Main_ResizeViewCache()

static void R_Main_ResizeViewCache ( void )
static

Definition at line 3011 of file gl_rmain.c.

3012{
3013 int numentities = r_refdef.scene.numentities;
3016 if (r_refdef.viewcache.maxentities < numentities)
3017 {
3018 r_refdef.viewcache.maxentities = numentities;
3022 }
3023 // bones_was_here: r_refdef.viewcache.world_pvsbits was (re)allocated here, now done in Mod_BSP_FatPVS()
3024 if (r_refdef.viewcache.world_numleafs != numleafs)
3025 {
3030 }
3031 if (r_refdef.viewcache.world_numsurfaces != numsurfaces)
3032 {
3033 r_refdef.viewcache.world_numsurfaces = numsurfaces;
3037 }
3038}
int num_surfaces

References model_t::brush, r_refdef_viewcache_t::entityvisible, r_refdef_viewcache_t::maxentities, Mem_Alloc, Mem_Free, model_brush_t::num_leafs, model_t::num_surfaces, r_refdef_scene_t::numentities, r_main_mempool, r_refdef, r_refdef_t::scene, r_refdef_t::viewcache, r_refdef_viewcache_t::world_leafvisible, r_refdef_viewcache_t::world_numleafs, r_refdef_viewcache_t::world_numsurfaces, r_refdef_viewcache_t::world_surfacevisible, and r_refdef_scene_t::worldmodel.

Referenced by R_View_Update().

◆ R_Mesh_AddBrushMeshFromPlanes()

void R_Mesh_AddBrushMeshFromPlanes ( rmesh_t * mesh,
int numplanes,
mplane_t * planes )

Definition at line 6364 of file gl_rmain.c.

6365{
6366 int planenum, planenum2;
6367 int w;
6368 int tempnumpoints;
6369 mplane_t *plane, *plane2;
6370 double maxdist;
6371 double temppoints[2][256*3];
6372 // figure out how large a bounding box we need to properly compute this brush
6373 maxdist = 0;
6374 for (w = 0;w < numplanes;w++)
6375 maxdist = max(maxdist, fabs(planes[w].dist));
6376 // now make it large enough to enclose the entire brush, and round it off to a reasonable multiple of 1024
6377 maxdist = floor(maxdist * (4.0 / 1024.0) + 1) * 1024.0;
6378 for (planenum = 0, plane = planes;planenum < numplanes;planenum++, plane++)
6379 {
6380 w = 0;
6381 tempnumpoints = 4;
6382 PolygonD_QuadForPlane(temppoints[w], plane->normal[0], plane->normal[1], plane->normal[2], plane->dist, maxdist);
6383 for (planenum2 = 0, plane2 = planes;planenum2 < numplanes && tempnumpoints >= 3;planenum2++, plane2++)
6384 {
6385 if (planenum2 == planenum)
6386 continue;
6387 PolygonD_Divide(tempnumpoints, temppoints[w], plane2->normal[0], plane2->normal[1], plane2->normal[2], plane2->dist, R_MESH_PLANE_DIST_EPSILON, 0, NULL, NULL, 256, temppoints[!w], &tempnumpoints, NULL);
6388 w = !w;
6389 }
6390 if (tempnumpoints < 3)
6391 continue;
6392 // generate elements forming a triangle fan for this polygon
6393 R_Mesh_AddPolygon3d(mesh, tempnumpoints, temppoints[w]);
6394 }
6395}
#define R_MESH_PLANE_DIST_EPSILON
Definition gl_rmain.c:6363
static void R_Mesh_AddPolygon3d(rmesh_t *mesh, int numvertices, double *vertex3d)
Definition gl_rmain.c:6342
void PolygonD_QuadForPlane(double *outpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double quadsize)
Definition polygon.c:54
void PolygonD_Divide(int innumpoints, const double *inpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double epsilon, int outfrontmaxpoints, double *outfrontpoints, int *neededfrontpoints, int outbackmaxpoints, double *outbackpoints, int *neededbackpoints, int *oncountpointer)
Definition polygon.c:245

References mplane_t::dist, fabs(), floor(), max, mplane_t::normal, NULL, PolygonD_Divide(), PolygonD_QuadForPlane(), R_Mesh_AddPolygon3d(), R_MESH_PLANE_DIST_EPSILON, and w.

◆ R_Mesh_AddPolygon3d()

static void R_Mesh_AddPolygon3d ( rmesh_t * mesh,
int numvertices,
double * vertex3d )
static

Definition at line 6342 of file gl_rmain.c.

6343{
6344 int i;
6345 int *e, element[3];
6346 element[0] = R_Mesh_AddVertex(mesh, vertex3d[0], vertex3d[1], vertex3d[2]);vertex3d += 3;
6347 element[1] = R_Mesh_AddVertex(mesh, vertex3d[0], vertex3d[1], vertex3d[2]);vertex3d += 3;
6348 e = mesh->element3i + mesh->numtriangles * 3;
6349 for (i = 0;i < numvertices - 2;i++, vertex3d += 3)
6350 {
6351 element[2] = R_Mesh_AddVertex(mesh, vertex3d[0], vertex3d[1], vertex3d[2]);
6352 if (mesh->numtriangles < mesh->maxtriangles)
6353 {
6354 *e++ = element[0];
6355 *e++ = element[1];
6356 *e++ = element[2];
6357 mesh->numtriangles++;
6358 }
6359 element[1] = element[2];
6360 }
6361}
static int R_Mesh_AddVertex(rmesh_t *mesh, float x, float y, float z)
Definition gl_rmain.c:6299
int numtriangles
Definition render.h:169
int * element3i
Definition render.h:170
int maxtriangles
Definition render.h:168

References rmesh_t::element3i, i, rmesh_t::maxtriangles, rmesh_t::numtriangles, and R_Mesh_AddVertex().

Referenced by R_Mesh_AddBrushMeshFromPlanes().

◆ R_Mesh_AddPolygon3f()

void R_Mesh_AddPolygon3f ( rmesh_t * mesh,
int numvertices,
float * vertex3f )

Definition at line 6321 of file gl_rmain.c.

6322{
6323 int i;
6324 int *e, element[3];
6325 element[0] = R_Mesh_AddVertex(mesh, vertex3f[0], vertex3f[1], vertex3f[2]);vertex3f += 3;
6326 element[1] = R_Mesh_AddVertex(mesh, vertex3f[0], vertex3f[1], vertex3f[2]);vertex3f += 3;
6327 e = mesh->element3i + mesh->numtriangles * 3;
6328 for (i = 0;i < numvertices - 2;i++, vertex3f += 3)
6329 {
6330 element[2] = R_Mesh_AddVertex(mesh, vertex3f[0], vertex3f[1], vertex3f[2]);
6331 if (mesh->numtriangles < mesh->maxtriangles)
6332 {
6333 *e++ = element[0];
6334 *e++ = element[1];
6335 *e++ = element[2];
6336 mesh->numtriangles++;
6337 }
6338 element[1] = element[2];
6339 }
6340}

References rmesh_t::element3i, i, rmesh_t::maxtriangles, rmesh_t::numtriangles, and R_Mesh_AddVertex().

◆ R_Mesh_AddVertex()

static int R_Mesh_AddVertex ( rmesh_t * mesh,
float x,
float y,
float z )
static

Definition at line 6299 of file gl_rmain.c.

6300{
6301 int i;
6302 float *vertex3f;
6303 float v[3];
6304 VectorSet(v, x, y, z);
6305 for (i = 0, vertex3f = mesh->vertex3f;i < mesh->numvertices;i++, vertex3f += 3)
6306 if (VectorDistance2(v, vertex3f) < mesh->epsilon2)
6307 break;
6308 if (i == mesh->numvertices)
6309 {
6310 if (mesh->numvertices < mesh->maxvertices)
6311 {
6312 VectorCopy(v, vertex3f);
6313 mesh->numvertices++;
6314 }
6315 return mesh->numvertices;
6316 }
6317 else
6318 return i;
6319}
GLubyte GLubyte GLubyte z
Definition glquake.h:782
#define VectorDistance2(a, b)
Definition mathlib.h:107
float epsilon2
Definition render.h:172
float * vertex3f
Definition render.h:160
int maxvertices
Definition render.h:158
int numvertices
Definition render.h:159

References rmesh_t::epsilon2, i, rmesh_t::maxvertices, rmesh_t::numvertices, v, VectorCopy, VectorDistance2, VectorSet, rmesh_t::vertex3f, x, y, and z.

Referenced by R_Mesh_AddPolygon3d(), and R_Mesh_AddPolygon3f().

◆ R_ModulateColors()

void R_ModulateColors ( float * in,
float * out,
int verts,
float r,
float g,
float b )

Definition at line 321 of file gl_rmain.c.

322{
323 int i;
324 for (i = 0;i < verts;i++)
325 {
326 out[0] = in[0] * r;
327 out[1] = in[1] * g;
328 out[2] = in[2] * b;
329 out[3] = in[3];
330 in += 4;
331 out += 4;
332 }
333}

References b, g, i, and r.

◆ R_MotionBlurView()

static void R_MotionBlurView ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )
static

Definition at line 5251 of file gl_rmain.c.

5252{
5254
5256 {
5257 // declare variables
5258 float blur_factor, blur_mouseaccel, blur_velocity;
5259 static float blur_average;
5260 static vec3_t blur_oldangles; // used to see how quickly the mouse is moving
5261
5262 // set a goal for the factoring
5265 blur_mouseaccel = bound(0, ((fabs(VectorLength(cl.viewangles) - VectorLength(blur_oldangles)) * 10) - r_motionblur_mousefactor_minspeed.value)
5267 blur_factor = ((blur_velocity * r_motionblur_velocityfactor.value)
5268 + (blur_mouseaccel * r_motionblur_mousefactor.value));
5269
5270 // from the goal, pick an averaged value between goal and last value
5272 blur_average = blur_average * (1 - cl.motionbluralpha) + blur_factor * cl.motionbluralpha;
5273
5274 // enforce minimum amount of blur
5275 blur_factor = blur_average * (1 - r_motionblur_minblur.value) + r_motionblur_minblur.value;
5276
5277 //Con_Printf("motionblur: direct factor: %f, averaged factor: %f, velocity: %f, mouse accel: %f \n", blur_factor, blur_average, blur_velocity, blur_mouseaccel);
5278
5279 // calculate values into a standard alpha
5280 cl.motionbluralpha = 1 - exp(-
5281 (
5282 (r_motionblur.value * blur_factor / 80)
5283 +
5285 )
5286 /
5287 max(0.0001, cl.time - cl.oldtime) // fps independent
5288 );
5289
5290 // randomization for the blur value to combat persistent ghosting
5293
5294 // apply the blur on top of the current view
5295 R_ResetViewRendering2D(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5297 {
5299 GL_Color(1, 1, 1, cl.motionbluralpha);
5300 R_CalcTexCoordsForView(0, 0, viewwidth, viewheight, viewwidth, viewheight, r_fb.ghosttexcoord2f);
5302 R_SetupShader_Generic(r_fb.ghosttexture, false, true, true);
5304 r_refdef.stats[r_stat_bloom_drawpixels] += viewwidth * viewheight;
5305 }
5306
5307 // updates old view angles for next pass
5308 VectorCopy(cl.viewangles, blur_oldangles);
5309
5310 // copy view into the ghost texture
5311 R_Mesh_CopyToTexture(r_fb.ghosttexture, 0, 0, viewx, viewy, viewwidth, viewheight);
5312 r_refdef.stats[r_stat_bloom_copypixels] += viewwidth * viewheight;
5313 r_fb.ghosttexture_valid = true;
5314 }
5315}
#define CSHIFT_DAMAGE
Definition client.h:512
void R_Mesh_CopyToTexture(rtexture_t *tex, int tx, int ty, int sx, int sy, int width, int height)
static void R_CalcTexCoordsForView(float x, float y, float w, float h, float tw, float th, float *texcoord2f)
Definition gl_rmain.c:4547
@ r_stat_bloom_copypixels
Definition r_stats.h:43
double oldtime
Definition client.h:868
vec3_t movement_velocity
Definition client.h:810
cshift_t cshifts[NUM_CSHIFTS]
Definition client.h:775
vec3_t viewangles
Definition client.h:786
double time
Definition client.h:868
float motionbluralpha
Definition client.h:882
float percent
Definition client.h:507
float ghosttexcoord2f[8]
Definition render.h:891
qbool envmap
Definition render.h:455

References bound, cl, CSHIFT_DAMAGE, client_state_t::cshifts, r_refdef_t::envmap, fabs(), r_framebufferstate_t::ghosttexcoord2f, r_framebufferstate_t::ghosttexture, r_framebufferstate_t::ghosttexture_valid, GL_BlendFunc(), GL_Color(), GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, identitymatrix, r_refdef_view_t::ismain, lhrandom, max, client_state_t::motionbluralpha, client_state_t::movement_velocity, NULL, client_state_t::oldtime, cshift_t::percent, polygonelement3i, polygonelement3s, R_CalcTexCoordsForView(), r_damageblur, R_EntityMatrix(), r_fb, R_Mesh_CopyToTexture(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), r_motionblur, r_motionblur_averaging, r_motionblur_maxblur, r_motionblur_minblur, r_motionblur_mousefactor, r_motionblur_mousefactor_maxspeed, r_motionblur_mousefactor_minspeed, r_motionblur_randomize, r_motionblur_velocityfactor, r_motionblur_velocityfactor_maxspeed, r_motionblur_velocityfactor_minspeed, r_refdef, R_ResetViewRendering2D(), r_screenvertex3f, R_SetupShader_Generic(), r_stat_bloom_copypixels, r_stat_bloom_drawpixels, R_Stereo_Active(), r_refdef_t::stats, client_state_t::time, cvar_t::value, VectorCopy, VectorLength, r_refdef_t::view, and client_state_t::viewangles.

Referenced by R_RenderView().

◆ R_ProcessModelTextureSurfaceList()

static void R_ProcessModelTextureSurfaceList ( int texturenumsurfaces,
const msurface_t ** texturesurfacelist,
qbool writedepth,
qbool depthonly,
qbool prepass,
qbool ui )
static

Definition at line 8978 of file gl_rmain.c.

8979{
8981 if (ui)
8982 R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth, prepass, ui);
8983 else if (depthonly)
8984 R_DrawTextureSurfaceList_DepthOnly(texturenumsurfaces, texturesurfacelist);
8985 else if (prepass)
8986 {
8988 return;
8990 R_ProcessTransparentTextureSurfaceList(texturenumsurfaces, texturesurfacelist);
8991 else
8992 R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth, prepass, ui);
8993 }
8995 R_DrawTextureSurfaceList_Sky(texturenumsurfaces, texturesurfacelist);
8997 return;
8999 {
9000 // in the deferred case, transparent surfaces were queued during prepass
9002 R_ProcessTransparentTextureSurfaceList(texturenumsurfaces, texturesurfacelist);
9003 }
9004 else
9005 {
9006 // the alphatest check is to make sure we write depth for anything we skipped on the depth-only pass earlier
9007 R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth || (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST), prepass, ui);
9008 }
9010}
qbool r_shadow_usingdeferredprepass
Definition r_shadow.c:64
static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:8587
static void R_ProcessTransparentTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:8933
static void R_DrawTextureSurfaceList_DepthOnly(int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:8965

References CHECKGLERROR, texture_t::currentmaterialflags, cvar_t::integer, MATERIALFLAG_ALPHATEST, MATERIALFLAG_SKY, MATERIALFLAG_WALL, MATERIALFLAGMASK_DEPTHSORTED, R_DrawModelTextureSurfaceList(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_Sky(), R_ProcessTransparentTextureSurfaceList(), r_shadow_usingdeferredprepass, r_showsurfaces, rsurface, and rsurfacestate_t::texture.

Referenced by R_QueueModelSurfaceList().

◆ R_ProcessTransparentTextureSurfaceList()

static void R_ProcessTransparentTextureSurfaceList ( int texturenumsurfaces,
const msurface_t ** texturesurfacelist )
static

Definition at line 8933 of file gl_rmain.c.

8934{
8935 // transparent surfaces get pushed off into the transparent queue
8936 int surfacelistindex;
8937 const msurface_t *surface;
8938 vec3_t tempcenter, center;
8939 for (surfacelistindex = 0;surfacelistindex < texturenumsurfaces;surfacelistindex++)
8940 {
8941 surface = texturesurfacelist[surfacelistindex];
8943 {
8944 tempcenter[0] = bound(surface->mins[0], rsurface.localvieworigin[0], surface->maxs[0]);
8945 tempcenter[1] = bound(surface->mins[1], rsurface.localvieworigin[1], surface->maxs[1]);
8946 tempcenter[2] = bound(surface->mins[2], rsurface.localvieworigin[2], surface->maxs[2]);
8947 }
8948 else
8949 {
8950 tempcenter[0] = (surface->mins[0] + surface->maxs[0]) * 0.5f;
8951 tempcenter[1] = (surface->mins[1] + surface->maxs[1]) * 0.5f;
8952 tempcenter[2] = (surface->mins[2] + surface->maxs[2]) * 0.5f;
8953 }
8954 Matrix4x4_Transform(&rsurface.matrix, tempcenter, center);
8955 if (rsurface.entity->transparent_offset) // transparent offset
8956 {
8960 }
8962 }
8963}
static void R_DrawSurface_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rmain.c:8851
#define RENDER_WORLDOBJECT
Definition protocol.h:362
@ TRANSPARENTSORT_SKY
Definition r_qshader.h:193
float transparent_offset
Definition client.h:340
vec3_t localvieworigin
Definition render.h:728
dptransparentsortcategory_t transparentsort

References bound, texture_t::currentmaterialflags, rsurfacestate_t::entity, entity_render_t::flags, r_refdef_view_t::forward, cvar_t::integer, rsurfacestate_t::localvieworigin, MATERIALFLAG_NODEPTHTEST, rsurfacestate_t::matrix, Matrix4x4_Transform(), msurface_t::maxs, msurface_t::mins, rsurfacestate_t::modelsurfaces, R_DrawSurface_TransparentCallback(), R_MeshQueue_AddTransparent(), r_refdef, r_transparent_sortsurfacesbynearest, RENDER_WORLDOBJECT, rsurface, rsurfacestate_t::rtlight, rsurfacestate_t::texture, entity_render_t::transparent_offset, texture_t::transparentsort, TRANSPARENTSORT_HUD, TRANSPARENTSORT_SKY, and r_refdef_t::view.

Referenced by R_ProcessModelTextureSurfaceList().

◆ R_QueueModelSurfaceList()

static void R_QueueModelSurfaceList ( entity_render_t * ent,
int numsurfaces,
const msurface_t ** surfacelist,
int flagsmask,
qbool writedepth,
qbool depthonly,
qbool prepass,
qbool ui )
static

Definition at line 9012 of file gl_rmain.c.

9013{
9014 int i, j;
9017 // break the surface list down into batches by texture and use of lightmapping
9018 for (i = 0;i < numsurfaces;i = j)
9019 {
9020 j = i + 1;
9021 // texture is the base texture pointer, rsurface.texture is the
9022 // current frame/skin the texture is directing us to use (for example
9023 // if a model has 2 skins and it is on skin 1, then skin 0 tells us to
9024 // use skin 1 instead)
9025 texture = surfacelist[i]->texture;
9028 {
9029 // if this texture is not the kind we want, skip ahead to the next one
9030 for (;j < numsurfaces && texture == surfacelist[j]->texture;j++)
9031 ;
9032 continue;
9033 }
9034 if(depthonly || prepass)
9035 {
9039 // simply scan ahead until we find a different texture or lightmap state
9040 for (;j < numsurfaces && texture == surfacelist[j]->texture;j++)
9041 ;
9042 }
9043 else
9044 {
9045 rsurface.lightmaptexture = surfacelist[i]->lightmaptexture;
9048 // simply scan ahead until we find a different texture or lightmap state
9049 for (;j < numsurfaces && texture == surfacelist[j]->texture && rsurface.lightmaptexture == surfacelist[j]->lightmaptexture;j++)
9050 ;
9051 }
9052 // render the range of surfaces
9053 R_ProcessModelTextureSurfaceList(j - i, surfacelist + i, writedepth, depthonly, prepass, ui);
9054 }
9056}
void R_FrameData_SetMark(void)
set a marker that allows you to discard the following temporary memory allocations
Definition gl_rmain.c:3581
void R_FrameData_ReturnToMark(void)
discard recent memory allocations (rewind to marker)
Definition gl_rmain.c:3588
static void R_ProcessModelTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool depthonly, qbool prepass, qbool ui)
Definition gl_rmain.c:8978
#define MATERIALFLAG_NODRAW
Definition model_brush.h:96

References texture_t::currentmaterialflags, msurface_t::deluxemaptexture, rsurfacestate_t::deluxemaptexture, i, msurface_t::lightmaptexture, rsurfacestate_t::lightmaptexture, MATERIALFLAG_NODRAW, NULL, R_FrameData_ReturnToMark(), R_FrameData_SetMark(), R_GetCurrentTexture(), R_ProcessModelTextureSurfaceList(), rsurface, msurface_t::texture, rsurfacestate_t::texture, texture, and rsurfacestate_t::uselightmaptexture.

Referenced by R_DrawModelSurfaces().

◆ R_RenderScene()

void R_RenderScene ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 5830 of file gl_rmain.c.

5831{
5832 qbool shadowmapping = false;
5833
5835 R_TimeReport("beginscene");
5836
5838
5839 R_UpdateFog();
5840
5842
5844
5846
5848 R_TimeReport("skystartframe");
5849
5851 {
5853 {
5856 R_TimeReport("worldsky");
5857 }
5858
5860 R_TimeReport("bmodelsky");
5861
5863 {
5864 // we have to force off the water clipping plane while rendering sky
5865 R_SetupView(false, viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5866 R_Sky();
5867 R_SetupView(true, viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5869 R_TimeReport("sky");
5870 }
5871 }
5872
5873 // save the framebuffer info for R_Shadow_RenderMode_Reset during this view render
5874 r_shadow_viewfbo = viewfbo;
5875 r_shadow_viewdepthtexture = viewdepthtexture;
5876 r_shadow_viewcolortexture = viewcolortexture;
5877 r_shadow_viewx = viewx;
5878 r_shadow_viewy = viewy;
5879 r_shadow_viewwidth = viewwidth;
5880 r_shadow_viewheight = viewheight;
5881
5885 R_TimeReport("preparelights");
5886
5887 // render all the shadowmaps that will be used for this view
5888 shadowmapping = R_Shadow_ShadowMappingEnabled();
5889 if (shadowmapping || r_shadow_shadowmapatlas_modelshadows_size)
5890 {
5893 R_TimeReport("shadowmaps");
5894 }
5895
5896 // render prepass deferred lighting if r_shadow_deferred is on, this produces light buffers that will be sampled in forward pass
5899
5900 // now we begin the forward pass of the view render
5902 {
5905 R_TimeReport("worlddepth");
5906 }
5907 if (r_depthfirst.integer >= 2)
5908 {
5911 R_TimeReport("modeldepth");
5912 }
5913
5915 {
5918 R_TimeReport("world");
5919 }
5920
5921 R_DrawModels();
5923 R_TimeReport("models");
5924
5926 {
5929 R_TimeReport("rtlights");
5930 }
5931
5933 {
5936 R_TimeReport("modeldecals");
5937
5940 R_TimeReport("particles");
5941
5944 R_TimeReport("explosions");
5945 }
5946
5948 {
5950 {
5951 R_DrawLocs();
5953 R_TimeReport("showlocs");
5954 }
5955
5957 {
5958 R_DrawPortals();
5960 R_TimeReport("portals");
5961 }
5962
5963 if (r_showbboxes_client.value > 0)
5964 {
5967 R_TimeReport("clbboxes");
5968 }
5969 if (r_showbboxes.value > 0)
5970 {
5973 R_TimeReport("svbboxes");
5974 }
5975 }
5976
5978 {
5981 R_TimeReport("drawtrans");
5982 }
5983
5985 {
5988 R_TimeReport("worlddebug");
5991 R_TimeReport("modeldebug");
5992 }
5993
5995 {
5998 R_TimeReport("coronas");
5999 }
6000}
void R_DrawParticles(void)
static int R_DrawBrushModelsSky(void)
only used if skyrendermasked, and normally returns false
Definition gl_rmain.c:4058
static void R_DrawModelsDebug(void)
Definition gl_rmain.c:4112
static void R_DrawLocs(void)
Definition gl_rmain.c:9121
void R_UpdateFog(void)
Definition gl_rmain.c:5396
static void R_DrawModels(void)
Definition gl_rmain.c:4078
cvar_t cl_locs_show
Definition cl_main.c:98
void R_SetupView(qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4384
int r_shadow_shadowmapatlas_modelshadows_size
Definition r_shadow.c:69
static void R_DrawModelDecals(void)
Definition gl_rmain.c:9711
static void R_DrawModelsDepth(void)
Definition gl_rmain.c:4097
static void R_DrawEntityBBoxes(prvm_prog_t *prog)
Definition gl_rmain.c:6120
void R_DrawPortals(void)
Definition gl_rsurf.c:381
void Matrix4x4_CreateTranslate(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:584
void R_MeshQueue_BeginScene(void)
Definition meshqueue.c:26
void R_MeshQueue_RenderTransparent(void)
Definition meshqueue.c:62
void R_DrawExplosions(void)
int r_shadow_viewx
Definition r_shadow.c:127
void R_Shadow_DrawShadowMaps(void)
Definition r_shadow.c:4204
rtexture_t * r_shadow_viewdepthtexture
Definition r_shadow.c:125
int r_shadow_viewfbo
Definition r_shadow.c:124
void R_Shadow_PrepareLights(void)
Definition r_shadow.c:4031
qbool R_Shadow_ShadowMappingEnabled(void)
Definition r_shadow.c:378
void R_Shadow_PrepareModelShadows(void)
Definition r_shadow.c:4242
rtexture_t * r_shadow_viewcolortexture
Definition r_shadow.c:126
int r_shadow_viewy
Definition r_shadow.c:128
void R_Shadow_DrawCoronas(void)
Definition r_shadow.c:4528
void R_Shadow_DrawLights(void)
Definition r_shadow.c:4226
void R_Shadow_DrawPrepass(void)
Definition r_shadow.c:3958
int r_shadow_viewwidth
Definition r_shadow.c:129
int r_shadow_viewheight
Definition r_shadow.c:130
void R_Sky(void)
Definition r_sky.c:403
void R_SkyStartFrame(void)
Definition r_sky.c:57
int r_timereport_active
Definition r_stats.c:189
void R_TimeReport(const char *desc)
Definition r_stats.c:193
@ r_stat_renders
Definition r_stats.h:11
csqc_vidvars_t csqc_vidvars
Definition client.h:834
qbool drawworld
Definition client.h:706

References cl, cl_locs_show, CLVM_prog, client_state_t::csqc_vidvars, model_t::Draw, model_t::DrawDebug, model_t::DrawDepth, model_t::DrawSky, csqc_vidvars_t::drawworld, cvar_t::integer, Matrix4x4_CreateTranslate(), r_depthfirst, R_DrawBrushModelsSky(), R_DrawEntityBBoxes(), R_DrawExplosions(), R_DrawLocs(), R_DrawModelDecals(), R_DrawModels(), R_DrawModelsDebug(), R_DrawModelsDepth(), R_DrawParticles(), R_DrawPortals(), r_drawportals, R_MeshQueue_BeginScene(), R_MeshQueue_RenderTransparent(), r_refdef, R_SetupView(), R_Shadow_DrawCoronas(), R_Shadow_DrawLights(), R_Shadow_DrawPrepass(), R_Shadow_DrawShadowMaps(), R_Shadow_PrepareLights(), R_Shadow_PrepareModelShadows(), r_shadow_shadowmapatlas_modelshadows_size, R_Shadow_ShadowMappingEnabled(), r_shadow_usingdeferredprepass, r_shadow_viewcolortexture, r_shadow_viewdepthtexture, r_shadow_viewfbo, r_shadow_viewheight, r_shadow_viewwidth, r_shadow_viewx, r_shadow_viewy, r_showbboxes, r_showbboxes_client, r_showcollisionbrushes, r_shownormals, r_showoverdraw, r_showtris, R_Sky(), R_SkyStartFrame(), r_stat_renders, R_TimeReport(), r_timereport_active, r_transparent, R_UpdateFog(), r_waterscroll, r_waterscrollmatrix, r_refdef_t::scene, r_refdef_view_t::showdebug, sin(), skyrenderlater, skyrendermasked, r_refdef_t::stats, SVVM_prog, r_refdef_scene_t::time, cvar_t::value, r_refdef_t::view, r_refdef_scene_t::worldentity, and r_refdef_scene_t::worldmodel.

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_RenderTarget_FreeUnused()

void R_RenderTarget_FreeUnused ( qbool force)

Definition at line 4523 of file gl_rmain.c.

4524{
4525 unsigned int i, j, end;
4526 end = (unsigned int)Mem_ExpandableArray_IndexRange(&r_fb.rendertargets); // checked
4527 for (i = 0; i < end; i++)
4528 {
4530 // free resources for rendertargets that have not been used for a while
4531 // (note: this check is run after the frame render, so any targets used
4532 // this frame will not be affected even at low framerates)
4533 if (r && (host.realtime - r->lastusetime > 0.2 || force))
4534 {
4535 if (r->fbo)
4537 for (j = 0; j < sizeof(r->colortexture) / sizeof(r->colortexture[0]); j++)
4538 if (r->colortexture[j])
4539 R_FreeTexture(r->colortexture[j]);
4540 if (r->depthtexture)
4541 R_FreeTexture(r->depthtexture);
4543 }
4544 }
4545}
void R_Mesh_DestroyFramebufferObject(int fbo)
host_static_t host
Definition host.c:41
double realtime
the accumulated mainloop time since application started (with filtering), without any slowmo or clamp...
Definition host.h:46

References host, i, int(), Mem_ExpandableArray_FreeRecord(), Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), r, r_fb, R_FreeTexture(), R_Mesh_DestroyFramebufferObject(), host_static_t::realtime, and r_framebufferstate_t::rendertargets.

Referenced by gl_main_shutdown(), and SCR_DrawScreen().

◆ R_RenderTarget_Get()

r_rendertarget_t * R_RenderTarget_Get ( int texturewidth,
int textureheight,
textype_t depthtextype,
qbool depthisrenderbuffer,
textype_t colortextype0,
textype_t colortextype1,
textype_t colortextype2,
textype_t colortextype3 )

Definition at line 4564 of file gl_rmain.c.

4565{
4566 unsigned int i, j, end;
4568 char vabuf[256];
4569 // first try to reuse an existing slot if possible
4570 end = (unsigned int)Mem_ExpandableArray_IndexRange(&r_fb.rendertargets); // checked
4571 for (i = 0; i < end; i++)
4572 {
4574 if (r && r->lastusetime != host.realtime && r->texturewidth == texturewidth && r->textureheight == textureheight && r->depthtextype == depthtextype && r->colortextype[0] == colortextype0 && r->colortextype[1] == colortextype1 && r->colortextype[2] == colortextype2 && r->colortextype[3] == colortextype3)
4575 break;
4576 }
4577 if (i == end)
4578 {
4579 // no unused exact match found, so we have to make one in the first unused slot
4581 r->texturewidth = texturewidth;
4582 r->textureheight = textureheight;
4583 r->colortextype[0] = colortextype0;
4584 r->colortextype[1] = colortextype1;
4585 r->colortextype[2] = colortextype2;
4586 r->colortextype[3] = colortextype3;
4587 r->depthtextype = depthtextype;
4588 r->depthisrenderbuffer = depthisrenderbuffer;
4589 for (j = 0; j < 4; j++)
4590 if (r->colortextype[j])
4591 r->colortexture[j] = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "rendertarget%i_%i_type%i", i, j, (int)r->colortextype[j]), r->texturewidth, r->textureheight, NULL, r->colortextype[j], TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
4592 if (r->depthtextype)
4593 {
4594 if (r->depthisrenderbuffer)
4595 r->depthtexture = R_LoadTextureRenderBuffer(r_main_texturepool, va(vabuf, sizeof(vabuf), "renderbuffer%i_depth_type%i", i, (int)r->depthtextype), r->texturewidth, r->textureheight, r->depthtextype);
4596 else
4597 r->depthtexture = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "rendertarget%i_depth_type%i", i, (int)r->depthtextype), r->texturewidth, r->textureheight, NULL, r->depthtextype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
4598 }
4599 r->fbo = R_Mesh_CreateFramebufferObject(r->depthtexture, r->colortexture[0], r->colortexture[1], r->colortexture[2], r->colortexture[3]);
4600 }
4602 r_refdef.stats[r_stat_rendertargets_pixels] += r->texturewidth * r->textureheight;
4603 r->lastusetime = host.realtime;
4604 R_CalcTexCoordsForView(0, 0, r->texturewidth, r->textureheight, r->texturewidth, r->textureheight, r->texcoord2f);
4605 return r;
4606}
char * va(char *buf, size_t buflen, const char *format,...)
Definition common.c:972
int R_Mesh_CreateFramebufferObject(rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4)
Definition gl_backend.c:960
rtexture_t * R_LoadTextureRenderBuffer(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, textype_t textype)
@ r_stat_rendertargets_used
Definition r_stats.h:45
@ r_stat_rendertargets_pixels
Definition r_stats.h:46

References host, i, int(), Mem_ExpandableArray_AllocRecord(), Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), NULL, r, R_CalcTexCoordsForView(), r_fb, R_LoadTexture2D(), R_LoadTextureRenderBuffer(), r_main_texturepool, R_Mesh_CreateFramebufferObject(), r_refdef, r_stat_rendertargets_pixels, r_stat_rendertargets_used, host_static_t::realtime, r_framebufferstate_t::rendertargets, r_refdef_t::stats, TEXF_CLAMP, TEXF_FORCELINEAR, TEXF_RENDERTARGET, and va().

Referenced by R_Bloom_MakeTexture(), R_Bloom_StartFrame(), R_Envmap_f(), and R_Water_ProcessPlanes().

◆ R_RenderView()

void R_RenderView ( int fbo,
rtexture_t * depthtexture,
rtexture_t * colortexture,
int x,
int y,
int width,
int height )

Definition at line 5637 of file gl_rmain.c.

5638{
5639 matrix4x4_t originalmatrix = r_refdef.view.matrix, offsetmatrix;
5640 int viewfbo = 0;
5641 rtexture_t *viewdepthtexture = NULL;
5642 rtexture_t *viewcolortexture = NULL;
5643 int viewx = r_refdef.view.x, viewy = r_refdef.view.y, viewwidth = r_refdef.view.width, viewheight = r_refdef.view.height;
5644 qbool skipblend;
5645
5646 // finish any 2D rendering that was queued
5647 DrawQ_Finish();
5648
5650 R_TimeReport("start");
5651 r_textureframe++; // used only by R_GetCurrentTexture
5652 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
5653
5656
5659 else if (r_sortentities.integer)
5661
5663
5664 /* adjust for stereo display */
5665 if(R_Stereo_Active())
5666 {
5667 Matrix4x4_CreateFromQuakeEntity(&offsetmatrix, 0, r_stereo_separation.value * (0.5f - r_stereo_side), 0, 0, r_stereo_angle.value * (0.5f - r_stereo_side), 0, 1);
5668 Matrix4x4_Concat(&r_refdef.view.matrix, &originalmatrix, &offsetmatrix);
5669 }
5670
5672 {
5673 // TODO: FIXME: move this into its own backend function maybe? [2/5/2008 Andreas]
5676 R_TimeReport("depthclear");
5677
5678 r_refdef.view.showdebug = false;
5679
5680 r_fb.water.enabled = false;
5682
5684
5685 r_refdef.view.matrix = originalmatrix;
5686
5688 return;
5689 }
5690
5691 if (!r_refdef.scene.entities || r_refdef.view.width * r_refdef.view.height == 0 || !r_renderview.integer || cl_videoplaying/* || !r_refdef.scene.worldmodel*/)
5692 {
5693 r_refdef.view.matrix = originalmatrix;
5694 return;
5695 }
5696
5700
5702
5704 // in sRGB fallback, behave similar to true sRGB: convert this
5705 // value from linear to sRGB
5707
5709
5711
5712 // this will set up r_fb.rt_screen
5714
5715 // apply bloom brightness offset
5716 if(r_fb.rt_bloom)
5718
5720 if (skipblend)
5721 {
5722 // Render to the screen right away.
5723 viewfbo = fbo;
5724 viewdepthtexture = depthtexture;
5725 viewcolortexture = colortexture;
5726 viewx = x;
5727 viewy = y;
5728 viewwidth = width;
5729 viewheight = height;
5730 }
5731 else if (r_fb.rt_screen)
5732 {
5733 // R_Bloom_StartFrame probably set up an fbo for us to render into, it will be rendered to the window later in R_BlendView
5734 viewfbo = r_fb.rt_screen->fbo;
5735 viewdepthtexture = r_fb.rt_screen->depthtexture;
5736 viewcolortexture = r_fb.rt_screen->colortexture[0];
5737 viewx = 0;
5738 viewy = 0;
5739 viewwidth = r_fb.rt_screen->texturewidth;
5740 viewheight = r_fb.rt_screen->textureheight;
5741 }
5742
5743 R_Water_StartFrame(viewwidth, viewheight);
5744
5747 R_TimeReport("viewsetup");
5748
5749 R_ResetViewRendering3D(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5750
5751 // clear the whole fbo every frame - otherwise the driver will consider
5752 // it to be an inter-frame texture and stall in multi-gpu configurations
5753 if (r_fb.rt_screen)
5754 GL_ScissorTest(false);
5757 R_TimeReport("viewclear");
5758
5759 r_refdef.view.clear = true;
5760
5761 r_refdef.view.showdebug = true;
5762
5765 R_TimeReport("visibility");
5766
5769 R_TimeReport("animcache");
5770
5772 // R_Shadow_UpdateBounceGridTexture called R_TimeReport a few times internally, so we don't need to do that here.
5773
5775 if (r_fb.water.enabled)
5776 R_RenderWaterPlanes(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5777
5778 // for the actual view render we use scissoring a fair amount, so scissor
5779 // test needs to be on
5780 if (r_fb.rt_screen)
5781 GL_ScissorTest(true);
5783 R_RenderScene(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5785
5786 // postprocess uses textures that are not aligned with the viewport we're rendering, so no scissoring
5787 GL_ScissorTest(false);
5788
5789 R_MotionBlurView(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5790 if (!skipblend)
5791 R_BlendView(viewcolortexture, fbo, depthtexture, colortexture, x, y, width, height);
5793 R_TimeReport("blendview");
5794
5795 r_refdef.view.matrix = originalmatrix;
5796
5798
5799 // go back to 2d rendering
5800 DrawQ_Start();
5801}
int r_stereo_side
Definition cl_screen.c:1553
cvar_t r_stereo_angle
Definition cl_screen.c:87
void R_ClearScreen(qbool fogcolor)
Definition cl_screen.c:1534
cvar_t r_stereo_separation
Definition cl_screen.c:80
int cl_videoplaying
Definition cl_video.c:458
void DrawQ_Start(void)
Definition gl_draw.c:789
void DrawQ_Finish(void)
Definition gl_draw.c:1456
cvar_t r_renderview
Definition gl_backend.c:12
void GL_Scissor(int x, int y, int width, int height)
void GL_ScissorTest(int state)
void R_RenderView_UpdateViewVectors(void)
Definition gl_rmain.c:4512
static void R_BlendView(rtexture_t *viewcolortexture, int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int x, int y, int width, int height)
Definition gl_rmain.c:5317
static void R_SortEntities(void)
Definition gl_rmain.c:5620
void R_RenderScene(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:5830
void R_RenderWaterPlanes(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:5803
void R_ResetViewRendering3D(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4482
static qbool R_BlendView_IsTrivial(int viewwidth, int viewheight, int width, int height)
Definition gl_rmain.c:5224
static void R_Bloom_StartFrame(void)
Definition gl_rmain.c:5019
void V_MakeViewIsometric(void)
Definition view.c:968
static void R_MotionBlurView(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:5251
cvar_t v_isometric
Definition view.c:97
static void R_View_Update(const int *myscissor)
Definition gl_rmain.c:4374
qbool R_CompileShader_CheckStaticParms(void)
Definition gl_rmain.c:861
void R_AnimCache_ClearCache(void)
clear the animcache pointers on all known render entities
Definition gl_rmain.c:3762
static void R_Water_StartFrame(int viewwidth, int viewheight)
Definition gl_rmain.c:4608
void R_AnimCache_CacheVisibleEntities(void)
generate animcache data for all entities marked visible
Definition gl_rmain.c:3874
#define GL_DEPTH_BUFFER_BIT
Definition glquake.h:169
#define Image_sRGBFloatFromLinearFloat(c)
Definition image.h:68
void R_Shadow_UpdateBounceGridTexture(void)
Definition r_shadow.c:2755
void R_Shadow_UpdateWorldLightSelection(void)
Definition r_shadow.c:5289
int useperspective
if turned off it renders an ortho view
Definition render.h:280
matrix4x4_t matrix
Definition render.h:266
rtexture_t * depthtexture
Definition render.h:835
int numwaterplanes
Definition render.h:868
cvar_t vid_sRGB_fallback
Definition vid_shared.c:158
cvar_t vid_sRGB
Definition vid_shared.c:157

References CHECKGLERROR, cl_videoplaying, r_refdef_view_t::clear, cmd_local, r_refdef_view_t::colorscale, r_rendertarget_t::colortexture, r_rendertarget_t::depthtexture, DrawQ_Finish(), DrawQ_Start(), r_waterstate_t::enabled, r_refdef_scene_t::entities, rsurfacestate_t::entity, r_rendertarget_t::fbo, r_refdef_t::fogenabled, GL_Clear(), GL_DEPTH_BUFFER_BIT, GL_Scissor(), GL_ScissorTest(), height, r_refdef_view_t::height, r_viewport_t::height, Image_sRGBFloatFromLinearFloat, cvar_t::integer, r_refdef_view_t::ismain, r_refdef_view_t::isoverlay, r_refdef_view_t::matrix, Matrix4x4_Concat(), Matrix4x4_CreateFromQuakeEntity(), NULL, r_refdef_scene_t::numentities, r_waterstate_t::numwaterplanes, R_AnimCache_CacheVisibleEntities(), R_AnimCache_ClearCache(), R_BlendView(), R_BlendView_IsTrivial(), r_bloom_scenebrightness, R_Bloom_StartFrame(), R_ClearScreen(), R_CompileShader_CheckStaticParms(), r_drawentities, r_fb, R_GLSL_Restart_f(), r_hdr_irisadaptation_value, r_hdr_scenebrightness, R_Mesh_SetRenderTargets(), R_MotionBlurView(), r_refdef, R_RenderScene(), r_renderview, R_RenderView_UpdateViewVectors(), R_RenderWaterPlanes(), R_ResetViewRendering3D(), R_Shadow_UpdateBounceGridTexture(), R_Shadow_UpdateWorldLightSelection(), R_SortEntities(), r_sortentities, R_Stereo_Active(), r_stereo_angle, r_stereo_separation, r_stereo_side, r_textureframe, R_TimeReport(), r_timereport_active, r_trippy, R_View_Update(), R_Water_StartFrame(), rsurface, r_framebufferstate_t::rt_bloom, r_framebufferstate_t::rt_screen, r_refdef_t::scene, r_refdef_view_t::showdebug, viddef_t::sRGB3D, r_rendertarget_t::textureheight, r_rendertarget_t::texturewidth, r_refdef_view_t::useperspective, r_refdef_view_t::usevieworiginculling, v_isometric, V_MakeViewIsometric(), cvar_t::value, vid, vid_sRGB, vid_sRGB_fallback, r_refdef_t::view, r_refdef_view_t::viewport, r_framebufferstate_t::water, r_refdef_view_t::width, r_viewport_t::width, width, r_refdef_view_t::x, r_viewport_t::x, x, r_refdef_view_t::y, r_viewport_t::y, and y.

Referenced by R_Envmap_f(), SCR_DrawScreen(), and VM_CL_R_RenderScene().

◆ R_RenderView_UpdateViewVectors()

void R_RenderView_UpdateViewVectors ( void )

Definition at line 4512 of file gl_rmain.c.

4513{
4514 // break apart the view matrix into vectors for various purposes
4515 // it is important that this occurs outside the RenderScene function because that can be called from reflection renders, where the vectors come out wrong
4516 // however the r_refdef.view.origin IS updated in RenderScene intentionally - otherwise the sky renders at the wrong origin, etc
4519 // make an inverted copy of the view matrix for tracking sprites
4521}
int Matrix4x4_Invert_Full(matrix4x4_t *out, const matrix4x4_t *in1)
Definition matrixlib.c:145
void Matrix4x4_ToVectors(const matrix4x4_t *in, float vx[3], float vy[3], float vz[3], float t[3])
Definition matrixlib.c:939
vec3_t left
Definition render.h:269
vec3_t right
Definition render.h:270
matrix4x4_t inverse_matrix
Definition render.h:266

References r_refdef_view_t::forward, r_refdef_view_t::inverse_matrix, r_refdef_view_t::left, r_refdef_view_t::matrix, Matrix4x4_Invert_Full(), Matrix4x4_ToVectors(), r_refdef_view_t::origin, r_refdef, r_refdef_view_t::right, r_refdef_view_t::up, VectorNegate, and r_refdef_t::view.

Referenced by CL_VM_UpdateView(), R_RenderView(), and R_Water_ProcessPlanes().

◆ R_RenderWaterPlanes()

void R_RenderWaterPlanes ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 5803 of file gl_rmain.c.

5804{
5806 {
5809 R_TimeReport("waterworld");
5810 }
5811
5814 R_TimeReport("watermodels");
5815
5817 {
5818 R_Water_ProcessPlanes(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5820 R_TimeReport("waterscenes");
5821 }
5822}
static void R_DrawModelsAddWaterPlanes(void)
Definition gl_rmain.c:4127
static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4757

References cl, client_state_t::csqc_vidvars, model_t::DrawAddWaterPlanes, csqc_vidvars_t::drawworld, r_waterstate_t::numwaterplanes, R_DrawModelsAddWaterPlanes(), r_fb, r_refdef, R_TimeReport(), r_timereport_active, R_Water_ProcessPlanes(), r_refdef_t::scene, r_framebufferstate_t::water, r_refdef_scene_t::worldentity, and r_refdef_scene_t::worldmodel.

Referenced by R_RenderView().

◆ R_ResetViewRendering2D()

void R_ResetViewRendering2D ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 4477 of file gl_rmain.c.

4478{
4479 R_ResetViewRendering2D_Common(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight, 1.0f, 1.0f);
4480}
void R_ResetViewRendering2D_Common(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight, float x2, float y2)
Definition gl_rmain.c:4439

References R_ResetViewRendering2D_Common().

Referenced by R_BlendView(), and R_MotionBlurView().

◆ R_ResetViewRendering2D_Common()

void R_ResetViewRendering2D_Common ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight,
float x2,
float y2 )

Definition at line 4439 of file gl_rmain.c.

4440{
4441 r_viewport_t viewport;
4442 int viewy_adjusted;
4443
4445
4446 // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom.
4447 // Unless the render target is a FBO...
4448 viewy_adjusted = viewfbo ? viewy : vid.mode.height - viewheight - viewy;
4449
4450 R_Viewport_InitOrtho(&viewport, &identitymatrix, viewx, viewy_adjusted, viewwidth, viewheight, 0, 0, x2, y2, -10, 100, NULL);
4451 R_Mesh_SetRenderTargets(viewfbo);
4452 R_SetViewport(&viewport);
4453 GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
4454 GL_Color(1, 1, 1, 1);
4457 GL_ScissorTest(false);
4458 GL_DepthMask(false);
4459 GL_DepthRange(0, 1);
4460 GL_DepthTest(false);
4464 GL_PolygonOffset(0, 0);
4465 switch(vid.renderpath)
4466 {
4467 case RENDERPATH_GL32:
4468 case RENDERPATH_GLES2:
4470 break;
4471 }
4473
4475}
void GL_DepthFunc(int state)
#define GL_POLYGON_OFFSET_FILL
Definition glquake.h:183
#define GL_LEQUAL
Definition glquake.h:162

References CHECKGLERROR, r_refdef_view_t::colormask, GL_BlendFunc(), GL_Color(), GL_ColorMask(), GL_CullFace(), GL_DepthFunc(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_LEQUAL, GL_NONE, GL_ONE, GL_POLYGON_OFFSET_FILL, GL_PolygonOffset(), GL_Scissor(), GL_ScissorTest(), GL_ZERO, r_viewport_t::height, viddef_mode_t::height, identitymatrix, viddef_t::mode, NULL, R_EntityMatrix(), R_Mesh_ResetTextureState(), R_Mesh_SetRenderTargets(), r_refdef, R_SetViewport(), R_Viewport_InitOrtho(), viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, vid, r_refdef_t::view, r_viewport_t::width, r_viewport_t::x, x2, r_viewport_t::y, and y2.

Referenced by DrawQ_Start(), and R_ResetViewRendering2D().

◆ R_ResetViewRendering3D()

void R_ResetViewRendering3D ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 4482 of file gl_rmain.c.

4483{
4484 R_SetupView(true, viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
4486 GL_Color(1, 1, 1, 1);
4489 GL_ScissorTest(true);
4490 GL_DepthMask(true);
4491 GL_DepthRange(0, 1);
4492 GL_DepthTest(true);
4497 switch(vid.renderpath)
4498 {
4499 case RENDERPATH_GL32:
4500 case RENDERPATH_GLES2:
4502 break;
4503 }
4505}

References CHECKGLERROR, r_refdef_view_t::colormask, r_refdef_view_t::cullface_back, GL_BlendFunc(), GL_Color(), GL_ColorMask(), GL_CullFace(), GL_DepthFunc(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_LEQUAL, GL_ONE, GL_POLYGON_OFFSET_FILL, GL_PolygonOffset(), GL_Scissor(), GL_ScissorTest(), GL_ZERO, r_viewport_t::height, identitymatrix, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, R_EntityMatrix(), R_Mesh_ResetTextureState(), r_refdef, R_SetupView(), viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, vid, r_refdef_t::view, r_refdef_view_t::viewport, r_viewport_t::width, r_viewport_t::x, and r_viewport_t::y.

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_SelectScene()

void R_SelectScene ( r_refdef_scene_type_t scenetype)

Definition at line 5573 of file gl_rmain.c.

5573 {
5574 if( scenetype != r_currentscenetype ) {
5575 // store the old scenetype
5577 r_currentscenetype = scenetype;
5578 // move in the new scene
5580 }
5581}

References r_currentscenetype, r_refdef, r_scenes_store, and r_refdef_t::scene.

Referenced by MP_Draw(), and MVM_error_cmd().

◆ R_SetupShader_DeferredLight()

void R_SetupShader_DeferredLight ( const rtlight_t * rtlight)

Definition at line 2091 of file gl_rmain.c.

2092{
2093 // select a permutation of the lighting shader appropriate to this
2094 // combination of texture, entity, light source, and fogging, only use the
2095 // minimum features necessary to avoid wasting rendering time in the
2096 // fragment shader on features that are not being used
2097 uint64_t permutation = 0;
2098 unsigned int mode = 0;
2099 const float *lightcolorbase = rtlight->currentcolor;
2100 float ambientscale = rtlight->ambientscale;
2101 float diffusescale = rtlight->diffusescale;
2102 float specularscale = rtlight->specularscale;
2103 // this is the location of the light in view space
2104 vec3_t viewlightorigin;
2105 // this transforms from view space (camera) to light space (cubemap)
2106 matrix4x4_t viewtolight;
2107 matrix4x4_t lighttoview;
2108 float viewtolight16f[16];
2109 // light source
2111 if (rtlight->currentcubemap != r_texture_whitecube)
2112 permutation |= SHADERPERMUTATION_CUBEFILTER;
2113 if (diffusescale > 0)
2114 permutation |= SHADERPERMUTATION_DIFFUSE;
2115 if (specularscale > 0 && r_shadow_gloss.integer > 0)
2118 {
2119 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
2121 permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT;
2122
2124 permutation |= SHADERPERMUTATION_DEPTHRGB;
2125 }
2127 GL_AlphaToCoverage(false);
2128 Matrix4x4_Transform(&r_refdef.view.viewport.viewmatrix, rtlight->shadoworigin, viewlightorigin);
2130 Matrix4x4_Invert_Full(&viewtolight, &lighttoview);
2131 Matrix4x4_ToArrayFloatGL(&viewtolight, viewtolight16f);
2132 switch(vid.renderpath)
2133 {
2134 case RENDERPATH_GL32:
2135 case RENDERPATH_GLES2:
2137 if (r_glsl_permutation->loc_LightPosition >= 0) qglUniform3f( r_glsl_permutation->loc_LightPosition , viewlightorigin[0], viewlightorigin[1], viewlightorigin[2]);
2138 if (r_glsl_permutation->loc_ViewToLight >= 0) qglUniformMatrix4fv(r_glsl_permutation->loc_ViewToLight , 1, false, viewtolight16f);
2139 if (r_glsl_permutation->loc_DeferredColor_Ambient >= 0) qglUniform3f( r_glsl_permutation->loc_DeferredColor_Ambient , lightcolorbase[0] * ambientscale , lightcolorbase[1] * ambientscale , lightcolorbase[2] * ambientscale );
2140 if (r_glsl_permutation->loc_DeferredColor_Diffuse >= 0) qglUniform3f( r_glsl_permutation->loc_DeferredColor_Diffuse , lightcolorbase[0] * diffusescale , lightcolorbase[1] * diffusescale , lightcolorbase[2] * diffusescale );
2141 if (r_glsl_permutation->loc_DeferredColor_Specular >= 0) qglUniform3f( r_glsl_permutation->loc_DeferredColor_Specular , lightcolorbase[0] * specularscale, lightcolorbase[1] * specularscale, lightcolorbase[2] * specularscale);
2147
2153 break;
2154 }
2155}
void GL_AlphaToCoverage(qbool state)
rtexture_t * r_shadow_prepassgeometrynormalmaptexture
Definition r_shadow.c:120
qbool r_shadow_shadowmapvsdct
Definition r_shadow.c:57
rtexture_t * r_shadow_attenuationgradienttexture
Definition r_shadow.c:108
float r_shadow_lightshadowmap_parameters[4]
Definition r_shadow.c:41
qbool r_shadow_usingshadowmap2d
Definition r_shadow.c:37
float r_shadow_lightshadowmap_texturescale[4]
Definition r_shadow.c:40
rtexture_t * r_shadow_shadowmapvsdcttexture
Definition r_shadow.c:112
rtexture_t * r_shadow_shadowmap2ddepthtexture
Definition r_shadow.c:111
rtexture_t * r_shadow_shadowmap2ddepthbuffer
Definition r_shadow.c:110
#define SHADERPERMUTATION_SPECULAR
(lightsource or deluxemapping) render specular effects
Definition render.h:86
@ SHADERMODE_DEFERREDLIGHTSOURCE
(deferred) use directional pixel shading from light source (rtlight) on screenspace geometry buffers
Definition render.h:68
#define SHADERPERMUTATION_DEPTHRGB
read/write depth values in RGB color coded format for older hardware without depth samplers
Definition render.h:101
#define SHADERPERMUTATION_SHADOWMAPVSDCT
(lightsource) use virtual shadow depth cube texture for shadowmap indexing
Definition render.h:92
#define SHADERPERMUTATION_SHADOWMAP2D
(lightsource) use shadowmap texture as light filter
Definition render.h:91
#define SHADERPERMUTATION_CUBEFILTER
(lightsource) use cubemap light filter
Definition render.h:83
#define SHADERPERMUTATION_DIFFUSE
(lightsource) whether to use directional shading
Definition render.h:73
float screentodepth[2]
used by deferred renderer to calculate linear depth from device depth coordinates
Definition render.h:250
matrix4x4_t viewmatrix
actual matrix for rendering (transforms to viewspace)
Definition render.h:241
vec_t ambientscale
ambient intensity to render
Definition client.h:128
rtexture_t * currentcubemap
this is R_GetCubemap(rtlight->cubemapname)
Definition client.h:153
vec3_t currentcolor
Definition client.h:147
vec_t specularscale
specular intensity to render
Definition client.h:132
vec3_t shadoworigin
used only for casting shadows
Definition client.h:138
matrix4x4_t matrix_lighttoworld
matrix for transforming light filter coordinates to world coordinates
Definition client.h:110
vec_t diffusescale
diffuse intensity to render
Definition client.h:130

References viddef_t::allowalphatocoverage, rtlight_t::ambientscale, rtlight_t::currentcolor, rtlight_t::currentcubemap, rtlight_t::diffusescale, GL_AlphaToCoverage(), cvar_t::integer, r_glsl_permutation_t::loc_DeferredColor_Ambient, r_glsl_permutation_t::loc_DeferredColor_Diffuse, r_glsl_permutation_t::loc_DeferredColor_Specular, r_glsl_permutation_t::loc_LightPosition, r_glsl_permutation_t::loc_PixelToScreenTexCoord, r_glsl_permutation_t::loc_ScreenToDepth, r_glsl_permutation_t::loc_ShadowMap_Parameters, r_glsl_permutation_t::loc_ShadowMap_TextureScale, r_glsl_permutation_t::loc_SpecularPower, r_glsl_permutation_t::loc_ViewToLight, Matrix4x4_Concat(), Matrix4x4_Invert_Full(), Matrix4x4_ToArrayFloatGL(), Matrix4x4_Transform(), rtlight_t::matrix_lighttoworld, mode, r_fb, r_glsl_permutation, R_Mesh_TexBind(), r_refdef, R_SetupShader_SetPermutationGLSL(), r_shadow_attenuationgradienttexture, r_shadow_gloss, r_shadow_gloss2exponent, r_shadow_glossexact, r_shadow_glossexponent, r_shadow_lightshadowmap_parameters, r_shadow_lightshadowmap_texturescale, r_shadow_prepassgeometrynormalmaptexture, r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, r_shadow_shadowmapvsdct, r_shadow_shadowmapvsdcttexture, r_shadow_usingshadowmap2d, r_texture_whitecube, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, rsurface, rsurfacestate_t::rtlight, r_framebufferstate_t::screentextureheight, r_framebufferstate_t::screentexturewidth, r_viewport_t::screentodepth, SHADERMODE_DEFERREDLIGHTSOURCE, SHADERPERMUTATION_CUBEFILTER, SHADERPERMUTATION_DEPTHRGB, SHADERPERMUTATION_DIFFUSE, SHADERPERMUTATION_SHADOWMAP2D, SHADERPERMUTATION_SHADOWMAPVSDCT, SHADERPERMUTATION_SPECULAR, rtlight_t::shadoworigin, rtlight_t::specularscale, r_glsl_permutation_t::tex_Texture_Attenuation, r_glsl_permutation_t::tex_Texture_Cube, r_glsl_permutation_t::tex_Texture_CubeProjection, r_glsl_permutation_t::tex_Texture_ScreenNormalMap, r_glsl_permutation_t::tex_Texture_ShadowMap2D, cvar_t::value, vid, r_refdef_t::view, r_viewport_t::viewmatrix, and r_refdef_view_t::viewport.

Referenced by R_Shadow_RenderMode_DrawDeferredLight().

◆ R_SetupShader_DepthOrShadow()

void R_SetupShader_DepthOrShadow ( qbool notrippy,
qbool depthrgb,
qbool skeletal )

Definition at line 1493 of file gl_rmain.c.

1494{
1495 uint64_t permutation = 0;
1496 if (r_trippy.integer && !notrippy)
1497 permutation |= SHADERPERMUTATION_TRIPPY;
1498 if (depthrgb)
1499 permutation |= SHADERPERMUTATION_DEPTHRGB;
1500 if (skeletal)
1501 permutation |= SHADERPERMUTATION_SKELETAL;
1502
1504 GL_AlphaToCoverage(false);
1505 switch (vid.renderpath)
1506 {
1507 case RENDERPATH_GL32:
1508 case RENDERPATH_GLES2:
1510#ifndef USE_GLES2 /* FIXME: GLES3 only */
1512#endif
1513 break;
1514 }
1515}
#define GL_UNIFORM_BUFFER
Definition glquake.h:413
#define SHADERPERMUTATION_SKELETAL
(skeletal models) use skeletal matrices to deform vertices (gpu-skinning)
Definition render.h:103
@ SHADERMODE_DEPTH_OR_SHADOW
(depthfirst/shadows) vertex shader only
Definition render.h:54
#define SHADERPERMUTATION_TRIPPY
use trippy vertex shader effect
Definition render.h:100
const r_meshbuffer_t * batchskeletaltransform3x4buffer
Definition render.h:708
int batchskeletaltransform3x4size
Definition render.h:710
int batchskeletaltransform3x4offset
Definition render.h:709

References viddef_t::allowalphatocoverage, rsurfacestate_t::batchskeletaltransform3x4buffer, rsurfacestate_t::batchskeletaltransform3x4offset, rsurfacestate_t::batchskeletaltransform3x4size, r_meshbuffer_t::bufferobject, GL_AlphaToCoverage(), GL_UNIFORM_BUFFER, cvar_t::integer, r_glsl_permutation, R_SetupShader_SetPermutationGLSL(), r_trippy, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, rsurface, SHADERMODE_DEPTH_OR_SHADOW, SHADERPERMUTATION_DEPTHRGB, SHADERPERMUTATION_SKELETAL, SHADERPERMUTATION_TRIPPY, r_glsl_permutation_t::ubibind_Skeletal_Transform12_UniformBlock, r_glsl_permutation_t::ubiloc_Skeletal_Transform12_UniformBlock, and vid.

Referenced by R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_Sky(), R_Shadow_ClearShadowMapTexture(), and R_Shadow_RenderMode_ShadowMap().

◆ R_SetupShader_Generic()

void R_SetupShader_Generic ( rtexture_t * t,
qbool usegamma,
qbool notrippy,
qbool suppresstexalpha )

Definition at line 1461 of file gl_rmain.c.

1462{
1463 uint64_t permutation = 0;
1464 if (r_trippy.integer && !notrippy)
1465 permutation |= SHADERPERMUTATION_TRIPPY;
1466 permutation |= SHADERPERMUTATION_VIEWTINT;
1467 if (t)
1468 permutation |= SHADERPERMUTATION_DIFFUSE;
1470 permutation |= SHADERPERMUTATION_GAMMARAMPS;
1471 if (suppresstexalpha)
1472 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1474 GL_AlphaToCoverage(false);
1475 switch (vid.renderpath)
1476 {
1477 case RENDERPATH_GL32:
1478 case RENDERPATH_GLES2:
1484 break;
1485 }
1486}
cvar_t v_glslgamma_2d
Definition vid_shared.c:186
@ SHADERMODE_GENERIC
(particles/HUD/etc) vertex color, optionally multiplied by one texture
Definition render.h:52
#define SHADERPERMUTATION_REFLECTCUBE
fake reflections using global cubemap (not HDRI light probe)
Definition render.h:96
qbool sRGB2D
whether 2D rendering is sRGB corrected (based on sRGBcapable2D)
Definition vid.h:75

References viddef_t::allowalphatocoverage, GL_AlphaToCoverage(), cvar_t::integer, r_glsl_permutation, R_Mesh_TexBind(), R_SetupShader_SetPermutationGLSL(), r_texture_gammaramps, r_trippy, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, SHADERMODE_GENERIC, SHADERPERMUTATION_DIFFUSE, SHADERPERMUTATION_GAMMARAMPS, SHADERPERMUTATION_REFLECTCUBE, SHADERPERMUTATION_TRIPPY, SHADERPERMUTATION_VIEWTINT, viddef_t::sRGB2D, r_glsl_permutation_t::tex_Texture_First, r_glsl_permutation_t::tex_Texture_GammaRamps, v_glslgamma_2d, vid, and vid_gammatables_trivial.

Referenced by R_Bloom_MakeTexture(), R_DrawExplosion_TransparentCallback(), R_DrawModelDecals_Entity(), R_DrawParticle_TransparentCallback(), R_MotionBlurView(), R_SetupShader_Generic_NoTexture(), and SCR_DrawLoadingScreen().

◆ R_SetupShader_Generic_NoTexture()

◆ R_SetupShader_SetPermutationGLSL()

static void R_SetupShader_SetPermutationGLSL ( unsigned int mode,
uint64_t permutation )
static

Definition at line 1346 of file gl_rmain.c.

1347{
1348 r_glsl_permutation_t *perm = R_GLSL_FindPermutation(mode, permutation);
1349 if (r_glsl_permutation != perm)
1350 {
1351 r_glsl_permutation = perm;
1353 {
1355 {
1356 Con_DPrintf("Compiling shader mode %u permutation %" PRIx64 "\n", mode, permutation);
1357 R_GLSL_CompilePermutation(perm, mode, permutation);
1358 }
1360 {
1361 // remove features until we find a valid permutation
1362 unsigned i;
1363 for (i = 0;i < SHADERPERMUTATION_COUNT;i++)
1364 {
1365 // reduce i more quickly whenever it would not remove any bits
1366 uint64_t j = 1ll<<(SHADERPERMUTATION_COUNT-1-i);
1367 if (!(permutation & j))
1368 continue;
1369 permutation -= j;
1372 R_GLSL_CompilePermutation(perm, mode, permutation);
1374 break;
1375 }
1377 {
1378 //Con_Printf("Could not find a working OpenGL 2.0 shader for permutation %s %s\n", shadermodeinfo[mode].filename, shadermodeinfo[mode].pretext);
1380 qglUseProgram(0);CHECKGLERROR
1381 return; // no bit left to clear, entire mode is broken
1382 }
1383 }
1384 }
1387 }
1392}
static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode, uint64_t permutation)
Definition gl_rmain.c:1024
static r_glsl_permutation_t * R_GLSL_FindPermutation(unsigned int mode, uint64_t permutation)
Definition gl_rmain.c:940

References CHECKGLERROR, cl, r_glsl_permutation_t::compiled, Con_DPrintf(), gl_modelview16f, gl_modelviewprojection16f, i, r_glsl_permutation_t::loc_ClientTime, r_glsl_permutation_t::loc_ModelViewMatrix, r_glsl_permutation_t::loc_ModelViewProjectionMatrix, mode, r_glsl_permutation_t::program, R_GLSL_CompilePermutation(), R_GLSL_FindPermutation(), r_glsl_permutation, SHADERPERMUTATION_COUNT, and client_state_t::time.

Referenced by gl_main_start(), R_BlendView(), R_SetupShader_DeferredLight(), R_SetupShader_DepthOrShadow(), R_SetupShader_Generic(), and R_SetupShader_Surface().

◆ R_SetupShader_Surface()

void R_SetupShader_Surface ( const float rtlightambient[3],
const float rtlightdiffuse[3],
const float rtlightspecular[3],
rsurfacepass_t rsurfacepass,
int texturenumsurfaces,
const msurface_t ** texturesurfacelist,
void * surfacewaterplane,
qbool notrippy,
qbool ui )

Definition at line 1563 of file gl_rmain.c.

1564{
1565 // select a permutation of the lighting shader appropriate to this
1566 // combination of texture, entity, light source, and fogging, only use the
1567 // minimum features necessary to avoid wasting rendering time in the
1568 // fragment shader on features that are not being used
1569 uint64_t permutation = 0;
1570 unsigned int mode = 0;
1571 int blendfuncflags;
1573 float m16f[16];
1574 matrix4x4_t tempmatrix;
1575 r_waterstate_waterplane_t *waterplane = (r_waterstate_waterplane_t *)surfacewaterplane;
1576 if (r_trippy.integer && !notrippy)
1577 permutation |= SHADERPERMUTATION_TRIPPY;
1579 permutation |= SHADERPERMUTATION_ALPHAKILL;
1581 permutation |= SHADERPERMUTATION_OCCLUDE;
1582 if (t->r_water_waterscroll[0] && t->r_water_waterscroll[1])
1583 permutation |= SHADERPERMUTATION_NORMALMAPSCROLLBLEND; // todo: make generic
1584 if (rsurfacepass == RSURFPASS_BACKGROUND)
1585 {
1586 // distorted background
1588 {
1591 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1593 {
1594 // this is the right thing to do for wateralpha
1596 blendfuncflags = R_BlendFuncFlags(GL_ONE, GL_ZERO);
1597 }
1598 else
1599 {
1600 // this is the right thing to do for entity alpha
1603 }
1604 }
1606 {
1609 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1612 }
1613 else
1614 {
1619 }
1621 GL_AlphaToCoverage(false);
1622 }
1623 else if (rsurfacepass == RSURFPASS_DEFERREDGEOMETRY)
1624 {
1626 {
1627 switch(t->offsetmapping)
1628 {
1629 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1632 case OFFSETMAPPING_OFF: break;
1633 }
1634 }
1637 // normalmap (deferred prepass), may use alpha test on diffuse
1640 blendfuncflags = R_BlendFuncFlags(GL_ONE, GL_ZERO);
1642 GL_AlphaToCoverage(false);
1643 }
1644 else if (rsurfacepass == RSURFPASS_RTLIGHT)
1645 {
1647 {
1648 switch(t->offsetmapping)
1649 {
1650 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1653 case OFFSETMAPPING_OFF: break;
1654 }
1655 }
1659 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1660 // light source
1663 permutation |= SHADERPERMUTATION_CUBEFILTER;
1664 if (VectorLength2(rtlightdiffuse) > 0)
1665 permutation |= SHADERPERMUTATION_DIFFUSE;
1666 if (VectorLength2(rtlightspecular) > 0)
1668 if (r_refdef.fogenabled)
1670 if (t->colormapping)
1671 permutation |= SHADERPERMUTATION_COLORMAPPING;
1673 {
1674 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1676 permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT;
1677
1679 permutation |= SHADERPERMUTATION_DEPTHRGB;
1680 }
1681 if (t->reflectmasktexture)
1682 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1684 blendfuncflags = R_BlendFuncFlags(GL_SRC_ALPHA, GL_ONE);
1686 GL_AlphaToCoverage(false);
1687 }
1689 {
1691 {
1692 switch(t->offsetmapping)
1693 {
1694 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1697 case OFFSETMAPPING_OFF: break;
1698 }
1699 }
1703 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1704 // directional model lighting
1707 permutation |= SHADERPERMUTATION_GLOW;
1708 permutation |= SHADERPERMUTATION_DIFFUSE;
1710 permutation |= SHADERPERMUTATION_SPECULAR;
1711 if (r_refdef.fogenabled)
1713 if (t->colormapping)
1714 permutation |= SHADERPERMUTATION_COLORMAPPING;
1716 {
1717 permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
1718 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1719
1721 permutation |= SHADERPERMUTATION_DEPTHRGB;
1722 }
1724 permutation |= SHADERPERMUTATION_REFLECTION;
1727 if (t->reflectmasktexture)
1728 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1730 {
1731 permutation |= SHADERPERMUTATION_BOUNCEGRID;
1734 }
1736 blendfuncflags = R_BlendFuncFlags(t->currentblendfunc[0], t->currentblendfunc[1]);
1737 // when using alphatocoverage, we don't need alphakill
1739 {
1741 {
1743 permutation &= ~SHADERPERMUTATION_ALPHAKILL;
1744 }
1745 else
1746 GL_AlphaToCoverage(false);
1747 }
1748 }
1750 {
1752 {
1753 switch(t->offsetmapping)
1754 {
1755 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1758 case OFFSETMAPPING_OFF: break;
1759 }
1760 }
1764 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1765 // directional model lighting
1768 permutation |= SHADERPERMUTATION_GLOW;
1770 permutation |= SHADERPERMUTATION_DIFFUSE;
1772 permutation |= SHADERPERMUTATION_SPECULAR;
1773 if (r_refdef.fogenabled)
1775 if (t->colormapping)
1776 permutation |= SHADERPERMUTATION_COLORMAPPING;
1778 {
1779 permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
1780 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1781
1783 permutation |= SHADERPERMUTATION_DEPTHRGB;
1784 }
1786 permutation |= SHADERPERMUTATION_REFLECTION;
1789 if (t->reflectmasktexture)
1790 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1792 {
1793 permutation |= SHADERPERMUTATION_BOUNCEGRID;
1796 }
1798 blendfuncflags = R_BlendFuncFlags(t->currentblendfunc[0], t->currentblendfunc[1]);
1799 // when using alphatocoverage, we don't need alphakill
1801 {
1803 {
1805 permutation &= ~SHADERPERMUTATION_ALPHAKILL;
1806 }
1807 else
1808 GL_AlphaToCoverage(false);
1809 }
1810 }
1811 else
1812 {
1814 {
1815 switch(t->offsetmapping)
1816 {
1817 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1820 case OFFSETMAPPING_OFF: break;
1821 }
1822 }
1826 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1827 // lightmapped wall
1829 permutation |= SHADERPERMUTATION_GLOW;
1830 if (r_refdef.fogenabled && !ui)
1832 if (t->colormapping)
1833 permutation |= SHADERPERMUTATION_COLORMAPPING;
1835 {
1836 permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
1837 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1838
1840 permutation |= SHADERPERMUTATION_DEPTHRGB;
1841 }
1843 permutation |= SHADERPERMUTATION_REFLECTION;
1846 if (t->reflectmasktexture)
1847 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1849 {
1850 // deluxemapping (light direction texture)
1853 else
1855 permutation |= SHADERPERMUTATION_DIFFUSE;
1858 }
1859 else if (r_glsl_deluxemapping.integer >= 2)
1860 {
1861 // fake deluxemapping (uniform light direction in tangentspace)
1864 else
1866 permutation |= SHADERPERMUTATION_DIFFUSE;
1869 }
1871 {
1872 // ordinary lightmapping (q1bsp, q3bsp)
1874 }
1875 else
1876 {
1877 // ordinary vertex coloring (q3bsp)
1879 }
1881 {
1882 permutation |= SHADERPERMUTATION_BOUNCEGRID;
1885 }
1887 blendfuncflags = R_BlendFuncFlags(t->currentblendfunc[0], t->currentblendfunc[1]);
1888 // when using alphatocoverage, we don't need alphakill
1890 {
1892 {
1894 permutation &= ~SHADERPERMUTATION_ALPHAKILL;
1895 }
1896 else
1897 GL_AlphaToCoverage(false);
1898 }
1899 }
1900 if(!(blendfuncflags & BLENDFUNC_ALLOWS_ANYFOG))
1902 if(blendfuncflags & BLENDFUNC_ALLOWS_FOG_HACKALPHA && !ui)
1903 permutation |= SHADERPERMUTATION_FOGALPHAHACK;
1904 switch(vid.renderpath)
1905 {
1906 case RENDERPATH_GL32:
1907 case RENDERPATH_GLES2:
1910 // this has to be after RSurf_PrepareVerticesForBatch
1912 permutation |= SHADERPERMUTATION_SKELETAL;
1914#ifndef USE_GLES2 /* FIXME: GLES3 only */
1916#endif
1919 {
1922 if (r_glsl_permutation->loc_LightColor >= 0) qglUniform3f(r_glsl_permutation->loc_LightColor, 1, 1, 1); // DEPRECATED
1923 if (r_glsl_permutation->loc_Color_Ambient >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Ambient, rtlightambient[0], rtlightambient[1], rtlightambient[2]);
1924 if (r_glsl_permutation->loc_Color_Diffuse >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Diffuse, rtlightdiffuse[0], rtlightdiffuse[1], rtlightdiffuse[2]);
1925 if (r_glsl_permutation->loc_Color_Specular >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Specular, rtlightspecular[0], rtlightspecular[1], rtlightspecular[2]);
1926
1927 // additive passes are only darkened by fog, not tinted
1929 qglUniform3f(r_glsl_permutation->loc_FogColor, 0, 0, 0);
1931 }
1932 else
1933 {
1935 {
1937 }
1938 else if (mode == SHADERMODE_LIGHTGRID)
1939 {
1943 // other LightGrid uniforms handled below
1944 }
1945 else if (mode == SHADERMODE_LIGHTDIRECTION)
1946 {
1952 if (r_glsl_permutation->loc_LightColor >= 0) qglUniform3f(r_glsl_permutation->loc_LightColor, 1, 1, 1); // DEPRECATED
1954 }
1955 else
1956 {
1962 }
1963 // additive passes are only darkened by fog, not tinted
1964 if (r_glsl_permutation->loc_FogColor >= 0 && !ui)
1965 {
1966 if(blendfuncflags & BLENDFUNC_ALLOWS_FOG_HACK0)
1967 qglUniform3f(r_glsl_permutation->loc_FogColor, 0, 0, 0);
1968 else
1970 }
1980 }
1981 if (r_glsl_permutation->loc_TexMatrix >= 0) {Matrix4x4_ToArrayFloatGL(&t->currenttexmatrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_TexMatrix, 1, false, m16f);}
1984 if (permutation & SHADERPERMUTATION_SHADOWMAPORTHO)
1985 {
1988 }
1989 else
1990 {
1993 }
1994
1999 {
2000 if (t->pantstexture)
2002 else
2003 qglUniform3f(r_glsl_permutation->loc_Color_Pants, 0, 0, 0);
2004 }
2006 {
2007 if (t->shirttexture)
2009 else
2010 qglUniform3f(r_glsl_permutation->loc_Color_Shirt, 0, 0, 0);
2011 }
2021 );
2029 {
2030 float m9f[9];
2032 Matrix4x4_ToArrayFloatGL(&tempmatrix, m16f);
2033 qglUniformMatrix4fv(r_glsl_permutation->loc_LightGridMatrix, 1, false, m16f);
2034 Matrix4x4_Normalize3(&tempmatrix, &rsurface.matrix);
2035 Matrix4x4_ToArrayFloatGL(&tempmatrix, m16f);
2036 m9f[0] = m16f[0];m9f[1] = m16f[1];m9f[2] = m16f[2];
2037 m9f[3] = m16f[4];m9f[4] = m16f[5];m9f[5] = m16f[6];
2038 m9f[6] = m16f[8];m9f[7] = m16f[9];m9f[8] = m16f[10];
2039 qglUniformMatrix3fv(r_glsl_permutation->loc_LightGridNormalMatrix, 1, false, m9f);
2040 }
2041
2062 if (rsurfacepass == RSURFPASS_BACKGROUND)
2063 {
2067 }
2068 else
2069 {
2071 }
2076 {
2078 if (rsurface.rtlight)
2079 {
2082 }
2083 }
2087 break;
2088 }
2089}
rtexture_t * r_shadow_prepasslightingdiffusetexture
Definition r_shadow.c:121
rtexture_t * r_shadow_prepasslightingspeculartexture
Definition r_shadow.c:122
void RSurf_UploadBuffersForBatch(void)
Definition gl_rmain.c:7340
#define BLENDFUNC_ALLOWS_ANYFOG
Definition gl_rmain.c:1521
int R_TextureFlags(rtexture_t *rt)
void Matrix4x4_Normalize3(matrix4x4_t *out, matrix4x4_t *in1)
Definition matrixlib.c:508
#define MATERIALFLAG_OCCLUDE
#define RENDER_NOSELFSHADOW
Definition protocol.h:367
@ OFFSETMAPPING_DEFAULT
Definition r_qshader.h:186
@ OFFSETMAPPING_LINEAR
Definition r_qshader.h:187
@ OFFSETMAPPING_RELIEF
Definition r_qshader.h:188
float r_shadow_modelshadowmap_parameters[4]
Definition r_shadow.c:43
qbool r_shadow_usingshadowmaportho
Definition r_shadow.c:38
matrix4x4_t r_shadow_shadowmapmatrix
Definition r_shadow.c:62
r_shadow_bouncegrid_state_t r_shadow_bouncegrid_state
Definition r_shadow.c:259
float r_shadow_modelshadowmap_texturescale[4]
Definition r_shadow.c:42
#define SHADERPERMUTATION_FOGALPHAHACK
fog color and density determined by texture mapped on vertical axis
Definition render.h:81
@ SHADERMODE_DEFERREDGEOMETRY
(deferred) render material properties to screenspace geometry buffers
Definition render.h:67
@ SHADERMODE_FLATCOLOR
(lightmap) modulate texture by uniform color (q1bsp, q3bsp)
Definition render.h:55
@ SHADERMODE_LIGHTDIRECTION
(lightmap) use directional pixel shading from fixed light direction (q3bsp)
Definition render.h:63
@ SHADERMODE_VERTEXCOLOR
(lightmap) modulate texture by vertex colors (q3bsp)
Definition render.h:56
@ SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE
(lightmap) use directional pixel shading from texture containing modelspace light directions (q3bsp d...
Definition render.h:58
@ SHADERMODE_LIGHTMAP
(lightmap) modulate texture by lightmap texture (q1bsp, q3bsp)
Definition render.h:57
@ SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP
Definition render.h:60
@ SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE
(lightmap) use directional pixel shading from texture containing tangentspace light directions (q1bsp...
Definition render.h:59
@ SHADERMODE_WATER
refract background and reflection (the material is rendered normally after this pass)
Definition render.h:66
@ SHADERMODE_LIGHTSOURCE
(lightsource) use directional pixel shading from light source (rtlight)
Definition render.h:64
@ SHADERMODE_LIGHTGRID
(lightmap) use directional pixel shading from lightgrid data (q3bsp)
Definition render.h:62
@ SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR
Definition render.h:61
@ SHADERMODE_REFRACTION
refract background (the material is rendered normally after this pass)
Definition render.h:65
#define SHADERPERMUTATION_ALPHAKILL
(deferredgeometry) discard pixel if diffuse texture alpha below 0.5, (generic) apply global alpha
Definition render.h:95
#define SHADERPERMUTATION_ALPHAGEN_VERTEX
alphaGen vertex
Definition render.h:102
#define SHADERPERMUTATION_GLOW
(lightmap) blend in an additive glow texture
Definition render.h:84
#define SHADERPERMUTATION_FOGHEIGHTTEXTURE
fog color and density determined by texture mapped on vertical axis
Definition render.h:80
#define SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL
(lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standar...
Definition render.h:99
#define SHADERPERMUTATION_FOGOUTSIDE
tint the color by fog color or black if using additive blend mode
Definition render.h:79
#define SHADERPERMUTATION_OCCLUDE
use occlusion buffer for corona
Definition render.h:104
#define BATCHNEED_ARRAY_LIGHTMAP
Definition render.h:791
#define SHADERPERMUTATION_OFFSETMAPPING
adjust texcoords to roughly simulate a displacement mapped surface
Definition render.h:89
#define SHADERPERMUTATION_BOUNCEGRID
(lightmap) use Texture_BounceGrid as an additional source of ambient light
Definition render.h:98
#define SHADERPERMUTATION_VERTEXTEXTUREBLEND
indicates this is a two-layer material blend based on vertex alpha (q3bsp)
Definition render.h:74
#define SHADERPERMUTATION_FOGINSIDE
tint the color by fog color or black if using additive blend mode
Definition render.h:78
#define SHADERPERMUTATION_NORMALMAPSCROLLBLEND
(water) counter-direction normalmaps scrolling
Definition render.h:97
#define SHADERPERMUTATION_SHADOWMAPORTHO
(lightsource) use orthographic shadowmap projection
Definition render.h:93
#define SHADERPERMUTATION_REFLECTION
normalmap-perturbed reflection of the scene infront of the surface, preformed as an overlay on the su...
Definition render.h:88
@ RSURFPASS_RTLIGHT
Definition render.h:806
#define SHADERPERMUTATION_DEFERREDLIGHTMAP
(lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping
Definition render.h:94
#define SHADERPERMUTATION_COLORMAPPING
indicates this is a colormapped skin
Definition render.h:76
#define BATCHNEED_ARRAY_TEXCOORD
Definition render.h:790
#define SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING
adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also...
Definition render.h:90
matrix4x4_t lightgridworldtotexturematrix
qbool deluxemapping_modelspace
rtexture_t * lightgridtexture
model_brushq3_t brushq3
qbool fogplaneviewabove
Definition render.h:422
float quality
render quality (0 to 1) - affects r_drawparticles_drawdistance and others
Definition render.h:321
struct rtexture_s * texture
Definition r_shadow.h:100
float screencenter[2]
Definition render.h:872
float screenscale[2]
Definition render.h:871
r_rendertarget_t * rt_refraction
Definition render.h:849
r_rendertarget_t * rt_camera
Definition render.h:851
r_rendertarget_t * rt_reflection
Definition render.h:850
matrix4x4_t entitytolight
Definition render.h:754
float fogplaneviewdist
Definition render.h:744
float fogheightfade
Definition render.h:743
float fograngerecip
Definition render.h:740
vec3_t entitylightorigin
Definition render.h:751
float fogplane[4]
Definition render.h:742
float refractfactor
dpoffsetmapping_technique_t offsetmapping
float r_water_waterscroll[2]
float reflectmin
vec4_t refractcolor4f
struct rtexture_s * reflectcubetexture
float reflectmax
float offsetscale
float r_water_wateralpha
float reflectfactor
float offsetbias
vec4_t reflectcolor4f

References viddef_t::allowalphatocoverage, texture_t::backgroundbasetexture, texture_t::backgroundglosstexture, texture_t::backgroundglowtexture, texture_t::backgroundnmaptexture, texture_t::basematerialflags, texture_t::basetexture, BATCHNEED_ALLOWMULTIDRAW, BATCHNEED_ARRAY_LIGHTMAP, BATCHNEED_ARRAY_NORMAL, BATCHNEED_ARRAY_TEXCOORD, BATCHNEED_ARRAY_VECTOR, BATCHNEED_ARRAY_VERTEX, BATCHNEED_ARRAY_VERTEXCOLOR, rsurfacestate_t::batchskeletaltransform3x4buffer, rsurfacestate_t::batchskeletaltransform3x4offset, rsurfacestate_t::batchskeletaltransform3x4size, BLENDFUNC_ALLOWS_ANYFOG, BLENDFUNC_ALLOWS_FOG_HACK0, BLENDFUNC_ALLOWS_FOG_HACKALPHA, model_t::brushq3, r_meshbuffer_t::bufferobject, CHECKGLERROR, cl, texture_t::colormapping, r_refdef_view_t::colorscale, r_rendertarget_t::colortexture, client_state_t::csqc_vidvars, texture_t::currentalpha, texture_t::currentbackgroundtexmatrix, texture_t::currentblendfunc, rtlight_t::currentcubemap, texture_t::currentmaterialflags, texture_t::currenttexmatrix, model_brushq3_t::deluxemapping, model_brushq3_t::deluxemapping_modelspace, rsurfacestate_t::deluxemaptexture, r_shadow_bouncegrid_state_t::directional, csqc_vidvars_t::drawworld, r_waterstate_t::enabled, rsurfacestate_t::ent_flags, rsurfacestate_t::entitylightorigin, rsurfacestate_t::entitytolight, r_refdef_t::fogcolor, r_refdef_t::fogenabled, rsurfacestate_t::fogheightfade, rsurfacestate_t::fogplane, r_refdef_t::fogplaneviewabove, rsurfacestate_t::fogplaneviewdist, rsurfacestate_t::fograngerecip, GL_AlphaToCoverage(), GL_BlendFunc(), gl_lightmaps, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_UNIFORM_BUFFER, GL_ZERO, texture_t::glosstexture, texture_t::glowtexture, cvar_t::integer, r_shadow_bouncegrid_state_t::intensity, r_refdef_view_t::isoverlay, model_brushq3_t::lightgridtexture, model_brushq3_t::lightgridworldtotexturematrix, rsurfacestate_t::lightmaptexture, r_glsl_permutation_t::loc_Alpha, r_glsl_permutation_t::loc_BackgroundTexMatrix, r_glsl_permutation_t::loc_BounceGridIntensity, r_glsl_permutation_t::loc_BounceGridMatrix, r_glsl_permutation_t::loc_Color_Ambient, r_glsl_permutation_t::loc_Color_Diffuse, r_glsl_permutation_t::loc_Color_Glow, r_glsl_permutation_t::loc_Color_Pants, r_glsl_permutation_t::loc_Color_Shirt, r_glsl_permutation_t::loc_Color_Specular, r_glsl_permutation_t::loc_DeferredMod_Diffuse, r_glsl_permutation_t::loc_DeferredMod_Specular, r_glsl_permutation_t::loc_DistortScaleRefractReflect, r_glsl_permutation_t::loc_EyePosition, r_glsl_permutation_t::loc_FogColor, r_glsl_permutation_t::loc_FogHeightFade, r_glsl_permutation_t::loc_FogPlane, r_glsl_permutation_t::loc_FogPlaneViewDist, r_glsl_permutation_t::loc_FogRangeRecip, r_glsl_permutation_t::loc_LightColor, r_glsl_permutation_t::loc_LightDir, r_glsl_permutation_t::loc_LightGridMatrix, r_glsl_permutation_t::loc_LightGridNormalMatrix, r_glsl_permutation_t::loc_LightPosition, r_glsl_permutation_t::loc_ModelToLight, r_glsl_permutation_t::loc_ModelToReflectCube, r_glsl_permutation_t::loc_NormalmapScrollBlend, r_glsl_permutation_t::loc_OffsetMapping_Bias, r_glsl_permutation_t::loc_OffsetMapping_LodDistance, r_glsl_permutation_t::loc_OffsetMapping_ScaleSteps, r_glsl_permutation_t::loc_PixelToScreenTexCoord, r_glsl_permutation_t::loc_ReflectColor, r_glsl_permutation_t::loc_ReflectFactor, r_glsl_permutation_t::loc_ReflectOffset, r_glsl_permutation_t::loc_RefractColor, r_glsl_permutation_t::loc_ScreenCenterRefractReflect, r_glsl_permutation_t::loc_ScreenScaleRefractReflect, r_glsl_permutation_t::loc_ScreenToDepth, r_glsl_permutation_t::loc_ShadowMap_Parameters, r_glsl_permutation_t::loc_ShadowMap_TextureScale, r_glsl_permutation_t::loc_ShadowMapMatrix, r_glsl_permutation_t::loc_SpecularPower, r_glsl_permutation_t::loc_TexMatrix, rsurfacestate_t::localvieworigin, MATERIALFLAG_ALPHAGEN_VERTEX, MATERIALFLAG_ALPHATEST, MATERIALFLAG_BLENDED, MATERIALFLAG_LIGHTGRID, MATERIALFLAG_MODELLIGHT, MATERIALFLAG_OCCLUDE, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_VERTEXTEXTUREBLEND, MATERIALFLAG_WATERALPHA, MATERIALFLAG_WATERSHADER, r_shadow_bouncegrid_state_t::matrix, rsurfacestate_t::matrix, Matrix4x4_Concat(), Matrix4x4_Normalize3(), Matrix4x4_ToArrayFloatGL(), max, mode, rsurfacestate_t::modellightmapcolor4f, texture_t::nmaptexture, texture_t::offsetbias, texture_t::offsetmapping, OFFSETMAPPING_DEFAULT, OFFSETMAPPING_LINEAR, OFFSETMAPPING_OFF, OFFSETMAPPING_RELIEF, texture_t::offsetscale, texture_t::pantstexture, r_refdef_view_t::quality, R_BlendFuncFlags(), r_fb, r_glsl_deluxemapping, r_glsl_offsetmapping, r_glsl_offsetmapping_lod_distance, r_glsl_offsetmapping_reliefmapping, r_glsl_offsetmapping_reliefmapping_refinesteps, r_glsl_offsetmapping_reliefmapping_steps, r_glsl_offsetmapping_scale, r_glsl_offsetmapping_steps, r_glsl_permutation, r_hdr_glowintensity, R_Mesh_TexBind(), r_refdef, R_SetupShader_SetPermutationGLSL(), r_shadow_attenuationgradienttexture, r_shadow_bouncegrid_state, r_shadow_glossexact, r_shadow_lightshadowmap_parameters, r_shadow_lightshadowmap_texturescale, r_shadow_modelshadowmap_parameters, r_shadow_modelshadowmap_texturescale, r_shadow_prepassgeometrynormalmaptexture, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, r_shadow_shadowmapmatrix, r_shadow_shadowmapvsdct, r_shadow_shadowmapvsdcttexture, r_shadow_usingdeferredprepass, r_shadow_usingshadowmap2d, r_shadow_usingshadowmaportho, r_texture_black, r_texture_blanknormalmap, r_texture_fogattenuation, r_texture_fogheighttexture, r_texture_gammaramps, r_texture_white, r_texture_whitecube, R_TextureFlags(), r_transparent_alphatocoverage, r_trippy, r_water_reflectdistort, r_water_refractdistort, texture_t::r_water_wateralpha, texture_t::r_water_waterscroll, r_wateralpha, texture_t::reflectcolor4f, texture_t::reflectcubetexture, texture_t::reflectfactor, texture_t::reflectmasktexture, texture_t::reflectmax, texture_t::reflectmin, texture_t::refractcolor4f, texture_t::refractfactor, texture_t::render_colormap_pants, texture_t::render_colormap_shirt, texture_t::render_glowmod, texture_t::render_lightmap_ambient, texture_t::render_lightmap_diffuse, texture_t::render_lightmap_specular, texture_t::render_modellight_ambient, texture_t::render_modellight_diffuse, texture_t::render_modellight_lightdir_local, texture_t::render_modellight_specular, RENDER_NOSELFSHADOW, texture_t::render_rtlight_diffuse, texture_t::render_rtlight_specular, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, RSurf_PrepareVerticesForBatch(), RSurf_UploadBuffersForBatch(), rsurface, RSURFPASS_BACKGROUND, RSURFPASS_DEFERREDGEOMETRY, RSURFPASS_RTLIGHT, r_waterstate_waterplane_t::rt_camera, r_waterstate_waterplane_t::rt_reflection, r_waterstate_waterplane_t::rt_refraction, rsurfacestate_t::rtlight, r_refdef_t::scene, r_waterstate_t::screencenter, r_waterstate_t::screenscale, r_framebufferstate_t::screentextureheight, r_framebufferstate_t::screentexturewidth, r_viewport_t::screentodepth, SHADERMODE_DEFERREDGEOMETRY, SHADERMODE_FLATCOLOR, SHADERMODE_GENERIC, SHADERMODE_LIGHTDIRECTION, SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP, SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR, SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE, SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE, SHADERMODE_LIGHTGRID, SHADERMODE_LIGHTMAP, SHADERMODE_LIGHTSOURCE, SHADERMODE_REFRACTION, SHADERMODE_VERTEXCOLOR, SHADERMODE_WATER, SHADERPERMUTATION_ALPHAGEN_VERTEX, SHADERPERMUTATION_ALPHAKILL, SHADERPERMUTATION_BOUNCEGRID, SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL, SHADERPERMUTATION_COLORMAPPING, SHADERPERMUTATION_CUBEFILTER, SHADERPERMUTATION_DEFERREDLIGHTMAP, SHADERPERMUTATION_DEPTHRGB, SHADERPERMUTATION_DIFFUSE, SHADERPERMUTATION_FOGALPHAHACK, SHADERPERMUTATION_FOGHEIGHTTEXTURE, SHADERPERMUTATION_FOGINSIDE, SHADERPERMUTATION_FOGOUTSIDE, SHADERPERMUTATION_GLOW, SHADERPERMUTATION_NORMALMAPSCROLLBLEND, SHADERPERMUTATION_OCCLUDE, SHADERPERMUTATION_OFFSETMAPPING, SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING, SHADERPERMUTATION_REFLECTCUBE, SHADERPERMUTATION_REFLECTION, SHADERPERMUTATION_SHADOWMAP2D, SHADERPERMUTATION_SHADOWMAPORTHO, SHADERPERMUTATION_SHADOWMAPVSDCT, SHADERPERMUTATION_SKELETAL, SHADERPERMUTATION_SPECULAR, SHADERPERMUTATION_TRIPPY, SHADERPERMUTATION_VERTEXTEXTUREBLEND, texture_t::shirttexture, texture_t::specularpower, r_glsl_permutation_t::tex_Texture_Attenuation, r_glsl_permutation_t::tex_Texture_BounceGrid, r_glsl_permutation_t::tex_Texture_Color, r_glsl_permutation_t::tex_Texture_Cube, r_glsl_permutation_t::tex_Texture_CubeProjection, r_glsl_permutation_t::tex_Texture_Deluxemap, r_glsl_permutation_t::tex_Texture_First, r_glsl_permutation_t::tex_Texture_FogHeightTexture, r_glsl_permutation_t::tex_Texture_FogMask, r_glsl_permutation_t::tex_Texture_GammaRamps, r_glsl_permutation_t::tex_Texture_Gloss, r_glsl_permutation_t::tex_Texture_Glow, r_glsl_permutation_t::tex_Texture_LightGrid, r_glsl_permutation_t::tex_Texture_Lightmap, r_glsl_permutation_t::tex_Texture_Normal, r_glsl_permutation_t::tex_Texture_Pants, r_glsl_permutation_t::tex_Texture_ReflectCube, r_glsl_permutation_t::tex_Texture_Reflection, r_glsl_permutation_t::tex_Texture_ReflectMask, r_glsl_permutation_t::tex_Texture_Refraction, r_glsl_permutation_t::tex_Texture_ScreenDiffuse, r_glsl_permutation_t::tex_Texture_ScreenNormalMap, r_glsl_permutation_t::tex_Texture_ScreenSpecular, r_glsl_permutation_t::tex_Texture_Second, r_glsl_permutation_t::tex_Texture_SecondaryColor, r_glsl_permutation_t::tex_Texture_SecondaryGloss, r_glsl_permutation_t::tex_Texture_SecondaryGlow, r_glsl_permutation_t::tex_Texture_SecondaryNormal, r_glsl_permutation_t::tex_Texture_ShadowMap2D, r_glsl_permutation_t::tex_Texture_Shirt, TEXF_ALPHA, r_shadow_bouncegrid_state_t::texture, rsurfacestate_t::texture, r_glsl_permutation_t::ubibind_Skeletal_Transform12_UniformBlock, r_glsl_permutation_t::ubiloc_Skeletal_Transform12_UniformBlock, rsurfacestate_t::uselightmaptexture, cvar_t::value, VectorLength2, vid, r_refdef_t::view, r_refdef_view_t::viewport, r_framebufferstate_t::water, and r_refdef_scene_t::worldmodel.

Referenced by R_DrawTextureSurfaceList_GL20(), and R_Shadow_RenderLighting_Light_GLSL().

◆ R_SetupView()

void R_SetupView ( qbool allowwaterclippingplane,
int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 4384 of file gl_rmain.c.

4385{
4386 const float *customclipplane = NULL;
4387 float plane[4];
4388 int viewy_adjusted;
4389 if (r_refdef.view.useclipplane && allowwaterclippingplane)
4390 {
4391 // LadyHavoc: couldn't figure out how to make this approach work the same in DPSOFTRAST
4395 dist = r_refdef.view.clipplane.dist;
4396 plane[0] = r_refdef.view.clipplane.normal[0];
4397 plane[1] = r_refdef.view.clipplane.normal[1];
4398 plane[2] = r_refdef.view.clipplane.normal[2];
4399 plane[3] = -dist;
4400 customclipplane = plane;
4401 }
4402
4403 // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom.
4404 // Unless the render target is a FBO...
4405 viewy_adjusted = viewfbo ? viewy : vid.mode.height - viewheight - viewy;
4406
4408 R_Viewport_InitOrtho3D(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.ortho_x, r_refdef.view.ortho_y, -r_refdef.farclip, r_refdef.farclip, customclipplane);
4410 R_Viewport_InitPerspectiveInfinite(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, customclipplane);
4411 else
4412 R_Viewport_InitPerspective(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, r_refdef.farclip, customclipplane);
4413 R_Mesh_SetRenderTargets(viewfbo);
4415}
void R_Viewport_InitPerspective(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:677
void R_Viewport_InitOrtho3D(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:635
void R_Viewport_InitPerspectiveInfinite(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, const float *nearplane)
Definition gl_backend.c:719
double farclip
Definition render.h:413
double nearclip
Definition render.h:410
float frustum_y
Definition render.h:277
qbool useclipplane
Definition render.h:274
float frustum_x
Definition render.h:277
float ortho_x
Definition render.h:287
float ortho_y
Definition render.h:287
mplane_t clipplane
Definition render.h:276
qbool stencil
Definition vid.h:74

References r_refdef_view_t::clipplane, mplane_t::dist, DotProduct, r_refdef_t::farclip, r_refdef_view_t::frustum_x, r_refdef_view_t::frustum_y, viddef_mode_t::height, cvar_t::integer, r_refdef_view_t::matrix, viddef_t::mode, r_refdef_t::nearclip, mplane_t::normal, NULL, r_refdef_view_t::origin, r_refdef_view_t::ortho_x, r_refdef_view_t::ortho_y, R_Mesh_SetRenderTargets(), r_refdef, R_SetViewport(), r_useinfinitefarclip, R_Viewport_InitOrtho3D(), R_Viewport_InitPerspective(), R_Viewport_InitPerspectiveInfinite(), r_water_clippingplanebias, viddef_t::stencil, r_refdef_view_t::useclipplane, r_refdef_view_t::useperspective, cvar_t::value, vid, r_refdef_t::view, and r_refdef_view_t::viewport.

Referenced by R_RenderScene(), R_ResetViewRendering3D(), and R_Water_ProcessPlanes().

◆ R_ShaderStrCat()

static char * R_ShaderStrCat ( const char ** strings)
static

Definition at line 965 of file gl_rmain.c.

966{
967 char *string, *s;
968 const char **p = strings;
969 const char *t;
970 size_t len = 0;
971 for (p = strings;(t = *p);p++)
972 len += strlen(t);
973 len++;
974 s = string = (char *)Mem_Alloc(r_main_mempool, len);
975 len = 0;
976 for (p = strings;(t = *p);p++)
977 {
978 len = strlen(t);
979 memcpy(s, t, len);
980 s += len;
981 }
982 *s = 0;
983 return string;
984}
GLsizei const GLchar ** string
Definition glquake.h:728

References Mem_Alloc, r_main_mempool, string, and strlen().

Referenced by R_InitShaderModeInfo().

◆ R_SkinFrame_Find()

skinframe_t * R_SkinFrame_Find ( const char * name,
int textureflags,
int comparewidth,
int compareheight,
int comparecrc,
qbool add )

Definition at line 2240 of file gl_rmain.c.

2241{
2242 skinframe_t *item;
2243 int compareflags = textureflags & TEXF_IMPORTANTBITS;
2244 int hashindex;
2245 char basename[MAX_QPATH];
2246
2247 Image_StripImageExtension(name, basename, sizeof(basename));
2248
2249 hashindex = CRC_Block((unsigned char *)basename, strlen(basename)) & (SKINFRAME_HASH - 1);
2250 for (item = r_skinframe.hash[hashindex];item;item = item->next)
2251 if (!strcmp(item->basename, basename) &&
2252 item->textureflags == compareflags &&
2253 item->comparewidth == comparewidth &&
2254 item->compareheight == compareheight &&
2255 item->comparecrc == comparecrc)
2256 break;
2257
2258 if (!item)
2259 {
2260 if (!add)
2261 return NULL;
2263 memset(item, 0, sizeof(*item));
2264 dp_strlcpy(item->basename, basename, sizeof(item->basename));
2265 item->textureflags = compareflags;
2266 item->comparewidth = comparewidth;
2267 item->compareheight = compareheight;
2268 item->comparecrc = comparecrc;
2269 item->next = r_skinframe.hash[hashindex];
2270 r_skinframe.hash[hashindex] = item;
2271 }
2272 else if (textureflags & TEXF_FORCE_RELOAD)
2274
2276 return item;
2277}
#define SKINFRAME_HASH
Definition gl_rmain.c:2157
void R_SkinFrame_PurgeSkinFrame(skinframe_t *s)
Definition gl_rmain.c:2184
void R_SkinFrame_MarkUsed(skinframe_t *skinframe)
Definition gl_rmain.c:2176
void Image_StripImageExtension(const char *in, char *out, size_t size_out)
Definition image.c:913
#define TEXF_IMPORTANTBITS
Definition r_textures.h:39
#define TEXF_FORCE_RELOAD
Definition r_textures.h:41
skinframe_t * hash[SKINFRAME_HASH]
Definition gl_rmain.c:2163
struct skinframe_s * next
Definition r_textures.h:142
int compareheight
Definition r_textures.h:146
char basename[MAX_QPATH]
Definition r_textures.h:143

References r_skinframe_t::array, skinframe_t::basename, skinframe_t::comparecrc, skinframe_t::compareheight, skinframe_t::comparewidth, CRC_Block(), dp_strlcpy, r_skinframe_t::hash, Image_StripImageExtension(), MAX_QPATH, Mem_ExpandableArray_AllocRecord(), name, skinframe_t::next, NULL, r_skinframe, R_SkinFrame_MarkUsed(), R_SkinFrame_PurgeSkinFrame(), SKINFRAME_HASH, strlen(), TEXF_FORCE_RELOAD, TEXF_IMPORTANTBITS, and skinframe_t::textureflags.

Referenced by R_LoadQWSkin(), R_SkinFrame_LoadExternal(), R_SkinFrame_LoadExternal_SkinFrame(), R_SkinFrame_LoadInternal8bit(), R_SkinFrame_LoadInternalBGRA(), R_SkinFrame_LoadInternalQuake(), R_SkinFrame_LoadInternalUsingTexture(), and R_SkinFrame_LoadMissing().

◆ R_SkinFrame_FindNextByName()

skinframe_t * R_SkinFrame_FindNextByName ( skinframe_t * last,
const char * name )

Definition at line 2217 of file gl_rmain.c.

2217 {
2218 skinframe_t *item;
2219 char basename[MAX_QPATH];
2220
2221 Image_StripImageExtension(name, basename, sizeof(basename));
2222
2223 if( last == NULL ) {
2224 int hashindex;
2225 hashindex = CRC_Block((unsigned char *)basename, strlen(basename)) & (SKINFRAME_HASH - 1);
2226 item = r_skinframe.hash[hashindex];
2227 } else {
2228 item = last->next;
2229 }
2230
2231 // linearly search through the hash bucket
2232 for( ; item ; item = item->next ) {
2233 if( !strcmp( item->basename, basename ) ) {
2234 return item;
2235 }
2236 }
2237 return NULL;
2238}

References skinframe_t::basename, CRC_Block(), r_skinframe_t::hash, Image_StripImageExtension(), MAX_QPATH, name, skinframe_t::next, NULL, r_skinframe, SKINFRAME_HASH, and strlen().

◆ R_SkinFrame_GenerateTexturesFromQPixels()

static void R_SkinFrame_GenerateTexturesFromQPixels ( skinframe_t * skinframe,
qbool colormapped )
static

Definition at line 2676 of file gl_rmain.c.

2677{
2678 int width;
2679 int height;
2680 unsigned char *skindata;
2681 char vabuf[1024];
2682
2683 if (!skinframe->qpixels)
2684 return;
2685
2686 if (!skinframe->qhascolormapping)
2687 colormapped = false;
2688
2689 if (colormapped)
2690 {
2691 if (!skinframe->qgeneratebase)
2692 return;
2693 }
2694 else
2695 {
2696 if (!skinframe->qgeneratemerged)
2697 return;
2698 }
2699
2700 width = skinframe->qwidth;
2701 height = skinframe->qheight;
2702 skindata = skinframe->qpixels;
2703
2704 if (skinframe->qgeneratenmap)
2705 {
2706 unsigned char *a, *b;
2707 skinframe->qgeneratenmap = false;
2708 a = (unsigned char *)Mem_Alloc(tempmempool, width * height * 8);
2709 b = a + width * height * 4;
2710 // use either a custom palette or the quake palette
2713 skinframe->nmap = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), width, height, b, TEXTYPE_BGRA, (skinframe->textureflags | TEXF_ALPHA) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP), -1, NULL);
2714 Mem_Free(a);
2715 }
2716
2717 if (skinframe->qgenerateglow)
2718 {
2719 skinframe->qgenerateglow = false;
2720 if (skinframe->hasalpha) // fence textures
2721 skinframe->glow = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags | TEXF_ALPHA, -1, palette_bgra_onlyfullbrights_transparent); // glow
2722 else
2723 skinframe->glow = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, palette_bgra_onlyfullbrights); // glow
2724 }
2725
2726 if (colormapped)
2727 {
2728 skinframe->qgeneratebase = false;
2729 skinframe->base = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nospecial", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, skinframe->glow ? palette_bgra_nocolormapnofullbrights : palette_bgra_nocolormap);
2730 skinframe->pants = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_pants", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, palette_bgra_pantsaswhite);
2731 skinframe->shirt = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_shirt", skinframe->basename), width, height, skindata, vid.sRGB3D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, skinframe->textureflags, -1, palette_bgra_shirtaswhite);
2732 }
2733 else
2734 {
2735 skinframe->qgeneratemerged = false;
2736 if (skinframe->hasalpha) // fence textures
2738 else
2740 }
2741
2742 if (!skinframe->qgeneratemerged && !skinframe->qgeneratebase)
2743 {
2744 Mem_Free(skinframe->qpixels);
2745 skinframe->qpixels = NULL;
2746 }
2747}
void Image_HeightmapToNormalmap_BGRA(const unsigned char *inpixels, unsigned char *outpixels, int width, int height, int clamp, float bumpscale)
Definition image.c:1769
void Image_Copy8bitBGRA(const unsigned char *in, unsigned char *out, int pixels, const unsigned int *pal)
Definition image.c:129
cvar_t r_mipnormalmaps
unsigned int palette_bgra_nocolormap[256]
Definition palette.c:16
unsigned int palette_bgra_transparent[256]
Definition palette.c:24
unsigned int palette_bgra_onlyfullbrights_transparent[256]
Definition palette.c:21
unsigned int palette_bgra_nocolormapnofullbrights[256]
Definition palette.c:17
unsigned int palette_bgra_shirtaswhite[256]
Definition palette.c:23
unsigned int palette_bgra_complete[256]
Definition palette.c:13
unsigned int palette_bgra_nofullbrights_transparent[256]
Definition palette.c:19
unsigned int palette_bgra_nofullbrights[256]
Definition palette.c:18
unsigned int palette_bgra_onlyfullbrights[256]
Definition palette.c:20
unsigned int palette_bgra_pantsaswhite[256]
Definition palette.c:22
cvar_t r_shadow_bumpscale_basetexture
Definition r_shadow.c:141
@ TEXTYPE_PALETTE
Definition r_textures.h:49
@ TEXTYPE_SRGB_PALETTE
Definition r_textures.h:69
struct rtexture_s * pants
Definition r_textures.h:130
qbool qgeneratebase
Definition r_textures.h:161
struct rtexture_s * merged
Definition r_textures.h:128
struct rtexture_s * shirt
Definition r_textures.h:131
qbool qhascolormapping
Definition r_textures.h:160
struct rtexture_s * nmap
Definition r_textures.h:132
qbool qgenerateglow
Definition r_textures.h:164
unsigned char * qpixels
Definition r_textures.h:157
struct rtexture_s * glow
Definition r_textures.h:134
qbool qgeneratenmap
Definition r_textures.h:163
qbool qgeneratemerged
Definition r_textures.h:162
qbool hasalpha
Definition r_textures.h:153

References a, b, skinframe_t::base, skinframe_t::basename, skinframe_t::glow, skinframe_t::hasalpha, height, Image_Copy8bitBGRA(), Image_HeightmapToNormalmap_BGRA(), cvar_t::integer, Mem_Alloc, Mem_Free, skinframe_t::merged, skinframe_t::nmap, NULL, palette_bgra_complete, palette_bgra_nocolormap, palette_bgra_nocolormapnofullbrights, palette_bgra_nofullbrights, palette_bgra_nofullbrights_transparent, palette_bgra_onlyfullbrights, palette_bgra_onlyfullbrights_transparent, palette_bgra_pantsaswhite, palette_bgra_shirtaswhite, palette_bgra_transparent, skinframe_t::pants, skinframe_t::qgeneratebase, skinframe_t::qgenerateglow, skinframe_t::qgeneratemerged, skinframe_t::qgeneratenmap, skinframe_t::qhascolormapping, skinframe_t::qheight, skinframe_t::qpixels, skinframe_t::qwidth, R_LoadTexture2D(), r_main_texturepool, r_mipnormalmaps, r_shadow_bumpscale_basetexture, skinframe_t::shirt, viddef_t::sRGB3D, tempmempool, TEXF_ALPHA, TEXF_MIPMAP, skinframe_t::textureflags, TEXTYPE_BGRA, TEXTYPE_PALETTE, TEXTYPE_SRGB_PALETTE, va(), cvar_t::value, vid, and width.

Referenced by R_GetCurrentTexture().

◆ R_SkinFrame_LoadExternal()

skinframe_t * R_SkinFrame_LoadExternal ( const char * name,
int textureflags,
qbool complain,
qbool fallbacknotexture )

Definition at line 2314 of file gl_rmain.c.

2315{
2316 skinframe_t *skinframe;
2317
2318 if (cls.state == ca_dedicated)
2319 return NULL;
2320
2321 // return an existing skinframe if already loaded
2322 skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, 0, false);
2323 if (skinframe && skinframe->base)
2324 return skinframe;
2325
2326 // if the skinframe doesn't exist this will create it
2327 return R_SkinFrame_LoadExternal_SkinFrame(skinframe, name, textureflags, complain, fallbacknotexture);
2328}
@ ca_dedicated
Definition client.h:530
skinframe_t * R_SkinFrame_LoadExternal_SkinFrame(skinframe_t *skinframe, const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
Definition gl_rmain.c:2331
cactive_t state
Definition client.h:568

References skinframe_t::base, ca_dedicated, cls, name, NULL, R_SkinFrame_Find(), R_SkinFrame_LoadExternal_SkinFrame(), and client_static_t::state.

Referenced by Draw_CachePic_Flags(), Draw_GetPicTexture(), Draw_IsPicLoaded(), Mod_CreateShaderPassFromQ3ShaderLayer(), Mod_IDP0_Load(), Mod_IDS2_Load(), Mod_LoadTextureFromQ3Shader(), Mod_Q1BSP_LoadTextures(), Mod_Sprite_SharedSetup(), R_InitParticleTexture(), and R_ReplaceWorldTexture_f().

◆ R_SkinFrame_LoadExternal_SkinFrame()

skinframe_t * R_SkinFrame_LoadExternal_SkinFrame ( skinframe_t * skinframe,
const char * name,
int textureflags,
qbool complain,
qbool fallbacknotexture )

Definition at line 2331 of file gl_rmain.c.

2332{
2333 int j;
2334 unsigned char *pixels;
2335 unsigned char *bumppixels;
2336 unsigned char *basepixels = NULL;
2337 int basepixels_width = 0;
2338 int basepixels_height = 0;
2339 rtexture_t *ddsbase = NULL;
2340 qbool ddshasalpha = false;
2341 float ddsavgcolor[4];
2342 char basename[MAX_QPATH];
2343 int miplevel = R_PicmipForFlags(textureflags);
2344 int savemiplevel = miplevel;
2345 int mymiplevel;
2346 char vabuf[1024];
2347
2348 if (cls.state == ca_dedicated)
2349 return NULL;
2350
2351 Image_StripImageExtension(name, basename, sizeof(basename));
2352
2353 // check for DDS texture file first
2354 if (!r_loaddds || !(ddsbase = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s.dds", basename), vid.sRGB3D, textureflags, &ddshasalpha, ddsavgcolor, miplevel, false)))
2355 {
2356 basepixels = loadimagepixelsbgra(name, complain, true, false, &miplevel);
2357 if (basepixels == NULL && fallbacknotexture)
2358 basepixels = Image_GenerateNoTexture();
2359 if (basepixels == NULL)
2360 return NULL;
2361 }
2362
2363 // FIXME handle miplevel
2364
2366 Con_Printf("loading skin \"%s\"\n", name);
2367
2368 // we've got some pixels to store, so really allocate this new texture now
2369 if (!skinframe)
2370 skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, 0, true);
2371 textureflags &= ~TEXF_FORCE_RELOAD;
2372 skinframe->stain = NULL;
2373 skinframe->merged = NULL;
2374 skinframe->base = NULL;
2375 skinframe->pants = NULL;
2376 skinframe->shirt = NULL;
2377 skinframe->nmap = NULL;
2378 skinframe->gloss = NULL;
2379 skinframe->glow = NULL;
2380 skinframe->fog = NULL;
2381 skinframe->reflect = NULL;
2382 skinframe->hasalpha = false;
2383 // we could store the q2animname here too
2384
2385 if (ddsbase)
2386 {
2387 skinframe->base = ddsbase;
2388 skinframe->hasalpha = ddshasalpha;
2389 VectorCopy(ddsavgcolor, skinframe->avgcolor);
2390 if (r_loadfog && skinframe->hasalpha)
2391 skinframe->fog = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_mask.dds", skinframe->basename), false, textureflags | TEXF_ALPHA, NULL, NULL, miplevel, true);
2392 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2393 }
2394 else
2395 {
2396 basepixels_width = image_width;
2397 basepixels_height = image_height;
2398 skinframe->base = R_LoadTexture2D (r_main_texturepool, skinframe->basename, basepixels_width, basepixels_height, basepixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_color.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), miplevel, NULL);
2399 if (textureflags & TEXF_ALPHA)
2400 {
2401 for (j = 3;j < basepixels_width * basepixels_height * 4;j += 4)
2402 {
2403 if (basepixels[j] < 255)
2404 {
2405 skinframe->hasalpha = true;
2406 break;
2407 }
2408 }
2409 if (r_loadfog && skinframe->hasalpha)
2410 {
2411 // has transparent pixels
2412 pixels = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height * 4);
2413 for (j = 0;j < image_width * image_height * 4;j += 4)
2414 {
2415 pixels[j+0] = 255;
2416 pixels[j+1] = 255;
2417 pixels[j+2] = 255;
2418 pixels[j+3] = basepixels[j+3];
2419 }
2420 skinframe->fog = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_mask", skinframe->basename), image_width, image_height, pixels, TEXTYPE_BGRA, textureflags & (gl_texturecompression_color.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), miplevel, NULL);
2422 }
2423 }
2424 R_SKINFRAME_LOAD_AVERAGE_COLORS(basepixels_width * basepixels_height, basepixels[4 * pix + comp]);
2425#ifndef USE_GLES2
2426 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2427 if (r_savedds && skinframe->base)
2428 R_SaveTextureDDSFile(skinframe->base, va(vabuf, sizeof(vabuf), "dds/%s.dds", skinframe->basename), r_texture_dds_save.integer < 2, skinframe->hasalpha);
2429 if (r_savedds && skinframe->fog)
2430 R_SaveTextureDDSFile(skinframe->fog, va(vabuf, sizeof(vabuf), "dds/%s_mask.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2431#endif
2432 }
2433
2434 if (r_loaddds)
2435 {
2436 mymiplevel = savemiplevel;
2437 if (r_loadnormalmap)
2438 skinframe->nmap = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_norm.dds", skinframe->basename), false, (TEXF_ALPHA | textureflags) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP), NULL, NULL, mymiplevel, true);
2439 skinframe->glow = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_glow.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2440 if (r_loadgloss)
2441 skinframe->gloss = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_gloss.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2442 skinframe->pants = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_pants.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2443 skinframe->shirt = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_shirt.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2444 skinframe->reflect = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_reflect.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2445 }
2446
2447 // _norm is the name used by tenebrae and has been adopted as standard
2448 if (r_loadnormalmap && skinframe->nmap == NULL)
2449 {
2450 mymiplevel = savemiplevel;
2451 if ((pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_norm", skinframe->basename), false, false, false, &mymiplevel)) != NULL)
2452 {
2453 skinframe->nmap = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), image_width, image_height, pixels, TEXTYPE_BGRA, (TEXF_ALPHA | textureflags) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP) & (gl_texturecompression_normal.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2455 pixels = NULL;
2456 }
2457 else if (r_shadow_bumpscale_bumpmap.value > 0 && (bumppixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_bump", skinframe->basename), false, false, false, &mymiplevel)) != NULL)
2458 {
2459 pixels = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height * 4);
2461 skinframe->nmap = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), image_width, image_height, pixels, TEXTYPE_BGRA, (TEXF_ALPHA | textureflags) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP) & (gl_texturecompression_normal.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2463 Mem_Free(bumppixels);
2464 }
2466 {
2467 pixels = (unsigned char *)Mem_Alloc(tempmempool, basepixels_width * basepixels_height * 4);
2468 Image_HeightmapToNormalmap_BGRA(basepixels, pixels, basepixels_width, basepixels_height, false, r_shadow_bumpscale_basetexture.value);
2469 skinframe->nmap = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), basepixels_width, basepixels_height, pixels, TEXTYPE_BGRA, (TEXF_ALPHA | textureflags) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP) & (gl_texturecompression_normal.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2471 }
2472#ifndef USE_GLES2
2473 if (r_savedds && skinframe->nmap)
2474 R_SaveTextureDDSFile(skinframe->nmap, va(vabuf, sizeof(vabuf), "dds/%s_norm.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2475#endif
2476 }
2477
2478 // _luma is supported only for tenebrae compatibility
2479 // _blend and .blend are supported only for Q3 & QL compatibility, this hack can be removed if better Q3 shader support is implemented
2480 // _glow is the preferred name
2481 mymiplevel = savemiplevel;
2482 if (skinframe->glow == NULL && ((pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), false, false, false, &mymiplevel)) || (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s.blend", skinframe->basename), false, false, false, &mymiplevel)) || (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_blend", skinframe->basename), false, false, false, &mymiplevel)) || (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_luma", skinframe->basename), false, false, false, &mymiplevel))))
2483 {
2484 skinframe->glow = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_glow.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2485#ifndef USE_GLES2
2486 if (r_savedds && skinframe->glow)
2487 R_SaveTextureDDSFile(skinframe->glow, va(vabuf, sizeof(vabuf), "dds/%s_glow.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2488#endif
2490 }
2491
2492 mymiplevel = savemiplevel;
2493 if (skinframe->gloss == NULL && r_loadgloss && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_gloss", skinframe->basename), false, false, false, &mymiplevel)))
2494 {
2495 skinframe->gloss = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_gloss", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, (TEXF_ALPHA | textureflags) & (gl_texturecompression_gloss.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2496#ifndef USE_GLES2
2497 if (r_savedds && skinframe->gloss)
2498 R_SaveTextureDDSFile(skinframe->gloss, va(vabuf, sizeof(vabuf), "dds/%s_gloss.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2499#endif
2501 pixels = NULL;
2502 }
2503
2504 mymiplevel = savemiplevel;
2505 if (skinframe->pants == NULL && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_pants", skinframe->basename), false, false, false, &mymiplevel)))
2506 {
2507 skinframe->pants = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_pants", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_color.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2508#ifndef USE_GLES2
2509 if (r_savedds && skinframe->pants)
2510 R_SaveTextureDDSFile(skinframe->pants, va(vabuf, sizeof(vabuf), "dds/%s_pants.dds", skinframe->basename), r_texture_dds_save.integer < 2, false);
2511#endif
2513 pixels = NULL;
2514 }
2515
2516 mymiplevel = savemiplevel;
2517 if (skinframe->shirt == NULL && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_shirt", skinframe->basename), false, false, false, &mymiplevel)))
2518 {
2519 skinframe->shirt = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_shirt", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_color.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2520#ifndef USE_GLES2
2521 if (r_savedds && skinframe->shirt)
2522 R_SaveTextureDDSFile(skinframe->shirt, va(vabuf, sizeof(vabuf), "dds/%s_shirt.dds", skinframe->basename), r_texture_dds_save.integer < 2, false);
2523#endif
2525 pixels = NULL;
2526 }
2527
2528 mymiplevel = savemiplevel;
2529 if (skinframe->reflect == NULL && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_reflect", skinframe->basename), false, false, false, &mymiplevel)))
2530 {
2531 skinframe->reflect = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_reflect", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_reflectmask.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2532#ifndef USE_GLES2
2533 if (r_savedds && skinframe->reflect)
2534 R_SaveTextureDDSFile(skinframe->reflect, va(vabuf, sizeof(vabuf), "dds/%s_reflect.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2535#endif
2537 pixels = NULL;
2538 }
2539
2540 if (basepixels)
2541 Mem_Free(basepixels);
2542
2543 return skinframe;
2544}
#define R_SKINFRAME_LOAD_AVERAGE_COLORS(cnt, getpixel)
Definition gl_rmain.c:2279
cvar_t gl_texturecompression_reflectmask
Definition gl_textures.c:47
cvar_t gl_texturecompression_color
Definition gl_textures.c:38
rtexture_t * R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filename, qbool srgb, int flags, qbool *hasalphaflag, float *avgcolor, int miplevel, qbool optionaltexture)
int R_SaveTextureDDSFile(rtexture_t *rt, const char *filename, qbool skipuncompressed, qbool hasalpha)
cvar_t gl_texturecompression_glow
Definition gl_textures.c:41
cvar_t gl_texturecompression_gloss
Definition gl_textures.c:40
int R_PicmipForFlags(int flags)
cvar_t gl_texturecompression_normal
Definition gl_textures.c:39
cvar_t r_shadow_bumpscale_bumpmap
Definition r_shadow.c:142
struct rtexture_s * stain
Definition r_textures.h:127
struct rtexture_s * reflect
Definition r_textures.h:136
struct rtexture_s * gloss
Definition r_textures.h:133
struct rtexture_s * fog
Definition r_textures.h:135
float avgcolor[4]
Definition r_textures.h:155

References skinframe_t::avgcolor, skinframe_t::base, skinframe_t::basename, ca_dedicated, cls, Con_Printf(), developer_loading, skinframe_t::fog, gl_texturecompression, gl_texturecompression_color, gl_texturecompression_gloss, gl_texturecompression_glow, gl_texturecompression_normal, gl_texturecompression_reflectmask, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, Image_GenerateNoTexture(), image_height, Image_HeightmapToNormalmap_BGRA(), Image_StripImageExtension(), image_width, cvar_t::integer, loadimagepixelsbgra(), MAX_QPATH, Mem_Alloc, Mem_Free, skinframe_t::merged, name, skinframe_t::nmap, NULL, skinframe_t::pants, pixels, r_loaddds, r_loadfog, r_loadgloss, r_loadnormalmap, R_LoadTexture2D(), R_LoadTextureDDSFile(), r_main_texturepool, r_mipnormalmaps, R_PicmipForFlags(), r_savedds, R_SaveTextureDDSFile(), r_shadow_bumpscale_basetexture, r_shadow_bumpscale_bumpmap, R_SkinFrame_Find(), R_SKINFRAME_LOAD_AVERAGE_COLORS, r_texture_dds_save, skinframe_t::reflect, skinframe_t::shirt, viddef_t::sRGB3D, skinframe_t::stain, client_static_t::state, tempmempool, TEXF_ALPHA, TEXF_COMPRESS, TEXF_MIPMAP, TEXTYPE_BGRA, TEXTYPE_SRGB_BGRA, va(), cvar_t::value, VectorCopy, and vid.

Referenced by Draw_CachePic_Flags(), and R_SkinFrame_LoadExternal().

◆ R_SkinFrame_LoadInternal8bit()

skinframe_t * R_SkinFrame_LoadInternal8bit ( const char * name,
int textureflags,
const unsigned char * skindata,
int width,
int height,
const unsigned int * palette,
const unsigned int * alphapalette )

Definition at line 2749 of file gl_rmain.c.

2750{
2751 int i;
2752 skinframe_t *skinframe;
2753 char vabuf[1024];
2754
2755 if (cls.state == ca_dedicated)
2756 return NULL;
2757
2758 // if already loaded just return it, otherwise make a new skinframe
2759 skinframe = R_SkinFrame_Find(name, textureflags, width, height, skindata ? CRC_Block(skindata, width*height) : 0, true);
2760 if (skinframe->base)
2761 return skinframe;
2762 textureflags &= ~TEXF_FORCE_RELOAD;
2763
2764 skinframe->stain = NULL;
2765 skinframe->merged = NULL;
2766 skinframe->base = NULL;
2767 skinframe->pants = NULL;
2768 skinframe->shirt = NULL;
2769 skinframe->nmap = NULL;
2770 skinframe->gloss = NULL;
2771 skinframe->glow = NULL;
2772 skinframe->fog = NULL;
2773 skinframe->reflect = NULL;
2774 skinframe->hasalpha = false;
2775
2776 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2777 if (!skindata)
2778 return NULL;
2779
2781 Con_Printf("loading embedded 8bit image \"%s\"\n", name);
2782
2783 skinframe->base = skinframe->merged = R_LoadTexture2D(r_main_texturepool, skinframe->basename, width, height, skindata, TEXTYPE_PALETTE, textureflags, -1, palette);
2784 if ((textureflags & TEXF_ALPHA) && alphapalette)
2785 {
2786 for (i = 0;i < width * height;i++)
2787 {
2788 if (((unsigned char *)palette)[skindata[i]*4+3] < 255)
2789 {
2790 skinframe->hasalpha = true;
2791 break;
2792 }
2793 }
2794 if (r_loadfog && skinframe->hasalpha)
2795 skinframe->fog = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_fog", skinframe->basename), width, height, skindata, TEXTYPE_PALETTE, textureflags, -1, alphapalette);
2796 }
2797
2798 R_SKINFRAME_LOAD_AVERAGE_COLORS(width * height, ((unsigned char *)palette)[skindata[pix]*4 + comp]);
2799 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2800
2801 return skinframe;
2802}

References skinframe_t::base, skinframe_t::basename, ca_dedicated, cls, Con_Printf(), CRC_Block(), developer_loading, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, height, i, cvar_t::integer, skinframe_t::merged, name, skinframe_t::nmap, NULL, skinframe_t::pants, r_loadfog, R_LoadTexture2D(), r_main_texturepool, R_SkinFrame_Find(), R_SKINFRAME_LOAD_AVERAGE_COLORS, skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, client_static_t::state, TEXF_ALPHA, TEXTYPE_PALETTE, va(), and width.

Referenced by R_Shadow_MakeTextures().

◆ R_SkinFrame_LoadInternalBGRA()

skinframe_t * R_SkinFrame_LoadInternalBGRA ( const char * name,
int textureflags,
const unsigned char * skindata,
int width,
int height,
int comparewidth,
int compareheight,
int comparecrc,
qbool sRGB )

Definition at line 2546 of file gl_rmain.c.

2547{
2548 int i;
2549 skinframe_t *skinframe;
2550 char vabuf[1024];
2551
2552 if (cls.state == ca_dedicated)
2553 return NULL;
2554
2555 // if already loaded just return it, otherwise make a new skinframe
2556 skinframe = R_SkinFrame_Find(name, textureflags, comparewidth, compareheight, comparecrc, true);
2557 if (skinframe->base)
2558 return skinframe;
2559 textureflags &= ~TEXF_FORCE_RELOAD;
2560
2561 skinframe->stain = NULL;
2562 skinframe->merged = NULL;
2563 skinframe->base = NULL;
2564 skinframe->pants = NULL;
2565 skinframe->shirt = NULL;
2566 skinframe->nmap = NULL;
2567 skinframe->gloss = NULL;
2568 skinframe->glow = NULL;
2569 skinframe->fog = NULL;
2570 skinframe->reflect = NULL;
2571 skinframe->hasalpha = false;
2572
2573 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2574 if (!skindata)
2575 return NULL;
2576
2578 Con_Printf("loading 32bit skin \"%s\"\n", name);
2579
2581 {
2582 unsigned char *a = (unsigned char *)Mem_Alloc(tempmempool, width * height * 8);
2583 unsigned char *b = a + width * height * 4;
2585 skinframe->nmap = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), width, height, b, TEXTYPE_BGRA, (textureflags | TEXF_ALPHA) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP), -1, NULL);
2586 Mem_Free(a);
2587 }
2588 skinframe->base = skinframe->merged = R_LoadTexture2D(r_main_texturepool, skinframe->basename, width, height, skindata, sRGB ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags, -1, NULL);
2589 if (textureflags & TEXF_ALPHA)
2590 {
2591 for (i = 3;i < width * height * 4;i += 4)
2592 {
2593 if (skindata[i] < 255)
2594 {
2595 skinframe->hasalpha = true;
2596 break;
2597 }
2598 }
2599 if (r_loadfog && skinframe->hasalpha)
2600 {
2601 unsigned char *fogpixels = (unsigned char *)Mem_Alloc(tempmempool, width * height * 4);
2602 memcpy(fogpixels, skindata, width * height * 4);
2603 for (i = 0;i < width * height * 4;i += 4)
2604 fogpixels[i] = fogpixels[i+1] = fogpixels[i+2] = 255;
2605 skinframe->fog = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_fog", skinframe->basename), width, height, fogpixels, TEXTYPE_BGRA, textureflags, -1, NULL);
2606 Mem_Free(fogpixels);
2607 }
2608 }
2609
2610 R_SKINFRAME_LOAD_AVERAGE_COLORS(width * height, skindata[4 * pix + comp]);
2611 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2612
2613 return skinframe;
2614}

References a, b, skinframe_t::base, skinframe_t::basename, ca_dedicated, cls, Con_Printf(), developer_loading, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, height, i, Image_HeightmapToNormalmap_BGRA(), cvar_t::integer, Mem_Alloc, Mem_Free, skinframe_t::merged, name, skinframe_t::nmap, NULL, skinframe_t::pants, r_loadfog, r_loadnormalmap, R_LoadTexture2D(), r_main_texturepool, r_mipnormalmaps, r_shadow_bumpscale_basetexture, R_SkinFrame_Find(), R_SKINFRAME_LOAD_AVERAGE_COLORS, skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, client_static_t::state, tempmempool, TEXF_ALPHA, TEXF_MIPMAP, TEXTYPE_BGRA, TEXTYPE_SRGB_BGRA, va(), cvar_t::value, and width.

Referenced by CL_Beams_SetupBuiltinTexture(), Curl_EndDownload(), Draw_NewPic(), Mod_Q1BSP_LoadSplitSky(), Mod_Q1BSP_LoadTextures(), Mod_Sprite_SharedSetup(), R_InitParticleTexture(), R_LoadSkyBox(), R_Shadow_MakeTextures_MakeCorona(), and R_SkinFrame_LoadNoTexture().

◆ R_SkinFrame_LoadInternalQuake()

skinframe_t * R_SkinFrame_LoadInternalQuake ( const char * name,
int textureflags,
int loadpantsandshirt,
int loadglowtexture,
const unsigned char * skindata,
int width,
int height )

Definition at line 2616 of file gl_rmain.c.

2617{
2618 int i;
2619 int featuresmask;
2620 skinframe_t *skinframe;
2621
2622 if (cls.state == ca_dedicated)
2623 return NULL;
2624
2625 // if already loaded just return it, otherwise make a new skinframe
2626 skinframe = R_SkinFrame_Find(name, textureflags, width, height, skindata ? CRC_Block(skindata, width*height) : 0, true);
2627 if (skinframe->base)
2628 return skinframe;
2629 //textureflags &= ~TEXF_FORCE_RELOAD;
2630
2631 skinframe->stain = NULL;
2632 skinframe->merged = NULL;
2633 skinframe->base = NULL;
2634 skinframe->pants = NULL;
2635 skinframe->shirt = NULL;
2636 skinframe->nmap = NULL;
2637 skinframe->gloss = NULL;
2638 skinframe->glow = NULL;
2639 skinframe->fog = NULL;
2640 skinframe->reflect = NULL;
2641 skinframe->hasalpha = false;
2642
2643 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2644 if (!skindata)
2645 return NULL;
2646
2648 Con_Printf("loading quake skin \"%s\"\n", name);
2649
2650 // we actually don't upload anything until the first use, because mdl skins frequently go unused, and are almost never used in both modes (colormapped and non-colormapped)
2651 skinframe->qpixels = (unsigned char *)Mem_Alloc(r_main_mempool, width*height); // FIXME LEAK
2652 memcpy(skinframe->qpixels, skindata, width*height);
2653 skinframe->qwidth = width;
2654 skinframe->qheight = height;
2655
2656 featuresmask = 0;
2657 for (i = 0;i < width * height;i++)
2658 featuresmask |= palette_featureflags[skindata[i]];
2659
2660 skinframe->hasalpha = false;
2661 // fence textures
2662 if (name[0] == '{')
2663 skinframe->hasalpha = true;
2664 skinframe->qhascolormapping = loadpantsandshirt && (featuresmask & (PALETTEFEATURE_PANTS | PALETTEFEATURE_SHIRT));
2666 skinframe->qgeneratemerged = true;
2667 skinframe->qgeneratebase = skinframe->qhascolormapping;
2668 skinframe->qgenerateglow = loadglowtexture && (featuresmask & PALETTEFEATURE_GLOW);
2669
2670 R_SKINFRAME_LOAD_AVERAGE_COLORS(width * height, ((unsigned char *)palette_bgra_complete)[skindata[pix]*4 + comp]);
2671 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2672
2673 return skinframe;
2674}
unsigned char palette_featureflags[256]
Definition palette.c:26
#define PALETTEFEATURE_SHIRT
Definition palette.h:8
#define PALETTEFEATURE_GLOW
Definition palette.h:9
#define PALETTEFEATURE_PANTS
Definition palette.h:7

References skinframe_t::base, ca_dedicated, cls, Con_Printf(), CRC_Block(), developer_loading, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, height, i, cvar_t::integer, Mem_Alloc, skinframe_t::merged, name, skinframe_t::nmap, NULL, palette_bgra_complete, palette_featureflags, PALETTEFEATURE_GLOW, PALETTEFEATURE_PANTS, PALETTEFEATURE_SHIRT, skinframe_t::pants, skinframe_t::qgeneratebase, skinframe_t::qgenerateglow, skinframe_t::qgeneratemerged, skinframe_t::qgeneratenmap, skinframe_t::qhascolormapping, skinframe_t::qheight, skinframe_t::qpixels, skinframe_t::qwidth, r_main_mempool, r_shadow_bumpscale_basetexture, R_SkinFrame_Find(), R_SKINFRAME_LOAD_AVERAGE_COLORS, skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, client_static_t::state, cvar_t::value, and width.

Referenced by Mod_IDP0_Load(), Mod_Q1BSP_LoadTextures(), and R_LoadQWSkin().

◆ R_SkinFrame_LoadInternalUsingTexture()

skinframe_t * R_SkinFrame_LoadInternalUsingTexture ( const char * name,
int textureflags,
rtexture_t * tex,
int width,
int height,
qbool sRGB )

Definition at line 2840 of file gl_rmain.c.

2841{
2842 skinframe_t *skinframe;
2843 if (cls.state == ca_dedicated)
2844 return NULL;
2845 // if already loaded just return it, otherwise make a new skinframe
2846 skinframe = R_SkinFrame_Find(name, textureflags, width, height, 0, true);
2847 if (skinframe->base)
2848 return skinframe;
2849 textureflags &= ~TEXF_FORCE_RELOAD;
2850 skinframe->stain = NULL;
2851 skinframe->merged = NULL;
2852 skinframe->base = NULL;
2853 skinframe->pants = NULL;
2854 skinframe->shirt = NULL;
2855 skinframe->nmap = NULL;
2856 skinframe->gloss = NULL;
2857 skinframe->glow = NULL;
2858 skinframe->fog = NULL;
2859 skinframe->reflect = NULL;
2860 skinframe->hasalpha = (textureflags & TEXF_ALPHA) != 0;
2861 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2862 if (!tex)
2863 return NULL;
2865 Con_Printf("loading 32bit skin \"%s\"\n", name);
2866 skinframe->base = skinframe->merged = tex;
2867 Vector4Set(skinframe->avgcolor, 1, 1, 1, 1); // bogus placeholder
2868 return skinframe;
2869}

References skinframe_t::avgcolor, skinframe_t::base, ca_dedicated, cls, Con_Printf(), developer_loading, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, height, cvar_t::integer, skinframe_t::merged, name, skinframe_t::nmap, NULL, skinframe_t::pants, R_SkinFrame_Find(), skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, client_static_t::state, TEXF_ALPHA, Vector4Set, and width.

◆ R_SkinFrame_LoadMissing()

skinframe_t * R_SkinFrame_LoadMissing ( void )

Definition at line 2804 of file gl_rmain.c.

2805{
2806 skinframe_t *skinframe;
2807
2808 if (cls.state == ca_dedicated)
2809 return NULL;
2810
2811 skinframe = R_SkinFrame_Find("missing", TEXF_FORCENEAREST, 0, 0, 0, true);
2812 skinframe->stain = NULL;
2813 skinframe->merged = NULL;
2814 skinframe->base = NULL;
2815 skinframe->pants = NULL;
2816 skinframe->shirt = NULL;
2817 skinframe->nmap = NULL;
2818 skinframe->gloss = NULL;
2819 skinframe->glow = NULL;
2820 skinframe->fog = NULL;
2821 skinframe->reflect = NULL;
2822 skinframe->hasalpha = false;
2823
2824 skinframe->avgcolor[0] = rand() / RAND_MAX;
2825 skinframe->avgcolor[1] = rand() / RAND_MAX;
2826 skinframe->avgcolor[2] = rand() / RAND_MAX;
2827 skinframe->avgcolor[3] = 1;
2828
2829 return skinframe;
2830}

References skinframe_t::avgcolor, skinframe_t::base, ca_dedicated, cls, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, skinframe_t::merged, skinframe_t::nmap, NULL, skinframe_t::pants, R_SkinFrame_Find(), skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, client_static_t::state, and TEXF_FORCENEAREST.

Referenced by Mod_BuildAliasSkinsFromSkinFiles(), Mod_IDP2_Load(), Mod_IDS2_Load(), Mod_LoadTextureFromQ3Shader(), Mod_Q1BSP_LoadTextures(), Mod_Sprite_SharedSetup(), and Mod_SpriteSetupTexture().

◆ R_SkinFrame_LoadNoTexture()

skinframe_t * R_SkinFrame_LoadNoTexture ( void )

Definition at line 2832 of file gl_rmain.c.

2833{
2834 if (cls.state == ca_dedicated)
2835 return NULL;
2836
2837 return R_SkinFrame_LoadInternalBGRA("notexture", TEXF_FORCENEAREST, Image_GenerateNoTexture(), 16, 16, 0, 0, 0, false);
2838}
skinframe_t * R_SkinFrame_LoadInternalBGRA(const char *name, int textureflags, const unsigned char *skindata, int width, int height, int comparewidth, int compareheight, int comparecrc, qbool sRGB)
Definition gl_rmain.c:2546

References ca_dedicated, cls, Image_GenerateNoTexture(), NULL, R_SkinFrame_LoadInternalBGRA(), client_static_t::state, and TEXF_FORCENEAREST.

◆ R_SkinFrame_MarkUsed()

void R_SkinFrame_MarkUsed ( skinframe_t * skinframe)

Definition at line 2176 of file gl_rmain.c.

2177{
2178 if (!skinframe)
2179 return;
2180 // mark the skinframe as used for the purging code
2182}
unsigned int loadsequence
Definition r_textures.h:151

References r_skinframe_t::loadsequence, skinframe_t::loadsequence, and r_skinframe.

Referenced by Draw_CachePic_Flags(), Draw_NewPic(), gl_draw_newmap(), mod_newmap(), r_lightningbeams_newmap(), r_part_newmap(), r_shadow_newmap(), and R_SkinFrame_Find().

◆ R_SkinFrame_PrepareForPurge()

void R_SkinFrame_PrepareForPurge ( void )

Definition at line 2168 of file gl_rmain.c.

2169{
2171 // wrap it without hitting zero
2172 if (r_skinframe.loadsequence >= 200)
2174}

References r_skinframe_t::loadsequence, and r_skinframe.

Referenced by R_Modules_NewMap().

◆ R_SkinFrame_Purge()

void R_SkinFrame_Purge ( void )

Definition at line 2203 of file gl_rmain.c.

2204{
2205 int i;
2206 skinframe_t *s;
2207 for (i = 0;i < SKINFRAME_HASH;i++)
2208 {
2209 for (s = r_skinframe.hash[i];s;s = s->next)
2210 {
2213 }
2214 }
2215}

References r_skinframe_t::hash, i, r_skinframe_t::loadsequence, skinframe_t::loadsequence, skinframe_t::next, r_skinframe, R_SkinFrame_PurgeSkinFrame(), and SKINFRAME_HASH.

Referenced by R_Modules_NewMap().

◆ R_SkinFrame_PurgeSkinFrame()

◆ R_SortEntities()

static void R_SortEntities ( void )
static

Definition at line 5620 of file gl_rmain.c.

5621{
5622 // below or equal 2 ents, sorting never gains anything
5623 if(r_refdef.scene.numentities <= 2)
5624 return;
5625 // sort
5627}
static int R_SortEntities_Compare(const void *ap, const void *bp)
Definition gl_rmain.c:5598

References r_refdef_scene_t::entities, r_refdef_scene_t::numentities, r_refdef, R_SortEntities_Compare(), and r_refdef_t::scene.

Referenced by R_RenderView().

◆ R_SortEntities_Compare()

static int R_SortEntities_Compare ( const void * ap,
const void * bp )
static

Definition at line 5598 of file gl_rmain.c.

5599{
5600 const entity_render_t *a = *(const entity_render_t **)ap;
5601 const entity_render_t *b = *(const entity_render_t **)bp;
5602
5603 // 1. compare model
5604 if(a->model < b->model)
5605 return -1;
5606 if(a->model > b->model)
5607 return +1;
5608
5609 // 2. compare skin
5610 // TODO possibly calculate the REAL skinnum here first using
5611 // skinscenes?
5612 if(a->skinnum < b->skinnum)
5613 return -1;
5614 if(a->skinnum > b->skinnum)
5615 return +1;
5616
5617 // everything we compared is equal
5618 return 0;
5619}

References a, and b.

Referenced by R_SortEntities().

◆ R_tcMod_ApplyToMatrix()

static void R_tcMod_ApplyToMatrix ( matrix4x4_t * texmatrix,
q3shaderinfo_layer_tcmod_t * tcmod,
int currentmaterialflags )
static

Definition at line 6445 of file gl_rmain.c.

6446{
6447 int w, h, idx;
6448 float shadertime;
6449 float f;
6450 float offsetd[2];
6451 float tcmat[12];
6452 matrix4x4_t matrix, temp;
6453 // if shadertime exceeds about 9 hours (32768 seconds), just wrap it,
6454 // it's better to have one huge fixup every 9 hours than gradual
6455 // degradation over time which looks consistently bad after many hours.
6456 //
6457 // tcmod scroll in particular suffers from this degradation which can't be
6458 // effectively worked around even with floor() tricks because we don't
6459 // know if tcmod scroll is the last tcmod being applied, and for clampmap
6460 // a workaround involving floor() would be incorrect anyway...
6461 shadertime = rsurface.shadertime;
6462 if (shadertime >= 32768.0f)
6463 shadertime -= floor(rsurface.shadertime * (1.0f / 32768.0f)) * 32768.0f;
6464 switch(tcmod->tcmod)
6465 {
6466 case Q3TCMOD_COUNT:
6467 case Q3TCMOD_NONE:
6468 if (currentmaterialflags & MATERIALFLAG_WATERSCROLL)
6469 matrix = r_waterscrollmatrix;
6470 else
6471 matrix = identitymatrix;
6472 break;
6474 // this is used in Q3 to allow the gamecode to control texcoord
6475 // scrolling on the entity, which is not supported in darkplaces yet.
6476 Matrix4x4_CreateTranslate(&matrix, 0, 0, 0);
6477 break;
6478 case Q3TCMOD_ROTATE:
6479 Matrix4x4_CreateTranslate(&matrix, 0.5, 0.5, 0);
6480 Matrix4x4_ConcatRotate(&matrix, tcmod->parms[0] * rsurface.shadertime, 0, 0, 1);
6481 Matrix4x4_ConcatTranslate(&matrix, -0.5, -0.5, 0);
6482 break;
6483 case Q3TCMOD_SCALE:
6484 Matrix4x4_CreateScale3(&matrix, tcmod->parms[0], tcmod->parms[1], 1);
6485 break;
6486 case Q3TCMOD_SCROLL:
6487 // this particular tcmod is a "bug for bug" compatible one with regards to
6488 // Quake3, the wrapping is unnecessary with our shadetime fix but quake3
6489 // specifically did the wrapping and so we must mimic that...
6490 offsetd[0] = tcmod->parms[0] * rsurface.shadertime;
6491 offsetd[1] = tcmod->parms[1] * rsurface.shadertime;
6492 Matrix4x4_CreateTranslate(&matrix, offsetd[0] - floor(offsetd[0]), offsetd[1] - floor(offsetd[1]), 0);
6493 break;
6494 case Q3TCMOD_PAGE: // poor man's animmap (to store animations into a single file, useful for HTTP downloaded textures)
6495 w = (int) tcmod->parms[0];
6496 h = (int) tcmod->parms[1];
6497 f = rsurface.shadertime / (tcmod->parms[2] * w * h);
6498 f = f - floor(f);
6499 idx = (int) floor(f * w * h);
6500 Matrix4x4_CreateTranslate(&matrix, (idx % w) / tcmod->parms[0], (idx / w) / tcmod->parms[1], 0);
6501 break;
6502 case Q3TCMOD_STRETCH:
6503 f = 1.0f / R_EvaluateQ3WaveFunc(tcmod->wavefunc, tcmod->waveparms);
6504 Matrix4x4_CreateFromQuakeEntity(&matrix, 0.5f * (1 - f), 0.5 * (1 - f), 0, 0, 0, 0, f);
6505 break;
6506 case Q3TCMOD_TRANSFORM:
6507 VectorSet(tcmat + 0, tcmod->parms[0], tcmod->parms[1], 0);
6508 VectorSet(tcmat + 3, tcmod->parms[2], tcmod->parms[3], 0);
6509 VectorSet(tcmat + 6, 0 , 0 , 1);
6510 VectorSet(tcmat + 9, tcmod->parms[4], tcmod->parms[5], 0);
6511 Matrix4x4_FromArray12FloatGL(&matrix, tcmat);
6512 break;
6513 case Q3TCMOD_TURBULENT:
6514 // this is handled in the RSurf_PrepareVertices function
6515 matrix = identitymatrix;
6516 break;
6517 }
6518 temp = *texmatrix;
6519 Matrix4x4_Concat(texmatrix, &matrix, &temp);
6520}
static float R_EvaluateQ3WaveFunc(q3wavefunc_t func, const float *parms)
Definition gl_rmain.c:6407
void Matrix4x4_FromArray12FloatGL(matrix4x4_t *out, const float in[12])
Definition matrixlib.c:1352
void Matrix4x4_CreateScale3(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:695
void Matrix4x4_ConcatTranslate(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:1757
void Matrix4x4_ConcatRotate(matrix4x4_t *out, double angle, double x, double y, double z)
Definition matrixlib.c:1766
@ Q3TCMOD_SCALE
Definition r_qshader.h:114
@ Q3TCMOD_ROTATE
Definition r_qshader.h:113
@ Q3TCMOD_ENTITYTRANSLATE
Definition r_qshader.h:112
@ Q3TCMOD_TRANSFORM
Definition r_qshader.h:117
@ Q3TCMOD_SCROLL
Definition r_qshader.h:115
@ Q3TCMOD_PAGE
Definition r_qshader.h:119
@ Q3TCMOD_TURBULENT
Definition r_qshader.h:118
@ Q3TCMOD_STRETCH
Definition r_qshader.h:116
@ Q3TCMOD_NONE
Definition r_qshader.h:111
@ Q3TCMOD_COUNT
Definition r_qshader.h:120
float parms[Q3TCMOD_MAXPARMS]
Definition r_qshader.h:152
float waveparms[Q3WAVEPARMS]
Definition r_qshader.h:154

References f, floor(), identitymatrix, int(), MATERIALFLAG_WATERSCROLL, Matrix4x4_Concat(), Matrix4x4_ConcatRotate(), Matrix4x4_ConcatTranslate(), Matrix4x4_CreateFromQuakeEntity(), Matrix4x4_CreateScale3(), Matrix4x4_CreateTranslate(), Matrix4x4_FromArray12FloatGL(), q3shaderinfo_layer_tcmod_t::parms, Q3TCMOD_COUNT, Q3TCMOD_ENTITYTRANSLATE, Q3TCMOD_NONE, Q3TCMOD_PAGE, Q3TCMOD_ROTATE, Q3TCMOD_SCALE, Q3TCMOD_SCROLL, Q3TCMOD_STRETCH, Q3TCMOD_TRANSFORM, Q3TCMOD_TURBULENT, R_EvaluateQ3WaveFunc(), r_waterscrollmatrix, rsurface, rsurfacestate_t::shadertime, q3shaderinfo_layer_tcmod_t::tcmod, VectorSet, w, q3shaderinfo_layer_tcmod_t::wavefunc, and q3shaderinfo_layer_tcmod_t::waveparms.

Referenced by R_GetCurrentTexture().

◆ R_TestQ3WaveFunc()

static qbool R_TestQ3WaveFunc ( q3wavefunc_t func,
const float * parms )
static

Definition at line 6397 of file gl_rmain.c.

6398{
6399 if(parms[0] == 0 && parms[1] == 0)
6400 return false;
6401 if(func >> Q3WAVEFUNC_USER_SHIFT) // assumes rsurface to be set!
6403 return false;
6404 return true;
6405}

References bound, Q3WAVEFUNC_USER_COUNT, Q3WAVEFUNC_USER_SHIFT, rsurface, and rsurfacestate_t::userwavefunc_param.

Referenced by RSurf_PrepareVerticesForBatch().

◆ R_UpdateFog()

void R_UpdateFog ( void )

Definition at line 5396 of file gl_rmain.c.

5397{
5398 // Nehahra fog
5399 if (gamemode == GAME_NEHAHRA)
5400 {
5402 {
5408 r_refdef.fog_alpha = 1;
5409 r_refdef.fog_start = 0;
5411 r_refdef.fog_height = 1<<30;
5412 r_refdef.fog_fadedepth = 128;
5413 }
5414 else if (r_refdef.oldgl_fogenable)
5415 {
5416 r_refdef.oldgl_fogenable = false;
5418 r_refdef.fog_red = 0;
5419 r_refdef.fog_green = 0;
5420 r_refdef.fog_blue = 0;
5421 r_refdef.fog_alpha = 0;
5422 r_refdef.fog_start = 0;
5423 r_refdef.fog_end = 0;
5424 r_refdef.fog_height = 1<<30;
5425 r_refdef.fog_fadedepth = 128;
5426 }
5427 }
5428
5429 // fog parms
5433
5435 {
5436 r_refdef.fogenabled = true;
5437 // this is the point where the fog reaches 0.9986 alpha, which we
5438 // consider a good enough cutoff point for the texture
5439 // (0.9986 * 256 == 255.6)
5440 if (r_fog_exp2.integer)
5442 else
5449 // fog color was already set
5450 // update the fog texture
5455 }
5456 else
5457 r_refdef.fogenabled = false;
5458
5459 // fog color
5461 {
5465
5470
5471 {
5472 vec3_t fogvec;
5473 VectorCopy(r_refdef.fogcolor, fogvec);
5474 // color.rgb *= ContrastBoost * SceneBrightness;
5475 VectorScale(fogvec, r_refdef.view.colorscale, fogvec);
5476 r_refdef.fogcolor[0] = bound(0.0f, fogvec[0], 1.0f);
5477 r_refdef.fogcolor[1] = bound(0.0f, fogvec[1], 1.0f);
5478 r_refdef.fogcolor[2] = bound(0.0f, fogvec[2], 1.0f);
5479 }
5480 }
5481}
static void R_BuildFogTexture(void)
Definition gl_rmain.c:470
static void R_BuildFogHeightTexture(void)
Definition gl_rmain.c:526
float fogplaneviewdist
Definition render.h:421
float fog_height_texcoordscale
Definition render.h:449
qbool oldgl_fogenable
Definition render.h:441
float fog_height_tablescale
Definition render.h:448
float fogheightfade
Definition render.h:423
float fogmasktabledistmultiplier
Definition render.h:427
float fograngerecip
Definition render.h:426
float fogplane[4]
Definition render.h:420

References bound, r_refdef_view_t::colorscale, DotProduct, r_refdef_t::fog_alpha, r_refdef_t::fog_blue, r_refdef_t::fog_density, r_refdef_t::fog_end, r_refdef_t::fog_fadedepth, r_refdef_t::fog_green, r_refdef_t::fog_height, r_refdef_t::fog_height_tablescale, r_refdef_t::fog_height_tablesize, r_refdef_t::fog_height_texcoordscale, r_refdef_t::fog_height_texturename, r_refdef_t::fog_red, r_refdef_t::fog_start, r_refdef_t::fogcolor, r_refdef_t::fogenabled, r_refdef_t::fogheightfade, r_refdef_t::fogheighttexturename, r_refdef_t::fogmasktable_alpha, r_refdef_t::fogmasktable_density, r_refdef_t::fogmasktable_range, r_refdef_t::fogmasktable_start, r_refdef_t::fogmasktabledistmultiplier, FOGMASKTABLEWIDTH, r_refdef_t::fogplane, r_refdef_t::fogplaneviewabove, r_refdef_t::fogplaneviewdist, r_refdef_t::fogrange, r_refdef_t::fograngerecip, GAME_NEHAHRA, gamemode, gl_fogblue, gl_fogdensity, gl_fogenable, gl_foggreen, gl_fogred, gl_skyclip, cvar_t::integer, max, r_refdef_t::oldgl_fogenable, r_refdef_view_t::origin, R_BuildFogHeightTexture(), R_BuildFogTexture(), r_drawfog, r_fog_exp2, r_refdef, cvar_t::value, Vector4Set, VectorCopy, VectorScale, and r_refdef_t::view.

Referenced by R_ClearScreen(), and R_RenderScene().

◆ R_UpdateVariables()

void R_UpdateVariables ( void )

Definition at line 5483 of file gl_rmain.c.

5484{
5486
5487 r_refdef.scene.ambientintensity = r_ambient.value * (1.0f / 64.0f);
5488
5493
5498
5505 {
5507
5508 // Apply the default lightstyle to the lightmap even on q3bsp
5509 if (cl.worldmodel && cl.worldmodel->type == mod_brushq3) {
5511 }
5512 }
5514 {
5515 r_refdef.scene.rtworld = false;
5517 r_refdef.scene.rtdlight = false;
5520 }
5521
5522 r_gpuskeletal = false;
5523 switch(vid.renderpath)
5524 {
5525 case RENDERPATH_GL32:
5527 case RENDERPATH_GLES2:
5529 {
5531 {
5532 // build GLSL gamma texture
5533#define RAMPWIDTH 256
5534 unsigned short ramp[RAMPWIDTH * 3];
5535 unsigned char rampbgr[RAMPWIDTH][4];
5536 int i;
5537
5539
5541 for(i = 0; i < RAMPWIDTH; ++i)
5542 {
5543 rampbgr[i][0] = (unsigned char) (ramp[i + 2 * RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
5544 rampbgr[i][1] = (unsigned char) (ramp[i + RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
5545 rampbgr[i][2] = (unsigned char) (ramp[i] * 255.0 / 65535.0 + 0.5);
5546 rampbgr[i][3] = 0;
5547 }
5549 {
5550 R_UpdateTexture(r_texture_gammaramps, &rampbgr[0][0], 0, 0, 0, RAMPWIDTH, 1, 1, 0);
5551 }
5552 else
5553 {
5555 }
5556 }
5557 }
5558 else
5559 {
5560 // remove GLSL gamma texture
5561 }
5562 break;
5563 }
5564}
unsigned int r_texture_gammaramps_serial
Definition gl_rmain.c:282
#define RAMPWIDTH
cvar_t r_ambient
Definition gl_rsurf.c:28
void R_Textures_Frame(void)
cvar_t r_shadow_realtime_dlight
Definition r_shadow.c:159
cvar_t r_shadow_realtime_world_shadows
Definition r_shadow.c:166
cvar_t r_shadow_realtime_world
Definition r_shadow.c:163
cvar_t r_shadow_realtime_dlight_shadows
Definition r_shadow.c:160
cvar_t r_shadow_realtime_world_lightmaps
Definition r_shadow.c:165
cvar_t gl_flashblend
Definition r_shadow.c:236
@ mod_brushq3
cvar_t r_shadow_frontsidecasting
Definition r_shadow.c:158
float radius
float lightmapscale
float rtlightstylevalue[MAX_LIGHTSTYLES]
float fraction of base light value
Definition render.h:377
qbool rtworldshadows
Definition render.h:390
qbool rtdlightshadows
Definition render.h:392
unsigned int vid_gammatables_serial
so other subsystems can poll if gamma parameters have changed; this starts with 0 and gets increased ...
void VID_BuildGammaTables(unsigned short *ramps, int rampsize)
builds the current gamma tables into an array (needs 3*rampsize items)

References r_refdef_scene_t::ambientintensity, bound, cl, Cvar_SetValueQuick(), r_refdef_t::farclip, gl_flashblend, i, cvar_t::integer, r_refdef_scene_t::lightmapintensity, model_t::lightmapscale, mod_brushq3, r_refdef_t::nearclip, NULL, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, r_ambient, r_dynamic, r_farclip_base, r_farclip_world, r_glsl_skeletal, r_gpuskeletal, R_LoadTexture2D(), r_main_texturepool, r_nearclip, r_refdef, r_shadow_frontsidecasting, r_shadow_realtime_dlight, r_shadow_realtime_dlight_shadows, r_shadow_realtime_world, r_shadow_realtime_world_lightmaps, r_shadow_realtime_world_shadows, r_showsurfaces, r_texture_gammaramps, r_texture_gammaramps_serial, R_Textures_Frame(), R_UpdateTexture(), model_t::radius, RAMPWIDTH, viddef_t::renderpath, RENDERPATH_GL32, RENDERPATH_GLES2, r_refdef_scene_t::rtdlight, r_refdef_scene_t::rtdlightshadows, r_refdef_scene_t::rtlightstylevalue, r_refdef_scene_t::rtworld, r_refdef_scene_t::rtworldshadows, r_refdef_t::scene, viddef_t::stencil, TEXF_CLAMP, TEXF_FORCELINEAR, TEXF_PERSISTENT, TEXTYPE_BGRA, cvar_t::value, vid, VID_BuildGammaTables(), vid_gammatables_serial, vid_gammatables_trivial, client_state_t::worldmodel, and r_refdef_scene_t::worldmodel.

Referenced by R_Envmap_f(), and SCR_DrawScreen().

◆ R_View_SetFrustum()

static void R_View_SetFrustum ( const int * scissor)
static

Definition at line 4189 of file gl_rmain.c.

4190{
4191 int i;
4192 double fpx = +1, fnx = -1, fpy = +1, fny = -1;
4193 vec3_t forward, left, up, origin, v;
4195 return;
4196 if(scissor)
4197 {
4198 // flipped x coordinates (because x points left here)
4199 fpx = 1.0 - 2.0 * (scissor[0] - r_refdef.view.viewport.x) / (double) (r_refdef.view.viewport.width);
4200 fnx = 1.0 - 2.0 * (scissor[0] + scissor[2] - r_refdef.view.viewport.x) / (double) (r_refdef.view.viewport.width);
4201 // non-flipped y coordinates
4202 fny = -1.0 + 2.0 * (scissor[1] - r_refdef.view.viewport.y) / (double) (r_refdef.view.viewport.height);
4203 fpy = -1.0 + 2.0 * (scissor[1] + scissor[3] - r_refdef.view.viewport.y) / (double) (r_refdef.view.viewport.height);
4204 }
4205
4206 // we can't trust r_refdef.view.forward and friends in reflected scenes
4208
4209#if 0
4210 r_refdef.view.frustum[0].normal[0] = 0 - 1.0 / r_refdef.view.frustum_x;
4211 r_refdef.view.frustum[0].normal[1] = 0 - 0;
4212 r_refdef.view.frustum[0].normal[2] = -1 - 0;
4213 r_refdef.view.frustum[1].normal[0] = 0 + 1.0 / r_refdef.view.frustum_x;
4214 r_refdef.view.frustum[1].normal[1] = 0 + 0;
4215 r_refdef.view.frustum[1].normal[2] = -1 + 0;
4216 r_refdef.view.frustum[2].normal[0] = 0 - 0;
4217 r_refdef.view.frustum[2].normal[1] = 0 - 1.0 / r_refdef.view.frustum_y;
4218 r_refdef.view.frustum[2].normal[2] = -1 - 0;
4219 r_refdef.view.frustum[3].normal[0] = 0 + 0;
4220 r_refdef.view.frustum[3].normal[1] = 0 + 1.0 / r_refdef.view.frustum_y;
4221 r_refdef.view.frustum[3].normal[2] = -1 + 0;
4222#endif
4223
4224#if 0
4225 zNear = r_refdef.nearclip;
4226 nudge = 1.0 - 1.0 / (1<<23);
4227 r_refdef.view.frustum[4].normal[0] = 0 - 0;
4228 r_refdef.view.frustum[4].normal[1] = 0 - 0;
4229 r_refdef.view.frustum[4].normal[2] = -1 - -nudge;
4230 r_refdef.view.frustum[4].dist = 0 - -2 * zNear * nudge;
4231 r_refdef.view.frustum[5].normal[0] = 0 + 0;
4232 r_refdef.view.frustum[5].normal[1] = 0 + 0;
4233 r_refdef.view.frustum[5].normal[2] = -1 + -nudge;
4234 r_refdef.view.frustum[5].dist = 0 + -2 * zNear * nudge;
4235#endif
4236
4237
4238
4239#if 0
4240 r_refdef.view.frustum[0].normal[0] = m[3] - m[0];
4241 r_refdef.view.frustum[0].normal[1] = m[7] - m[4];
4242 r_refdef.view.frustum[0].normal[2] = m[11] - m[8];
4243 r_refdef.view.frustum[0].dist = m[15] - m[12];
4244
4245 r_refdef.view.frustum[1].normal[0] = m[3] + m[0];
4246 r_refdef.view.frustum[1].normal[1] = m[7] + m[4];
4247 r_refdef.view.frustum[1].normal[2] = m[11] + m[8];
4248 r_refdef.view.frustum[1].dist = m[15] + m[12];
4249
4250 r_refdef.view.frustum[2].normal[0] = m[3] - m[1];
4251 r_refdef.view.frustum[2].normal[1] = m[7] - m[5];
4252 r_refdef.view.frustum[2].normal[2] = m[11] - m[9];
4253 r_refdef.view.frustum[2].dist = m[15] - m[13];
4254
4255 r_refdef.view.frustum[3].normal[0] = m[3] + m[1];
4256 r_refdef.view.frustum[3].normal[1] = m[7] + m[5];
4257 r_refdef.view.frustum[3].normal[2] = m[11] + m[9];
4258 r_refdef.view.frustum[3].dist = m[15] + m[13];
4259
4260 r_refdef.view.frustum[4].normal[0] = m[3] - m[2];
4261 r_refdef.view.frustum[4].normal[1] = m[7] - m[6];
4262 r_refdef.view.frustum[4].normal[2] = m[11] - m[10];
4263 r_refdef.view.frustum[4].dist = m[15] - m[14];
4264
4265 r_refdef.view.frustum[5].normal[0] = m[3] + m[2];
4266 r_refdef.view.frustum[5].normal[1] = m[7] + m[6];
4267 r_refdef.view.frustum[5].normal[2] = m[11] + m[10];
4268 r_refdef.view.frustum[5].dist = m[15] + m[14];
4269#endif
4270
4272 {
4273 // calculate frustum corners, which are used to calculate deformed frustum planes for shadow caster culling
4274 VectorMAMAM(1024, forward, fnx * 1024.0 * r_refdef.view.frustum_x, left, fny * 1024.0 * r_refdef.view.frustum_y, up, r_refdef.view.frustumcorner[0]);
4275 VectorMAMAM(1024, forward, fpx * 1024.0 * r_refdef.view.frustum_x, left, fny * 1024.0 * r_refdef.view.frustum_y, up, r_refdef.view.frustumcorner[1]);
4276 VectorMAMAM(1024, forward, fnx * 1024.0 * r_refdef.view.frustum_x, left, fpy * 1024.0 * r_refdef.view.frustum_y, up, r_refdef.view.frustumcorner[2]);
4277 VectorMAMAM(1024, forward, fpx * 1024.0 * r_refdef.view.frustum_x, left, fpy * 1024.0 * r_refdef.view.frustum_y, up, r_refdef.view.frustumcorner[3]);
4278
4279 // then the normals from the corners relative to origin
4284
4285 // in a NORMAL view, forward cross left == up
4286 // in a REFLECTED view, forward cross left == down
4287 // so our cross products above need to be adjusted for a left handed coordinate system
4288 CrossProduct(forward, left, v);
4289 if(DotProduct(v, up) < 0)
4290 {
4295 }
4296
4297 // Leaving those out was a mistake, those were in the old code, and they
4298 // fix a reproducable bug in this one: frustum culling got fucked up when viewmatrix was an identity matrix
4299 // I couldn't reproduce it after adding those normalizations. --blub
4304
4305 // make the corners absolute
4310
4311 // one more normal
4313
4319 }
4320 else
4321 {
4322 VectorScale(left, -1.0f, r_refdef.view.frustum[0].normal);
4323 VectorScale(left, 1.0f, r_refdef.view.frustum[1].normal);
4332 }
4334
4336 {
4339 }
4340
4341 for (i = 0;i < r_refdef.view.numfrustumplanes;i++)
4343
4344 // LadyHavoc: note to all quake engine coders, Quake had a special case
4345 // for 90 degrees which assumed a square view (wrong), so I removed it,
4346 // Quake2 has it disabled as well.
4347
4348 // rotate R_VIEWFORWARD right by FOV_X/2 degrees
4349 //RotatePointAroundVector( r_refdef.view.frustum[0].normal, up, forward, -(90 - r_refdef.fov_x / 2));
4350 //r_refdef.view.frustum[0].dist = DotProduct (r_refdef.view.origin, frustum[0].normal);
4351 //PlaneClassify(&frustum[0]);
4352
4353 // rotate R_VIEWFORWARD left by FOV_X/2 degrees
4354 //RotatePointAroundVector( r_refdef.view.frustum[1].normal, up, forward, (90 - r_refdef.fov_x / 2));
4355 //r_refdef.view.frustum[1].dist = DotProduct (r_refdef.view.origin, frustum[1].normal);
4356 //PlaneClassify(&frustum[1]);
4357
4358 // rotate R_VIEWFORWARD up by FOV_X/2 degrees
4359 //RotatePointAroundVector( r_refdef.view.frustum[2].normal, left, forward, -(90 - r_refdef.fov_y / 2));
4360 //r_refdef.view.frustum[2].dist = DotProduct (r_refdef.view.origin, frustum[2].normal);
4361 //PlaneClassify(&frustum[2]);
4362
4363 // rotate R_VIEWFORWARD down by FOV_X/2 degrees
4364 //RotatePointAroundVector( r_refdef.view.frustum[3].normal, left, forward, (90 - r_refdef.fov_y / 2));
4365 //r_refdef.view.frustum[3].dist = DotProduct (r_refdef.view.origin, frustum[3].normal);
4366 //PlaneClassify(&frustum[3]);
4367
4368 // nearclip plane
4369 //VectorCopy(forward, r_refdef.view.frustum[4].normal);
4370 //r_refdef.view.frustum[4].dist = DotProduct (r_refdef.view.origin, frustum[4].normal) + r_nearclip.value;
4371 //PlaneClassify(&frustum[4]);
4372}
cvar_t r_lockvisibility
Definition gl_rsurf.c:30
void PlaneClassify(mplane_t *p)
Definition mathlib.c:310
#define VectorMAMAM(scale1, b1, scale2, b2, scale3, b3, out)
Definition mathlib.h:117
#define VectorAdd(a, b, out)
Definition mathlib.h:100
vec3_t frustumcorner[4]
Definition render.h:278

References r_refdef_view_t::clipplane, CrossProduct, mplane_t::dist, DotProduct, r_refdef_t::farclip, forward, r_refdef_view_t::frustum, r_refdef_view_t::frustum_x, r_refdef_view_t::frustum_y, r_refdef_view_t::frustumcorner, r_viewport_t::height, i, cvar_t::integer, r_refdef_view_t::matrix, Matrix4x4_ToVectors(), r_refdef_t::nearclip, mplane_t::normal, r_refdef_view_t::numfrustumplanes, origin, r_refdef_view_t::origin, r_refdef_view_t::ortho_x, r_refdef_view_t::ortho_y, PlaneClassify(), r_lockvisibility, r_refdef, up, r_refdef_view_t::useclipplane, r_refdef_view_t::useperspective, v, VectorAdd, VectorCopy, VectorMAMAM, VectorNegate, VectorNormalize, VectorScale, r_refdef_t::view, r_refdef_view_t::viewport, r_viewport_t::width, r_viewport_t::x, and r_viewport_t::y.

Referenced by R_View_Update().

◆ R_View_Update()

static void R_View_Update ( const int * myscissor)
static

Definition at line 4374 of file gl_rmain.c.

4375{
4377 R_View_SetFrustum(myscissor);
4380}
static void R_View_UpdateEntityVisible(void)
Definition gl_rmain.c:3992
static void R_View_SetFrustum(const int *scissor)
Definition gl_rmain.c:4189
static void R_Main_ResizeViewCache(void)
Definition gl_rmain.c:3011
void R_View_WorldVisibility(qbool forcenovis)
Definition gl_rsurf.c:436

References R_Main_ResizeViewCache(), r_refdef, R_View_SetFrustum(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), r_refdef_view_t::usevieworiginculling, and r_refdef_t::view.

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_View_UpdateEntityVisible()

static void R_View_UpdateEntityVisible ( void )
static

Definition at line 3992 of file gl_rmain.c.

3993{
3994 int i;
3995 int renderimask;
3996 int samples;
3997 entity_render_t *ent;
3998
4000 renderimask = RENDER_EXTERIORMODEL | RENDER_VIEWMODEL;
4002 renderimask = RENDER_VIEWMODEL;
4003 else
4004 renderimask = RENDER_EXTERIORMODEL;
4006 renderimask |= RENDER_VIEWMODEL;
4008 renderimask |= RENDER_EXTERIORMODEL;
4011 {
4012 // worldmodel can check visibility
4013 for (i = 0;i < r_refdef.scene.numentities;i++)
4014 {
4015 ent = r_refdef.scene.entities[i];
4017 {
4019 continue;
4020 }
4021 if (!(ent->flags & renderimask))
4022 if (!R_CullFrustum(ent->mins, ent->maxs) || (ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)))
4025 }
4026 }
4027 else
4028 {
4029 // no worldmodel or it can't check visibility
4030 for (i = 0;i < r_refdef.scene.numentities;i++)
4031 {
4032 ent = r_refdef.scene.entities[i];
4033 if (!(ent->flags & renderimask))
4034 if (!R_CullFrustum(ent->mins, ent->maxs) || (ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)))
4036 }
4037 }
4039 {
4040 for (i = 0;i < r_refdef.scene.numentities;i++)
4041 {
4043 continue;
4044 ent = r_refdef.scene.entities[i];
4045 if (!(ent->flags & (RENDER_VIEWMODEL | RENDER_WORLDOBJECT | RENDER_NODEPTHTEST)) && !(ent->model && (ent->model->name[0] == '*')))
4046 {
4052 }
4053 }
4054 }
4055}
qbool R_CanSeeBox(int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t entboxexpand, vec_t pad, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs)
Definition gl_rmain.c:3888
GLsizei samples
Definition glquake.h:623
@ mod_sprite
#define RENDER_EXTERIORMODEL
Definition protocol.h:359
cvar_t chase_active
Definition view.c:132
#define SPR_LABEL
Definition spritegn.h:101
#define SPR_LABEL_SCALE
Definition spritegn.h:102
double last_trace_visibility
Definition client.h:442
int(* BoxTouchingVisibleLeafs)(struct model_s *model, const unsigned char *visibleleafs, const vec3_t mins, const vec3_t maxs)
model_sprite_t sprite
modtype_t type
char name[MAX_QPATH]
qbool hideplayer
Definition render.h:877

References model_brush_t::BoxTouchingVisibleLeafs, model_t::brush, chase_active, r_refdef_scene_t::entities, r_refdef_viewcache_t::entityvisible, r_refdef_t::envmap, entity_render_t::flags, r_waterstate_t::hideplayer, host, i, cvar_t::integer, entity_render_t::last_trace_visibility, entity_render_t::maxs, entity_render_t::mins, mod_sprite, entity_render_t::model, model_t::name, r_refdef_scene_t::numentities, r_refdef_view_t::origin, R_CanSeeBox(), r_cullentities_trace, r_cullentities_trace_delay, r_cullentities_trace_enlarge, r_cullentities_trace_expand, r_cullentities_trace_eyejitter, r_cullentities_trace_pad, r_cullentities_trace_samples, r_cullentities_trace_tempentitysamples, R_CullFrustum(), r_drawexteriormodel, r_drawviewmodel, r_fb, r_novis, r_refdef, host_static_t::realtime, RENDER_EXTERIORMODEL, RENDER_NODEPTHTEST, RENDER_VIEWMODEL, RENDER_WORLDOBJECT, r_waterstate_t::renderingscene, samples, r_refdef_t::scene, SPR_LABEL, SPR_LABEL_SCALE, model_t::sprite, model_sprite_t::sprnum_type, model_t::type, cvar_t::value, r_refdef_t::view, r_refdef_t::viewcache, r_framebufferstate_t::water, r_refdef_viewcache_t::world_leafvisible, r_refdef_viewcache_t::world_novis, and r_refdef_scene_t::worldmodel.

Referenced by R_View_Update().

◆ R_Water_AddWaterPlane()

void R_Water_AddWaterPlane ( msurface_t * surface,
int entno )

Definition at line 4640 of file gl_rmain.c.

4641{
4642 int planeindex, bestplaneindex, vertexindex;
4643 vec3_t mins, maxs, normal, center, v, n;
4644 vec_t planescore, bestplanescore;
4645 mplane_t plane;
4647 texture_t *t = R_GetCurrentTexture(surface->texture);
4648
4649 rsurface.texture = t;
4651 // if the model has no normals, it's probably off-screen and they were not generated, so don't add it anyway
4653 return;
4654 // average the vertex normals, find the surface bounds (after deformvertexes)
4658 VectorCopy(v, mins);
4659 VectorCopy(v, maxs);
4660 for (vertexindex = 1;vertexindex < rsurface.batchnumvertices;vertexindex++)
4661 {
4665 mins[0] = min(mins[0], v[0]);
4666 mins[1] = min(mins[1], v[1]);
4667 mins[2] = min(mins[2], v[2]);
4668 maxs[0] = max(maxs[0], v[0]);
4669 maxs[1] = max(maxs[1], v[1]);
4670 maxs[2] = max(maxs[2], v[2]);
4671 }
4673 VectorMAM(0.5f, mins, 0.5f, maxs, center);
4674
4675 VectorCopy(normal, plane.normal);
4676 VectorNormalize(plane.normal);
4677 plane.dist = DotProduct(center, plane.normal);
4678 PlaneClassify(&plane);
4679 if (PlaneDiff(r_refdef.view.origin, &plane) < 0)
4680 {
4681 // skip backfaces (except if nocullface is set)
4682// if (!(t->currentmaterialflags & MATERIALFLAG_NOCULLFACE))
4683// return;
4684 VectorNegate(plane.normal, plane.normal);
4685 plane.dist *= -1;
4686 PlaneClassify(&plane);
4687 }
4688
4689
4690 // find a matching plane if there is one
4691 bestplaneindex = -1;
4692 bestplanescore = 1048576.0f;
4693 for (planeindex = 0, p = r_fb.water.waterplanes;planeindex < r_fb.water.numwaterplanes;planeindex++, p++)
4694 {
4695 if(p->camera_entity == t->camera_entity)
4696 {
4697 planescore = 1.0f - DotProduct(plane.normal, p->plane.normal) + fabs(plane.dist - p->plane.dist) * 0.001f;
4698 if (bestplaneindex < 0 || bestplanescore > planescore)
4699 {
4700 bestplaneindex = planeindex;
4701 bestplanescore = planescore;
4702 }
4703 }
4704 }
4705 planeindex = bestplaneindex;
4706
4707 // if this surface does not fit any known plane rendered this frame, add one
4708 if (planeindex < 0 || bestplanescore > 0.001f)
4709 {
4711 {
4712 // store the new plane
4713 planeindex = r_fb.water.numwaterplanes++;
4714 p = r_fb.water.waterplanes + planeindex;
4715 p->plane = plane;
4716 // clear materialflags and pvs
4717 p->materialflags = 0;
4718 p->pvsvalid = false;
4720 VectorCopy(mins, p->mins);
4721 VectorCopy(maxs, p->maxs);
4722 }
4723 else
4724 {
4725 // We're totally screwed.
4726 return;
4727 }
4728 }
4729 else
4730 {
4731 // merge mins/maxs when we're adding this surface to the plane
4732 p = r_fb.water.waterplanes + planeindex;
4733 p->mins[0] = min(p->mins[0], mins[0]);
4734 p->mins[1] = min(p->mins[1], mins[1]);
4735 p->mins[2] = min(p->mins[2], mins[2]);
4736 p->maxs[0] = max(p->maxs[0], maxs[0]);
4737 p->maxs[1] = max(p->maxs[1], maxs[1]);
4738 p->maxs[2] = max(p->maxs[2], maxs[2]);
4739 }
4740 // merge this surface's materialflags into the waterplane
4743 {
4744 // merge this surface's PVS into the waterplane
4747 {
4749 p->pvsvalid = true;
4750 }
4751 }
4752}
#define PlaneDiff(point, plane)
Definition mathlib.h:257
int clusterindex
size_t(* FatPVS)(struct model_s *model, const vec3_t org, vec_t radius, unsigned char **pvsbuffer, mempool_t *pool, qbool merge)
mleaf_t *(* PointInLeaf)(struct model_s *model, const vec3_t p)
int maxwaterplanes
Definition render.h:867
unsigned char * pvsbits
Definition render.h:854

References BATCHNEED_ARRAY_NORMAL, BATCHNEED_ARRAY_VERTEX, BATCHNEED_NOGAPS, rsurfacestate_t::batchnormal3f, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchvertex3f, model_t::brush, r_waterstate_waterplane_t::camera_entity, texture_t::camera_entity, mleaf_t::clusterindex, texture_t::currentmaterialflags, mplane_t::dist, DotProduct, fabs(), model_brush_t::FatPVS, MATERIALFLAG_CAMERA, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_WATERSHADER, r_waterstate_waterplane_t::materialflags, rsurfacestate_t::matrix, Matrix4x4_Transform(), Matrix4x4_Transform3x3(), max, maxs, r_waterstate_waterplane_t::maxs, r_waterstate_t::maxwaterplanes, min, mins, r_waterstate_waterplane_t::mins, n, mplane_t::normal, normal, r_waterstate_t::numwaterplanes, r_refdef_view_t::origin, r_waterstate_waterplane_t::plane, PlaneClassify(), PlaneDiff, model_brush_t::PointInLeaf, r_waterstate_waterplane_t::pvsbits, r_waterstate_waterplane_t::pvsvalid, r_fb, R_GetCurrentTexture(), r_main_mempool, r_refdef, RSurf_PrepareVerticesForBatch(), rsurface, r_refdef_t::scene, msurface_t::texture, rsurfacestate_t::texture, v, VectorAdd, VectorCopy, VectorMAM, VectorNegate, VectorNormalize, r_refdef_t::view, r_framebufferstate_t::water, r_waterstate_t::waterplanes, and r_refdef_scene_t::worldmodel.

Referenced by R_Mod_DrawAddWaterPlanes().

◆ R_Water_ProcessPlanes()

static void R_Water_ProcessPlanes ( int fbo,
rtexture_t * depthtexture,
rtexture_t * colortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )
static

Definition at line 4757 of file gl_rmain.c.

4758{
4759 int myscissor[4];
4760 r_refdef_view_t originalview;
4761 r_refdef_view_t myview;
4762 int planeindex, qualityreduction = 0, old_r_dynamic = 0, old_r_shadows = 0, old_r_worldrtlight = 0, old_r_dlight = 0, old_r_particles = 0, old_r_decals = 0;
4764 vec3_t visorigin;
4765 r_rendertarget_t *rt;
4766
4767 originalview = r_refdef.view;
4768
4769 // lowquality hack, temporarily shut down some cvars and restore afterwards
4770 qualityreduction = r_water_lowquality.integer;
4771 if (qualityreduction > 0)
4772 {
4773 if (qualityreduction >= 1)
4774 {
4775 old_r_shadows = r_shadows.integer;
4776 old_r_worldrtlight = r_shadow_realtime_world.integer;
4777 old_r_dlight = r_shadow_realtime_dlight.integer;
4781 }
4782 if (qualityreduction >= 2)
4783 {
4784 old_r_dynamic = r_dynamic.integer;
4785 old_r_particles = r_drawparticles.integer;
4786 old_r_decals = r_drawdecals.integer;
4790 }
4791 }
4792
4793 for (planeindex = 0, p = r_fb.water.waterplanes; planeindex < r_fb.water.numwaterplanes; planeindex++, p++)
4794 {
4795 p->rt_reflection = NULL;
4796 p->rt_refraction = NULL;
4797 p->rt_camera = NULL;
4798 }
4799
4800 // render views
4801 r_refdef.view = originalview;
4802 r_refdef.view.showdebug = false;
4805 r_refdef.view.useclipplane = true;
4806 myview = r_refdef.view;
4807 r_fb.water.renderingscene = true;
4808 for (planeindex = 0, p = r_fb.water.waterplanes;planeindex < r_fb.water.numwaterplanes;planeindex++, p++)
4809 {
4811 continue;
4812
4814 {
4816 if (rt->colortexture[0] == NULL || rt->depthtexture == NULL)
4817 goto error;
4818 r_refdef.view = myview;
4822 {
4824 if (R_ScissorForBBox(p->mins, p->maxs, myscissor))
4825 {
4826 p->rt_reflection = NULL;
4827 p->rt_refraction = NULL;
4828 p->rt_camera = NULL;
4829 continue;
4830 }
4831 }
4832
4834 // reflected view origin may be in solid, so don't cull with it
4836 // reverse the cullface settings for this render
4839 // combined pvs (based on what can be seen from each surface center)
4841 {
4842 r_refdef.view.usecustompvs = true;
4843 if (p->pvsvalid)
4845 else
4847 }
4848
4851 GL_ScissorTest(false);
4853 GL_ScissorTest(true);
4854 R_View_Update(r_water_scissormode.integer & 2 ? myscissor : NULL);
4857 GL_Scissor(myscissor[0], myscissor[1], myscissor[2], myscissor[3]);
4858 R_RenderScene(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight);
4859
4860 r_fb.water.hideplayer = false;
4861 p->rt_reflection = rt;
4862 }
4863
4864 // render the normal view scene and copy into texture
4865 // (except that a clipping plane should be used to hide everything on one side of the water, and the viewer's weapon model should be omitted)
4867 {
4869 if (rt->colortexture[0] == NULL || rt->depthtexture == NULL)
4870 goto error;
4871 r_refdef.view = myview;
4873 {
4875 if (R_ScissorForBBox(p->mins, p->maxs, myscissor))
4876 {
4877 p->rt_reflection = NULL;
4878 p->rt_refraction = NULL;
4879 p->rt_camera = NULL;
4880 continue;
4881 }
4882 }
4883
4884 // combined pvs (based on what can be seen from each surface center)
4886 {
4887 r_refdef.view.usecustompvs = true;
4888 if (p->pvsvalid)
4890 else
4892 }
4893
4895
4899
4901 {
4902 // we need to perform a matrix transform to render the view... so let's get the transformation matrix
4903 r_fb.water.hideplayer = false; // we don't want to hide the player model from these ones
4907 {
4908 r_refdef.view.usecustompvs = true;
4910 }
4911 }
4912
4914
4916 GL_ScissorTest(false);
4918 GL_ScissorTest(true);
4919 R_View_Update(r_water_scissormode.integer & 2 ? myscissor : NULL);
4922 GL_Scissor(myscissor[0], myscissor[1], myscissor[2], myscissor[3]);
4923 R_RenderScene(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight);
4924
4925 r_fb.water.hideplayer = false;
4926 p->rt_refraction = rt;
4927 }
4928 else if (p->materialflags & MATERIALFLAG_CAMERA)
4929 {
4931 if (rt->colortexture[0] == NULL || rt->depthtexture == NULL)
4932 goto error;
4933 r_refdef.view = myview;
4934
4938
4941 r_refdef.view.frustum_x = 1; // tan(45 * M_PI / 180.0);
4942 r_refdef.view.frustum_y = 1; // tan(45 * M_PI / 180.0);
4943 r_refdef.view.ortho_x = 90; // abused as angle by VM_CL_R_SetView
4944 r_refdef.view.ortho_y = 90; // abused as angle by VM_CL_R_SetView
4945
4946 if(p->camera_entity)
4947 {
4948 // we need to perform a matrix transform to render the view... so let's get the transformation matrix
4950 }
4951
4952 // note: all of the view is used for displaying... so
4953 // there is no use in scissoring
4954
4955 // reverse the cullface settings for this render
4958 // also reverse the view matrix
4959 Matrix4x4_ConcatScale3(&r_refdef.view.matrix, 1, 1, -1); // this serves to invert texcoords in the result, as the copied texture is mapped the wrong way round
4962 {
4963 r_refdef.view.usecustompvs = true;
4965 }
4966
4967 // camera needs no clipplane
4968 r_refdef.view.useclipplane = false;
4969 // TODO: is the camera origin always valid? if so we don't need to clear this
4971
4973
4974 r_fb.water.hideplayer = false;
4975
4977 GL_ScissorTest(false);
4979 GL_ScissorTest(true);
4982 R_RenderScene(rt->fbo, rt->depthtexture, rt->colortexture[0], 0, 0, rt->texturewidth, rt->textureheight);
4983
4984 r_fb.water.hideplayer = false;
4985 p->rt_camera = rt;
4986 }
4987
4988 }
4989 r_fb.water.renderingscene = false;
4990 r_refdef.view = originalview;
4991 R_ResetViewRendering3D(fbo, depthtexture, colortexture, viewx, viewy, viewwidth, viewheight);
4994 goto finish;
4995error:
4996 r_refdef.view = originalview;
4997 r_fb.water.renderingscene = false;
4999 Con_Printf("R_Water_ProcessPlanes: Error: texture creation failed! Turned off r_water.\n");
5000finish:
5001 // lowquality hack, restore cvars
5002 if (qualityreduction > 0)
5003 {
5004 if (qualityreduction >= 1)
5005 {
5006 Cvar_SetValueQuick(&r_shadows, old_r_shadows);
5007 Cvar_SetValueQuick(&r_shadow_realtime_world, old_r_worldrtlight);
5009 }
5010 if (qualityreduction >= 2)
5011 {
5012 Cvar_SetValueQuick(&r_dynamic, old_r_dynamic);
5013 Cvar_SetValueQuick(&r_drawparticles, old_r_particles);
5014 Cvar_SetValueQuick(&r_drawdecals, old_r_decals);
5015 }
5016 }
5017}
qbool CL_VM_TransformView(int entnum, matrix4x4_t *viewmatrix, mplane_t *clipplane, vec3_t visorigin)
Definition csprogs.c:1196
cvar_t r_drawparticles
#define GL_BACK
Definition glquake.h:133
#define GL_FRONT
Definition glquake.h:132
void Matrix4x4_ConcatScale3(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:1784
void Matrix4x4_Reflect(matrix4x4_t *out, double normalx, double normaly, double normalz, double dist, double axisscale)
Definition matrixlib.c:535
void error(string err,...)
int num_pvsclusterbytes
qbool usecustompvs
uses r_refdef.viewcache.pvsbits as-is rather than computing it
Definition render.h:275
int cullface_front
Definition render.h:317
int cameraheight
Definition render.h:865
int camerawidth
Definition render.h:865
int waterheight
Definition render.h:863

References model_t::brush, r_waterstate_waterplane_t::camera_entity, r_waterstate_t::cameraheight, r_waterstate_t::camerawidth, chase_active, CL_VM_TransformView(), r_refdef_view_t::clipplane, r_rendertarget_t::colortexture, r_rendertarget_t::colortextype, Con_Printf(), r_refdef_view_t::cullface_back, r_refdef_view_t::cullface_front, Cvar_SetValueQuick(), r_rendertarget_t::depthtexture, mplane_t::dist, error(), model_brush_t::FatPVS, r_rendertarget_t::fbo, r_refdef_t::fogenabled, r_refdef_view_t::frustum_x, r_refdef_view_t::frustum_y, GL_BACK, GL_FRONT, GL_Scissor(), GL_ScissorTest(), r_refdef_view_t::height, r_waterstate_t::hideplayer, cvar_t::integer, MATERIALFLAG_CAMERA, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_WATERSHADER, r_waterstate_waterplane_t::materialflags, r_refdef_view_t::matrix, Matrix4x4_ConcatScale3(), Matrix4x4_OriginFromMatrix(), Matrix4x4_Reflect(), MAX_EDICTS, r_waterstate_waterplane_t::maxs, r_waterstate_waterplane_t::mins, mplane_t::normal, NULL, model_brush_t::num_pvsclusterbytes, r_waterstate_t::numwaterplanes, r_refdef_view_t::origin, r_refdef_view_t::ortho_x, r_refdef_view_t::ortho_y, r_waterstate_waterplane_t::plane, PlaneClassify(), r_waterstate_waterplane_t::pvsbits, r_waterstate_waterplane_t::pvsvalid, R_AnimCache_CacheVisibleEntities(), R_ClearScreen(), r_drawdecals, r_drawparticles, r_dynamic, r_fb, r_main_mempool, r_refdef, R_RenderScene(), R_RenderTarget_Get(), R_RenderView_UpdateViewVectors(), R_ResetViewRendering3D(), R_ScissorForBBox(), R_SetupView(), r_shadow_realtime_dlight, r_shadow_realtime_world, r_shadows, R_View_Update(), r_water, r_water_cameraentitiesonly, r_water_hideplayer, r_water_lowquality, r_water_scissormode, r_waterstate_t::renderingscene, r_waterstate_waterplane_t::rt_camera, r_waterstate_waterplane_t::rt_reflection, r_waterstate_waterplane_t::rt_refraction, r_framebufferstate_t::rt_screen, r_refdef_t::scene, r_refdef_view_t::showdebug, r_rendertarget_t::textureheight, r_rendertarget_t::texturewidth, TEXTYPE_DEPTHBUFFER24STENCIL8, TEXTYPE_UNUSED, r_refdef_view_t::useclipplane, r_refdef_view_t::usecustompvs, r_refdef_view_t::usevieworiginculling, cvar_t::value, VectorNegate, r_refdef_t::view, r_refdef_t::viewcache, r_framebufferstate_t::water, r_waterstate_t::waterheight, r_waterstate_t::waterplanes, r_waterstate_t::waterwidth, r_refdef_view_t::width, r_refdef_viewcache_t::world_pvsbits, and r_refdef_scene_t::worldmodel.

Referenced by R_RenderWaterPlanes().

◆ R_Water_StartFrame()

static void R_Water_StartFrame ( int viewwidth,
int viewheight )
static

Definition at line 4608 of file gl_rmain.c.

4609{
4610 int waterwidth, waterheight;
4611
4612 if (viewwidth > (int)vid.maxtexturesize_2d || viewheight > (int)vid.maxtexturesize_2d)
4613 return;
4614
4615 // set waterwidth and waterheight to the water resolution that will be
4616 // used (often less than the screen resolution for faster rendering)
4617 waterwidth = (int)bound(16, viewwidth * r_water_resolutionmultiplier.value, viewwidth);
4618 waterheight = (int)bound(16, viewheight * r_water_resolutionmultiplier.value, viewheight);
4619
4621 waterwidth = waterheight = 0;
4622
4623 // set up variables that will be used in shader setup
4624 r_fb.water.waterwidth = waterwidth;
4625 r_fb.water.waterheight = waterheight;
4626 r_fb.water.texturewidth = waterwidth;
4627 r_fb.water.textureheight = waterheight;
4628 r_fb.water.camerawidth = waterwidth;
4629 r_fb.water.cameraheight = waterheight;
4630 r_fb.water.screenscale[0] = 0.5f;
4631 r_fb.water.screenscale[1] = 0.5f;
4632 r_fb.water.screencenter[0] = 0.5f;
4633 r_fb.water.screencenter[1] = 0.5f;
4634 r_fb.water.enabled = waterwidth != 0;
4635
4638}
cvar_t r_lockpvs
Definition gl_rsurf.c:29
#define MAX_WATERPLANES
max number of water planes visible (each one causes additional view renders)
Definition qdefs.h:129
int texturewidth
Definition render.h:864
int textureheight
Definition render.h:864

References bound, r_waterstate_t::cameraheight, r_waterstate_t::camerawidth, r_waterstate_t::enabled, int(), cvar_t::integer, MAX_WATERPLANES, viddef_t::maxtexturesize_2d, r_waterstate_t::maxwaterplanes, r_waterstate_t::numwaterplanes, r_fb, r_lockpvs, r_lockvisibility, r_showsurfaces, r_water, r_water_resolutionmultiplier, r_waterstate_t::screencenter, r_waterstate_t::screenscale, r_waterstate_t::textureheight, r_waterstate_t::texturewidth, cvar_t::value, vid, r_framebufferstate_t::water, r_waterstate_t::waterheight, and r_waterstate_t::waterwidth.

Referenced by R_RenderView().

◆ Render_Init()

void Render_Init ( void )

Definition at line 3420 of file gl_rmain.c.

3421{
3424 GL_Main_Init();
3425 Font_Init();
3426 GL_Draw_Init();
3427 R_Shadow_Init();
3428 R_Sky_Init();
3429 GL_Surf_Init();
3430 Sbar_Init();
3436}
void CL_MeshEntities_Init(void)
Definition cl_main.c:2555
void R_Particles_Init(void)
void Font_Init(void)
Definition ft2.c:443
void gl_backend_init(void)
Definition gl_backend.c:339
void GL_Draw_Init(void)
Definition gl_draw.c:747
void GL_Main_Init(void)
Definition gl_rmain.c:3220
void GL_Surf_Init(void)
Definition gl_rsurf.c:1564
void R_Textures_Init(void)
void Mod_RenderInit(void)
void R_Explosion_Init(void)
void R_LightningBeams_Init(void)
Definition r_lightning.c:96
void R_Shadow_Init(void)
Definition r_shadow.c:601
void R_Sky_Init(void)
Definition r_sky.c:464
void Sbar_Init(void)
Definition sbar.c:359

References CL_MeshEntities_Init(), Font_Init(), gl_backend_init(), GL_Draw_Init(), GL_Main_Init(), GL_Surf_Init(), Mod_RenderInit(), R_Explosion_Init(), R_LightningBeams_Init(), R_Particles_Init(), R_Shadow_Init(), R_Sky_Init(), R_Textures_Init(), and Sbar_Init().

Referenced by CL_Init().

◆ RSurf_ActiveCustomEntity()

void RSurf_ActiveCustomEntity ( const matrix4x4_t * matrix,
const matrix4x4_t * inversematrix,
int entflags,
double shadertime,
float r,
float g,
float b,
float a,
int numvertices,
const float * vertex3f,
const float * texcoord2f,
const float * normal3f,
const float * svector3f,
const float * tvector3f,
const float * color4f,
int numtriangles,
const int * element3i,
const unsigned short * element3s,
qbool wantnormals,
qbool wanttangents )

Definition at line 7146 of file gl_rmain.c.

7147{
7149 if (r != 1.0f || g != 1.0f || b != 1.0f || a != 1.0f) {
7150 // HACK to provide a valid entity with modded colors to R_GetCurrentTexture.
7151 // A better approach could be making this copy only once per frame.
7152 static entity_render_t custom_entity;
7153 int q;
7154 custom_entity = *rsurface.entity;
7155 for (q = 0; q < 3; ++q) {
7156 float colormod = q == 0 ? r : q == 1 ? g : b;
7157 custom_entity.render_fullbright[q] *= colormod;
7158 custom_entity.render_modellight_ambient[q] *= colormod;
7159 custom_entity.render_modellight_diffuse[q] *= colormod;
7160 custom_entity.render_lightmap_ambient[q] *= colormod;
7161 custom_entity.render_lightmap_diffuse[q] *= colormod;
7162 custom_entity.render_rtlight_diffuse[q] *= colormod;
7163 }
7164 custom_entity.alpha *= a;
7165 rsurface.entity = &custom_entity;
7166 }
7169 rsurface.ent_qwskin = -1;
7170 rsurface.ent_flags = entflags;
7171 rsurface.shadertime = r_refdef.scene.time - shadertime;
7172 rsurface.modelnumvertices = numvertices;
7173 rsurface.modelnumtriangles = numtriangles;
7174 rsurface.matrix = *matrix;
7175 rsurface.inversematrix = *inversematrix;
7185 memset(rsurface.frameblend, 0, sizeof(rsurface.frameblend));
7186 rsurface.frameblend[0].lerp = 1;
7187 rsurface.ent_alttextures = false;
7199 if (wanttangents)
7200 {
7201 rsurface.modelvertex3f = (float *)vertex3f;
7202 rsurface.modelsvector3f = svector3f ? (float *)svector3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7203 rsurface.modeltvector3f = tvector3f ? (float *)tvector3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7204 rsurface.modelnormal3f = normal3f ? (float *)normal3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7205 }
7206 else if (wantnormals)
7207 {
7208 rsurface.modelvertex3f = (float *)vertex3f;
7211 rsurface.modelnormal3f = normal3f ? (float *)normal3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7212 }
7213 else
7214 {
7215 rsurface.modelvertex3f = (float *)vertex3f;
7219 }
7229 rsurface.modellightmapcolor4f = (float *)color4f;
7232 rsurface.modeltexcoordtexture2f = (float *)texcoord2f;
7244 rsurface.modelelement3i = (int *)element3i;
7247 rsurface.modelelement3s = (unsigned short *)element3s;
7291
7293 {
7294 if ((wantnormals || wanttangents) && !normal3f)
7295 {
7296 rsurface.modelnormal3f = (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7298 }
7299 if (wanttangents && !svector3f)
7300 {
7301 rsurface.modelsvector3f = (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7302 rsurface.modeltvector3f = (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7304 }
7305 }
7306}
vector colormod
void Matrix4x4_TransformStandardPlane(const matrix4x4_t *in, float x, float y, float z, float d, float *o)
Definition matrixlib.c:1717
double Matrix4x4_ScaleFromMatrix(const matrix4x4_t *in)
Definition matrixlib.c:1805
void Mod_BuildNormals(int firstvertex, int numvertices, int numtriangles, const float *vertex3f, const int *elements, float *normal3f, qbool areaweighting)
void Mod_BuildTextureVectorsFromNormals(int firstvertex, int numvertices, int numtriangles, const float *vertex3f, const float *texcoord2f, const float *normal3f, const int *elements, float *svector3f, float *tvector3f, qbool areaweighting)
@ r_stat_batch_entitycustom_surfaces
Definition r_stats.h:164
@ r_stat_batch_entitycustom_triangles
Definition r_stats.h:166
@ r_stat_batch_entitycustom_vertices
Definition r_stats.h:165
@ r_stat_batch_entitycustom_count
Definition r_stats.h:163
float lerp
Definition client.h:313
int batchskeletalindex4ub_bufferoffset
Definition render.h:696
int modelskeletalweight4ub_bufferoffset
Definition render.h:648
int * batchelement3i
Definition render.h:700
unsigned short * batchelement3s
Definition render.h:703
float * entityskeletaltransform3x4
Definition render.h:618
unsigned char * modelskeletalindex4ub
Definition render.h:643
int modeltvector3f_bufferoffset
Definition render.h:630
int batchskeletalweight4ub_bufferoffset
Definition render.h:699
int batchelement3s_bufferoffset
Definition render.h:705
float * batchtexcoordlightmap2f
Definition render.h:691
int batchnumtriangles
Definition render.h:672
int batchelement3i_bufferoffset
Definition render.h:702
int modelelement3i_bufferoffset
Definition render.h:651
const r_meshbuffer_t * batchtexcoordlightmap2f_vertexbuffer
Definition render.h:692
int modelsvector3f_bufferoffset
Definition render.h:627
unsigned short * modelelement3s
Definition render.h:652
int batchtexcoordlightmap2f_bufferoffset
Definition render.h:693
int modeltexcoordlightmap2f_bufferoffset
Definition render.h:642
int * modellightmapoffsets
Definition render.h:655
const r_meshbuffer_t * modellightmapcolor4f_vertexbuffer
Definition render.h:635
int modelelement3s_bufferoffset
Definition render.h:654
int batchnormal3f_bufferoffset
Definition render.h:684
unsigned char * batchskeletalindex4ub
Definition render.h:694
const r_meshbuffer_t * batchlightmapcolor4f_vertexbuffer
Definition render.h:686
float * modeltvector3f
Definition render.h:628
const r_meshbuffer_t * modeltexcoordlightmap2f_vertexbuffer
Definition render.h:641
const r_meshbuffer_t * batchsvector3f_vertexbuffer
Definition render.h:677
qbool modelgeneratedvertex
Definition render.h:611
float fogmasktabledistmultiplier
Definition render.h:741
float * modeltexcoordtexture2f
Definition render.h:637
int modellightmapcolor4f_bufferoffset
Definition render.h:636
const r_meshbuffer_t * batchtvector3f_vertexbuffer
Definition render.h:680
int batchlightmapcolor4f_bufferoffset
Definition render.h:687
const r_meshbuffer_t * entityskeletaltransform3x4buffer
Definition render.h:619
unsigned char * modelskeletalweight4ub
Definition render.h:646
const r_meshbuffer_t * modelvertex3f_vertexbuffer
Definition render.h:623
const r_meshbuffer_t * modelnormal3f_vertexbuffer
Definition render.h:632
float * modelsvector3f
Definition render.h:625
int modelnormal3f_bufferoffset
Definition render.h:633
int entityskeletaltransform3x4size
Definition render.h:621
const r_meshbuffer_t * modelelement3s_indexbuffer
Definition render.h:653
int batchtvector3f_bufferoffset
Definition render.h:681
int batchfirsttriangle
Definition render.h:671
int entityskeletaltransform3x4offset
Definition render.h:620
const r_meshbuffer_t * modeltvector3f_vertexbuffer
Definition render.h:629
const r_meshbuffer_t * batchtexcoordtexture2f_vertexbuffer
Definition render.h:689
int modelskeletalindex4ub_bufferoffset
Definition render.h:645
const r_meshbuffer_t * batchskeletalweight4ub_vertexbuffer
Definition render.h:698
int modelnumvertices
Definition render.h:656
int entityskeletalnumtransforms
Definition render.h:617
const r_meshbuffer_t * batchelement3i_indexbuffer
Definition render.h:701
float matrixscale
Definition render.h:722
int modelvertex3f_bufferoffset
Definition render.h:624
frameblend_t frameblend[MAX_FRAMEBLENDS]
Definition render.h:725
const r_meshbuffer_t * batchnormal3f_vertexbuffer
Definition render.h:683
int modeltexcoordtexture2f_bufferoffset
Definition render.h:639
const r_meshbuffer_t * modelskeletalindex4ub_vertexbuffer
Definition render.h:644
unsigned char * batchskeletalweight4ub
Definition render.h:697
const r_meshbuffer_t * modelelement3i_indexbuffer
Definition render.h:650
const r_meshbuffer_t * modelsvector3f_vertexbuffer
Definition render.h:626
const r_meshbuffer_t * modelskeletalweight4ub_vertexbuffer
Definition render.h:647
int batchsvector3f_bufferoffset
Definition render.h:678
skeleton_t * skeleton
Definition render.h:726
int batchtexcoordtexture2f_bufferoffset
Definition render.h:690
const r_meshbuffer_t * batchelement3s_indexbuffer
Definition render.h:704
const r_meshbuffer_t * batchskeletalindex4ub_vertexbuffer
Definition render.h:695
qbool batchgeneratedvertex
Definition render.h:665
const r_meshbuffer_t * modeltexcoordtexture2f_vertexbuffer
Definition render.h:638

References a, entity_render_t::alpha, b, rsurfacestate_t::basepolygonfactor, rsurfacestate_t::basepolygonoffset, rsurfacestate_t::batchelement3i, rsurfacestate_t::batchelement3i_bufferoffset, rsurfacestate_t::batchelement3i_indexbuffer, rsurfacestate_t::batchelement3s, rsurfacestate_t::batchelement3s_bufferoffset, rsurfacestate_t::batchelement3s_indexbuffer, rsurfacestate_t::batchfirsttriangle, rsurfacestate_t::batchfirstvertex, rsurfacestate_t::batchgeneratedvertex, rsurfacestate_t::batchlightmapcolor4f, rsurfacestate_t::batchlightmapcolor4f_bufferoffset, rsurfacestate_t::batchlightmapcolor4f_vertexbuffer, rsurfacestate_t::batchnormal3f, rsurfacestate_t::batchnormal3f_bufferoffset, rsurfacestate_t::batchnormal3f_vertexbuffer, rsurfacestate_t::batchnumtriangles, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchskeletalindex4ub, rsurfacestate_t::batchskeletalindex4ub_bufferoffset, rsurfacestate_t::batchskeletalindex4ub_vertexbuffer, rsurfacestate_t::batchskeletalweight4ub, rsurfacestate_t::batchskeletalweight4ub_bufferoffset, rsurfacestate_t::batchskeletalweight4ub_vertexbuffer, rsurfacestate_t::batchsvector3f, rsurfacestate_t::batchsvector3f_bufferoffset, rsurfacestate_t::batchsvector3f_vertexbuffer, rsurfacestate_t::batchtexcoordlightmap2f, rsurfacestate_t::batchtexcoordlightmap2f_bufferoffset, rsurfacestate_t::batchtexcoordlightmap2f_vertexbuffer, rsurfacestate_t::batchtexcoordtexture2f, rsurfacestate_t::batchtexcoordtexture2f_bufferoffset, rsurfacestate_t::batchtexcoordtexture2f_vertexbuffer, rsurfacestate_t::batchtvector3f, rsurfacestate_t::batchtvector3f_bufferoffset, rsurfacestate_t::batchtvector3f_vertexbuffer, rsurfacestate_t::batchvertex3f, rsurfacestate_t::batchvertex3f_bufferoffset, rsurfacestate_t::batchvertex3f_vertexbuffer, colormod, rsurfacestate_t::ent_alttextures, rsurfacestate_t::ent_flags, rsurfacestate_t::ent_qwskin, rsurfacestate_t::ent_skinnum, rsurfacestate_t::entity, rsurfacestate_t::entityskeletalnumtransforms, rsurfacestate_t::entityskeletaltransform3x4, rsurfacestate_t::entityskeletaltransform3x4buffer, rsurfacestate_t::entityskeletaltransform3x4offset, rsurfacestate_t::entityskeletaltransform3x4size, r_refdef_t::fogheightfade, rsurfacestate_t::fogheightfade, rsurfacestate_t::fogmasktabledistmultiplier, FOGMASKTABLEWIDTH, r_refdef_t::fogplane, rsurfacestate_t::fogplane, rsurfacestate_t::fogplaneviewdist, r_refdef_t::fograngerecip, rsurfacestate_t::fograngerecip, rsurfacestate_t::forcecurrenttextureupdate, rsurfacestate_t::frameblend, g, cvar_t::integer, rsurfacestate_t::inversematrix, rsurfacestate_t::inversematrixscale, frameblend_t::lerp, rsurfacestate_t::localvieworigin, rsurfacestate_t::matrix, Matrix4x4_ScaleFromMatrix(), Matrix4x4_Transform(), Matrix4x4_TransformStandardPlane(), rsurfacestate_t::matrixscale, Mod_BuildNormals(), Mod_BuildTextureVectorsFromNormals(), rsurfacestate_t::modelelement3i, rsurfacestate_t::modelelement3i_bufferoffset, rsurfacestate_t::modelelement3i_indexbuffer, rsurfacestate_t::modelelement3s, rsurfacestate_t::modelelement3s_bufferoffset, rsurfacestate_t::modelelement3s_indexbuffer, rsurfacestate_t::modelgeneratedvertex, rsurfacestate_t::modellightmapcolor4f, rsurfacestate_t::modellightmapcolor4f_bufferoffset, rsurfacestate_t::modellightmapcolor4f_vertexbuffer, rsurfacestate_t::modellightmapoffsets, rsurfacestate_t::modelnormal3f, rsurfacestate_t::modelnormal3f_bufferoffset, rsurfacestate_t::modelnormal3f_vertexbuffer, rsurfacestate_t::modelnumtriangles, rsurfacestate_t::modelnumvertices, rsurfacestate_t::modelskeletalindex4ub, rsurfacestate_t::modelskeletalindex4ub_bufferoffset, rsurfacestate_t::modelskeletalindex4ub_vertexbuffer, rsurfacestate_t::modelskeletalweight4ub, rsurfacestate_t::modelskeletalweight4ub_bufferoffset, rsurfacestate_t::modelskeletalweight4ub_vertexbuffer, rsurfacestate_t::modelsurfaces, rsurfacestate_t::modelsvector3f, rsurfacestate_t::modelsvector3f_bufferoffset, rsurfacestate_t::modelsvector3f_vertexbuffer, rsurfacestate_t::modeltexcoordlightmap2f, rsurfacestate_t::modeltexcoordlightmap2f_bufferoffset, rsurfacestate_t::modeltexcoordlightmap2f_vertexbuffer, rsurfacestate_t::modeltexcoordtexture2f, rsurfacestate_t::modeltexcoordtexture2f_bufferoffset, rsurfacestate_t::modeltexcoordtexture2f_vertexbuffer, rsurfacestate_t::modeltvector3f, rsurfacestate_t::modeltvector3f_bufferoffset, rsurfacestate_t::modeltvector3f_vertexbuffer, rsurfacestate_t::modelvertex3f, rsurfacestate_t::modelvertex3f_bufferoffset, rsurfacestate_t::modelvertex3f_vertexbuffer, NULL, r_refdef_view_t::origin, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, r, R_EntityMatrix(), R_FrameData_Alloc(), r_refdef, r_smoothnormals_areaweighting, r_stat_batch_entitycustom_count, r_stat_batch_entitycustom_surfaces, r_stat_batch_entitycustom_triangles, r_stat_batch_entitycustom_vertices, entity_render_t::render_fullbright, entity_render_t::render_lightmap_ambient, entity_render_t::render_lightmap_diffuse, entity_render_t::render_modellight_ambient, entity_render_t::render_modellight_diffuse, entity_render_t::render_rtlight_diffuse, rsurface, r_refdef_t::scene, rsurfacestate_t::shadertime, rsurfacestate_t::skeleton, r_refdef_t::stats, r_refdef_scene_t::time, r_refdef_t::view, and r_refdef_scene_t::worldentity.

Referenced by R_DrawCorona(), R_DrawModelDecals_Entity(), R_DrawNoModel_TransparentCallback(), R_Model_Sprite_Draw_TransparentCallback(), R_Shadow_DrawCursor_TransparentCallback(), R_Shadow_DrawLightSprite_TransparentCallback(), R_SkyBox(), and R_SkySphere().

◆ RSurf_ActiveModelEntity()

void RSurf_ActiveModelEntity ( const entity_render_t * ent,
qbool wantnormals,
qbool wanttangents,
qbool prepass )

Definition at line 6921 of file gl_rmain.c.

6922{
6923 model_t *model = ent->model;
6924 //if (rsurface.entity == ent && (!model->surfmesh.isanimated || (!wantnormals && !wanttangents)))
6925 // return;
6927 rsurface.skeleton = ent->skeleton;
6930 rsurface.ent_qwskin = (ent->entitynumber <= cl.maxclients && ent->entitynumber >= 1 && cls.protocol == PROTOCOL_QUAKEWORLD && cl.scores[ent->entitynumber - 1].qw_skin[0] && !strcmp(ent->model->name, "progs/player.mdl")) ? (ent->entitynumber - 1) : -1;
6931 rsurface.ent_flags = ent->flags;
6935 rsurface.matrix = ent->matrix;
6946 memcpy(rsurface.frameblend, ent->frameblend, sizeof(ent->frameblend));
6950 if (ent->model->brush.submodel && !prepass)
6951 {
6954 }
6955 // if the animcache code decided it should use the shader path, skip the deform step
6961 if (model->surfmesh.isanimated && model->AnimateVertices && !rsurface.entityskeletaltransform3x4)
6962 {
6963 if (ent->animcache_vertex3f)
6964 {
6967 r_refdef.stats[r_stat_batch_entitycache_vertices] += model->surfmesh.num_vertices;
6968 r_refdef.stats[r_stat_batch_entitycache_triangles] += model->surfmesh.num_triangles;
6972 rsurface.modelsvector3f = wanttangents ? ent->animcache_svector3f : NULL;
6975 rsurface.modeltvector3f = wanttangents ? ent->animcache_tvector3f : NULL;
6978 rsurface.modelnormal3f = wantnormals ? ent->animcache_normal3f : NULL;
6981 }
6982 else if (wanttangents)
6983 {
6986 r_refdef.stats[r_stat_batch_entityanimate_vertices] += model->surfmesh.num_vertices;
6987 r_refdef.stats[r_stat_batch_entityanimate_triangles] += model->surfmesh.num_triangles;
6988 rsurface.modelvertex3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
6989 rsurface.modelsvector3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
6990 rsurface.modeltvector3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
6991 rsurface.modelnormal3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7003 }
7004 else if (wantnormals)
7005 {
7008 r_refdef.stats[r_stat_batch_entityanimate_vertices] += model->surfmesh.num_vertices;
7009 r_refdef.stats[r_stat_batch_entityanimate_triangles] += model->surfmesh.num_triangles;
7010 rsurface.modelvertex3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7013 rsurface.modelnormal3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7025 }
7026 else
7027 {
7030 r_refdef.stats[r_stat_batch_entityanimate_vertices] += model->surfmesh.num_vertices;
7031 r_refdef.stats[r_stat_batch_entityanimate_triangles] += model->surfmesh.num_triangles;
7032 rsurface.modelvertex3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7047 }
7049 }
7050 else
7051 {
7053 {
7056 r_refdef.stats[r_stat_batch_entityskeletal_vertices] += model->surfmesh.num_vertices;
7057 r_refdef.stats[r_stat_batch_entityskeletal_triangles] += model->surfmesh.num_triangles;
7058 }
7059 else
7060 {
7063 r_refdef.stats[r_stat_batch_entitystatic_vertices] += model->surfmesh.num_vertices;
7064 r_refdef.stats[r_stat_batch_entitystatic_triangles] += model->surfmesh.num_triangles;
7065 }
7066 rsurface.modelvertex3f = model->surfmesh.data_vertex3f;
7067 rsurface.modelvertex3f_vertexbuffer = model->surfmesh.data_vertex3f_vertexbuffer;
7068 rsurface.modelvertex3f_bufferoffset = model->surfmesh.data_vertex3f_bufferoffset;
7069 rsurface.modelsvector3f = model->surfmesh.data_svector3f;
7070 rsurface.modelsvector3f_vertexbuffer = model->surfmesh.data_svector3f_vertexbuffer;
7071 rsurface.modelsvector3f_bufferoffset = model->surfmesh.data_svector3f_bufferoffset;
7072 rsurface.modeltvector3f = model->surfmesh.data_tvector3f;
7073 rsurface.modeltvector3f_vertexbuffer = model->surfmesh.data_tvector3f_vertexbuffer;
7074 rsurface.modeltvector3f_bufferoffset = model->surfmesh.data_tvector3f_bufferoffset;
7075 rsurface.modelnormal3f = model->surfmesh.data_normal3f;
7076 rsurface.modelnormal3f_vertexbuffer = model->surfmesh.data_normal3f_vertexbuffer;
7077 rsurface.modelnormal3f_bufferoffset = model->surfmesh.data_normal3f_bufferoffset;
7079 }
7080 rsurface.modellightmapcolor4f = model->surfmesh.data_lightmapcolor4f;
7081 rsurface.modellightmapcolor4f_vertexbuffer = model->surfmesh.data_lightmapcolor4f_vertexbuffer;
7082 rsurface.modellightmapcolor4f_bufferoffset = model->surfmesh.data_lightmapcolor4f_bufferoffset;
7083 rsurface.modeltexcoordtexture2f = model->surfmesh.data_texcoordtexture2f;
7084 rsurface.modeltexcoordtexture2f_vertexbuffer = model->surfmesh.data_texcoordtexture2f_vertexbuffer;
7085 rsurface.modeltexcoordtexture2f_bufferoffset = model->surfmesh.data_texcoordtexture2f_bufferoffset;
7086 rsurface.modeltexcoordlightmap2f = model->surfmesh.data_texcoordlightmap2f;
7087 rsurface.modeltexcoordlightmap2f_vertexbuffer = model->surfmesh.data_texcoordlightmap2f_vertexbuffer;
7088 rsurface.modeltexcoordlightmap2f_bufferoffset = model->surfmesh.data_texcoordlightmap2f_bufferoffset;
7089 rsurface.modelskeletalindex4ub = model->surfmesh.data_skeletalindex4ub;
7090 rsurface.modelskeletalindex4ub_vertexbuffer = model->surfmesh.data_skeletalindex4ub_vertexbuffer;
7091 rsurface.modelskeletalindex4ub_bufferoffset = model->surfmesh.data_skeletalindex4ub_bufferoffset;
7092 rsurface.modelskeletalweight4ub = model->surfmesh.data_skeletalweight4ub;
7093 rsurface.modelskeletalweight4ub_vertexbuffer = model->surfmesh.data_skeletalweight4ub_vertexbuffer;
7094 rsurface.modelskeletalweight4ub_bufferoffset = model->surfmesh.data_skeletalweight4ub_bufferoffset;
7095 rsurface.modelelement3i = model->surfmesh.data_element3i;
7096 rsurface.modelelement3i_indexbuffer = model->surfmesh.data_element3i_indexbuffer;
7097 rsurface.modelelement3i_bufferoffset = model->surfmesh.data_element3i_bufferoffset;
7098 rsurface.modelelement3s = model->surfmesh.data_element3s;
7099 rsurface.modelelement3s_indexbuffer = model->surfmesh.data_element3s_indexbuffer;
7100 rsurface.modelelement3s_bufferoffset = model->surfmesh.data_element3s_bufferoffset;
7101 rsurface.modellightmapoffsets = model->surfmesh.data_lightmapoffsets;
7102 rsurface.modelnumvertices = model->surfmesh.num_vertices;
7103 rsurface.modelnumtriangles = model->surfmesh.num_triangles;
7104 rsurface.modelsurfaces = model->data_surfaces;
7144}
@ PROTOCOL_QUAKEWORLD
quakeworld protocol
Definition common.h:145
@ r_stat_batch_entityanimate_count
Definition r_stats.h:151
@ r_stat_batch_entitycache_triangles
Definition r_stats.h:150
@ r_stat_batch_entityskeletal_vertices
Definition r_stats.h:157
@ r_stat_batch_entitystatic_surfaces
Definition r_stats.h:160
@ r_stat_batch_entitycache_vertices
Definition r_stats.h:149
@ r_stat_batch_entitycache_surfaces
Definition r_stats.h:148
@ r_stat_batch_entityanimate_surfaces
Definition r_stats.h:152
@ r_stat_batch_entitystatic_triangles
Definition r_stats.h:162
@ r_stat_batch_entitystatic_count
Definition r_stats.h:159
@ r_stat_batch_entityskeletal_surfaces
Definition r_stats.h:156
@ r_stat_batch_entitystatic_vertices
Definition r_stats.h:161
@ r_stat_batch_entityanimate_vertices
Definition r_stats.h:153
@ r_stat_batch_entitycache_count
Definition r_stats.h:147
@ r_stat_batch_entityskeletal_triangles
Definition r_stats.h:158
@ r_stat_batch_entityskeletal_count
Definition r_stats.h:155
@ r_stat_batch_entityanimate_triangles
Definition r_stats.h:154
protocolversion_t protocol
Definition client.h:617
vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT]
Definition client.h:445

References entity_render_t::animcache_normal3f, entity_render_t::animcache_normal3f_bufferoffset, entity_render_t::animcache_normal3f_vertexbuffer, entity_render_t::animcache_skeletaltransform3x4, entity_render_t::animcache_skeletaltransform3x4buffer, entity_render_t::animcache_skeletaltransform3x4offset, entity_render_t::animcache_skeletaltransform3x4size, entity_render_t::animcache_svector3f, entity_render_t::animcache_svector3f_bufferoffset, entity_render_t::animcache_svector3f_vertexbuffer, entity_render_t::animcache_tvector3f, entity_render_t::animcache_tvector3f_bufferoffset, entity_render_t::animcache_tvector3f_vertexbuffer, entity_render_t::animcache_vertex3f, entity_render_t::animcache_vertex3f_bufferoffset, entity_render_t::animcache_vertex3f_vertexbuffer, rsurfacestate_t::basepolygonfactor, rsurfacestate_t::basepolygonoffset, rsurfacestate_t::batchelement3i, rsurfacestate_t::batchelement3i_bufferoffset, rsurfacestate_t::batchelement3i_indexbuffer, rsurfacestate_t::batchelement3s, rsurfacestate_t::batchelement3s_bufferoffset, rsurfacestate_t::batchelement3s_indexbuffer, rsurfacestate_t::batchfirsttriangle, rsurfacestate_t::batchfirstvertex, rsurfacestate_t::batchgeneratedvertex, rsurfacestate_t::batchlightmapcolor4f, rsurfacestate_t::batchlightmapcolor4f_bufferoffset, rsurfacestate_t::batchlightmapcolor4f_vertexbuffer, rsurfacestate_t::batchnormal3f, rsurfacestate_t::batchnormal3f_bufferoffset, rsurfacestate_t::batchnormal3f_vertexbuffer, rsurfacestate_t::batchnumtriangles, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchskeletalindex4ub, rsurfacestate_t::batchskeletalindex4ub_bufferoffset, rsurfacestate_t::batchskeletalindex4ub_vertexbuffer, rsurfacestate_t::batchskeletalweight4ub, rsurfacestate_t::batchskeletalweight4ub_bufferoffset, rsurfacestate_t::batchskeletalweight4ub_vertexbuffer, rsurfacestate_t::batchsvector3f, rsurfacestate_t::batchsvector3f_bufferoffset, rsurfacestate_t::batchsvector3f_vertexbuffer, rsurfacestate_t::batchtexcoordlightmap2f, rsurfacestate_t::batchtexcoordlightmap2f_bufferoffset, rsurfacestate_t::batchtexcoordlightmap2f_vertexbuffer, rsurfacestate_t::batchtexcoordtexture2f, rsurfacestate_t::batchtexcoordtexture2f_bufferoffset, rsurfacestate_t::batchtexcoordtexture2f_vertexbuffer, rsurfacestate_t::batchtvector3f, rsurfacestate_t::batchtvector3f_bufferoffset, rsurfacestate_t::batchtvector3f_vertexbuffer, rsurfacestate_t::batchvertex3f, rsurfacestate_t::batchvertex3f_bufferoffset, rsurfacestate_t::batchvertex3f_vertexbuffer, model_t::brush, cl, cls, rsurfacestate_t::ent_alttextures, rsurfacestate_t::ent_flags, rsurfacestate_t::ent_qwskin, rsurfacestate_t::ent_skinnum, rsurfacestate_t::entity, entity_render_t::entitynumber, rsurfacestate_t::entityskeletalnumtransforms, rsurfacestate_t::entityskeletaltransform3x4, rsurfacestate_t::entityskeletaltransform3x4buffer, rsurfacestate_t::entityskeletaltransform3x4offset, rsurfacestate_t::entityskeletaltransform3x4size, entity_render_t::flags, r_refdef_t::fogheightfade, rsurfacestate_t::fogheightfade, rsurfacestate_t::fogmasktabledistmultiplier, FOGMASKTABLEWIDTH, r_refdef_t::fogplane, rsurfacestate_t::fogplane, r_refdef_t::fogplaneviewdist, rsurfacestate_t::fogplaneviewdist, r_refdef_t::fograngerecip, rsurfacestate_t::fograngerecip, rsurfacestate_t::forcecurrenttextureupdate, framegroupblend_t::frame, entity_render_t::frameblend, rsurfacestate_t::frameblend, entity_render_t::framegroupblend, cvar_t::integer, entity_render_t::inversematrix, rsurfacestate_t::inversematrix, rsurfacestate_t::inversematrixscale, rsurfacestate_t::localvieworigin, entity_render_t::matrix, rsurfacestate_t::matrix, Matrix4x4_ScaleFromMatrix(), Matrix4x4_Transform(), Matrix4x4_TransformStandardPlane(), rsurfacestate_t::matrixscale, client_state_t::maxclients, entity_render_t::model, model, rsurfacestate_t::modelelement3i, rsurfacestate_t::modelelement3i_bufferoffset, rsurfacestate_t::modelelement3i_indexbuffer, rsurfacestate_t::modelelement3s, rsurfacestate_t::modelelement3s_bufferoffset, rsurfacestate_t::modelelement3s_indexbuffer, rsurfacestate_t::modelgeneratedvertex, rsurfacestate_t::modellightmapcolor4f, rsurfacestate_t::modellightmapcolor4f_bufferoffset, rsurfacestate_t::modellightmapcolor4f_vertexbuffer, rsurfacestate_t::modellightmapoffsets, rsurfacestate_t::modelnormal3f, rsurfacestate_t::modelnormal3f_bufferoffset, rsurfacestate_t::modelnormal3f_vertexbuffer, rsurfacestate_t::modelnumtriangles, rsurfacestate_t::modelnumvertices, rsurfacestate_t::modelskeletalindex4ub, rsurfacestate_t::modelskeletalindex4ub_bufferoffset, rsurfacestate_t::modelskeletalindex4ub_vertexbuffer, rsurfacestate_t::modelskeletalweight4ub, rsurfacestate_t::modelskeletalweight4ub_bufferoffset, rsurfacestate_t::modelskeletalweight4ub_vertexbuffer, rsurfacestate_t::modelsurfaces, rsurfacestate_t::modelsvector3f, rsurfacestate_t::modelsvector3f_bufferoffset, rsurfacestate_t::modelsvector3f_vertexbuffer, rsurfacestate_t::modeltexcoordlightmap2f, rsurfacestate_t::modeltexcoordlightmap2f_bufferoffset, rsurfacestate_t::modeltexcoordlightmap2f_vertexbuffer, rsurfacestate_t::modeltexcoordtexture2f, rsurfacestate_t::modeltexcoordtexture2f_bufferoffset, rsurfacestate_t::modeltexcoordtexture2f_vertexbuffer, rsurfacestate_t::modeltvector3f, rsurfacestate_t::modeltvector3f_bufferoffset, rsurfacestate_t::modeltvector3f_vertexbuffer, rsurfacestate_t::modelvertex3f, rsurfacestate_t::modelvertex3f_bufferoffset, rsurfacestate_t::modelvertex3f_vertexbuffer, model_t::name, NULL, r_refdef_view_t::origin, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, client_static_t::protocol, PROTOCOL_QUAKEWORLD, scoreboard_t::qw_skin, R_EntityMatrix(), R_FrameData_Alloc(), r_fullbright, r_fullbright_directed, r_polygonoffset_submodel_factor, r_polygonoffset_submodel_offset, r_refdef, r_stat_batch_entityanimate_count, r_stat_batch_entityanimate_surfaces, r_stat_batch_entityanimate_triangles, r_stat_batch_entityanimate_vertices, r_stat_batch_entitycache_count, r_stat_batch_entitycache_surfaces, r_stat_batch_entitycache_triangles, r_stat_batch_entitycache_vertices, r_stat_batch_entityskeletal_count, r_stat_batch_entityskeletal_surfaces, r_stat_batch_entityskeletal_triangles, r_stat_batch_entityskeletal_vertices, r_stat_batch_entitystatic_count, r_stat_batch_entitystatic_surfaces, r_stat_batch_entitystatic_triangles, r_stat_batch_entitystatic_vertices, RENDER_DYNAMICMODELLIGHT, RENDER_LIGHT, rsurface, r_refdef_t::scene, client_state_t::scores, entity_render_t::shadertime, rsurfacestate_t::shadertime, entity_render_t::skeleton, rsurfacestate_t::skeleton, entity_render_t::skinnum, r_refdef_t::stats, model_brush_t::submodel, r_refdef_scene_t::time, entity_render_t::userwavefunc_param, rsurfacestate_t::userwavefunc_param, cvar_t::value, and r_refdef_t::view.

Referenced by R_DecalSystem_SplatEntity(), R_DrawBBoxMesh(), R_DrawModelDecals_Entity(), R_DrawModelSurfaces(), R_DrawParticle_TransparentCallback(), R_DrawSurface_TransparentCallback(), R_Mod_DrawAddWaterPlanes(), R_Mod_GetLightInfo(), R_Shadow_DrawCoronas(), R_Shadow_DrawEntityShadow(), R_Shadow_DrawModelShadowMaps(), R_Shadow_DrawWorldLight(), R_Shadow_DrawWorldShadow_ShadowMap(), and R_Shadow_SetupEntityLight().

◆ RSurf_DrawBatch()

void RSurf_DrawBatch ( void )

Definition at line 8477 of file gl_rmain.c.

8478{
8479 // sometimes a zero triangle surface (usually a degenerate patch) makes it
8480 // through the pipeline, killing it earlier in the pipeline would have
8481 // per-surface overhead rather than per-batch overhead, so it's best to
8482 // reject it here, before it hits glDraw.
8483 if (rsurface.batchnumtriangles == 0)
8484 return;
8485#if 0
8486 // batch debugging code
8488 {
8489 int i;
8490 int j;
8491 int c;
8492 const int *e;
8494 for (i = 0;i < rsurface.batchnumtriangles*3;i++)
8495 {
8496 c = e[i];
8497 for (j = 0;j < rsurface.entity->model->num_surfaces;j++)
8498 {
8500 {
8502 Sys_Error("RSurf_DrawBatch: index %i uses different texture (%s) than surface %i which it belongs to (which uses %s)\n", c, rsurface.texture->name, j, rsurface.modelsurfaces[j].texture->name);
8503 break;
8504 }
8505 }
8506 }
8507 }
8508#endif
8510 {
8511 // issue multiple draws rather than copying index data
8512 int numsurfaces = rsurface.batchmultidrawnumsurfaces;
8513 const msurface_t **surfacelist = rsurface.batchmultidrawsurfacelist;
8514 int i, j, k, firstvertex, endvertex, firsttriangle, endtriangle;
8515 for (i = 0;i < numsurfaces;)
8516 {
8517 // combine consecutive surfaces as one draw
8518 for (k = i, j = i + 1;j < numsurfaces;k = j, j++)
8519 if (surfacelist[j] != surfacelist[k] + 1)
8520 break;
8521 firstvertex = surfacelist[i]->num_firstvertex;
8522 endvertex = surfacelist[k]->num_firstvertex + surfacelist[k]->num_vertices;
8523 firsttriangle = surfacelist[i]->num_firsttriangle;
8524 endtriangle = surfacelist[k]->num_firsttriangle + surfacelist[k]->num_triangles;
8526 i = j;
8527 }
8528 }
8529 else
8530 {
8531 // there is only one consecutive run of index data (may have been combined)
8533 }
8534}
surfmesh_t surfmesh
const msurface_t ** batchmultidrawsurfacelist
Definition render.h:668
int batchmultidrawnumsurfaces
Definition render.h:667
qbool batchmultidraw
Definition render.h:666
float * data_vertex3f
char name[64]

References rsurfacestate_t::batchelement3i, rsurfacestate_t::batchelement3i_bufferoffset, rsurfacestate_t::batchelement3i_indexbuffer, rsurfacestate_t::batchelement3s, rsurfacestate_t::batchelement3s_bufferoffset, rsurfacestate_t::batchelement3s_indexbuffer, rsurfacestate_t::batchfirsttriangle, rsurfacestate_t::batchfirstvertex, rsurfacestate_t::batchmultidraw, rsurfacestate_t::batchmultidrawnumsurfaces, rsurfacestate_t::batchmultidrawsurfacelist, rsurfacestate_t::batchnumtriangles, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchvertex3f, surfmesh_t::data_vertex3f, rsurfacestate_t::entity, i, cvar_t::integer, entity_render_t::model, rsurfacestate_t::modelsurfaces, texture_t::name, msurface_t::num_firsttriangle, msurface_t::num_firstvertex, model_t::num_surfaces, msurface_t::num_triangles, msurface_t::num_vertices, R_Mesh_Draw(), r_refdef, r_test, rsurface, r_refdef_t::scene, model_t::surfmesh, Sys_Error(), msurface_t::texture, rsurfacestate_t::texture, and r_refdef_scene_t::worldentity.

Referenced by R_DrawDebugModel(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_GL20(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_Mod_DrawShadowMap(), R_Shadow_RenderLighting_Light_GLSL(), and R_Shadow_RenderLighting_VisibleLighting().

◆ RSurf_FindWaterPlaneForSurface()

static int RSurf_FindWaterPlaneForSurface ( const msurface_t * surface)
static

Definition at line 8536 of file gl_rmain.c.

8537{
8538 // pick the closest matching water plane
8539 int planeindex, vertexindex, bestplaneindex = -1;
8540 float d, bestd;
8541 vec3_t vert;
8542 const float *v;
8544 qbool prepared = false;
8545 bestd = 0;
8546 for (planeindex = 0, p = r_fb.water.waterplanes;planeindex < r_fb.water.numwaterplanes;planeindex++, p++)
8547 {
8549 continue;
8550 d = 0;
8551 if(!prepared)
8552 {
8554 prepared = true;
8555 if(rsurface.batchnumvertices == 0)
8556 break;
8557 }
8558 for (vertexindex = 0, v = rsurface.batchvertex3f + rsurface.batchfirstvertex * 3;vertexindex < rsurface.batchnumvertices;vertexindex++, v += 3)
8559 {
8561 d += fabs(PlaneDiff(vert, &p->plane));
8562 }
8563 if (bestd > d || bestplaneindex < 0)
8564 {
8565 bestd = d;
8566 bestplaneindex = planeindex;
8567 }
8568 }
8569 return bestplaneindex;
8570 // NOTE: this MAY return a totally unrelated water plane; we can ignore
8571 // this situation though, as it might be better to render single larger
8572 // batches with useless stuff (backface culled for example) than to
8573 // render multiple smaller batches
8574}

References rsurfacestate_t::batchfirstvertex, BATCHNEED_ARRAY_VERTEX, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchvertex3f, r_waterstate_waterplane_t::camera_entity, texture_t::camera_entity, fabs(), rsurfacestate_t::matrix, Matrix4x4_Transform(), r_waterstate_t::numwaterplanes, r_waterstate_waterplane_t::plane, PlaneDiff, r_fb, RSurf_PrepareVerticesForBatch(), rsurface, rsurfacestate_t::texture, v, r_framebufferstate_t::water, and r_waterstate_t::waterplanes.

Referenced by R_DrawTextureSurfaceList_GL20().

◆ RSurf_FogPoint()

float RSurf_FogPoint ( const float * v)

Definition at line 7308 of file gl_rmain.c.

7309{
7310 // this code is identical to the USEFOGINSIDE/USEFOGOUTSIDE code in the shader
7314 float fogfrac;
7315 unsigned int fogmasktableindex;
7318 else
7320 fogmasktableindex = (unsigned int)(VectorDistance(r_refdef.view.origin, v) * fogfrac * r_refdef.fogmasktabledistmultiplier);
7321 return r_refdef.fogmasktable[min(fogmasktableindex, FOGMASKTABLEWIDTH - 1)];
7322}
#define VectorDistance(a, b)
Definition mathlib.h:108
uniform highp float FogHeightFade
float fogfrac
vec3 float FogPlaneVertexDist
uniform highp float FogPlaneViewDist

References DotProduct, fogfrac, FogHeightFade, r_refdef_t::fogheightfade, r_refdef_t::fogmasktable, r_refdef_t::fogmasktabledistmultiplier, FOGMASKTABLEWIDTH, r_refdef_t::fogplane, FogPlaneVertexDist, r_refdef_t::fogplaneviewabove, FogPlaneViewDist, r_refdef_t::fogplaneviewdist, int(), max, min, r_refdef_view_t::origin, r_refdef, v, VectorDistance, and r_refdef_t::view.

◆ RSurf_FogVertex()

float RSurf_FogVertex ( const float * v)

Definition at line 7324 of file gl_rmain.c.

7325{
7326 // this code is identical to the USEFOGINSIDE/USEFOGOUTSIDE code in the shader
7330 float fogfrac;
7331 unsigned int fogmasktableindex;
7334 else
7337 return r_refdef.fogmasktable[min(fogmasktableindex, FOGMASKTABLEWIDTH - 1)];
7338}

References DotProduct, fogfrac, FogHeightFade, rsurfacestate_t::fogheightfade, r_refdef_t::fogmasktable, rsurfacestate_t::fogmasktabledistmultiplier, FOGMASKTABLEWIDTH, rsurfacestate_t::fogplane, FogPlaneVertexDist, r_refdef_t::fogplaneviewabove, FogPlaneViewDist, rsurfacestate_t::fogplaneviewdist, int(), rsurfacestate_t::localvieworigin, max, min, r_refdef, rsurface, v, and VectorDistance.

Referenced by R_DrawBBoxMesh(), R_DrawModelDecals_Entity(), R_DrawNoModel_TransparentCallback(), and R_DrawParticle_TransparentCallback().

◆ RSurf_PrepareVerticesForBatch()

void RSurf_PrepareVerticesForBatch ( int batchneed,
int texturenumsurfaces,
const msurface_t ** texturesurfacelist )

Definition at line 7388 of file gl_rmain.c.

7389{
7390 int deformindex;
7391 int firsttriangle;
7392 int numtriangles;
7393 int firstvertex;
7394 int endvertex;
7395 int numvertices;
7396 int surfacefirsttriangle;
7397 int surfacenumtriangles;
7398 int surfacefirstvertex;
7399 int surfaceendvertex;
7400 int surfacenumvertices;
7401 int batchnumsurfaces = texturenumsurfaces;
7402 int batchnumvertices;
7403 int batchnumtriangles;
7404 int i, j;
7405 qbool gaps;
7406 qbool dynamicvertex;
7407 float amplitude;
7408 float animpos;
7409 float center[3], forward[3], right[3], up[3], v[3], newforward[3], newright[3], newup[3];
7410 float waveparms[4];
7411 unsigned char *ub;
7412 q3shaderinfo_deform_t *deform;
7413 const msurface_t *surface, *firstsurface;
7414 if (!texturenumsurfaces)
7415 return;
7416 // find vertex range of this surface batch
7417 gaps = false;
7418 firstsurface = texturesurfacelist[0];
7419 firsttriangle = firstsurface->num_firsttriangle;
7420 batchnumvertices = 0;
7421 batchnumtriangles = 0;
7422 firstvertex = endvertex = firstsurface->num_firstvertex;
7423 for (i = 0;i < texturenumsurfaces;i++)
7424 {
7425 surface = texturesurfacelist[i];
7426 if (surface != firstsurface + i)
7427 gaps = true;
7428 surfacefirstvertex = surface->num_firstvertex;
7429 surfaceendvertex = surfacefirstvertex + surface->num_vertices;
7430 surfacenumvertices = surface->num_vertices;
7431 surfacenumtriangles = surface->num_triangles;
7432 if (firstvertex > surfacefirstvertex)
7433 firstvertex = surfacefirstvertex;
7434 if (endvertex < surfaceendvertex)
7435 endvertex = surfaceendvertex;
7436 batchnumvertices += surfacenumvertices;
7437 batchnumtriangles += surfacenumtriangles;
7438 }
7439
7441 if (gaps)
7443 r_refdef.stats[r_stat_batch_surfaces] += batchnumsurfaces;
7444 r_refdef.stats[r_stat_batch_vertices] += batchnumvertices;
7445 r_refdef.stats[r_stat_batch_triangles] += batchnumtriangles;
7446
7447 // we now know the vertex range used, and if there are any gaps in it
7448 rsurface.batchfirstvertex = firstvertex;
7449 rsurface.batchnumvertices = endvertex - firstvertex;
7450 rsurface.batchfirsttriangle = firsttriangle;
7451 rsurface.batchnumtriangles = batchnumtriangles;
7452
7453 // check if any dynamic vertex processing must occur
7454 dynamicvertex = false;
7455
7456 // we must use vertexbuffers for rendering, we can upload vertex buffers
7457 // easily enough but if the basevertex is non-zero it becomes more
7458 // difficult, so force dynamicvertex path in that case - it's suboptimal
7459 // but the most optimal case is to have the geometry sources provide their
7460 // own anyway.
7461 if (!rsurface.modelvertex3f_vertexbuffer && firstvertex != 0)
7462 dynamicvertex = true;
7463
7464 // a cvar to force the dynamic vertex path to be taken, for debugging
7466 {
7467 if (!dynamicvertex)
7468 {
7473 }
7474 dynamicvertex = true;
7475 }
7476
7477 // if there is a chance of animated vertex colors, it's a dynamic batch
7478 if ((batchneed & BATCHNEED_ARRAY_VERTEXCOLOR) && texturesurfacelist[0]->lightmapinfo)
7479 {
7480 if (!dynamicvertex)
7481 {
7486 }
7487 dynamicvertex = true;
7488 }
7489
7490 for (deformindex = 0, deform = rsurface.texture->deforms;deformindex < Q3MAXDEFORMS && deform->deform && r_deformvertexes.integer;deformindex++, deform++)
7491 {
7492 switch (deform->deform)
7493 {
7494 default:
7496 case Q3DEFORM_TEXT0:
7497 case Q3DEFORM_TEXT1:
7498 case Q3DEFORM_TEXT2:
7499 case Q3DEFORM_TEXT3:
7500 case Q3DEFORM_TEXT4:
7501 case Q3DEFORM_TEXT5:
7502 case Q3DEFORM_TEXT6:
7503 case Q3DEFORM_TEXT7:
7504 case Q3DEFORM_NONE:
7505 break;
7507 if (!dynamicvertex)
7508 {
7513 }
7514 dynamicvertex = true;
7516 break;
7518 if (!dynamicvertex)
7519 {
7524 }
7525 dynamicvertex = true;
7527 break;
7528 case Q3DEFORM_NORMAL:
7529 if (!dynamicvertex)
7530 {
7535 }
7536 dynamicvertex = true;
7538 break;
7539 case Q3DEFORM_WAVE:
7540 if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
7541 break; // if wavefunc is a nop, ignore this transform
7542 if (!dynamicvertex)
7543 {
7548 }
7549 dynamicvertex = true;
7551 break;
7552 case Q3DEFORM_BULGE:
7553 if (!dynamicvertex)
7554 {
7559 }
7560 dynamicvertex = true;
7562 break;
7563 case Q3DEFORM_MOVE:
7564 if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
7565 break; // if wavefunc is a nop, ignore this transform
7566 if (!dynamicvertex)
7567 {
7572 }
7573 dynamicvertex = true;
7574 batchneed |= BATCHNEED_ARRAY_VERTEX;
7575 break;
7576 }
7577 }
7579 {
7581 {
7582 default:
7583 case Q3TCGEN_TEXTURE:
7584 break;
7585 case Q3TCGEN_LIGHTMAP:
7586 if (!dynamicvertex)
7587 {
7592 }
7593 dynamicvertex = true;
7594 batchneed |= BATCHNEED_ARRAY_LIGHTMAP;
7595 break;
7596 case Q3TCGEN_VECTOR:
7597 if (!dynamicvertex)
7598 {
7603 }
7604 dynamicvertex = true;
7605 batchneed |= BATCHNEED_ARRAY_VERTEX;
7606 break;
7608 if (!dynamicvertex)
7609 {
7614 }
7615 dynamicvertex = true;
7617 break;
7618 }
7620 {
7621 if (!dynamicvertex)
7622 {
7627 }
7628 dynamicvertex = true;
7630 }
7631 }
7632
7633 // the caller can specify BATCHNEED_NOGAPS to force a batch with
7634 // firstvertex = 0 and endvertex = numvertices (no gaps, no firstvertex),
7635 // we ensure this by treating the vertex batch as dynamic...
7636 if ((batchneed & BATCHNEED_ALWAYSCOPY) || ((batchneed & BATCHNEED_NOGAPS) && (gaps || firstvertex > 0)))
7637 {
7638 if (!dynamicvertex)
7639 {
7644 }
7645 dynamicvertex = true;
7646 }
7647
7648 // if we're going to have to apply the skeletal transform manually, we need to batch the skeletal data
7649 if (dynamicvertex && rsurface.entityskeletaltransform3x4)
7650 batchneed |= BATCHNEED_ARRAY_SKELETAL;
7651
7690
7691 // if any dynamic vertex processing has to occur in software, we copy the
7692 // entire surface list together before processing to rebase the vertices
7693 // to start at 0 (otherwise we waste a lot of room in a vertex buffer).
7694 //
7695 // if any gaps exist and we do not have a static vertex buffer, we have to
7696 // copy the surface list together to avoid wasting upload bandwidth on the
7697 // vertices in the gaps.
7698 //
7699 // if gaps exist and we have a static vertex buffer, we can choose whether
7700 // to combine the index buffer ranges into one dynamic index buffer or
7701 // simply issue multiple glDrawElements calls (BATCHNEED_ALLOWMULTIDRAW).
7702 //
7703 // in many cases the batch is reduced to one draw call.
7704
7705 rsurface.batchmultidraw = false;
7708
7709 if (!dynamicvertex)
7710 {
7711 // static vertex data, just set pointers...
7713 // if there are gaps, we want to build a combined index buffer,
7714 // otherwise use the original static buffer with an appropriate offset
7715 if (gaps)
7716 {
7722 {
7723 rsurface.batchmultidraw = true;
7724 rsurface.batchmultidrawnumsurfaces = texturenumsurfaces;
7725 rsurface.batchmultidrawsurfacelist = texturesurfacelist;
7726 return;
7727 }
7728 // build a new triangle elements array for this batch
7729 rsurface.batchelement3i = (int *)R_FrameData_Alloc(batchnumtriangles * sizeof(int[3]));
7731 numtriangles = 0;
7732 for (i = 0;i < texturenumsurfaces;i++)
7733 {
7734 surfacefirsttriangle = texturesurfacelist[i]->num_firsttriangle;
7735 surfacenumtriangles = texturesurfacelist[i]->num_triangles;
7736 memcpy(rsurface.batchelement3i + 3*numtriangles, rsurface.modelelement3i + 3*surfacefirsttriangle, surfacenumtriangles*sizeof(int[3]));
7737 numtriangles += surfacenumtriangles;
7738 }
7744 if (endvertex <= 65536)
7745 {
7746 // make a 16bit (unsigned short) index array if possible
7747 rsurface.batchelement3s = (unsigned short *)R_FrameData_Alloc(batchnumtriangles * sizeof(unsigned short[3]));
7748 for (i = 0;i < numtriangles*3;i++)
7750 }
7751 }
7752 else
7753 {
7755 r_refdef.stats[r_stat_batch_fast_surfaces] += batchnumsurfaces;
7756 r_refdef.stats[r_stat_batch_fast_vertices] += batchnumvertices;
7757 r_refdef.stats[r_stat_batch_fast_triangles] += batchnumtriangles;
7758 }
7759 return;
7760 }
7761
7762 // something needs software processing, do it for real...
7763 // we only directly handle separate array data in this case and then
7764 // generate interleaved data if needed...
7767 r_refdef.stats[r_stat_batch_dynamic_surfaces] += batchnumsurfaces;
7768 r_refdef.stats[r_stat_batch_dynamic_vertices] += batchnumvertices;
7769 r_refdef.stats[r_stat_batch_dynamic_triangles] += batchnumtriangles;
7770
7771 // now copy the vertex data into a combined array and make an index array
7772 // (this is what Quake3 does all the time)
7773 // we also apply any skeletal animation here that would have been done in
7774 // the vertex shader, because most of the dynamic vertex animation cases
7775 // need actual vertex positions and normals
7776 //if (dynamicvertex)
7777 {
7805 rsurface.batchelement3i = (int *)R_FrameData_Alloc(batchnumtriangles * sizeof(int[3]));
7814 // we'll only be setting up certain arrays as needed
7815 if (batchneed & BATCHNEED_ARRAY_VERTEX)
7816 rsurface.batchvertex3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7817 if (batchneed & BATCHNEED_ARRAY_NORMAL)
7818 rsurface.batchnormal3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7819 if (batchneed & BATCHNEED_ARRAY_VECTOR)
7820 {
7821 rsurface.batchsvector3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7822 rsurface.batchtvector3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7823 }
7824 if (batchneed & BATCHNEED_ARRAY_VERTEXCOLOR)
7825 rsurface.batchlightmapcolor4f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[4]));
7826 if (batchneed & BATCHNEED_ARRAY_TEXCOORD)
7827 rsurface.batchtexcoordtexture2f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
7828 if (batchneed & BATCHNEED_ARRAY_LIGHTMAP)
7829 rsurface.batchtexcoordlightmap2f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
7830 if (batchneed & BATCHNEED_ARRAY_SKELETAL)
7831 {
7832 rsurface.batchskeletalindex4ub = (unsigned char *)R_FrameData_Alloc(batchnumvertices * sizeof(unsigned char[4]));
7833 rsurface.batchskeletalweight4ub = (unsigned char *)R_FrameData_Alloc(batchnumvertices * sizeof(unsigned char[4]));
7834 }
7835 numvertices = 0;
7836 numtriangles = 0;
7837 for (i = 0;i < texturenumsurfaces;i++)
7838 {
7839 surfacefirstvertex = texturesurfacelist[i]->num_firstvertex;
7840 surfacenumvertices = texturesurfacelist[i]->num_vertices;
7841 surfacefirsttriangle = texturesurfacelist[i]->num_firsttriangle;
7842 surfacenumtriangles = texturesurfacelist[i]->num_triangles;
7843 // copy only the data requested
7845 {
7846 if (batchneed & BATCHNEED_ARRAY_VERTEX)
7847 {
7849 memcpy(rsurface.batchvertex3f + 3*numvertices, rsurface.modelvertex3f + 3*surfacefirstvertex, surfacenumvertices * sizeof(float[3]));
7850 else
7851 memset(rsurface.batchvertex3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7852 }
7853 if (batchneed & BATCHNEED_ARRAY_NORMAL)
7854 {
7856 memcpy(rsurface.batchnormal3f + 3*numvertices, rsurface.modelnormal3f + 3*surfacefirstvertex, surfacenumvertices * sizeof(float[3]));
7857 else
7858 memset(rsurface.batchnormal3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7859 }
7860 if (batchneed & BATCHNEED_ARRAY_VECTOR)
7861 {
7863 {
7864 memcpy(rsurface.batchsvector3f + 3*numvertices, rsurface.modelsvector3f + 3*surfacefirstvertex, surfacenumvertices * sizeof(float[3]));
7865 memcpy(rsurface.batchtvector3f + 3*numvertices, rsurface.modeltvector3f + 3*surfacefirstvertex, surfacenumvertices * sizeof(float[3]));
7866 }
7867 else
7868 {
7869 memset(rsurface.batchsvector3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7870 memset(rsurface.batchtvector3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7871 }
7872 }
7873 if (batchneed & BATCHNEED_ARRAY_VERTEXCOLOR)
7874 {
7876 memcpy(rsurface.batchlightmapcolor4f + 4*numvertices, rsurface.modellightmapcolor4f + 4*surfacefirstvertex, surfacenumvertices * sizeof(float[4]));
7877 else
7878 memset(rsurface.batchlightmapcolor4f + 4*numvertices, 0, surfacenumvertices * sizeof(float[4]));
7879 }
7880 if (batchneed & BATCHNEED_ARRAY_TEXCOORD)
7881 {
7883 memcpy(rsurface.batchtexcoordtexture2f + 2*numvertices, rsurface.modeltexcoordtexture2f + 2*surfacefirstvertex, surfacenumvertices * sizeof(float[2]));
7884 else
7885 memset(rsurface.batchtexcoordtexture2f + 2*numvertices, 0, surfacenumvertices * sizeof(float[2]));
7886 }
7887 if (batchneed & BATCHNEED_ARRAY_LIGHTMAP)
7888 {
7890 memcpy(rsurface.batchtexcoordlightmap2f + 2*numvertices, rsurface.modeltexcoordlightmap2f + 2*surfacefirstvertex, surfacenumvertices * sizeof(float[2]));
7891 else
7892 memset(rsurface.batchtexcoordlightmap2f + 2*numvertices, 0, surfacenumvertices * sizeof(float[2]));
7893 }
7894 if (batchneed & BATCHNEED_ARRAY_SKELETAL)
7895 {
7897 {
7898 memcpy(rsurface.batchskeletalindex4ub + 4*numvertices, rsurface.modelskeletalindex4ub + 4*surfacefirstvertex, surfacenumvertices * sizeof(unsigned char[4]));
7899 memcpy(rsurface.batchskeletalweight4ub + 4*numvertices, rsurface.modelskeletalweight4ub + 4*surfacefirstvertex, surfacenumvertices * sizeof(unsigned char[4]));
7900 }
7901 else
7902 {
7903 memset(rsurface.batchskeletalindex4ub + 4*numvertices, 0, surfacenumvertices * sizeof(unsigned char[4]));
7904 memset(rsurface.batchskeletalweight4ub + 4*numvertices, 0, surfacenumvertices * sizeof(unsigned char[4]));
7905 ub = rsurface.batchskeletalweight4ub + 4*numvertices;
7906 for (j = 0;j < surfacenumvertices;j++)
7907 ub[j*4] = 255;
7908 }
7909 }
7910 }
7911 RSurf_RenumberElements(rsurface.modelelement3i + 3*surfacefirsttriangle, rsurface.batchelement3i + 3*numtriangles, 3*surfacenumtriangles, numvertices - surfacefirstvertex);
7912 numvertices += surfacenumvertices;
7913 numtriangles += surfacenumtriangles;
7914 }
7915
7916 // generate a 16bit index array as well if possible
7917 // (in general, dynamic batches fit)
7918 if (numvertices <= 65536)
7919 {
7920 rsurface.batchelement3s = (unsigned short *)R_FrameData_Alloc(batchnumtriangles * sizeof(unsigned short[3]));
7921 for (i = 0;i < numtriangles*3;i++)
7923 }
7924
7925 // since we've copied everything, the batch now starts at 0
7927 rsurface.batchnumvertices = batchnumvertices;
7929 rsurface.batchnumtriangles = batchnumtriangles;
7930 }
7931
7932 // apply skeletal animation that would have been done in the vertex shader
7934 {
7935 const unsigned char *si;
7936 const unsigned char *sw;
7937 const float *t[4];
7938 const float *b = rsurface.batchskeletaltransform3x4;
7939 float *vp, *vs, *vt, *vn;
7940 float w[4];
7941 float m[3][4], n[3][4];
7942 float tp[3], ts[3], tt[3], tn[3];
7953 memset(m[0], 0, sizeof(m));
7954 memset(n[0], 0, sizeof(n));
7955 for (i = 0;i < batchnumvertices;i++)
7956 {
7957 t[0] = b + si[0]*12;
7958 if (sw[0] == 255)
7959 {
7960 // common case - only one matrix
7961 m[0][0] = t[0][ 0];
7962 m[0][1] = t[0][ 1];
7963 m[0][2] = t[0][ 2];
7964 m[0][3] = t[0][ 3];
7965 m[1][0] = t[0][ 4];
7966 m[1][1] = t[0][ 5];
7967 m[1][2] = t[0][ 6];
7968 m[1][3] = t[0][ 7];
7969 m[2][0] = t[0][ 8];
7970 m[2][1] = t[0][ 9];
7971 m[2][2] = t[0][10];
7972 m[2][3] = t[0][11];
7973 }
7974 else if (sw[2] + sw[3])
7975 {
7976 // blend 4 matrices
7977 t[1] = b + si[1]*12;
7978 t[2] = b + si[2]*12;
7979 t[3] = b + si[3]*12;
7980 w[0] = sw[0] * (1.0f / 255.0f);
7981 w[1] = sw[1] * (1.0f / 255.0f);
7982 w[2] = sw[2] * (1.0f / 255.0f);
7983 w[3] = sw[3] * (1.0f / 255.0f);
7984 // blend the matrices
7985 m[0][0] = t[0][ 0] * w[0] + t[1][ 0] * w[1] + t[2][ 0] * w[2] + t[3][ 0] * w[3];
7986 m[0][1] = t[0][ 1] * w[0] + t[1][ 1] * w[1] + t[2][ 1] * w[2] + t[3][ 1] * w[3];
7987 m[0][2] = t[0][ 2] * w[0] + t[1][ 2] * w[1] + t[2][ 2] * w[2] + t[3][ 2] * w[3];
7988 m[0][3] = t[0][ 3] * w[0] + t[1][ 3] * w[1] + t[2][ 3] * w[2] + t[3][ 3] * w[3];
7989 m[1][0] = t[0][ 4] * w[0] + t[1][ 4] * w[1] + t[2][ 4] * w[2] + t[3][ 4] * w[3];
7990 m[1][1] = t[0][ 5] * w[0] + t[1][ 5] * w[1] + t[2][ 5] * w[2] + t[3][ 5] * w[3];
7991 m[1][2] = t[0][ 6] * w[0] + t[1][ 6] * w[1] + t[2][ 6] * w[2] + t[3][ 6] * w[3];
7992 m[1][3] = t[0][ 7] * w[0] + t[1][ 7] * w[1] + t[2][ 7] * w[2] + t[3][ 7] * w[3];
7993 m[2][0] = t[0][ 8] * w[0] + t[1][ 8] * w[1] + t[2][ 8] * w[2] + t[3][ 8] * w[3];
7994 m[2][1] = t[0][ 9] * w[0] + t[1][ 9] * w[1] + t[2][ 9] * w[2] + t[3][ 9] * w[3];
7995 m[2][2] = t[0][10] * w[0] + t[1][10] * w[1] + t[2][10] * w[2] + t[3][10] * w[3];
7996 m[2][3] = t[0][11] * w[0] + t[1][11] * w[1] + t[2][11] * w[2] + t[3][11] * w[3];
7997 }
7998 else
7999 {
8000 // blend 2 matrices
8001 t[1] = b + si[1]*12;
8002 w[0] = sw[0] * (1.0f / 255.0f);
8003 w[1] = sw[1] * (1.0f / 255.0f);
8004 // blend the matrices
8005 m[0][0] = t[0][ 0] * w[0] + t[1][ 0] * w[1];
8006 m[0][1] = t[0][ 1] * w[0] + t[1][ 1] * w[1];
8007 m[0][2] = t[0][ 2] * w[0] + t[1][ 2] * w[1];
8008 m[0][3] = t[0][ 3] * w[0] + t[1][ 3] * w[1];
8009 m[1][0] = t[0][ 4] * w[0] + t[1][ 4] * w[1];
8010 m[1][1] = t[0][ 5] * w[0] + t[1][ 5] * w[1];
8011 m[1][2] = t[0][ 6] * w[0] + t[1][ 6] * w[1];
8012 m[1][3] = t[0][ 7] * w[0] + t[1][ 7] * w[1];
8013 m[2][0] = t[0][ 8] * w[0] + t[1][ 8] * w[1];
8014 m[2][1] = t[0][ 9] * w[0] + t[1][ 9] * w[1];
8015 m[2][2] = t[0][10] * w[0] + t[1][10] * w[1];
8016 m[2][3] = t[0][11] * w[0] + t[1][11] * w[1];
8017 }
8018 si += 4;
8019 sw += 4;
8020 // modify the vertex
8021 VectorCopy(vp, tp);
8022 vp[0] = tp[0] * m[0][0] + tp[1] * m[0][1] + tp[2] * m[0][2] + m[0][3];
8023 vp[1] = tp[0] * m[1][0] + tp[1] * m[1][1] + tp[2] * m[1][2] + m[1][3];
8024 vp[2] = tp[0] * m[2][0] + tp[1] * m[2][1] + tp[2] * m[2][2] + m[2][3];
8025 vp += 3;
8026 if (vn)
8027 {
8028 // the normal transformation matrix is a set of cross products...
8029 CrossProduct(m[1], m[2], n[0]);
8030 CrossProduct(m[2], m[0], n[1]);
8031 CrossProduct(m[0], m[1], n[2]); // is actually transpose(inverse(m)) * det(m)
8032 VectorCopy(vn, tn);
8033 vn[0] = tn[0] * n[0][0] + tn[1] * n[0][1] + tn[2] * n[0][2];
8034 vn[1] = tn[0] * n[1][0] + tn[1] * n[1][1] + tn[2] * n[1][2];
8035 vn[2] = tn[0] * n[2][0] + tn[1] * n[2][1] + tn[2] * n[2][2];
8036 VectorNormalize(vn);
8037 vn += 3;
8038 if (vs)
8039 {
8040 VectorCopy(vs, ts);
8041 vs[0] = ts[0] * n[0][0] + ts[1] * n[0][1] + ts[2] * n[0][2];
8042 vs[1] = ts[0] * n[1][0] + ts[1] * n[1][1] + ts[2] * n[1][2];
8043 vs[2] = ts[0] * n[2][0] + ts[1] * n[2][1] + ts[2] * n[2][2];
8044 VectorNormalize(vs);
8045 vs += 3;
8046 VectorCopy(vt, tt);
8047 vt[0] = tt[0] * n[0][0] + tt[1] * n[0][1] + tt[2] * n[0][2];
8048 vt[1] = tt[0] * n[1][0] + tt[1] * n[1][1] + tt[2] * n[1][2];
8049 vt[2] = tt[0] * n[2][0] + tt[1] * n[2][1] + tt[2] * n[2][2];
8050 VectorNormalize(vt);
8051 vt += 3;
8052 }
8053 }
8054 }
8057 }
8058
8059 // q1bsp surfaces rendered in vertex color mode have to have colors
8060 // calculated based on lightstyles
8061 if ((batchneed & BATCHNEED_ARRAY_VERTEXCOLOR) && texturesurfacelist[0]->lightmapinfo)
8062 {
8063 // generate color arrays for the surfaces in this list
8064 int c[4];
8065 int scale;
8066 int size3;
8067 const int *offsets;
8068 const unsigned char *lm;
8069 rsurface.batchlightmapcolor4f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[4]));
8072 numvertices = 0;
8073 for (i = 0;i < texturenumsurfaces;i++)
8074 {
8075 surface = texturesurfacelist[i];
8077 surfacenumvertices = surface->num_vertices;
8078 if (surface->lightmapinfo->samples)
8079 {
8080 for (j = 0;j < surfacenumvertices;j++)
8081 {
8082 lm = surface->lightmapinfo->samples + offsets[j];
8084 VectorScale(lm, scale, c);
8085 if (surface->lightmapinfo->styles[1] != 255)
8086 {
8087 size3 = ((surface->lightmapinfo->extents[0]>>4)+1)*((surface->lightmapinfo->extents[1]>>4)+1)*3;
8088 lm += size3;
8090 VectorMA(c, scale, lm, c);
8091 if (surface->lightmapinfo->styles[2] != 255)
8092 {
8093 lm += size3;
8095 VectorMA(c, scale, lm, c);
8096 if (surface->lightmapinfo->styles[3] != 255)
8097 {
8098 lm += size3;
8100 VectorMA(c, scale, lm, c);
8101 }
8102 }
8103 }
8104 c[0] >>= 7;
8105 c[1] >>= 7;
8106 c[2] >>= 7;
8107 Vector4Set(rsurface.batchlightmapcolor4f + 4*numvertices, min(c[0], 255) * (1.0f / 255.0f), min(c[1], 255) * (1.0f / 255.0f), min(c[2], 255) * (1.0f / 255.0f), 1);
8108 numvertices++;
8109 }
8110 }
8111 else
8112 {
8113 for (j = 0;j < surfacenumvertices;j++)
8114 {
8115 Vector4Set(rsurface.batchlightmapcolor4f + 4*numvertices, 0, 0, 0, 1);
8116 numvertices++;
8117 }
8118 }
8119 }
8120 }
8121
8122 // if vertices are deformed (sprite flares and things in maps, possibly
8123 // water waves, bulges and other deformations), modify the copied vertices
8124 // in place
8125 for (deformindex = 0, deform = rsurface.texture->deforms;deformindex < Q3MAXDEFORMS && deform->deform && r_deformvertexes.integer;deformindex++, deform++)
8126 {
8127 float scale;
8128 switch (deform->deform)
8129 {
8130 default:
8132 case Q3DEFORM_TEXT0:
8133 case Q3DEFORM_TEXT1:
8134 case Q3DEFORM_TEXT2:
8135 case Q3DEFORM_TEXT3:
8136 case Q3DEFORM_TEXT4:
8137 case Q3DEFORM_TEXT5:
8138 case Q3DEFORM_TEXT6:
8139 case Q3DEFORM_TEXT7:
8140 case Q3DEFORM_NONE:
8141 break;
8146 VectorNormalize(newforward);
8147 VectorNormalize(newright);
8148 VectorNormalize(newup);
8149// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8150// rsurface.batchvertex3f_vertexbuffer = NULL;
8151// rsurface.batchvertex3f_bufferoffset = 0;
8152// rsurface.batchsvector3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchsvector3f);
8153// rsurface.batchsvector3f_vertexbuffer = NULL;
8154// rsurface.batchsvector3f_bufferoffset = 0;
8155// rsurface.batchtvector3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchtvector3f);
8156// rsurface.batchtvector3f_vertexbuffer = NULL;
8157// rsurface.batchtvector3f_bufferoffset = 0;
8158// rsurface.batchnormal3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8159// rsurface.batchnormal3f_vertexbuffer = NULL;
8160// rsurface.batchnormal3f_bufferoffset = 0;
8161 // sometimes we're on a renderpath that does not use vectors (GL11/GL13/GLES1)
8166 // a single autosprite surface can contain multiple sprites...
8167 for (j = 0;j < batchnumvertices - 3;j += 4)
8168 {
8169 VectorClear(center);
8170 for (i = 0;i < 4;i++)
8171 VectorAdd(center, rsurface.batchvertex3f + 3*(j+i), center);
8172 VectorScale(center, 0.25f, center);
8176 for (i = 0;i < 4;i++)
8177 {
8178 VectorSubtract(rsurface.batchvertex3f + 3*(j+i), center, v);
8179 VectorMAMAMAM(1, center, DotProduct(forward, v), newforward, DotProduct(right, v), newright, DotProduct(up, v), newup, rsurface.batchvertex3f + 3*(j+i));
8180 }
8181 }
8182 // if we get here, BATCHNEED_ARRAY_NORMAL and BATCHNEED_ARRAY_VECTOR are in batchneed, so no need to check
8185 break;
8190 VectorNormalize(newforward);
8191 VectorNormalize(newright);
8192 VectorNormalize(newup);
8193// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8194// rsurface.batchvertex3f_vertexbuffer = NULL;
8195// rsurface.batchvertex3f_bufferoffset = 0;
8196 {
8197 const float *v1, *v2;
8198 vec3_t start, end;
8199 float f, l;
8200 struct
8201 {
8202 float length2;
8203 const float *v1;
8204 const float *v2;
8205 }
8206 shortest[2];
8207 memset(shortest, 0, sizeof(shortest));
8208 // a single autosprite surface can contain multiple sprites...
8209 for (j = 0;j < batchnumvertices - 3;j += 4)
8210 {
8211 VectorClear(center);
8212 for (i = 0;i < 4;i++)
8213 VectorAdd(center, rsurface.batchvertex3f + 3*(j+i), center);
8214 VectorScale(center, 0.25f, center);
8215 // find the two shortest edges, then use them to define the
8216 // axis vectors for rotating around the central axis
8217 for (i = 0;i < 6;i++)
8218 {
8219 v1 = rsurface.batchvertex3f + 3*(j+quadedges[i][0]);
8220 v2 = rsurface.batchvertex3f + 3*(j+quadedges[i][1]);
8221 l = VectorDistance2(v1, v2);
8222 // this length bias tries to make sense of square polygons, assuming they are meant to be upright
8223 if (v1[2] != v2[2])
8224 l += (1.0f / 1024.0f);
8225 if (shortest[0].length2 > l || i == 0)
8226 {
8227 shortest[1] = shortest[0];
8228 shortest[0].length2 = l;
8229 shortest[0].v1 = v1;
8230 shortest[0].v2 = v2;
8231 }
8232 else if (shortest[1].length2 > l || i == 1)
8233 {
8234 shortest[1].length2 = l;
8235 shortest[1].v1 = v1;
8236 shortest[1].v2 = v2;
8237 }
8238 }
8239 VectorLerp(shortest[0].v1, 0.5f, shortest[0].v2, start);
8240 VectorLerp(shortest[1].v1, 0.5f, shortest[1].v2, end);
8241 // this calculates the right vector from the shortest edge
8242 // and the up vector from the edge midpoints
8243 VectorSubtract(shortest[0].v1, shortest[0].v2, right);
8245 VectorSubtract(end, start, up);
8247 // calculate a forward vector to use instead of the original plane normal (this is how we get a new right vector)
8249 //Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.forward, forward);
8253 CrossProduct(up, forward, newright);
8254 VectorNormalize(newright);
8255 // rotate the quad around the up axis vector, this is made
8256 // especially easy by the fact we know the quad is flat,
8257 // so we only have to subtract the center position and
8258 // measure distance along the right vector, and then
8259 // multiply that by the newright vector and add back the
8260 // center position
8261 // we also need to subtract the old position to undo the
8262 // displacement from the center, which we do with a
8263 // DotProduct, the subtraction/addition of center is also
8264 // optimized into DotProducts here
8265 l = DotProduct(right, center);
8266 for (i = 0;i < 4;i++)
8267 {
8268 v1 = rsurface.batchvertex3f + 3*(j+i);
8269 f = DotProduct(right, v1) - l;
8270 VectorMAMAM(1, v1, -f, right, f, newright, rsurface.batchvertex3f + 3*(j+i));
8271 }
8272 }
8273 }
8274 if(batchneed & (BATCHNEED_ARRAY_NORMAL | BATCHNEED_ARRAY_VECTOR)) // otherwise these can stay NULL
8275 {
8276// rsurface.batchnormal3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8277// rsurface.batchnormal3f_vertexbuffer = NULL;
8278// rsurface.batchnormal3f_bufferoffset = 0;
8280 }
8281 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8282 {
8283// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8284// rsurface.batchsvector3f_vertexbuffer = NULL;
8285// rsurface.batchsvector3f_bufferoffset = 0;
8286// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8287// rsurface.batchtvector3f_vertexbuffer = NULL;
8288// rsurface.batchtvector3f_bufferoffset = 0;
8290 }
8291 break;
8292 case Q3DEFORM_NORMAL:
8293 // deform the normals to make reflections wavey
8294 rsurface.batchnormal3f = (float *)R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8297 for (j = 0;j < batchnumvertices;j++)
8298 {
8299 float vertex[3];
8300 float *normal = rsurface.batchnormal3f + 3*j;
8301 VectorScale(rsurface.batchvertex3f + 3*j, 0.98f, vertex);
8302 normal[0] = rsurface.batchnormal3f[j*3+0] + deform->parms[0] * noise4f( vertex[0], vertex[1], vertex[2], rsurface.shadertime * deform->parms[1]);
8303 normal[1] = rsurface.batchnormal3f[j*3+1] + deform->parms[0] * noise4f( 98 + vertex[0], vertex[1], vertex[2], rsurface.shadertime * deform->parms[1]);
8304 normal[2] = rsurface.batchnormal3f[j*3+2] + deform->parms[0] * noise4f(196 + vertex[0], vertex[1], vertex[2], rsurface.shadertime * deform->parms[1]);
8306 }
8307 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8308 {
8309// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8310// rsurface.batchsvector3f_vertexbuffer = NULL;
8311// rsurface.batchsvector3f_bufferoffset = 0;
8312// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8313// rsurface.batchtvector3f_vertexbuffer = NULL;
8314// rsurface.batchtvector3f_bufferoffset = 0;
8316 }
8317 break;
8318 case Q3DEFORM_WAVE:
8319 // deform vertex array to make wavey water and flags and such
8320 waveparms[0] = deform->waveparms[0];
8321 waveparms[1] = deform->waveparms[1];
8322 waveparms[2] = deform->waveparms[2];
8323 waveparms[3] = deform->waveparms[3];
8324 if(!R_TestQ3WaveFunc(deform->wavefunc, waveparms))
8325 break; // if wavefunc is a nop, don't make a dynamic vertex array
8326 // this is how a divisor of vertex influence on deformation
8327 animpos = deform->parms[0] ? 1.0f / deform->parms[0] : 100.0f;
8328 scale = R_EvaluateQ3WaveFunc(deform->wavefunc, waveparms);
8329// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8330// rsurface.batchvertex3f_vertexbuffer = NULL;
8331// rsurface.batchvertex3f_bufferoffset = 0;
8332// rsurface.batchnormal3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8333// rsurface.batchnormal3f_vertexbuffer = NULL;
8334// rsurface.batchnormal3f_bufferoffset = 0;
8335 for (j = 0;j < batchnumvertices;j++)
8336 {
8337 // if the wavefunc depends on time, evaluate it per-vertex
8338 if (waveparms[3])
8339 {
8340 waveparms[2] = deform->waveparms[2] + (rsurface.batchvertex3f[j*3+0] + rsurface.batchvertex3f[j*3+1] + rsurface.batchvertex3f[j*3+2]) * animpos;
8341 scale = R_EvaluateQ3WaveFunc(deform->wavefunc, waveparms);
8342 }
8344 }
8345 // if we get here, BATCHNEED_ARRAY_NORMAL is in batchneed, so no need to check
8347 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8348 {
8349// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8350// rsurface.batchsvector3f_vertexbuffer = NULL;
8351// rsurface.batchsvector3f_bufferoffset = 0;
8352// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8353// rsurface.batchtvector3f_vertexbuffer = NULL;
8354// rsurface.batchtvector3f_bufferoffset = 0;
8356 }
8357 break;
8358 case Q3DEFORM_BULGE:
8359 // deform vertex array to make the surface have moving bulges
8360// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8361// rsurface.batchvertex3f_vertexbuffer = NULL;
8362// rsurface.batchvertex3f_bufferoffset = 0;
8363// rsurface.batchnormal3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8364// rsurface.batchnormal3f_vertexbuffer = NULL;
8365// rsurface.batchnormal3f_bufferoffset = 0;
8366 for (j = 0;j < batchnumvertices;j++)
8367 {
8368 scale = sin(rsurface.batchtexcoordtexture2f[j*2+0] * deform->parms[0] + rsurface.shadertime * deform->parms[2]) * deform->parms[1];
8370 }
8371 // if we get here, BATCHNEED_ARRAY_NORMAL is in batchneed, so no need to check
8373 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8374 {
8375// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8376// rsurface.batchsvector3f_vertexbuffer = NULL;
8377// rsurface.batchsvector3f_bufferoffset = 0;
8378// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8379// rsurface.batchtvector3f_vertexbuffer = NULL;
8380// rsurface.batchtvector3f_bufferoffset = 0;
8382 }
8383 break;
8384 case Q3DEFORM_MOVE:
8385 // deform vertex array
8386 if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
8387 break; // if wavefunc is a nop, don't make a dynamic vertex array
8388 scale = R_EvaluateQ3WaveFunc(deform->wavefunc, deform->waveparms);
8389 VectorScale(deform->parms, scale, waveparms);
8390// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8391// rsurface.batchvertex3f_vertexbuffer = NULL;
8392// rsurface.batchvertex3f_bufferoffset = 0;
8393 for (j = 0;j < batchnumvertices;j++)
8394 VectorAdd(rsurface.batchvertex3f + 3*j, waveparms, rsurface.batchvertex3f + 3*j);
8395 break;
8396 }
8397 }
8398
8400 {
8401 // generate texcoords based on the chosen texcoord source
8403 {
8404 default:
8405 case Q3TCGEN_TEXTURE:
8406 break;
8407 case Q3TCGEN_LIGHTMAP:
8408 // rsurface.batchtexcoordtexture2f = R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8409 // rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8410 // rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8412 memcpy(rsurface.batchtexcoordtexture2f, rsurface.batchtexcoordlightmap2f, batchnumvertices * sizeof(float[2]));
8413 break;
8414 case Q3TCGEN_VECTOR:
8415 // rsurface.batchtexcoordtexture2f = R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8416 // rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8417 // rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8418 for (j = 0;j < batchnumvertices;j++)
8419 {
8422 }
8423 break;
8425 // make environment reflections using a spheremap
8426 rsurface.batchtexcoordtexture2f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8429 for (j = 0;j < batchnumvertices;j++)
8430 {
8431 // identical to Q3A's method, but executed in worldspace so
8432 // carried models can be shiny too
8433
8434 float viewer[3], d, reflected[3], worldreflected[3];
8435
8437 // VectorNormalize(viewer);
8438
8439 d = DotProduct(rsurface.batchnormal3f + 3*j, viewer);
8440
8441 reflected[0] = rsurface.batchnormal3f[j*3+0]*2*d - viewer[0];
8442 reflected[1] = rsurface.batchnormal3f[j*3+1]*2*d - viewer[1];
8443 reflected[2] = rsurface.batchnormal3f[j*3+2]*2*d - viewer[2];
8444 // note: this is proportinal to viewer, so we can normalize later
8445
8446 Matrix4x4_Transform3x3(&rsurface.matrix, reflected, worldreflected);
8447 VectorNormalize(worldreflected);
8448
8449 // note: this sphere map only uses world x and z!
8450 // so positive and negative y will LOOK THE SAME.
8451 rsurface.batchtexcoordtexture2f[j*2+0] = 0.5 + 0.5 * worldreflected[1];
8452 rsurface.batchtexcoordtexture2f[j*2+1] = 0.5 - 0.5 * worldreflected[2];
8453 }
8454 break;
8455 }
8456 // the only tcmod that needs software vertex processing is turbulent, so
8457 // check for it here and apply the changes if needed
8458 // and we only support that as the first one
8459 // (handling a mixture of turbulent and other tcmods would be problematic
8460 // without punting it entirely to a software path)
8462 {
8463 amplitude = rsurface.texture->materialshaderpass->tcmods[0].parms[1];
8465 // rsurface.batchtexcoordtexture2f = R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8466 // rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8467 // rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8468 for (j = 0;j < batchnumvertices;j++)
8469 {
8470 rsurface.batchtexcoordtexture2f[j*2+0] += amplitude * sin(((rsurface.batchvertex3f[j*3+0] + rsurface.batchvertex3f[j*3+2]) * 1.0 / 1024.0f + animpos) * M_PI * 2);
8471 rsurface.batchtexcoordtexture2f[j*2+1] += amplitude * sin(((rsurface.batchvertex3f[j*3+1] ) * 1.0 / 1024.0f + animpos) * M_PI * 2);
8472 }
8473 }
8474 }
8475}
static vec3_t offsets[NUMOFFSETS]
Definition cl_input.c:838
float noise4f(float x, float y, float z, float w)
static void RSurf_RenumberElements(const int *inelement3i, int *outelement3i, int numelements, int adjust)
Definition gl_rmain.c:7380
static const int quadedges[6][2]
Definition gl_rmain.c:7387
static qbool R_TestQ3WaveFunc(q3wavefunc_t func, const float *parms)
Definition gl_rmain.c:6397
void * R_FrameData_Store(size_t size, void *data)
allocate some temporary memory and copy this data into it
Definition gl_rmain.c:3573
#define VectorReflect(a, r, b, out)
Definition mathlib.h:121
#define VectorClear(a)
Definition mathlib.h:97
#define VectorMAMAMAM(scale1, b1, scale2, b2, scale3, b3, scale4, b4, out)
Definition mathlib.h:118
@ Q3DEFORM_NORMAL
Definition r_qshader.h:61
@ Q3DEFORM_TEXT3
Definition r_qshader.h:54
@ Q3DEFORM_TEXT5
Definition r_qshader.h:56
@ Q3DEFORM_TEXT0
Definition r_qshader.h:51
@ Q3DEFORM_AUTOSPRITE
Definition r_qshader.h:49
@ Q3DEFORM_PROJECTIONSHADOW
Definition r_qshader.h:48
@ Q3DEFORM_WAVE
Definition r_qshader.h:60
@ Q3DEFORM_TEXT1
Definition r_qshader.h:52
@ Q3DEFORM_TEXT2
Definition r_qshader.h:53
@ Q3DEFORM_NONE
Definition r_qshader.h:47
@ Q3DEFORM_AUTOSPRITE2
Definition r_qshader.h:50
@ Q3DEFORM_TEXT7
Definition r_qshader.h:58
@ Q3DEFORM_MOVE
Definition r_qshader.h:62
@ Q3DEFORM_TEXT6
Definition r_qshader.h:57
@ Q3DEFORM_TEXT4
Definition r_qshader.h:55
@ Q3DEFORM_BULGE
Definition r_qshader.h:59
@ Q3TCGEN_VECTOR
Definition r_qshader.h:104
@ Q3TCGEN_ENVIRONMENT
Definition r_qshader.h:102
@ Q3TCGEN_LIGHTMAP
Definition r_qshader.h:103
@ Q3TCGEN_TEXTURE
Definition r_qshader.h:101
@ r_stat_batch_fast_vertices
Definition r_stats.h:77
@ r_stat_batch_dynamic_triangles_because_deformvertexes_normal
Definition r_stats.h:110
@ r_stat_batch_dynamic_vertices_because_deformvertexes_move
Definition r_stats.h:121
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_wave
Definition r_stats.h:112
@ r_stat_batch_dynamic_batches_because_deformvertexes_autosprite
Definition r_stats.h:99
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_move
Definition r_stats.h:120
@ r_stat_batch_dynamic_vertices_because_deformvertexes_normal
Definition r_stats.h:109
@ r_stat_batch_dynamic_vertices_because_nogaps
Definition r_stats.h:141
@ r_stat_batch_dynamic_vertices_because_cvar
Definition r_stats.h:93
@ r_stat_batch_dynamic_batches_because_deformvertexes_bulge
Definition r_stats.h:115
@ r_stat_batch_dynamic_batches_because_tcmod_turbulent
Definition r_stats.h:135
@ r_stat_batch_dynamic_batches
Definition r_stats.h:83
@ r_stat_batch_dynamic_vertices_because_tcgen_lightmap
Definition r_stats.h:125
@ r_stat_batch_dynamic_surfaces_because_tcgen_environment
Definition r_stats.h:132
@ r_stat_batch_vertices
Definition r_stats.h:73
@ r_stat_batch_dynamic_batches_because_deformvertexes_move
Definition r_stats.h:119
@ r_stat_batch_copytriangles_vertices
Definition r_stats.h:81
@ r_stat_batch_dynamic_vertices_because_deformvertexes_wave
Definition r_stats.h:113
@ r_stat_batch_dynamic_triangles_because_cvar
Definition r_stats.h:94
@ r_stat_batch_dynamic_vertices_because_tcgen_environment
Definition r_stats.h:133
@ r_stat_batch_dynamic_batches_because_cvar
Definition r_stats.h:91
@ r_stat_batch_dynamic_batches_because_deformvertexes_wave
Definition r_stats.h:111
@ r_stat_batch_dynamic_triangles_because_deformvertexes_wave
Definition r_stats.h:114
@ r_stat_batch_dynamic_batches_because_lightmapvertex
Definition r_stats.h:95
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_normal
Definition r_stats.h:108
@ r_stat_batch_copytriangles_batches
Definition r_stats.h:79
@ r_stat_batch_dynamic_surfaces_because_tcgen_vector
Definition r_stats.h:128
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite2
Definition r_stats.h:104
@ r_stat_batch_dynamic_vertices
Definition r_stats.h:85
@ r_stat_batch_dynamic_triangles_because_deformvertexes_bulge
Definition r_stats.h:118
@ r_stat_batch_dynamic_triangles
Definition r_stats.h:86
@ r_stat_batch_dynamic_surfaces_because_nogaps
Definition r_stats.h:140
@ r_stat_batch_dynamic_vertices_because_tcgen_vector
Definition r_stats.h:129
@ r_stat_batch_triangles
Definition r_stats.h:74
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite
Definition r_stats.h:100
@ r_stat_batch_dynamicskeletal_triangles
Definition r_stats.h:90
@ r_stat_batch_dynamicskeletal_batches
Definition r_stats.h:87
@ r_stat_batch_dynamic_surfaces_because_tcgen_lightmap
Definition r_stats.h:124
@ r_stat_batch_surfaces
Definition r_stats.h:72
@ r_stat_batch_dynamicskeletal_vertices
Definition r_stats.h:89
@ r_stat_batch_dynamic_batches_because_nogaps
Definition r_stats.h:139
@ r_stat_batch_copytriangles_surfaces
Definition r_stats.h:80
@ r_stat_batch_fast_surfaces
Definition r_stats.h:76
@ r_stat_batch_dynamic_batches_because_tcgen_environment
Definition r_stats.h:131
@ r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite2
Definition r_stats.h:106
@ r_stat_batch_dynamic_surfaces_because_tcmod_turbulent
Definition r_stats.h:136
@ r_stat_batch_dynamic_batches_because_deformvertexes_normal
Definition r_stats.h:107
@ r_stat_batch_dynamic_surfaces_because_cvar
Definition r_stats.h:92
@ r_stat_batch_dynamic_batches_because_deformvertexes_autosprite2
Definition r_stats.h:103
@ r_stat_batch_dynamic_vertices_because_deformvertexes_bulge
Definition r_stats.h:117
@ r_stat_batch_dynamic_triangles_because_tcgen_environment
Definition r_stats.h:134
@ r_stat_batch_fast_triangles
Definition r_stats.h:78
@ r_stat_batch_dynamic_batches_because_tcgen_vector
Definition r_stats.h:127
@ r_stat_batch_dynamic_triangles_because_lightmapvertex
Definition r_stats.h:98
@ r_stat_batch_dynamic_triangles_because_nogaps
Definition r_stats.h:142
@ r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite
Definition r_stats.h:102
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_bulge
Definition r_stats.h:116
@ r_stat_batch_copytriangles_triangles
Definition r_stats.h:82
@ r_stat_batch_fast_batches
Definition r_stats.h:75
@ r_stat_batch_dynamicskeletal_surfaces
Definition r_stats.h:88
@ r_stat_batch_dynamic_vertices_because_lightmapvertex
Definition r_stats.h:97
@ r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite2
Definition r_stats.h:105
@ r_stat_batch_dynamic_batches_because_tcgen_lightmap
Definition r_stats.h:123
@ r_stat_batch_dynamic_surfaces_because_lightmapvertex
Definition r_stats.h:96
@ r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite
Definition r_stats.h:101
@ r_stat_batch_withgaps
Definition r_stats.h:71
@ r_stat_batch_dynamic_vertices_because_tcmod_turbulent
Definition r_stats.h:137
@ r_stat_batch_dynamic_triangles_because_tcgen_vector
Definition r_stats.h:130
@ r_stat_batch_dynamic_triangles_because_tcmod_turbulent
Definition r_stats.h:138
@ r_stat_batch_batches
Definition r_stats.h:70
@ r_stat_batch_dynamic_surfaces
Definition r_stats.h:84
@ r_stat_batch_dynamic_triangles_because_deformvertexes_move
Definition r_stats.h:122
@ r_stat_batch_dynamic_triangles_because_tcgen_lightmap
Definition r_stats.h:126
#define BATCHNEED_ARRAY_SKELETAL
Definition render.h:792
vec4 sw
unsigned char styles[MAXLIGHTMAPS]
unsigned char * samples
msurface_lightmapinfo_t * lightmapinfo
lightmaptexture rebuild information not used in q3bsp
q3wavefunc_t wavefunc
Definition r_qshader.h:178
float parms[Q3DEFORM_MAXPARMS]
Definition r_qshader.h:177
float waveparms[Q3WAVEPARMS]
Definition r_qshader.h:179
float parms[Q3TCGEN_MAXPARMS]
Definition r_qshader.h:145
int batchskeletalnumtransforms
Definition render.h:706
q3shaderinfo_layer_tcgen_t tcgen
Definition r_qshader.h:269
q3shaderinfo_deform_t deforms[Q3MAXDEFORMS]
static vec3_t right
Definition sv_user.c:305

References b, rsurfacestate_t::batchelement3i, rsurfacestate_t::batchelement3i_bufferoffset, rsurfacestate_t::batchelement3i_indexbuffer, rsurfacestate_t::batchelement3s, rsurfacestate_t::batchelement3s_bufferoffset, rsurfacestate_t::batchelement3s_indexbuffer, rsurfacestate_t::batchfirsttriangle, rsurfacestate_t::batchfirstvertex, rsurfacestate_t::batchgeneratedvertex, rsurfacestate_t::batchlightmapcolor4f, rsurfacestate_t::batchlightmapcolor4f_bufferoffset, rsurfacestate_t::batchlightmapcolor4f_vertexbuffer, rsurfacestate_t::batchmultidraw, rsurfacestate_t::batchmultidrawnumsurfaces, rsurfacestate_t::batchmultidrawsurfacelist, BATCHNEED_ALLOWMULTIDRAW, BATCHNEED_ALWAYSCOPY, BATCHNEED_ARRAY_LIGHTMAP, BATCHNEED_ARRAY_NORMAL, BATCHNEED_ARRAY_SKELETAL, BATCHNEED_ARRAY_TEXCOORD, BATCHNEED_ARRAY_VECTOR, BATCHNEED_ARRAY_VERTEX, BATCHNEED_ARRAY_VERTEXCOLOR, BATCHNEED_NOGAPS, rsurfacestate_t::batchnormal3f, rsurfacestate_t::batchnormal3f_bufferoffset, rsurfacestate_t::batchnormal3f_vertexbuffer, rsurfacestate_t::batchnumtriangles, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchskeletalindex4ub, rsurfacestate_t::batchskeletalindex4ub_bufferoffset, rsurfacestate_t::batchskeletalindex4ub_vertexbuffer, rsurfacestate_t::batchskeletalnumtransforms, rsurfacestate_t::batchskeletaltransform3x4, rsurfacestate_t::batchskeletaltransform3x4buffer, rsurfacestate_t::batchskeletaltransform3x4offset, rsurfacestate_t::batchskeletaltransform3x4size, rsurfacestate_t::batchskeletalweight4ub, rsurfacestate_t::batchskeletalweight4ub_bufferoffset, rsurfacestate_t::batchskeletalweight4ub_vertexbuffer, rsurfacestate_t::batchsvector3f, rsurfacestate_t::batchsvector3f_bufferoffset, rsurfacestate_t::batchsvector3f_vertexbuffer, rsurfacestate_t::batchtexcoordlightmap2f, rsurfacestate_t::batchtexcoordlightmap2f_bufferoffset, rsurfacestate_t::batchtexcoordlightmap2f_vertexbuffer, rsurfacestate_t::batchtexcoordtexture2f, rsurfacestate_t::batchtexcoordtexture2f_bufferoffset, rsurfacestate_t::batchtexcoordtexture2f_vertexbuffer, rsurfacestate_t::batchtvector3f, rsurfacestate_t::batchtvector3f_bufferoffset, rsurfacestate_t::batchtvector3f_vertexbuffer, rsurfacestate_t::batchvertex3f, rsurfacestate_t::batchvertex3f_bufferoffset, rsurfacestate_t::batchvertex3f_vertexbuffer, CrossProduct, q3shaderinfo_deform_t::deform, texture_t::deforms, DotProduct, rsurfacestate_t::entityskeletalnumtransforms, rsurfacestate_t::entityskeletaltransform3x4, rsurfacestate_t::entityskeletaltransform3x4buffer, rsurfacestate_t::entityskeletaltransform3x4offset, rsurfacestate_t::entityskeletaltransform3x4size, msurface_lightmapinfo_t::extents, f, forward, r_refdef_view_t::forward, i, cvar_t::integer, rsurfacestate_t::inversematrix, msurface_t::lightmapinfo, r_refdef_scene_t::lightstylevalue, rsurfacestate_t::localvieworigin, M_PI, texture_t::materialshaderpass, rsurfacestate_t::matrix, Matrix4x4_Transform3x3(), min, Mod_BuildNormals(), Mod_BuildTextureVectorsFromNormals(), rsurfacestate_t::modelelement3i, rsurfacestate_t::modelelement3i_bufferoffset, rsurfacestate_t::modelelement3i_indexbuffer, rsurfacestate_t::modelelement3s, rsurfacestate_t::modelelement3s_bufferoffset, rsurfacestate_t::modelelement3s_indexbuffer, rsurfacestate_t::modellightmapcolor4f, rsurfacestate_t::modellightmapcolor4f_bufferoffset, rsurfacestate_t::modellightmapcolor4f_vertexbuffer, rsurfacestate_t::modellightmapoffsets, rsurfacestate_t::modelnormal3f, rsurfacestate_t::modelnormal3f_bufferoffset, rsurfacestate_t::modelnormal3f_vertexbuffer, rsurfacestate_t::modelskeletalindex4ub, rsurfacestate_t::modelskeletalindex4ub_bufferoffset, rsurfacestate_t::modelskeletalindex4ub_vertexbuffer, rsurfacestate_t::modelskeletalweight4ub, rsurfacestate_t::modelskeletalweight4ub_bufferoffset, rsurfacestate_t::modelskeletalweight4ub_vertexbuffer, rsurfacestate_t::modelsvector3f, rsurfacestate_t::modelsvector3f_bufferoffset, rsurfacestate_t::modelsvector3f_vertexbuffer, rsurfacestate_t::modeltexcoordlightmap2f, rsurfacestate_t::modeltexcoordlightmap2f_bufferoffset, rsurfacestate_t::modeltexcoordlightmap2f_vertexbuffer, rsurfacestate_t::modeltexcoordtexture2f, rsurfacestate_t::modeltexcoordtexture2f_bufferoffset, rsurfacestate_t::modeltexcoordtexture2f_vertexbuffer, rsurfacestate_t::modeltvector3f, rsurfacestate_t::modeltvector3f_bufferoffset, rsurfacestate_t::modeltvector3f_vertexbuffer, rsurfacestate_t::modelvertex3f, rsurfacestate_t::modelvertex3f_bufferoffset, rsurfacestate_t::modelvertex3f_vertexbuffer, n, noise4f(), normal, NULL, msurface_t::num_firsttriangle, msurface_t::num_firstvertex, msurface_t::num_triangles, msurface_t::num_vertices, offsets, q3shaderinfo_deform_t::parms, q3shaderinfo_layer_tcgen_t::parms, q3shaderinfo_layer_tcmod_t::parms, Q3DEFORM_AUTOSPRITE, Q3DEFORM_AUTOSPRITE2, Q3DEFORM_BULGE, Q3DEFORM_MOVE, Q3DEFORM_NONE, Q3DEFORM_NORMAL, Q3DEFORM_PROJECTIONSHADOW, Q3DEFORM_TEXT0, Q3DEFORM_TEXT1, Q3DEFORM_TEXT2, Q3DEFORM_TEXT3, Q3DEFORM_TEXT4, Q3DEFORM_TEXT5, Q3DEFORM_TEXT6, Q3DEFORM_TEXT7, Q3DEFORM_WAVE, Q3TCGEN_ENVIRONMENT, Q3TCGEN_LIGHTMAP, Q3TCGEN_TEXTURE, Q3TCGEN_VECTOR, Q3TCMOD_TURBULENT, quadedges, r_batch_debugdynamicvertexpath, r_batch_multidraw, r_batch_multidraw_mintriangles, r_deformvertexes, R_EvaluateQ3WaveFunc(), R_FrameData_Alloc(), R_FrameData_Store(), r_refdef, r_smoothnormals_areaweighting, r_stat_batch_batches, r_stat_batch_copytriangles_batches, r_stat_batch_copytriangles_surfaces, r_stat_batch_copytriangles_triangles, r_stat_batch_copytriangles_vertices, r_stat_batch_dynamic_batches, r_stat_batch_dynamic_batches_because_cvar, r_stat_batch_dynamic_batches_because_deformvertexes_autosprite, r_stat_batch_dynamic_batches_because_deformvertexes_autosprite2, r_stat_batch_dynamic_batches_because_deformvertexes_bulge, r_stat_batch_dynamic_batches_because_deformvertexes_move, r_stat_batch_dynamic_batches_because_deformvertexes_normal, r_stat_batch_dynamic_batches_because_deformvertexes_wave, r_stat_batch_dynamic_batches_because_lightmapvertex, r_stat_batch_dynamic_batches_because_nogaps, r_stat_batch_dynamic_batches_because_tcgen_environment, r_stat_batch_dynamic_batches_because_tcgen_lightmap, r_stat_batch_dynamic_batches_because_tcgen_vector, r_stat_batch_dynamic_batches_because_tcmod_turbulent, r_stat_batch_dynamic_surfaces, r_stat_batch_dynamic_surfaces_because_cvar, r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite, r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite2, r_stat_batch_dynamic_surfaces_because_deformvertexes_bulge, r_stat_batch_dynamic_surfaces_because_deformvertexes_move, r_stat_batch_dynamic_surfaces_because_deformvertexes_normal, r_stat_batch_dynamic_surfaces_because_deformvertexes_wave, r_stat_batch_dynamic_surfaces_because_lightmapvertex, r_stat_batch_dynamic_surfaces_because_nogaps, r_stat_batch_dynamic_surfaces_because_tcgen_environment, r_stat_batch_dynamic_surfaces_because_tcgen_lightmap, r_stat_batch_dynamic_surfaces_because_tcgen_vector, r_stat_batch_dynamic_surfaces_because_tcmod_turbulent, r_stat_batch_dynamic_triangles, r_stat_batch_dynamic_triangles_because_cvar, r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite, r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite2, r_stat_batch_dynamic_triangles_because_deformvertexes_bulge, r_stat_batch_dynamic_triangles_because_deformvertexes_move, r_stat_batch_dynamic_triangles_because_deformvertexes_normal, r_stat_batch_dynamic_triangles_because_deformvertexes_wave, r_stat_batch_dynamic_triangles_because_lightmapvertex, r_stat_batch_dynamic_triangles_because_nogaps, r_stat_batch_dynamic_triangles_because_tcgen_environment, r_stat_batch_dynamic_triangles_because_tcgen_lightmap, r_stat_batch_dynamic_triangles_because_tcgen_vector, r_stat_batch_dynamic_triangles_because_tcmod_turbulent, r_stat_batch_dynamic_vertices, r_stat_batch_dynamic_vertices_because_cvar, r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite, r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite2, r_stat_batch_dynamic_vertices_because_deformvertexes_bulge, r_stat_batch_dynamic_vertices_because_deformvertexes_move, r_stat_batch_dynamic_vertices_because_deformvertexes_normal, r_stat_batch_dynamic_vertices_because_deformvertexes_wave, r_stat_batch_dynamic_vertices_because_lightmapvertex, r_stat_batch_dynamic_vertices_because_nogaps, r_stat_batch_dynamic_vertices_because_tcgen_environment, r_stat_batch_dynamic_vertices_because_tcgen_lightmap, r_stat_batch_dynamic_vertices_because_tcgen_vector, r_stat_batch_dynamic_vertices_because_tcmod_turbulent, r_stat_batch_dynamicskeletal_batches, r_stat_batch_dynamicskeletal_surfaces, r_stat_batch_dynamicskeletal_triangles, r_stat_batch_dynamicskeletal_vertices, r_stat_batch_fast_batches, r_stat_batch_fast_surfaces, r_stat_batch_fast_triangles, r_stat_batch_fast_vertices, r_stat_batch_surfaces, r_stat_batch_triangles, r_stat_batch_vertices, r_stat_batch_withgaps, R_TestQ3WaveFunc(), r_refdef_view_t::right, right, RSurf_RenumberElements(), rsurface, msurface_lightmapinfo_t::samples, scale, r_refdef_t::scene, rsurfacestate_t::shadertime, sin(), r_refdef_t::stats, msurface_lightmapinfo_t::styles, sw, q3shaderinfo_layer_tcgen_t::tcgen, texture_shaderpass_t::tcgen, q3shaderinfo_layer_tcmod_t::tcmod, texture_shaderpass_t::tcmods, rsurfacestate_t::texture, r_refdef_view_t::up, up, v, v1, v2, Vector4Set, VectorAdd, VectorClear, VectorCopy, VectorDistance2, VectorLength2, VectorLerp, VectorMA, VectorMAMAM, VectorMAMAMAM, VectorNegate, VectorNormalize, VectorReflect, VectorScale, VectorSubtract, r_refdef_t::view, w, q3shaderinfo_deform_t::wavefunc, and q3shaderinfo_deform_t::waveparms.

Referenced by R_DrawDebugModel(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_Mod_DrawShadowMap(), R_SetupShader_Surface(), R_Shadow_RenderLighting_VisibleLighting(), R_Water_AddWaterPlane(), and RSurf_FindWaterPlaneForSurface().

◆ RSurf_RenumberElements()

static void RSurf_RenumberElements ( const int * inelement3i,
int * outelement3i,
int numelements,
int adjust )
static

Definition at line 7380 of file gl_rmain.c.

7381{
7382 int i;
7383 for (i = 0;i < numelements;i++)
7384 outelement3i[i] = inelement3i[i] + adjust;
7385}

References i.

Referenced by RSurf_PrepareVerticesForBatch().

◆ RSurf_SetupDepthAndCulling()

void RSurf_SetupDepthAndCulling ( bool ui)

Definition at line 8576 of file gl_rmain.c.

8577{
8578 // submodels are biased to avoid z-fighting with world surfaces that they
8579 // may be exactly overlapping (avoids z-fighting artifacts on certain
8580 // doors and things in Quake maps)
8585}
float biaspolygonoffset
float biaspolygonfactor

References rsurfacestate_t::basepolygonfactor, rsurfacestate_t::basepolygonoffset, texture_t::biaspolygonfactor, texture_t::biaspolygonoffset, r_refdef_view_t::cullface_back, texture_t::currentmaterialflags, GL_CullFace(), GL_DepthRange(), GL_DepthTest(), GL_NONE, GL_PolygonOffset(), MATERIALFLAG_NOCULLFACE, MATERIALFLAG_NODEPTHTEST, MATERIALFLAG_SHORTDEPTHRANGE, r_refdef, rsurface, rsurfacestate_t::texture, and r_refdef_t::view.

Referenced by R_DrawModelTextureSurfaceList(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_Sky(), and R_Shadow_RenderLighting().

◆ RSurf_UploadBuffersForBatch()

void RSurf_UploadBuffersForBatch ( void )

Definition at line 7340 of file gl_rmain.c.

7341{
7342 // upload buffer data for generated vertex data (dynamicvertex case) or index data (copytriangles case) and models that lack it to begin with (e.g. DrawQ_FlushUI)
7343 // note that if rsurface.batchvertex3f_vertexbuffer is NULL, dynamicvertex is forced as we don't account for the proper base vertex here.
7362
7367
7375 R_Mesh_TexCoordPointer(5, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0);
7378}
void R_Mesh_VertexPointer(int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
void R_Mesh_TexCoordPointer(unsigned int unitnum, int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
void R_Mesh_ColorPointer(int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
#define GL_FLOAT
Definition glquake.h:124
#define GL_UNSIGNED_BYTE
Definition glquake.h:119

References rsurfacestate_t::batchelement3i, rsurfacestate_t::batchelement3i_bufferoffset, rsurfacestate_t::batchelement3i_indexbuffer, rsurfacestate_t::batchelement3s, rsurfacestate_t::batchelement3s_bufferoffset, rsurfacestate_t::batchelement3s_indexbuffer, rsurfacestate_t::batchlightmapcolor4f, rsurfacestate_t::batchlightmapcolor4f_bufferoffset, rsurfacestate_t::batchlightmapcolor4f_vertexbuffer, rsurfacestate_t::batchnormal3f, rsurfacestate_t::batchnormal3f_bufferoffset, rsurfacestate_t::batchnormal3f_vertexbuffer, rsurfacestate_t::batchnumtriangles, rsurfacestate_t::batchnumvertices, rsurfacestate_t::batchskeletalindex4ub, rsurfacestate_t::batchskeletalindex4ub_bufferoffset, rsurfacestate_t::batchskeletalindex4ub_vertexbuffer, rsurfacestate_t::batchskeletalweight4ub, rsurfacestate_t::batchskeletalweight4ub_bufferoffset, rsurfacestate_t::batchskeletalweight4ub_vertexbuffer, rsurfacestate_t::batchsvector3f, rsurfacestate_t::batchsvector3f_bufferoffset, rsurfacestate_t::batchsvector3f_vertexbuffer, rsurfacestate_t::batchtexcoordlightmap2f, rsurfacestate_t::batchtexcoordlightmap2f_bufferoffset, rsurfacestate_t::batchtexcoordlightmap2f_vertexbuffer, rsurfacestate_t::batchtexcoordtexture2f, rsurfacestate_t::batchtexcoordtexture2f_bufferoffset, rsurfacestate_t::batchtexcoordtexture2f_vertexbuffer, rsurfacestate_t::batchtvector3f, rsurfacestate_t::batchtvector3f_bufferoffset, rsurfacestate_t::batchtvector3f_vertexbuffer, rsurfacestate_t::batchvertex3f, rsurfacestate_t::batchvertex3f_bufferoffset, rsurfacestate_t::batchvertex3f_vertexbuffer, GL_FLOAT, GL_UNSIGNED_BYTE, NULL, R_BUFFERDATA_INDEX16, R_BUFFERDATA_INDEX32, R_BufferData_Store(), R_BUFFERDATA_VERTEX, R_Mesh_ColorPointer(), R_Mesh_TexCoordPointer(), R_Mesh_VertexPointer(), and rsurface.

Referenced by R_SetupShader_Surface().

◆ ShaderModeInfo_GetShaderText()

static char * ShaderModeInfo_GetShaderText ( shadermodeinfo_t * modeinfo,
qbool printfromdisknotice,
qbool builtinonly )
static

Definition at line 1006 of file gl_rmain.c.

1007{
1008 char *shaderstring;
1009 // if the mode has no filename we have to return the builtin string
1010 if (builtinonly || !modeinfo->filename)
1011 return Mem_strdup(r_main_mempool, modeinfo->builtinstring);
1012 // note that FS_LoadFile appends a 0 byte to make it a valid string
1013 shaderstring = (char *)FS_LoadFile(modeinfo->filename, r_main_mempool, false, NULL);
1014 if (shaderstring)
1015 {
1016 if (printfromdisknotice)
1017 Con_DPrintf("Loading shaders from file %s...\n", modeinfo->filename);
1018 return shaderstring;
1019 }
1020 // fall back to builtinstring
1021 return Mem_strdup(r_main_mempool, modeinfo->builtinstring);
1022}

References shadermodeinfo_t::builtinstring, Con_DPrintf(), shadermodeinfo_t::filename, FS_LoadFile(), Mem_strdup, NULL, and r_main_mempool.

Referenced by R_GLSL_CompilePermutation().

◆ V_MakeViewIsometric()

void V_MakeViewIsometric ( void )
extern

Definition at line 968 of file view.c.

969{
970 // when using isometric view to play normal games we have to rotate the camera to make the Ortho matrix do the right thing (forward as up the screen, etc)
971 matrix4x4_t relative;
972 matrix4x4_t modifiedview;
973 matrix4x4_t modify;
974 vec3_t forward, left, up, org;
975 float t[16];
976
983 r_refdef.view.ortho_x = r_refdef.view.frustum_x; // used by VM_CL_R_SetView
984 r_refdef.view.ortho_y = r_refdef.view.frustum_y; // used by VM_CL_R_SetView
985
986 t[0] = v_isometric_xx.value;
987 t[1] = v_isometric_xy.value;
988 t[2] = v_isometric_xz.value;
989 t[3] = 0.0f;
990 t[4] = v_isometric_yx.value;
991 t[5] = v_isometric_yy.value;
992 t[6] = v_isometric_yz.value;
993 t[7] = 0.0f;
994 t[8] = v_isometric_zx.value;
995 t[9] = v_isometric_zy.value;
996 t[10] = v_isometric_zz.value;
997 t[11] = 0.0f;
998 t[12] = 0.0f;
999 t[13] = 0.0f;
1000 t[14] = 0.0f;
1001 t[15] = 1.0f;
1002 Matrix4x4_FromArrayFloatGL(&modify, t);
1003
1004 // if the orientation is locked, extract the origin and create just a translate matrix to start with
1006 {
1007 vec3_t vx, vy, vz, origin;
1010 }
1011
1012 Matrix4x4_Concat(&modifiedview, &r_refdef.view.matrix, &modify);
1014 Matrix4x4_Concat(&r_refdef.view.matrix, &modifiedview, &relative);
1018
1020 {
1024 }
1025}
cvar_t vid_pixelheight
Definition cl_screen.c:58
void Matrix4x4_FromArrayFloatGL(matrix4x4_t *out, const float in[16])
Definition matrixlib.c:1204
vec_t viewzoom
Definition client.h:794
float frustumscale_y
Definition render.h:403
float frustumscale_x
Definition render.h:403
cvar_t v_isometric_xx
Definition view.c:99
cvar_t v_isometric_rot_pitch
Definition view.c:111
cvar_t v_isometric_verticalfov
Definition view.c:98
cvar_t v_isometric_flipcullface
Definition view.c:117
cvar_t v_isometric_zz
Definition view.c:107
cvar_t v_isometric_zx
Definition view.c:105
cvar_t v_isometric_usevieworiginculling
Definition view.c:119
cvar_t v_isometric_relx
Definition view.c:114
cvar_t v_isometric_yy
Definition view.c:103
cvar_t v_isometric_relz
Definition view.c:116
cvar_t v_isometric_rely
Definition view.c:115
cvar_t v_isometric_zy
Definition view.c:106
cvar_t v_isometric_rot_roll
Definition view.c:113
cvar_t v_isometric_tz
Definition view.c:110
cvar_t v_isometric_ty
Definition view.c:109
cvar_t v_isometric_tx
Definition view.c:108
cvar_t v_isometric_yx
Definition view.c:102
cvar_t v_isometric_rot_yaw
Definition view.c:112
cvar_t v_isometric_xy
Definition view.c:100
cvar_t v_isometric_locked_orientation
Definition view.c:118
cvar_t v_isometric_xz
Definition view.c:101
cvar_t v_isometric_yz
Definition view.c:104

References a, cl, r_refdef_view_t::cullface_back, r_refdef_view_t::cullface_front, float, forward, r_refdef_view_t::frustum_x, r_refdef_view_t::frustum_y, r_refdef_t::frustumscale_x, r_refdef_t::frustumscale_y, r_refdef_view_t::height, cvar_t::integer, r_refdef_view_t::matrix, Matrix4x4_Concat(), Matrix4x4_CreateFromQuakeEntity(), Matrix4x4_CreateTranslate(), Matrix4x4_FromArrayFloatGL(), Matrix4x4_FromVectors(), Matrix4x4_ToVectors(), origin, r_refdef_view_t::ortho_x, r_refdef_view_t::ortho_y, r_refdef, r_trippy, up, r_refdef_view_t::useperspective, r_refdef_view_t::usevieworiginculling, v_isometric_flipcullface, v_isometric_locked_orientation, v_isometric_relx, v_isometric_rely, v_isometric_relz, v_isometric_rot_pitch, v_isometric_rot_roll, v_isometric_rot_yaw, v_isometric_tx, v_isometric_ty, v_isometric_tz, v_isometric_usevieworiginculling, v_isometric_verticalfov, v_isometric_xx, v_isometric_xy, v_isometric_xz, v_isometric_yx, v_isometric_yy, v_isometric_yz, v_isometric_zx, v_isometric_zy, v_isometric_zz, cvar_t::value, VectorMAMAMAM, vid_pixelheight, r_refdef_t::view, client_state_t::viewzoom, and r_refdef_view_t::width.

Referenced by R_RenderView().

Variable Documentation

◆ bboxedges

const float bboxedges[BBOXEDGES][6]
static
Initial value:
=
{
{ 0, 0, 0, 1, 1, 1 },
{ 0, 0, 0, 0, 1, 0 },
{ 0, 0, 0, 1, 0, 0 },
{ 0, 1, 0, 1, 1, 0 },
{ 1, 0, 0, 1, 1, 0 },
{ 0, 0, 1, 0, 1, 1 },
{ 0, 0, 1, 1, 0, 1 },
{ 0, 1, 1, 1, 1, 1 },
{ 1, 0, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 1, 0, 1 },
{ 0, 1, 0, 0, 1, 1 },
{ 1, 1, 0, 1, 1, 1 },
}

Definition at line 6013 of file gl_rmain.c.

6014{
6015 // whole box
6016 { 0, 0, 0, 1, 1, 1 },
6017 // bottom edges
6018 { 0, 0, 0, 0, 1, 0 },
6019 { 0, 0, 0, 1, 0, 0 },
6020 { 0, 1, 0, 1, 1, 0 },
6021 { 1, 0, 0, 1, 1, 0 },
6022 // top edges
6023 { 0, 0, 1, 0, 1, 1 },
6024 { 0, 0, 1, 1, 0, 1 },
6025 { 0, 1, 1, 1, 1, 1 },
6026 { 1, 0, 1, 1, 1, 1 },
6027 // vertical edges
6028 { 0, 0, 0, 0, 0, 1 },
6029 { 1, 0, 0, 1, 0, 1 },
6030 { 0, 1, 0, 0, 1, 1 },
6031 { 1, 1, 0, 1, 1, 1 },
6032};

Referenced by R_DrawBBoxMesh().

◆ bboxelements

const unsigned short bboxelements[36]
static
Initial value:
=
{
5, 1, 3, 5, 3, 7,
6, 2, 0, 6, 0, 4,
7, 3, 2, 7, 2, 6,
4, 0, 1, 4, 1, 5,
4, 5, 7, 4, 7, 6,
1, 0, 2, 1, 2, 3,
}

Definition at line 6002 of file gl_rmain.c.

6003{
6004 5, 1, 3, 5, 3, 7,
6005 6, 2, 0, 6, 0, 4,
6006 7, 3, 2, 7, 2, 6,
6007 4, 0, 1, 4, 1, 5,
6008 4, 5, 7, 4, 7, 6,
6009 1, 0, 2, 1, 2, 3,
6010};

Referenced by R_DrawBBoxMesh().

◆ builtinshaderstrings

const char* builtinshaderstrings[]
static

Definition at line 596 of file gl_rmain.c.

597{
598#include "shader_glsl.h"
5990
600};

◆ cl_decals_bias

cvar_t cl_decals_bias
extern

Definition at line 310 of file cl_particles.c.

310{CF_CLIENT | CF_ARCHIVE, "cl_decals_bias", "0.125", "distance to bias decals from surface to prevent depth fighting"};
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
Definition cmd.h:53

Referenced by CL_Particles_Init(), and R_DecalSystem_SplatTriangle().

◆ cl_decals_max

cvar_t cl_decals_max
extern

Definition at line 311 of file cl_particles.c.

311{CF_CLIENT | CF_ARCHIVE, "cl_decals_max", "4096", "maximum number of decals allowed to exist in the world at once"};

Referenced by CL_Particles_Init(), and R_DrawModelDecals_FadeEntity().

◆ cl_decals_models

cvar_t cl_decals_models
extern

Definition at line 309 of file cl_particles.c.

309{CF_CLIENT | CF_ARCHIVE, "cl_decals_models", "0", "enables decals on animated models"};

Referenced by CL_Particles_Init(), and R_DecalSystem_SplatEntity().

◆ cl_decals_newsystem_intensitymultiplier

cvar_t cl_decals_newsystem_intensitymultiplier
extern

Definition at line 306 of file cl_particles.c.

306{CF_CLIENT | CF_ARCHIVE, "cl_decals_newsystem_intensitymultiplier", "2", "boosts intensity of decals (because the distance fade can make them hard to see otherwise)"};

Referenced by CL_Particles_Init(), and R_DecalSystem_SplatTriangle().

◆ cl_locs_show

cvar_t cl_locs_show
extern

Definition at line 98 of file cl_main.c.

98{CF_CLIENT, "locs_show", "0", "shows defined locations for editing purposes"};

Referenced by CL_Init(), and R_RenderScene().

◆ componentorder

int componentorder[4] = {0, 1, 2, 3}
static

Definition at line 2906 of file gl_rmain.c.

2906{0, 1, 2, 3};

Referenced by R_LoadCubemap().

◆ decalskinframe

skinframe_t* decalskinframe
extern

Definition at line 187 of file cl_particles.c.

Referenced by R_DrawModelDecals_Entity(), R_InitParticleTexture(), and r_part_newmap().

◆ developer_texturelogging

cvar_t developer_texturelogging = {CF_CLIENT, "developer_texturelogging", "0", "produces a textures.log file containing names of skins and map textures the engine tried to load"}

Definition at line 231 of file gl_rmain.c.

231{CF_CLIENT, "developer_texturelogging", "0", "produces a textures.log file containing names of skins and map textures the engine tried to load"};

Referenced by GL_Main_Init(), and loadimagepixelsbgra().

◆ gl_fogblue

cvar_t gl_fogblue = {CF_CLIENT, "gl_fogblue","0.3", "nehahra fog color blue value (for Nehahra compatibility only)"}

Definition at line 151 of file gl_rmain.c.

151{CF_CLIENT, "gl_fogblue","0.3", "nehahra fog color blue value (for Nehahra compatibility only)"};

Referenced by FOG_clear(), GL_Main_Init(), and R_UpdateFog().

◆ gl_fogdensity

cvar_t gl_fogdensity = {CF_CLIENT, "gl_fogdensity", "0.25", "nehahra fog density (recommend values below 0.1) (for Nehahra compatibility only)"}

Definition at line 148 of file gl_rmain.c.

148{CF_CLIENT, "gl_fogdensity", "0.25", "nehahra fog density (recommend values below 0.1) (for Nehahra compatibility only)"};

Referenced by FOG_clear(), GL_Main_Init(), and R_UpdateFog().

◆ gl_fogenable

cvar_t gl_fogenable = {CF_CLIENT, "gl_fogenable", "0", "nehahra fog enable (for Nehahra compatibility only)"}

Definition at line 147 of file gl_rmain.c.

147{CF_CLIENT, "gl_fogenable", "0", "nehahra fog enable (for Nehahra compatibility only)"};

Referenced by FOG_clear(), GL_Main_Init(), and R_UpdateFog().

◆ gl_fogend

cvar_t gl_fogend = {CF_CLIENT, "gl_fogend","0", "nehahra fog end distance (for Nehahra compatibility only)"}

Definition at line 153 of file gl_rmain.c.

153{CF_CLIENT, "gl_fogend","0", "nehahra fog end distance (for Nehahra compatibility only)"};

Referenced by GL_Main_Init().

◆ gl_foggreen

cvar_t gl_foggreen = {CF_CLIENT, "gl_foggreen","0.3", "nehahra fog color green value (for Nehahra compatibility only)"}

Definition at line 150 of file gl_rmain.c.

150{CF_CLIENT, "gl_foggreen","0.3", "nehahra fog color green value (for Nehahra compatibility only)"};

Referenced by FOG_clear(), GL_Main_Init(), and R_UpdateFog().

◆ gl_fogred

cvar_t gl_fogred = {CF_CLIENT, "gl_fogred","0.3", "nehahra fog color red value (for Nehahra compatibility only)"}

Definition at line 149 of file gl_rmain.c.

149{CF_CLIENT, "gl_fogred","0.3", "nehahra fog color red value (for Nehahra compatibility only)"};

Referenced by FOG_clear(), GL_Main_Init(), and R_UpdateFog().

◆ gl_fogstart

cvar_t gl_fogstart = {CF_CLIENT, "gl_fogstart", "0", "nehahra fog start distance (for Nehahra compatibility only)"}

Definition at line 152 of file gl_rmain.c.

152{CF_CLIENT, "gl_fogstart", "0", "nehahra fog start distance (for Nehahra compatibility only)"};

Referenced by GL_Main_Init().

◆ gl_lightmaps

cvar_t gl_lightmaps = {CF_CLIENT, "gl_lightmaps", "0", "draws only lightmaps, no texture (for level designers), a value of 2 keeps normalmap shading"}

Definition at line 233 of file gl_rmain.c.

233{CF_CLIENT, "gl_lightmaps", "0", "draws only lightmaps, no texture (for level designers), a value of 2 keeps normalmap shading"};

Referenced by GL_Main_Init(), R_GetCurrentTexture(), and R_SetupShader_Surface().

◆ gl_picmip

cvar_t gl_picmip
extern

Definition at line 29 of file gl_textures.c.

29{CF_CLIENT | CF_ARCHIVE, "gl_picmip", "0", "reduces resolution of textures by powers of 2, for example 1 will halve width/height, reducing texture memory usage by 75%"};

◆ gl_skyclip

cvar_t gl_skyclip = {CF_CLIENT, "gl_skyclip", "4608", "nehahra farclip distance - the real fog end (for Nehahra compatibility only)"}

Definition at line 154 of file gl_rmain.c.

154{CF_CLIENT, "gl_skyclip", "4608", "nehahra farclip distance - the real fog end (for Nehahra compatibility only)"};

Referenced by GL_Main_Init(), and R_UpdateFog().

◆ irisvecs

float irisvecs[7][3] = {{0, 0, 0}, {-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}}
static

Definition at line 4142 of file gl_rmain.c.

4142{{0, 0, 0}, {-1, 0, 0}, {1, 0, 0}, {0, -1, 0}, {0, 1, 0}, {0, 0, -1}, {0, 0, 1}};

Referenced by R_HDR_UpdateIrisAdaptation().

◆ loadingscreentexture

◆ locboxelements

unsigned short locboxelements[6 *2 *3]
Initial value:
=
{
0, 1, 2, 0, 2, 3,
4, 5, 6, 4, 6, 7,
8, 9,10, 8,10,11,
12,13,14, 12,14,15,
16,17,18, 16,18,19,
20,21,22, 20,22,23
}

Definition at line 9068 of file gl_rmain.c.

9069{
9070 0, 1, 2, 0, 2, 3,
9071 4, 5, 6, 4, 6, 7,
9072 8, 9,10, 8,10,11,
9073 12,13,14, 12,14,15,
9074 16,17,18, 16,18,19,
9075 20,21,22, 20,22,23
9076};

Referenced by R_DrawLoc_Callback().

◆ locboxvertex3f

float locboxvertex3f[6 *4 *3]
Initial value:
=
{
1,0,1, 1,0,0, 1,1,0, 1,1,1,
0,1,1, 0,1,0, 0,0,0, 0,0,1,
1,1,1, 1,1,0, 0,1,0, 0,1,1,
0,0,1, 0,0,0, 1,0,0, 1,0,1,
0,0,1, 1,0,1, 1,1,1, 0,1,1,
1,0,0, 0,0,0, 0,1,0, 1,1,0
}

Definition at line 9058 of file gl_rmain.c.

9059{
9060 1,0,1, 1,0,0, 1,1,0, 1,1,1,
9061 0,1,1, 0,1,0, 0,0,0, 0,0,1,
9062 1,1,1, 1,1,0, 0,1,0, 0,1,1,
9063 0,0,1, 0,0,0, 1,0,0, 1,0,1,
9064 0,0,1, 1,0,1, 1,1,1, 0,1,1,
9065 1,0,0, 0,0,0, 0,1,0, 1,1,0
9066};

Referenced by R_DrawLoc_Callback().

◆ nomodelcolor4f

const float nomodelcolor4f[6 *4]
static
Initial value:
=
{
0.0f, 0.0f, 0.5f, 1.0f,
0.0f, 0.0f, 0.5f, 1.0f,
0.0f, 0.5f, 0.0f, 1.0f,
0.0f, 0.5f, 0.0f, 1.0f,
0.5f, 0.0f, 0.0f, 1.0f,
0.5f, 0.0f, 0.0f, 1.0f
}

Definition at line 6178 of file gl_rmain.c.

6179{
6180 0.0f, 0.0f, 0.5f, 1.0f,
6181 0.0f, 0.0f, 0.5f, 1.0f,
6182 0.0f, 0.5f, 0.0f, 1.0f,
6183 0.0f, 0.5f, 0.0f, 1.0f,
6184 0.5f, 0.0f, 0.0f, 1.0f,
6185 0.5f, 0.0f, 0.0f, 1.0f
6186};

Referenced by R_DrawNoModel_TransparentCallback().

◆ nomodelelement3i

const int nomodelelement3i[24]
static
Initial value:
=
{
5, 2, 0,
5, 1, 2,
5, 0, 3,
5, 3, 1,
0, 2, 4,
2, 1, 4,
3, 0, 4,
1, 3, 4
}

Definition at line 6144 of file gl_rmain.c.

6145{
6146 5, 2, 0,
6147 5, 1, 2,
6148 5, 0, 3,
6149 5, 3, 1,
6150 0, 2, 4,
6151 2, 1, 4,
6152 3, 0, 4,
6153 1, 3, 4
6154};

Referenced by R_DrawNoModel_TransparentCallback().

◆ nomodelelement3s

const unsigned short nomodelelement3s[24]
static
Initial value:
=
{
5, 2, 0,
5, 1, 2,
5, 0, 3,
5, 3, 1,
0, 2, 4,
2, 1, 4,
3, 0, 4,
1, 3, 4
}

Definition at line 6156 of file gl_rmain.c.

6157{
6158 5, 2, 0,
6159 5, 1, 2,
6160 5, 0, 3,
6161 5, 3, 1,
6162 0, 2, 4,
6163 2, 1, 4,
6164 3, 0, 4,
6165 1, 3, 4
6166};

Referenced by R_DrawNoModel_TransparentCallback().

◆ nomodelvertex3f

const float nomodelvertex3f[6 *3]
static
Initial value:
=
{
-16, 0, 0,
16, 0, 0,
0, -16, 0,
0, 16, 0,
0, 0, -16,
0, 0, 16
}

Definition at line 6168 of file gl_rmain.c.

6169{
6170 -16, 0, 0,
6171 16, 0, 0,
6172 0, -16, 0,
6173 0, 16, 0,
6174 0, 0, -16,
6175 0, 0, 16
6176};

Referenced by R_DrawNoModel_TransparentCallback().

◆ quadedges

const int quadedges[6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}}
static

Definition at line 7387 of file gl_rmain.c.

7387{{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}};

Referenced by RSurf_PrepareVerticesForBatch().

◆ r_batch_debugdynamicvertexpath

cvar_t r_batch_debugdynamicvertexpath = {CF_CLIENT | CF_ARCHIVE, "r_batch_debugdynamicvertexpath", "0", "force the dynamic batching code path for debugging purposes"}

Definition at line 239 of file gl_rmain.c.

239{CF_CLIENT | CF_ARCHIVE, "r_batch_debugdynamicvertexpath", "0", "force the dynamic batching code path for debugging purposes"};

Referenced by GL_Main_Init(), and RSurf_PrepareVerticesForBatch().

◆ r_batch_dynamicbuffer

cvar_t r_batch_dynamicbuffer = {CF_CLIENT | CF_ARCHIVE, "r_batch_dynamicbuffer", "0", "use vertex/index buffers for drawing dynamic and copytriangles batches"}

Definition at line 240 of file gl_rmain.c.

240{CF_CLIENT | CF_ARCHIVE, "r_batch_dynamicbuffer", "0", "use vertex/index buffers for drawing dynamic and copytriangles batches"};

Referenced by GL_Main_Init().

◆ r_batch_multidraw

cvar_t r_batch_multidraw = {CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw", "1", "issue multiple glDrawElements calls when rendering a batch of surfaces with the same texture (otherwise the index data is copied to make it one draw)"}

Definition at line 237 of file gl_rmain.c.

237{CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw", "1", "issue multiple glDrawElements calls when rendering a batch of surfaces with the same texture (otherwise the index data is copied to make it one draw)"};

Referenced by GL_Main_Init(), and RSurf_PrepareVerticesForBatch().

◆ r_batch_multidraw_mintriangles

cvar_t r_batch_multidraw_mintriangles = {CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw_mintriangles", "0", "minimum number of triangles to activate multidraw path (copying small groups of triangles may be faster)"}

Definition at line 238 of file gl_rmain.c.

238{CF_CLIENT | CF_ARCHIVE, "r_batch_multidraw_mintriangles", "0", "minimum number of triangles to activate multidraw path (copying small groups of triangles may be faster)"};

Referenced by GL_Main_Init(), and RSurf_PrepareVerticesForBatch().

◆ r_bloom

cvar_t r_bloom = {CF_CLIENT | CF_ARCHIVE, "r_bloom", "0", "enables bloom effect (makes bright pixels affect neighboring pixels)"}

Definition at line 208 of file gl_rmain.c.

208{CF_CLIENT | CF_ARCHIVE, "r_bloom", "0", "enables bloom effect (makes bright pixels affect neighboring pixels)"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_StartFrame().

◆ r_bloom_blur

cvar_t r_bloom_blur = {CF_CLIENT | CF_ARCHIVE, "r_bloom_blur", "4", "how large the glow is"}

Definition at line 212 of file gl_rmain.c.

212{CF_CLIENT | CF_ARCHIVE, "r_bloom_blur", "4", "how large the glow is"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), R_Bloom_MakeTexture(), and R_Bloom_StartFrame().

◆ r_bloom_brighten

cvar_t r_bloom_brighten = {CF_CLIENT | CF_ARCHIVE, "r_bloom_brighten", "1", "how bright the glow is, after subtract/power"}

Definition at line 211 of file gl_rmain.c.

211{CF_CLIENT | CF_ARCHIVE, "r_bloom_brighten", "1", "how bright the glow is, after subtract/power"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_MakeTexture().

◆ r_bloom_colorexponent

cvar_t r_bloom_colorexponent = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorexponent", "1", "how exaggerated the glow is"}

Definition at line 214 of file gl_rmain.c.

214{CF_CLIENT | CF_ARCHIVE, "r_bloom_colorexponent", "1", "how exaggerated the glow is"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_MakeTexture().

◆ r_bloom_colorscale

cvar_t r_bloom_colorscale = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorscale", "1", "how bright the glow is"}

Definition at line 209 of file gl_rmain.c.

209{CF_CLIENT | CF_ARCHIVE, "r_bloom_colorscale", "1", "how bright the glow is"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_MakeTexture().

◆ r_bloom_colorsubtract

cvar_t r_bloom_colorsubtract = {CF_CLIENT | CF_ARCHIVE, "r_bloom_colorsubtract", "0.1", "reduces bloom colors by a certain amount"}

Definition at line 215 of file gl_rmain.c.

215{CF_CLIENT | CF_ARCHIVE, "r_bloom_colorsubtract", "0.1", "reduces bloom colors by a certain amount"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_BlendView().

◆ r_bloom_resolution

cvar_t r_bloom_resolution = {CF_CLIENT | CF_ARCHIVE, "r_bloom_resolution", "320", "what resolution to perform the bloom effect at (independent of screen resolution)"}

Definition at line 213 of file gl_rmain.c.

213{CF_CLIENT | CF_ARCHIVE, "r_bloom_resolution", "320", "what resolution to perform the bloom effect at (independent of screen resolution)"};

Referenced by GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_Bloom_StartFrame().

◆ r_bloom_scenebrightness

cvar_t r_bloom_scenebrightness = {CF_CLIENT | CF_ARCHIVE, "r_bloom_scenebrightness", "1", "global rendering brightness when bloom is enabled"}

Definition at line 216 of file gl_rmain.c.

216{CF_CLIENT | CF_ARCHIVE, "r_bloom_scenebrightness", "1", "global rendering brightness when bloom is enabled"};

Referenced by GL_Main_Init(), and R_RenderView().

◆ r_bufferdata_buffer

◆ r_bufferdata_cycle

int r_bufferdata_cycle = 0
static

Definition at line 3609 of file gl_rmain.c.

Referenced by R_BufferData_NewFrame(), R_BufferData_Resize(), and R_BufferData_Store().

◆ r_buffermegs

cvar_t r_buffermegs[R_BUFFERDATA_COUNT]
Initial value:
=
{
{CF_CLIENT | CF_ARCHIVE, "r_buffermegs_vertex", "4", "vertex buffer size for one frame"},
{CF_CLIENT | CF_ARCHIVE, "r_buffermegs_index16", "1", "index buffer size for one frame (16bit indices)"},
{CF_CLIENT | CF_ARCHIVE, "r_buffermegs_index32", "1", "index buffer size for one frame (32bit indices)"},
{CF_CLIENT | CF_ARCHIVE, "r_buffermegs_uniform", "0.25", "uniform buffer size for one frame"},
}

Definition at line 249 of file gl_rmain.c.

250{
251 {CF_CLIENT | CF_ARCHIVE, "r_buffermegs_vertex", "4", "vertex buffer size for one frame"},
252 {CF_CLIENT | CF_ARCHIVE, "r_buffermegs_index16", "1", "index buffer size for one frame (16bit indices)"},
253 {CF_CLIENT | CF_ARCHIVE, "r_buffermegs_index32", "1", "index buffer size for one frame (32bit indices)"},
254 {CF_CLIENT | CF_ARCHIVE, "r_buffermegs_uniform", "0.25", "uniform buffer size for one frame"},
255};

Referenced by GL_Main_Init(), and R_BufferData_Resize().

◆ r_celoutlines

cvar_t r_celoutlines = {CF_CLIENT | CF_ARCHIVE, "r_celoutlines", "0", "cartoon-style outlines (requires r_shadow_deferred)"}

Definition at line 145 of file gl_rmain.c.

145{CF_CLIENT | CF_ARCHIVE, "r_celoutlines", "0", "cartoon-style outlines (requires r_shadow_deferred)"};

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_celshading

cvar_t r_celshading = {CF_CLIENT | CF_ARCHIVE, "r_celshading", "0", "cartoon-style light shading (OpenGL 2.x only)"}

Definition at line 144 of file gl_rmain.c.

144{CF_CLIENT | CF_ARCHIVE, "r_celshading", "0", "cartoon-style light shading (OpenGL 2.x only)"}; // FIXME remove OpenGL 2.x only once implemented for DX9

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_colorfringe

cvar_t r_colorfringe = {CF_CLIENT | CF_ARCHIVE, "r_colorfringe", "0", "Chromatic aberration. Values higher than 0.025 will noticeably distort the image"}

Definition at line 189 of file gl_rmain.c.

189{CF_CLIENT | CF_ARCHIVE, "r_colorfringe", "0", "Chromatic aberration. Values higher than 0.025 will noticeably distort the image"};

Referenced by GL_Main_Init(), R_BlendView(), R_BlendView_IsTrivial(), and R_CompileShader_CheckStaticParms().

◆ r_compileshader_staticparms

unsigned int r_compileshader_staticparms[(SHADERSTATICPARMS_COUNT+0x1F) > > 5] = {0}
static

Definition at line 856 of file gl_rmain.c.

856{0};

Referenced by R_CompileShader_CheckStaticParms().

◆ r_cullentities_trace

cvar_t r_cullentities_trace = {CF_CLIENT, "r_cullentities_trace", "1", "probabistically cull invisible entities"}

Definition at line 101 of file gl_rmain.c.

101{CF_CLIENT, "r_cullentities_trace", "1", "probabistically cull invisible entities"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_delay

cvar_t r_cullentities_trace_delay = {CF_CLIENT, "r_cullentities_trace_delay", "1", "number of seconds until the entity gets actually culled"}

Definition at line 108 of file gl_rmain.c.

108{CF_CLIENT, "r_cullentities_trace_delay", "1", "number of seconds until the entity gets actually culled"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_enlarge

cvar_t r_cullentities_trace_enlarge = {CF_CLIENT, "r_cullentities_trace_enlarge", "0", "box enlargement for entity culling"}

Definition at line 105 of file gl_rmain.c.

105{CF_CLIENT, "r_cullentities_trace_enlarge", "0", "box enlargement for entity culling"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_entityocclusion

cvar_t r_cullentities_trace_entityocclusion = {CF_CLIENT, "r_cullentities_trace_entityocclusion", "1", "check for occluding entities such as doors, not just world hull"}

Definition at line 102 of file gl_rmain.c.

102{CF_CLIENT, "r_cullentities_trace_entityocclusion", "1", "check for occluding entities such as doors, not just world hull"};

Referenced by GL_Main_Init(), and R_CanSeeBox().

◆ r_cullentities_trace_expand

cvar_t r_cullentities_trace_expand = {CF_CLIENT, "r_cullentities_trace_expand", "0", "box expanded by this many units for entity culling"}

Definition at line 106 of file gl_rmain.c.

106{CF_CLIENT, "r_cullentities_trace_expand", "0", "box expanded by this many units for entity culling"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_eyejitter

cvar_t r_cullentities_trace_eyejitter = {CF_CLIENT, "r_cullentities_trace_eyejitter", "16", "randomly offset rays from the eye by this much to reduce the odds of flickering"}

Definition at line 109 of file gl_rmain.c.

109{CF_CLIENT, "r_cullentities_trace_eyejitter", "16", "randomly offset rays from the eye by this much to reduce the odds of flickering"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_pad

cvar_t r_cullentities_trace_pad = {CF_CLIENT, "r_cullentities_trace_pad", "8", "accept traces that hit within this many units of the box"}

Definition at line 107 of file gl_rmain.c.

107{CF_CLIENT, "r_cullentities_trace_pad", "8", "accept traces that hit within this many units of the box"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_samples

cvar_t r_cullentities_trace_samples = {CF_CLIENT, "r_cullentities_trace_samples", "2", "number of samples to test for entity culling (in addition to center sample)"}

Definition at line 103 of file gl_rmain.c.

103{CF_CLIENT, "r_cullentities_trace_samples", "2", "number of samples to test for entity culling (in addition to center sample)"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_cullentities_trace_tempentitysamples

cvar_t r_cullentities_trace_tempentitysamples = {CF_CLIENT, "r_cullentities_trace_tempentitysamples", "-1", "number of samples to test for entity culling of temp entities (including all CSQC entities), -1 disables trace culling on these entities to prevent flicker (pvs still applies)"}

Definition at line 104 of file gl_rmain.c.

104{CF_CLIENT, "r_cullentities_trace_tempentitysamples", "-1", "number of samples to test for entity culling of temp entities (including all CSQC entities), -1 disables trace culling on these entities to prevent flicker (pvs still applies)"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_currentscenetype

r_refdef_scene_type_t r_currentscenetype = RST_CLIENT
static

Definition at line 5566 of file gl_rmain.c.

Referenced by R_GetScenePointer(), and R_SelectScene().

◆ r_damageblur

cvar_t r_damageblur = {CF_CLIENT | CF_ARCHIVE, "r_damageblur", "0", "screen motionblur based on damage - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"}

Definition at line 60 of file gl_rmain.c.

60{CF_CLIENT | CF_ARCHIVE, "r_damageblur", "0", "screen motionblur based on damage - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"};

Referenced by GL_Main_Init(), R_Bloom_StartFrame(), and R_MotionBlurView().

◆ r_decalsystem_numqueued

int r_decalsystem_numqueued = 0

◆ r_decalsystem_queue

◆ r_deformvertexes

cvar_t r_deformvertexes = {CF_CLIENT, "r_deformvertexes", "1", "allows use of deformvertexes in shader files (can be turned off to check performance impact)"}

Definition at line 77 of file gl_rmain.c.

77{CF_CLIENT, "r_deformvertexes", "1", "allows use of deformvertexes in shader files (can be turned off to check performance impact)"};

Referenced by GL_Main_Init(), and RSurf_PrepareVerticesForBatch().

◆ r_depthfirst

cvar_t r_depthfirst = {CF_CLIENT | CF_ARCHIVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"}

Definition at line 72 of file gl_rmain.c.

72{CF_CLIENT | CF_ARCHIVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"};

Referenced by GL_Main_Init(), and R_RenderScene().

◆ r_draw2d

cvar_t r_draw2d = {CF_CLIENT, "r_draw2d","1", "draw 2D stuff (dangerous to turn off)"}

Definition at line 97 of file gl_rmain.c.

97{CF_CLIENT, "r_draw2d","1", "draw 2D stuff (dangerous to turn off)"};

Referenced by DrawQ_FlushUI(), DrawQ_String_Scale(), and GL_Main_Init().

◆ r_drawdecals

cvar_t r_drawdecals
extern

Definition at line 2149 of file cl_particles.c.

2149{CF_CLIENT, "r_drawdecals", "1", "enables drawing of decals"};

Referenced by R_DrawModelDecals(), R_Particles_Init(), and R_Water_ProcessPlanes().

◆ r_drawentities

cvar_t r_drawentities = {CF_CLIENT, "r_drawentities","1", "draw entities (doors, players, projectiles, etc)"}

Definition at line 96 of file gl_rmain.c.

96{CF_CLIENT, "r_drawentities","1", "draw entities (doors, players, projectiles, etc)"};

Referenced by GL_Main_Init(), and R_RenderView().

◆ r_drawexteriormodel

cvar_t r_drawexteriormodel = {CF_CLIENT, "r_drawexteriormodel","1", "draw your player model (e.g. in chase cam, reflections)"}

Definition at line 100 of file gl_rmain.c.

100{CF_CLIENT, "r_drawexteriormodel","1", "draw your player model (e.g. in chase cam, reflections)"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_drawfog

cvar_t r_drawfog = {CF_CLIENT | CF_ARCHIVE, "r_drawfog", "1", "allows one to disable fog rendering"}

Definition at line 139 of file gl_rmain.c.

139{CF_CLIENT | CF_ARCHIVE, "r_drawfog", "1", "allows one to disable fog rendering"};

Referenced by GL_Main_Init(), and R_UpdateFog().

◆ r_drawparticles

cvar_t r_drawparticles
extern

Definition at line 2145 of file cl_particles.c.

2145{CF_CLIENT, "r_drawparticles", "1", "enables drawing of particles"};

Referenced by R_DrawParticles(), R_Particles_Init(), and R_Water_ProcessPlanes().

◆ r_drawportals

cvar_t r_drawportals = {CF_CLIENT, "r_drawportals", "0", "shows portals (separating polygons) in world interior in quake1 maps"}

Definition at line 95 of file gl_rmain.c.

95{CF_CLIENT, "r_drawportals", "0", "shows portals (separating polygons) in world interior in quake1 maps"};

Referenced by GL_Main_Init(), and R_RenderScene().

◆ r_drawviewmodel

cvar_t r_drawviewmodel = {CF_CLIENT, "r_drawviewmodel","1", "draw your weapon model"}

Definition at line 99 of file gl_rmain.c.

99{CF_CLIENT, "r_drawviewmodel","1", "draw your weapon model"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_drawworld

cvar_t r_drawworld = {CF_CLIENT, "r_drawworld","1", "draw world (most static stuff)"}

Definition at line 98 of file gl_rmain.c.

98{CF_CLIENT, "r_drawworld","1", "draw world (most static stuff)"};

Referenced by CL_ClearState(), GL_Main_Init(), VM_CL_R_ClearScene(), and VM_CL_R_SetView().

◆ r_dynamic

cvar_t r_dynamic = {CF_CLIENT | CF_ARCHIVE, "r_dynamic","1", "enables dynamic lights (rocket glow and such)"}

Definition at line 121 of file gl_rmain.c.

121{CF_CLIENT | CF_ARCHIVE, "r_dynamic","1", "enables dynamic lights (rocket glow and such)"};

Referenced by CL_RelinkLightFlashes(), GL_Main_Init(), R_UpdateVariables(), and R_Water_ProcessPlanes().

◆ r_farclip_base

cvar_t r_farclip_base = {CF_CLIENT, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"}

Definition at line 74 of file gl_rmain.c.

74{CF_CLIENT, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"};

Referenced by GL_Main_Init(), and R_UpdateVariables().

◆ r_farclip_world

cvar_t r_farclip_world = {CF_CLIENT, "r_farclip_world", "2", "adds map size to farclip multiplied by this value"}

Definition at line 75 of file gl_rmain.c.

75{CF_CLIENT, "r_farclip_world", "2", "adds map size to farclip multiplied by this value"};

Referenced by GL_Main_Init(), and R_UpdateVariables().

◆ r_fb

◆ r_fog_clear

cvar_t r_fog_clear = {CF_CLIENT, "r_fog_clear", "1", "clears renderbuffer with fog color before render starts"}

Definition at line 138 of file gl_rmain.c.

138{CF_CLIENT, "r_fog_clear", "1", "clears renderbuffer with fog color before render starts"};

Referenced by GL_Main_Init(), and R_ClearScreen().

◆ r_fog_exp2

cvar_t r_fog_exp2 = {CF_CLIENT, "r_fog_exp2", "0", "uses GL_EXP2 fog (as in Nehahra) rather than realistic GL_EXP fog"}

Definition at line 137 of file gl_rmain.c.

137{CF_CLIENT, "r_fog_exp2", "0", "uses GL_EXP2 fog (as in Nehahra) rather than realistic GL_EXP fog"};

Referenced by GL_Main_Init(), R_BuildFogTexture(), and R_UpdateFog().

◆ r_framedata_mem

◆ r_framedatasize

cvar_t r_framedatasize = {CF_CLIENT | CF_ARCHIVE, "r_framedatasize", "0.5", "size of renderer data cache used during one frame (for skeletal animation caching, light processing, etc)"}

Definition at line 248 of file gl_rmain.c.

248{CF_CLIENT | CF_ARCHIVE, "r_framedatasize", "0.5", "size of renderer data cache used during one frame (for skeletal animation caching, light processing, etc)"};

Referenced by GL_Main_Init(), R_FrameData_Alloc(), and R_FrameData_Resize().

◆ r_fullbright

cvar_t r_fullbright = {CF_CLIENT, "r_fullbright","0", "makes map very bright and renders faster"}

Definition at line 112 of file gl_rmain.c.

112{CF_CLIENT, "r_fullbright","0", "makes map very bright and renders faster"};

Referenced by CL_RelinkStaticEntities(), CL_RelinkWorld(), CL_UpdateEntityShading_Entity(), CL_UpdateNetworkEntity(), CSQC_AddRenderEdict(), GL_Main_Init(), RSurf_ActiveModelEntity(), and VM_CL_makestatic().

◆ r_fullbright_directed

cvar_t r_fullbright_directed = {CF_CLIENT, "r_fullbright_directed", "0", "render fullbright things (unlit worldmodel and EF_FULLBRIGHT entities, but not fullbright shaders) using a constant light direction instead to add more depth while keeping uniform brightness"}

Definition at line 114 of file gl_rmain.c.

114{CF_CLIENT, "r_fullbright_directed", "0", "render fullbright things (unlit worldmodel and EF_FULLBRIGHT entities, but not fullbright shaders) using a constant light direction instead to add more depth while keeping uniform brightness"};

Referenced by CL_UpdateEntityShading_Entity(), GL_Main_Init(), and RSurf_ActiveModelEntity().

◆ r_fullbright_directed_ambient

cvar_t r_fullbright_directed_ambient = {CF_CLIENT, "r_fullbright_directed_ambient", "0.5", "ambient light multiplier for directed fullbright"}

Definition at line 115 of file gl_rmain.c.

115{CF_CLIENT, "r_fullbright_directed_ambient", "0.5", "ambient light multiplier for directed fullbright"};

Referenced by CL_UpdateEntityShading_GetDirectedFullbright(), and GL_Main_Init().

◆ r_fullbright_directed_diffuse

cvar_t r_fullbright_directed_diffuse = {CF_CLIENT, "r_fullbright_directed_diffuse", "0.75", "diffuse light multiplier for directed fullbright"}

Definition at line 116 of file gl_rmain.c.

116{CF_CLIENT, "r_fullbright_directed_diffuse", "0.75", "diffuse light multiplier for directed fullbright"};

Referenced by CL_UpdateEntityShading_GetDirectedFullbright(), and GL_Main_Init().

◆ r_fullbright_directed_pitch

cvar_t r_fullbright_directed_pitch = {CF_CLIENT, "r_fullbright_directed_pitch", "20", "constant pitch direction ('height') of the fake light source to use for fullbright"}

Definition at line 117 of file gl_rmain.c.

117{CF_CLIENT, "r_fullbright_directed_pitch", "20", "constant pitch direction ('height') of the fake light source to use for fullbright"};

Referenced by CL_UpdateEntityShading_GetDirectedFullbright(), and GL_Main_Init().

◆ r_fullbright_directed_pitch_relative

cvar_t r_fullbright_directed_pitch_relative = {CF_CLIENT, "r_fullbright_directed_pitch_relative", "0", "whether r_fullbright_directed_pitch is interpreted as absolute (0) or relative (1) pitch"}

Definition at line 118 of file gl_rmain.c.

118{CF_CLIENT, "r_fullbright_directed_pitch_relative", "0", "whether r_fullbright_directed_pitch is interpreted as absolute (0) or relative (1) pitch"};

Referenced by CL_UpdateEntityShading_GetDirectedFullbright(), and GL_Main_Init().

◆ r_fullbrights

cvar_t r_fullbrights = {CF_CLIENT | CF_ARCHIVE, "r_fullbrights", "1", "enables glowing pixels in quake textures (changes need r_restart to take effect)"}

Definition at line 122 of file gl_rmain.c.

122{CF_CLIENT | CF_ARCHIVE, "r_fullbrights", "1", "enables glowing pixels in quake textures (changes need r_restart to take effect)"};

Referenced by GL_Main_Init(), Mod_IDP0_Load(), Mod_Q1BSP_LoadTextures(), and R_LoadQWSkin().

◆ r_fxaa

cvar_t r_fxaa = {CF_CLIENT | CF_ARCHIVE, "r_fxaa", "0", "fast approximate anti aliasing"}

Definition at line 190 of file gl_rmain.c.

190{CF_CLIENT | CF_ARCHIVE, "r_fxaa", "0", "fast approximate anti aliasing"};

Referenced by GL_Main_Init(), R_BlendView_IsTrivial(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_deluxemapping

cvar_t r_glsl_deluxemapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"}

Definition at line 171 of file gl_rmain.c.

171{CF_CLIENT | CF_ARCHIVE, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping

cvar_t r_glsl_offsetmapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"}

Definition at line 172 of file gl_rmain.c.

172{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_lod

cvar_t r_glsl_offsetmapping_lod = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod", "0", "apply distance-based level-of-detail correction to number of offsetmappig steps, effectively making it render faster on large open-area maps"}

Definition at line 178 of file gl_rmain.c.

178{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod", "0", "apply distance-based level-of-detail correction to number of offsetmappig steps, effectively making it render faster on large open-area maps"};

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_offsetmapping_lod_distance

cvar_t r_glsl_offsetmapping_lod_distance = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod_distance", "32", "first LOD level distance, second level (-50% steps) is 2x of this, third (33%) - 3x etc."}

Definition at line 179 of file gl_rmain.c.

179{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod_distance", "32", "first LOD level distance, second level (-50% steps) is 2x of this, third (33%) - 3x etc."};

Referenced by GL_Main_Init(), R_CompileShader_CheckStaticParms(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_reliefmapping

cvar_t r_glsl_offsetmapping_reliefmapping = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping", "0", "relief mapping effect (higher quality)"}

Definition at line 174 of file gl_rmain.c.

174{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping", "0", "relief mapping effect (higher quality)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_reliefmapping_refinesteps

cvar_t r_glsl_offsetmapping_reliefmapping_refinesteps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_refinesteps", "5", "relief mapping refine steps (these are a binary search executed as the last step as given by r_glsl_offsetmapping_reliefmapping_steps)"}

Definition at line 176 of file gl_rmain.c.

176{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_refinesteps", "5", "relief mapping refine steps (these are a binary search executed as the last step as given by r_glsl_offsetmapping_reliefmapping_steps)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_reliefmapping_steps

cvar_t r_glsl_offsetmapping_reliefmapping_steps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_steps", "10", "relief mapping steps (note: too high values may be not supported by your GPU)"}

Definition at line 175 of file gl_rmain.c.

175{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping_steps", "10", "relief mapping steps (note: too high values may be not supported by your GPU)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_scale

cvar_t r_glsl_offsetmapping_scale = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_scale", "0.04", "how deep the offset mapping effect is"}

Definition at line 177 of file gl_rmain.c.

177{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_scale", "0.04", "how deep the offset mapping effect is"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_steps

cvar_t r_glsl_offsetmapping_steps = {CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_steps", "2", "offset mapping steps (note: too high values may be not supported by your GPU)"}

Definition at line 173 of file gl_rmain.c.

173{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_steps", "2", "offset mapping steps (note: too high values may be not supported by your GPU)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_permutation

◆ r_glsl_permutationarray

memexpandablearray_t r_glsl_permutationarray

storage for permutations linked in the hash table

Definition at line 938 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), R_GLSL_FindPermutation(), and R_GLSL_Restart_f().

◆ r_glsl_permutationhash

information about each possible shader permutation

Definition at line 934 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), R_GLSL_FindPermutation(), and R_GLSL_Restart_f().

◆ r_glsl_postprocess

cvar_t r_glsl_postprocess = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess", "0", "use a GLSL postprocessing shader"}

Definition at line 180 of file gl_rmain.c.

180{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess", "0", "use a GLSL postprocessing shader"};

Referenced by GL_Main_Init(), R_BlendView(), R_BlendView_IsTrivial(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_postprocess_uservec1

cvar_t r_glsl_postprocess_uservec1 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1", "0 0 0 0", "a 4-component vector to pass as uservec1 to the postprocessing shader (only useful if default.glsl has been customized)"}

Definition at line 181 of file gl_rmain.c.

181{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1", "0 0 0 0", "a 4-component vector to pass as uservec1 to the postprocessing shader (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_glsl_postprocess_uservec1_enable

cvar_t r_glsl_postprocess_uservec1_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1_enable", "1", "enables postprocessing uservec1 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}

Definition at line 185 of file gl_rmain.c.

185{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec1_enable", "1", "enables postprocessing uservec1 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_postprocess_uservec2

cvar_t r_glsl_postprocess_uservec2 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2", "0 0 0 0", "a 4-component vector to pass as uservec2 to the postprocessing shader (only useful if default.glsl has been customized)"}

Definition at line 182 of file gl_rmain.c.

182{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2", "0 0 0 0", "a 4-component vector to pass as uservec2 to the postprocessing shader (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_glsl_postprocess_uservec2_enable

cvar_t r_glsl_postprocess_uservec2_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2_enable", "1", "enables postprocessing uservec2 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}

Definition at line 186 of file gl_rmain.c.

186{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec2_enable", "1", "enables postprocessing uservec2 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_postprocess_uservec3

cvar_t r_glsl_postprocess_uservec3 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3", "0 0 0 0", "a 4-component vector to pass as uservec3 to the postprocessing shader (only useful if default.glsl has been customized)"}

Definition at line 183 of file gl_rmain.c.

183{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3", "0 0 0 0", "a 4-component vector to pass as uservec3 to the postprocessing shader (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_glsl_postprocess_uservec3_enable

cvar_t r_glsl_postprocess_uservec3_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3_enable", "1", "enables postprocessing uservec3 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}

Definition at line 187 of file gl_rmain.c.

187{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec3_enable", "1", "enables postprocessing uservec3 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_postprocess_uservec4

cvar_t r_glsl_postprocess_uservec4 = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4", "0 0 0 0", "a 4-component vector to pass as uservec4 to the postprocessing shader (only useful if default.glsl has been customized)"}

Definition at line 184 of file gl_rmain.c.

184{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4", "0 0 0 0", "a 4-component vector to pass as uservec4 to the postprocessing shader (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_glsl_postprocess_uservec4_enable

cvar_t r_glsl_postprocess_uservec4_enable = {CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4_enable", "1", "enables postprocessing uservec4 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"}

Definition at line 188 of file gl_rmain.c.

188{CF_CLIENT | CF_ARCHIVE, "r_glsl_postprocess_uservec4_enable", "1", "enables postprocessing uservec4 usage, creates USERVEC1 define (only useful if default.glsl has been customized)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_saturation

cvar_t r_glsl_saturation = {CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation", "1", "saturation multiplier (only working in glsl!)"}

Definition at line 242 of file gl_rmain.c.

242{CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation", "1", "saturation multiplier (only working in glsl!)"};

Referenced by GL_Main_Init(), R_BlendView(), and R_BlendView_IsTrivial().

◆ r_glsl_saturation_redcompensate

cvar_t r_glsl_saturation_redcompensate = {CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation_redcompensate", "0", "a 'vampire sight' addition to desaturation effect, does compensation for red color, r_glsl_restart is required"}

Definition at line 243 of file gl_rmain.c.

243{CF_CLIENT | CF_ARCHIVE, "r_glsl_saturation_redcompensate", "0", "a 'vampire sight' addition to desaturation effect, does compensation for red color, r_glsl_restart is required"};

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_skeletal

cvar_t r_glsl_skeletal = {CF_CLIENT | CF_ARCHIVE, "r_glsl_skeletal", "1", "render skeletal models faster using a gpu-skinning technique"}

Definition at line 170 of file gl_rmain.c.

170{CF_CLIENT | CF_ARCHIVE, "r_glsl_skeletal", "1", "render skeletal models faster using a gpu-skinning technique"};

Referenced by GL_Main_Init(), and R_UpdateVariables().

◆ r_glsl_vertextextureblend_usebothalphas

cvar_t r_glsl_vertextextureblend_usebothalphas = {CF_CLIENT | CF_ARCHIVE, "r_glsl_vertextextureblend_usebothalphas", "0", "use both alpha layers on vertex blended surfaces, each alpha layer sets amount of 'blend leak' on another layer, requires mod_q3shader_force_terrain_alphaflag on."}

Definition at line 245 of file gl_rmain.c.

245{CF_CLIENT | CF_ARCHIVE, "r_glsl_vertextextureblend_usebothalphas", "0", "use both alpha layers on vertex blended surfaces, each alpha layer sets amount of 'blend leak' on another layer, requires mod_q3shader_force_terrain_alphaflag on."};

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_gpuskeletal

qbool r_gpuskeletal
static

Definition at line 52 of file gl_rmain.c.

Referenced by R_AnimCache_GetEntity(), and R_UpdateVariables().

◆ r_hdr_glowintensity

cvar_t r_hdr_glowintensity = {CF_CLIENT | CF_ARCHIVE, "r_hdr_glowintensity", "1", "how bright light emitting textures should appear"}

Definition at line 219 of file gl_rmain.c.

219{CF_CLIENT | CF_ARCHIVE, "r_hdr_glowintensity", "1", "how bright light emitting textures should appear"};

Referenced by CL_UpdateEntityShading_Entity(), GL_Main_Init(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Graphics_Draw(), and R_SetupShader_Surface().

◆ r_hdr_irisadaptation

cvar_t r_hdr_irisadaptation = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation", "0", "adjust scene brightness according to light intensity at player location"}

Definition at line 220 of file gl_rmain.c.

220{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation", "0", "adjust scene brightness according to light intensity at player location"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_fade_down

cvar_t r_hdr_irisadaptation_fade_down = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_down", "0.5", "fade rate at which value adjusts to brightness"}

Definition at line 226 of file gl_rmain.c.

226{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_down", "0.5", "fade rate at which value adjusts to brightness"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_fade_up

cvar_t r_hdr_irisadaptation_fade_up = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_up", "0.1", "fade rate at which value adjusts to darkness"}

Definition at line 225 of file gl_rmain.c.

225{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_fade_up", "0.1", "fade rate at which value adjusts to darkness"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_maxvalue

cvar_t r_hdr_irisadaptation_maxvalue = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_maxvalue", "4", "maximum value that can result from multiplier / brightness"}

Definition at line 223 of file gl_rmain.c.

223{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_maxvalue", "4", "maximum value that can result from multiplier / brightness"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_minvalue

cvar_t r_hdr_irisadaptation_minvalue = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_minvalue", "0.5", "minimum value that can result from multiplier / brightness"}

Definition at line 222 of file gl_rmain.c.

222{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_minvalue", "0.5", "minimum value that can result from multiplier / brightness"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_multiplier

cvar_t r_hdr_irisadaptation_multiplier = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_multiplier", "2", "brightness at which value will be 1.0"}

Definition at line 221 of file gl_rmain.c.

221{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_multiplier", "2", "brightness at which value will be 1.0"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_radius

cvar_t r_hdr_irisadaptation_radius = {CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_radius", "15", "lighting within this many units of the eye is averaged"}

Definition at line 227 of file gl_rmain.c.

227{CF_CLIENT | CF_ARCHIVE, "r_hdr_irisadaptation_radius", "15", "lighting within this many units of the eye is averaged"};

Referenced by GL_Main_Init(), and R_HDR_UpdateIrisAdaptation().

◆ r_hdr_irisadaptation_value

cvar_t r_hdr_irisadaptation_value = {CF_CLIENT, "r_hdr_irisadaptation_value", "1", "current value as scenebrightness multiplier, changes continuously when irisadaptation is active"}

Definition at line 224 of file gl_rmain.c.

224{CF_CLIENT, "r_hdr_irisadaptation_value", "1", "current value as scenebrightness multiplier, changes continuously when irisadaptation is active"};

Referenced by GL_Main_Init(), R_HDR_UpdateIrisAdaptation(), and R_RenderView().

◆ r_hdr_scenebrightness

cvar_t r_hdr_scenebrightness = {CF_CLIENT | CF_ARCHIVE, "r_hdr_scenebrightness", "1", "global rendering brightness"}

Definition at line 218 of file gl_rmain.c.

218{CF_CLIENT | CF_ARCHIVE, "r_hdr_scenebrightness", "1", "global rendering brightness"};

Referenced by GL_Main_Init(), M_Menu_Options_AdjustSliders(), M_Menu_Options_Graphics_AdjustSliders(), M_Options_Draw(), M_Options_Graphics_Draw(), and R_RenderView().

◆ r_lerplightstyles

cvar_t r_lerplightstyles = {CF_CLIENT | CF_ARCHIVE, "r_lerplightstyles", "0", "enable animation smoothing on flickering lights"}

Definition at line 205 of file gl_rmain.c.

205{CF_CLIENT | CF_ARCHIVE, "r_lerplightstyles", "0", "enable animation smoothing on flickering lights"};

Referenced by CL_RelinkLightFlashes(), GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), and M_Options_Effects_Draw().

◆ r_lerpmodels

cvar_t r_lerpmodels = {CF_CLIENT | CF_ARCHIVE, "r_lerpmodels", "1", "enables animation smoothing on models"}

Definition at line 203 of file gl_rmain.c.

203{CF_CLIENT | CF_ARCHIVE, "r_lerpmodels", "1", "enables animation smoothing on models"};

Referenced by GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and VM_FrameBlendFromFrameGroupBlend().

◆ r_lerpsprites

cvar_t r_lerpsprites = {CF_CLIENT | CF_ARCHIVE, "r_lerpsprites", "0", "enables animation smoothing on sprites"}

Definition at line 202 of file gl_rmain.c.

202{CF_CLIENT | CF_ARCHIVE, "r_lerpsprites", "0", "enables animation smoothing on sprites"};

Referenced by GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and VM_FrameBlendFromFrameGroupBlend().

◆ r_loaddds

qbool r_loaddds
static

Definition at line 50 of file gl_rmain.c.

Referenced by gl_main_start(), and R_SkinFrame_LoadExternal_SkinFrame().

◆ r_loadfog

◆ r_loadgloss

qbool r_loadgloss
static

Definition at line 48 of file gl_rmain.c.

Referenced by gl_main_start(), and R_SkinFrame_LoadExternal_SkinFrame().

◆ r_loadnormalmap

qbool r_loadnormalmap
static

◆ r_lockpvs

cvar_t r_lockpvs
extern

Definition at line 29 of file gl_rsurf.c.

29{CF_CLIENT, "r_lockpvs", "0", "disables pvs switching, allows you to walk around and inspect what is visible from a given location in the map (anything not visible from your current location will not be drawn)"};

Referenced by GL_Surf_Init(), R_View_WorldVisibility(), and R_Water_StartFrame().

◆ r_lockvisibility

cvar_t r_lockvisibility
extern

Definition at line 30 of file gl_rsurf.c.

30{CF_CLIENT, "r_lockvisibility", "0", "disables visibility updates, allows you to walk around and inspect what is visible from a given viewpoint in the map (anything offscreen at the moment this is enabled will not be drawn)"};

Referenced by GL_Surf_Init(), R_View_SetFrustum(), R_View_WorldVisibility(), and R_Water_StartFrame().

◆ r_main_mempool

◆ r_main_texturepool

◆ r_maxqueries

unsigned int r_maxqueries

◆ r_maxsurfacelist

int r_maxsurfacelist = 0

Definition at line 9968 of file gl_rmain.c.

Referenced by R_DrawModelSurfaces().

◆ r_motionblur

cvar_t r_motionblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur", "0", "screen motionblur - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"}

Definition at line 59 of file gl_rmain.c.

59{CF_CLIENT | CF_ARCHIVE, "r_motionblur", "0", "screen motionblur - value represents intensity, somewhere around 0.5 recommended - NOTE: bad performance on multi-gpu!"};

Referenced by GL_Main_Init(), R_Bloom_StartFrame(), and R_MotionBlurView().

◆ r_motionblur_averaging

cvar_t r_motionblur_averaging = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_averaging", "0.1", "sliding average reaction time for velocity (higher = slower adaption to change)"}

Definition at line 61 of file gl_rmain.c.

61{CF_CLIENT | CF_ARCHIVE, "r_motionblur_averaging", "0.1", "sliding average reaction time for velocity (higher = slower adaption to change)"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_maxblur

cvar_t r_motionblur_maxblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_maxblur", "0.9", "maxmimum amount of blur"}

Definition at line 64 of file gl_rmain.c.

64{CF_CLIENT | CF_ARCHIVE, "r_motionblur_maxblur", "0.9", "maxmimum amount of blur"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_minblur

cvar_t r_motionblur_minblur = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_minblur", "0.5", "factor of blur to apply at all times (always have this amount of blur no matter what the other factors are)"}

Definition at line 63 of file gl_rmain.c.

63{CF_CLIENT | CF_ARCHIVE, "r_motionblur_minblur", "0.5", "factor of blur to apply at all times (always have this amount of blur no matter what the other factors are)"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_mousefactor

cvar_t r_motionblur_mousefactor = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor", "2", "factoring in of mouse acceleration to the blur equation - the faster the player turns their mouse, the more blur they get"}

Definition at line 68 of file gl_rmain.c.

68{CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor", "2", "factoring in of mouse acceleration to the blur equation - the faster the player turns their mouse, the more blur they get"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_mousefactor_maxspeed

cvar_t r_motionblur_mousefactor_maxspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_maxspeed", "50", "upper value of mouse acceleration when it reaches the peak factor into blur equation"}

Definition at line 70 of file gl_rmain.c.

70{CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_maxspeed", "50", "upper value of mouse acceleration when it reaches the peak factor into blur equation"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_mousefactor_minspeed

cvar_t r_motionblur_mousefactor_minspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_minspeed", "0", "lower value of mouse acceleration when it starts to factor into blur equation"}

Definition at line 69 of file gl_rmain.c.

69{CF_CLIENT | CF_ARCHIVE, "r_motionblur_mousefactor_minspeed", "0", "lower value of mouse acceleration when it starts to factor into blur equation"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_randomize

cvar_t r_motionblur_randomize = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_randomize", "0.1", "randomizing coefficient to workaround ghosting"}

Definition at line 62 of file gl_rmain.c.

62{CF_CLIENT | CF_ARCHIVE, "r_motionblur_randomize", "0.1", "randomizing coefficient to workaround ghosting"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_velocityfactor

cvar_t r_motionblur_velocityfactor = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor", "1", "factoring in of player velocity to the blur equation - the faster the player moves around the map, the more blur they get"}

Definition at line 65 of file gl_rmain.c.

65{CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor", "1", "factoring in of player velocity to the blur equation - the faster the player moves around the map, the more blur they get"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_velocityfactor_maxspeed

cvar_t r_motionblur_velocityfactor_maxspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_maxspeed", "800", "upper value of velocity when it reaches the peak factor into blur equation"}

Definition at line 67 of file gl_rmain.c.

67{CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_maxspeed", "800", "upper value of velocity when it reaches the peak factor into blur equation"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_motionblur_velocityfactor_minspeed

cvar_t r_motionblur_velocityfactor_minspeed = {CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_minspeed", "400", "lower value of velocity when it starts to factor into blur equation"}

Definition at line 66 of file gl_rmain.c.

66{CF_CLIENT | CF_ARCHIVE, "r_motionblur_velocityfactor_minspeed", "400", "lower value of velocity when it starts to factor into blur equation"};

Referenced by GL_Main_Init(), and R_MotionBlurView().

◆ r_nearclip

cvar_t r_nearclip = {CF_CLIENT, "r_nearclip", "1", "distance from camera of nearclip plane" }

Definition at line 76 of file gl_rmain.c.

76{CF_CLIENT, "r_nearclip", "1", "distance from camera of nearclip plane" };

Referenced by GL_Main_Init(), R_UpdateVariables(), and R_View_WorldVisibility().

◆ r_nolerp_list

cvar_t r_nolerp_list = {CF_CLIENT | CF_ARCHIVE, "r_nolerp_list", "progs/v_nail.mdl,progs/v_nail2.mdl,progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl", "comma separated list of models that will not have their animations smoothed"}

Definition at line 204 of file gl_rmain.c.

204{CF_CLIENT | CF_ARCHIVE, "r_nolerp_list", "progs/v_nail.mdl,progs/v_nail2.mdl,progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl", "comma separated list of models that will not have their animations smoothed"};

Referenced by GL_Main_Init(), and Mod_IDP0_Load().

◆ r_numqueries

unsigned int r_numqueries

◆ r_polygonoffset_decals_factor

cvar_t r_polygonoffset_decals_factor = {CF_CLIENT, "r_polygonoffset_decals_factor", "0", "biases depth values of decals to prevent z-fighting artifacts"}

Definition at line 135 of file gl_rmain.c.

135{CF_CLIENT, "r_polygonoffset_decals_factor", "0", "biases depth values of decals to prevent z-fighting artifacts"};

Referenced by GL_Main_Init(), and R_DrawModelDecals_Entity().

◆ r_polygonoffset_decals_offset

cvar_t r_polygonoffset_decals_offset = {CF_CLIENT, "r_polygonoffset_decals_offset", "-14", "biases depth values of decals to prevent z-fighting artifacts"}

Definition at line 136 of file gl_rmain.c.

136{CF_CLIENT, "r_polygonoffset_decals_offset", "-14", "biases depth values of decals to prevent z-fighting artifacts"};

Referenced by GL_Main_Init(), and R_DrawModelDecals_Entity().

◆ r_polygonoffset_submodel_factor

cvar_t r_polygonoffset_submodel_factor = {CF_CLIENT, "r_polygonoffset_submodel_factor", "0", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"}

Definition at line 133 of file gl_rmain.c.

133{CF_CLIENT, "r_polygonoffset_submodel_factor", "0", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"};

Referenced by GL_Main_Init(), and RSurf_ActiveModelEntity().

◆ r_polygonoffset_submodel_offset

cvar_t r_polygonoffset_submodel_offset = {CF_CLIENT, "r_polygonoffset_submodel_offset", "14", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"}

Definition at line 134 of file gl_rmain.c.

134{CF_CLIENT, "r_polygonoffset_submodel_offset", "14", "biases depth values of world submodels such as doors, to prevent z-fighting artifacts in Quake maps"};

Referenced by GL_Main_Init(), and RSurf_ActiveModelEntity().

◆ r_q1bsp_lightmap_updates_combine

cvar_t r_q1bsp_lightmap_updates_combine = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_combine", "2", "combine lightmap texture updates to make fewer glTexSubImage2D calls, modes: 0 = immediately upload lightmaps (may be thousands of small 3x3 updates), 1 = combine to one call, 2 = combine to one full texture update (glTexImage2D) which tells the driver it does not need to lock the resource (faster on most drivers)"}

Definition at line 258 of file gl_rmain.c.

258{CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_combine", "2", "combine lightmap texture updates to make fewer glTexSubImage2D calls, modes: 0 = immediately upload lightmaps (may be thousands of small 3x3 updates), 1 = combine to one call, 2 = combine to one full texture update (glTexImage2D) which tells the driver it does not need to lock the resource (faster on most drivers)"};

Referenced by GL_Main_Init(), R_BuildLightMap(), and R_DrawModelSurfaces().

◆ r_q1bsp_lightmap_updates_enabled

cvar_t r_q1bsp_lightmap_updates_enabled = {CF_CLIENT, "r_q1bsp_lightmap_updates_enabled", "1", "allow lightmaps to be updated on Q1BSP maps (don't turn this off except for debugging)"}

Definition at line 257 of file gl_rmain.c.

257{CF_CLIENT, "r_q1bsp_lightmap_updates_enabled", "1", "allow lightmaps to be updated on Q1BSP maps (don't turn this off except for debugging)"};

Referenced by GL_Main_Init(), and R_DrawModelSurfaces().

◆ r_q1bsp_lightmap_updates_hidden_surfaces

cvar_t r_q1bsp_lightmap_updates_hidden_surfaces = {CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_hidden_surfaces", "0", "update lightmaps on surfaces that are not visible, so that updates only occur on frames where lightstyles changed value (animation or light switches), only makes sense with combine = 2"}

Definition at line 259 of file gl_rmain.c.

259{CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_hidden_surfaces", "0", "update lightmaps on surfaces that are not visible, so that updates only occur on frames where lightstyles changed value (animation or light switches), only makes sense with combine = 2"};

Referenced by GL_Main_Init(), and R_DrawModelSurfaces().

◆ r_q1bsp_skymasking

cvar_t r_q1bsp_skymasking = {CF_CLIENT, "r_q1bsp_skymasking", "1", "allows sky polygons in quake1 maps to obscure other geometry"}

Definition at line 132 of file gl_rmain.c.

132{CF_CLIENT, "r_q1bsp_skymasking", "1", "allows sky polygons in quake1 maps to obscure other geometry"};

Referenced by GL_Main_Init(), and R_DrawTextureSurfaceList_Sky().

◆ r_queries

unsigned int r_queries[MAX_OCCLUSION_QUERIES]

◆ r_qwskincache

r_qwskincache_t* r_qwskincache
static

Definition at line 308 of file gl_rmain.c.

Referenced by gl_main_newmap(), gl_main_shutdown(), gl_main_start(), and R_GetCurrentTexture().

◆ r_qwskincache_size

int r_qwskincache_size
static

Definition at line 309 of file gl_rmain.c.

Referenced by gl_main_newmap(), gl_main_shutdown(), gl_main_start(), and R_GetCurrentTexture().

◆ r_refdef

r_refdef_t r_refdef

Definition at line 57 of file gl_rmain.c.

Referenced by CL_Beam_AddPolygons(), CL_Beam_CalculatePositions(), CL_ClearTempEntities(), CL_ExpandCSQCRenderEntities(), CL_Fog_f(), CL_Fog_HeightTexture_f(), CL_Frame(), CL_GetEntityMatrix(), CL_GetTagMatrix(), CL_Init(), CL_LinkNetworkEntity(), CL_Locs_RemoveNearest_f(), CL_MeshEntities_Scene_AddRenderEntity(), CL_NewParticlesFromEffectinfo(), CL_NewTempEntity(), CL_ParseEntityLump(), CL_ParticleEffect_Fallback(), CL_RelinkBeams(), CL_RelinkLightFlashes(), CL_RelinkStaticEntities(), CL_RelinkWorld(), CL_TimeRefresh_f(), CL_UpdateEntityShading(), CL_UpdateEntityShading_Entity(), CL_UpdatePrydonCursor(), CL_UpdateScreen(), CL_UpdateWorld(), CL_VM_UpdateView(), Collision_Cache_Lookup(), CSQC_AddRenderEdict(), CSQC_R_RecalcView(), DrawQ_Finish(), DrawQ_FlushUI(), DrawQ_RecalcView(), DrawQ_SetClipArea(), DrawQ_Start(), FOG_clear(), gl_main_start(), Mod_BSP_LightPoint_RecursiveBSPNode(), Mod_Mesh_Finalize(), MP_Draw(), R_AnimCache_CacheVisibleEntities(), R_AnimCache_ClearCache(), R_AnimCache_GetEntity(), R_BeginCoronaQuery(), R_BlendView(), R_BlendView_IsTrivial(), R_Bloom_MakeTexture(), R_Bloom_StartFrame(), R_BufferData_Store(), R_BuildFogHeightTexture(), R_BuildFogTexture(), R_BuildLightMap(), R_CalcBeam_Vertex3f(), R_CanSeeBox(), R_ClearScreen(), R_CompleteLightPoint(), R_CullFrustum(), R_DebugLine(), R_DecalSystem_ApplySplatEntities(), R_DrawBBoxMesh(), R_DrawBrushModelsSky(), R_DrawCorona(), R_DrawDebugModel(), R_DrawExplosion_TransparentCallback(), R_DrawLoc_Callback(), R_DrawModelDecals(), R_DrawModelDecals_Entity(), R_DrawModelDecals_FadeEntity(), R_DrawModels(), R_DrawModelsAddWaterPlanes(), R_DrawModelsDebug(), R_DrawModelsDepth(), R_DrawModelSurfaces(), R_DrawModelTextureSurfaceList(), R_DrawNoModel_TransparentCallback(), R_DrawParticle_TransparentCallback(), R_DrawParticles(), R_DrawPortal_Callback(), R_DrawPortals(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_Envmap_f(), R_FrameData_Alloc(), R_GetCurrentTexture(), R_GetScenePointer(), R_HDR_UpdateIrisAdaptation(), R_ListWorldTextures_f(), R_Main_FreeViewCache(), R_Main_ResizeViewCache(), R_Mesh_Draw(), R_Mesh_UpdateMeshBuffer(), R_MeshQueue_AddTransparent(), R_MeshQueue_BeginScene(), R_Mod_DrawAddWaterPlanes(), R_Mod_DrawDepth(), R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Mod_GetLightInfo(), R_Model_Sprite_Draw_TransparentCallback(), R_MotionBlurView(), R_ProcessTransparentTextureSurfaceList(), R_RenderScene(), R_RenderTarget_Get(), R_RenderView(), R_RenderView_UpdateViewVectors(), R_RenderWaterPlanes(), R_ReplaceWorldTexture_f(), R_ResetViewRendering2D_Common(), R_ResetViewRendering3D(), R_RTLight_Compile(), R_ScissorForBBox(), R_SelectScene(), R_SetupShader_DeferredLight(), R_SetupShader_Surface(), R_SetupView(), R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_BounceGrid_CheckEnable(), R_Shadow_BounceGrid_UpdateSpacing(), R_Shadow_ClearShadowMapTexture(), R_Shadow_ClearStencil(), R_Shadow_ComputeShadowCasterCullingPlanes(), R_Shadow_CullFrustumSides(), R_Shadow_DrawCoronas(), R_Shadow_DrawCursor_TransparentCallback(), R_Shadow_DrawLight(), R_Shadow_DrawLightShadowMaps(), R_Shadow_DrawLightSprite_TransparentCallback(), R_Shadow_DrawModelShadowMaps(), R_Shadow_DrawPrepass(), R_Shadow_DrawWorldLight(), R_Shadow_DrawWorldShadow_ShadowMap(), R_Shadow_PrepareLight(), R_Shadow_PrepareLights(), R_Shadow_PrepareModelShadows(), R_Shadow_RenderMode_Begin(), R_Shadow_RenderMode_DrawDeferredLight(), R_Shadow_RenderMode_End(), R_Shadow_RenderMode_Lighting(), R_Shadow_RenderMode_Reset(), R_Shadow_RenderMode_ShadowMap(), R_Shadow_RenderMode_VisibleLighting(), R_Shadow_ScissorForBBox(), R_Shadow_SelectLightInView(), R_Shadow_SetCursorLocationForView(), R_Shadow_UpdateBounceGridTexture(), R_Sky(), R_SkySphere(), R_SkyStartFrame(), R_SortEntities(), R_Stain(), R_TimeReport_BeginFrame(), R_TimeReport_EndFrame(), R_TrackSprite(), R_UpdateFog(), R_UpdateVariables(), R_View_SetFrustum(), R_View_Update(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), R_View_WorldVisibility_CullSurfaces(), R_Water_AddWaterPlane(), R_Water_ProcessPlanes(), RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), RSurf_DrawBatch(), RSurf_FogPoint(), RSurf_FogVertex(), RSurf_PrepareVerticesForBatch(), RSurf_SetupDepthAndCulling(), Sbar_ShowFPS(), SCR_DrawScreen(), V_CalcIntermissionRefdef(), V_CalcRefdef(), V_CalcRefdefUsing(), V_CalcViewBlend(), V_MakeViewIsometric(), VM_CL_getlight(), VM_CL_project(), VM_CL_R_AddDynamicLight(), VM_CL_R_ClearScene(), VM_CL_R_RenderScene(), VM_CL_R_SetView(), and VM_CL_unproject().

◆ r_rendertarget_debug

cvar_t r_rendertarget_debug = {CF_CLIENT, "r_rendertarget_debug", "-1", "replaces the view with the contents of the specified render target (by number - note that these can fluctuate depending on scene)"}

Definition at line 161 of file gl_rmain.c.

161{CF_CLIENT, "r_rendertarget_debug", "-1", "replaces the view with the contents of the specified render target (by number - note that these can fluctuate depending on scene)"};

Referenced by GL_Main_Init(), and R_BlendView().

◆ r_savedds

qbool r_savedds
static

Definition at line 51 of file gl_rmain.c.

Referenced by gl_main_start(), and R_SkinFrame_LoadExternal_SkinFrame().

◆ r_scenes_store

r_refdef_scene_t r_scenes_store[RST_COUNT]
static

Definition at line 5567 of file gl_rmain.c.

Referenced by R_GetScenePointer(), and R_SelectScene().

◆ r_screenvertex3f

const float r_screenvertex3f
Initial value:
=
{
0, 0, 0,
1, 0, 0,
1, 1, 0,
0, 1, 0
}

vertex coordinates for a quad that covers the screen exactly

Definition at line 313 of file gl_rmain.c.

314{
315 0, 0, 0,
316 1, 0, 0,
317 1, 1, 0,
318 0, 1, 0
319};

Referenced by R_BlendView(), R_Bloom_MakeTexture(), and R_MotionBlurView().

◆ r_shadow_bouncegrid

cvar_t r_shadow_bouncegrid
extern

Definition at line 198 of file r_shadow.c.

198{CF_CLIENT | CF_ARCHIVE, "r_shadow_bouncegrid", "0", "perform particle tracing for indirect lighting (Global Illumination / radiosity) using a 3D texture covering the scene, only active on levels with realtime lights active (r_shadow_realtime_world is usually required for these)"};

Referenced by R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_BounceGrid_CheckEnable(), R_Shadow_BounceGrid_GenerateSettings(), R_Shadow_Init(), and R_Shadow_PrepareLight().

◆ r_shadow_occlusion_buf

unsigned int r_shadow_occlusion_buf
extern

Definition at line 136 of file r_shadow.c.

Referenced by gl_main_shutdown(), and R_DrawCorona().

◆ r_shadow_prepasslightingdiffusetexture

rtexture_t* r_shadow_prepasslightingdiffusetexture
extern

Definition at line 121 of file r_shadow.c.

Referenced by R_SetupShader_Surface().

◆ r_shadow_prepasslightingspeculartexture

rtexture_t* r_shadow_prepasslightingspeculartexture
extern

Definition at line 122 of file r_shadow.c.

Referenced by R_SetupShader_Surface().

◆ r_shadow_shadowmapatlas_modelshadows_size

int r_shadow_shadowmapatlas_modelshadows_size
extern

◆ r_shadow_shadowmappcf

int r_shadow_shadowmappcf
extern

◆ r_shadow_shadowmapsampler

qbool r_shadow_shadowmapsampler
extern

◆ r_shadow_usingdeferredprepass

qbool r_shadow_usingdeferredprepass
extern

◆ r_shadows

cvar_t r_shadows = {CF_CLIENT | CF_ARCHIVE, "r_shadows", "0", "casts fake stencil shadows from models onto the world (rtlights are unaffected by this); when set to 2, always cast the shadows in the direction set by r_shadows_throwdirection, otherwise use the model lighting."}

Definition at line 123 of file gl_rmain.c.

123{CF_CLIENT | CF_ARCHIVE, "r_shadows", "0", "casts fake stencil shadows from models onto the world (rtlights are unaffected by this); when set to 2, always cast the shadows in the direction set by r_shadows_throwdirection, otherwise use the model lighting."};

Referenced by GL_Main_Init(), R_Shadow_PrepareModelShadows(), and R_Water_ProcessPlanes().

◆ r_shadows_castfrombmodels

cvar_t r_shadows_castfrombmodels = {CF_CLIENT | CF_ARCHIVE, "r_shadows_castfrombmodels", "0", "do cast shadows from bmodels"}

Definition at line 128 of file gl_rmain.c.

128{CF_CLIENT | CF_ARCHIVE, "r_shadows_castfrombmodels", "0", "do cast shadows from bmodels"};

Referenced by GL_Main_Init(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_darken

cvar_t r_shadows_darken = {CF_CLIENT | CF_ARCHIVE, "r_shadows_darken", "0.5", "how much shadowed areas will be darkened"}

Definition at line 124 of file gl_rmain.c.

124{CF_CLIENT | CF_ARCHIVE, "r_shadows_darken", "0.5", "how much shadowed areas will be darkened"};

Referenced by GL_Main_Init(), and R_Shadow_DrawModelShadowMaps().

◆ r_shadows_drawafterrtlighting

cvar_t r_shadows_drawafterrtlighting = {CF_CLIENT | CF_ARCHIVE, "r_shadows_drawafterrtlighting", "0", "draw fake shadows AFTER realtime lightning is drawn. May be useful for simulating fast sunlight on large outdoor maps with only one noshadow rtlight. The price is less realistic appearance of dynamic light shadows."}

Definition at line 127 of file gl_rmain.c.

127{CF_CLIENT | CF_ARCHIVE, "r_shadows_drawafterrtlighting", "0", "draw fake shadows AFTER realtime lightning is drawn. May be useful for simulating fast sunlight on large outdoor maps with only one noshadow rtlight. The price is less realistic appearance of dynamic light shadows."};

Referenced by GL_Main_Init().

◆ r_shadows_focus

cvar_t r_shadows_focus = {CF_CLIENT | CF_ARCHIVE, "r_shadows_focus", "0 0 0", "offset the shadowed area focus"}

Definition at line 129 of file gl_rmain.c.

129{CF_CLIENT | CF_ARCHIVE, "r_shadows_focus", "0 0 0", "offset the shadowed area focus"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_shadowmapbias

cvar_t r_shadows_shadowmapbias = {CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapbias", "-1", "sets shadowmap bias for fake shadows. -1 sets the value of r_shadow_shadowmapping_bias. Needs shadowmapping ON."}

Definition at line 131 of file gl_rmain.c.

131{CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapbias", "-1", "sets shadowmap bias for fake shadows. -1 sets the value of r_shadow_shadowmapping_bias. Needs shadowmapping ON."};

Referenced by GL_Main_Init(), and R_Shadow_DrawModelShadowMaps().

◆ r_shadows_shadowmapscale

cvar_t r_shadows_shadowmapscale = {CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapscale", "0.25", "higher values increase shadowmap quality at a cost of area covered (multiply global shadowmap precision) for fake shadows. Needs shadowmapping ON."}

Definition at line 130 of file gl_rmain.c.

130{CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapscale", "0.25", "higher values increase shadowmap quality at a cost of area covered (multiply global shadowmap precision) for fake shadows. Needs shadowmapping ON."};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_throwdirection

cvar_t r_shadows_throwdirection = {CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdirection", "0 0 -1", "override throwing direction for r_shadows 2"}

Definition at line 126 of file gl_rmain.c.

126{CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdirection", "0 0 -1", "override throwing direction for r_shadows 2"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_throwdistance

cvar_t r_shadows_throwdistance = {CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdistance", "500", "how far to cast shadows from models"}

Definition at line 125 of file gl_rmain.c.

125{CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdistance", "500", "how far to cast shadows from models"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_showbboxes

cvar_t r_showbboxes = {CF_CLIENT, "r_showbboxes", "0", "shows bounding boxes of server entities, value controls opacity scaling (1 = 10%, 10 = 100%)"}

Definition at line 83 of file gl_rmain.c.

83{CF_CLIENT, "r_showbboxes", "0", "shows bounding boxes of server entities, value controls opacity scaling (1 = 10%, 10 = 100%)"};

Referenced by GL_Main_Init(), R_DrawEntityBBoxes_Callback(), and R_RenderScene().

◆ r_showbboxes_client

cvar_t r_showbboxes_client = {CF_CLIENT, "r_showbboxes_client", "0", "shows bounding boxes of clientside qc entities, value controls opacity scaling (1 = 10%, 10 = 100%)"}

Definition at line 84 of file gl_rmain.c.

84{CF_CLIENT, "r_showbboxes_client", "0", "shows bounding boxes of clientside qc entities, value controls opacity scaling (1 = 10%, 10 = 100%)"};

Referenced by GL_Main_Init(), R_DrawEntityBBoxes_Callback(), and R_RenderScene().

◆ r_showcollisionbrushes

cvar_t r_showcollisionbrushes = {CF_CLIENT, "r_showcollisionbrushes", "0", "draws collision brushes in quake3 maps (mode 1), mode 2 disables rendering of world (trippy!)"}

Definition at line 89 of file gl_rmain.c.

89{CF_CLIENT, "r_showcollisionbrushes", "0", "draws collision brushes in quake3 maps (mode 1), mode 2 disables rendering of world (trippy!)"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_showcollisionbrushes_polygonfactor

cvar_t r_showcollisionbrushes_polygonfactor = {CF_CLIENT, "r_showcollisionbrushes_polygonfactor", "-1", "expands outward the brush polygons a little bit, used to make collision brushes appear infront of walls"}

Definition at line 90 of file gl_rmain.c.

90{CF_CLIENT, "r_showcollisionbrushes_polygonfactor", "-1", "expands outward the brush polygons a little bit, used to make collision brushes appear infront of walls"};

Referenced by GL_Main_Init(), and R_DrawDebugModel().

◆ r_showcollisionbrushes_polygonoffset

cvar_t r_showcollisionbrushes_polygonoffset = {CF_CLIENT, "r_showcollisionbrushes_polygonoffset", "0", "nudges brush polygon depth in hardware depth units, used to make collision brushes appear infront of walls"}

Definition at line 91 of file gl_rmain.c.

91{CF_CLIENT, "r_showcollisionbrushes_polygonoffset", "0", "nudges brush polygon depth in hardware depth units, used to make collision brushes appear infront of walls"};

Referenced by GL_Main_Init(), and R_DrawDebugModel().

◆ r_showdisabledepthtest

cvar_t r_showdisabledepthtest = {CF_CLIENT, "r_showdisabledepthtest", "0", "disables depth testing on r_show* cvars, allowing you to see what hidden geometry the graphics card is processing"}

Definition at line 92 of file gl_rmain.c.

92{CF_CLIENT, "r_showdisabledepthtest", "0", "disables depth testing on r_show* cvars, allowing you to see what hidden geometry the graphics card is processing"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), R_DrawEntityBBoxes_Callback(), and R_Shadow_RenderLighting().

◆ r_showlighting

cvar_t r_showlighting = {CF_CLIENT, "r_showlighting", "0", "shows areas lit by lights, useful for finding out why some areas of a map render slowly (bright orange = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"}

Definition at line 88 of file gl_rmain.c.

88{CF_CLIENT, "r_showlighting", "0", "shows areas lit by lights, useful for finding out why some areas of a map render slowly (bright orange = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"};

Referenced by GL_Main_Init(), R_Shadow_DrawLight(), and R_Shadow_RenderMode_VisibleLighting().

◆ r_shownormals

cvar_t r_shownormals = {CF_CLIENT, "r_shownormals", "0", "shows per-vertex surface normals and tangent vectors for bumpmapped lighting"}

Definition at line 87 of file gl_rmain.c.

87{CF_CLIENT, "r_shownormals", "0", "shows per-vertex surface normals and tangent vectors for bumpmapped lighting"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_showoverdraw

cvar_t r_showoverdraw = {CF_CLIENT, "r_showoverdraw", "0", "shows overlapping geometry"}

Definition at line 82 of file gl_rmain.c.

82{CF_CLIENT, "r_showoverdraw", "0", "shows overlapping geometry"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_showparticleedges

cvar_t r_showparticleedges = {CF_CLIENT, "r_showparticleedges", "0", "renders a debug outline to show the polygon shape of each particle, for debugging rendering bugs with specific view types"}

Definition at line 94 of file gl_rmain.c.

94{CF_CLIENT, "r_showparticleedges", "0", "renders a debug outline to show the polygon shape of each particle, for debugging rendering bugs with specific view types"};

Referenced by GL_Main_Init(), and R_DrawParticle_TransparentCallback().

◆ r_showspriteedges

cvar_t r_showspriteedges = {CF_CLIENT, "r_showspriteedges", "0", "renders a debug outline to show the polygon shape of each sprite frame rendered (may be 2 or more in case of interpolated animations), for debugging rendering bugs with specific view types"}

Definition at line 93 of file gl_rmain.c.

93{CF_CLIENT, "r_showspriteedges", "0", "renders a debug outline to show the polygon shape of each sprite frame rendered (may be 2 or more in case of interpolated animations), for debugging rendering bugs with specific view types"};

Referenced by GL_Main_Init(), and R_Model_Sprite_Draw_TransparentCallback().

◆ r_showsurfaces

cvar_t r_showsurfaces = {CF_CLIENT, "r_showsurfaces", "0", "1 shows surfaces as different colors, or a value of 3 shows an approximation to vertex or object color (for a very approximate view of the game)"}

Definition at line 85 of file gl_rmain.c.

85{CF_CLIENT, "r_showsurfaces", "0", "1 shows surfaces as different colors, or a value of 3 shows an approximation to vertex or object color (for a very approximate view of the game)"};

Referenced by GL_Main_Init(), R_DrawModelDecals(), R_DrawModelDecals_Entity(), R_DrawModelDecals_FadeEntity(), R_DrawModelSurfaces(), R_DrawModelTextureSurfaceList(), R_DrawTextureSurfaceList_ShowSurfaces(), R_ProcessModelTextureSurfaceList(), R_UpdateVariables(), and R_Water_StartFrame().

◆ r_showtris

cvar_t r_showtris = {CF_CLIENT, "r_showtris", "0", "shows triangle outlines, value controls brightness (can be above 1)"}

Definition at line 86 of file gl_rmain.c.

86{CF_CLIENT, "r_showtris", "0", "shows triangle outlines, value controls brightness (can be above 1)"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_skinframe

◆ r_smoothnormals_areaweighting

cvar_t r_smoothnormals_areaweighting = {CF_CLIENT, "r_smoothnormals_areaweighting", "1", "uses significantly faster (and supposedly higher quality) area-weighted vertex normals and tangent vectors rather than summing normalized triangle normals and tangents"}

Definition at line 229 of file gl_rmain.c.

229{CF_CLIENT, "r_smoothnormals_areaweighting", "1", "uses significantly faster (and supposedly higher quality) area-weighted vertex normals and tangent vectors rather than summing normalized triangle normals and tangents"};

Referenced by GL_Main_Init(), Mod_Alias_MorphMesh_CompileFrames(), Mod_DARKPLACESMODEL_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_LoadFaces(), Mod_Q3BSP_LoadFaces(), Mod_VBSP_LoadFaces(), Mod_ZYMOTICMODEL_Load(), RSurf_ActiveCustomEntity(), and RSurf_PrepareVerticesForBatch().

◆ r_sortentities

cvar_t r_sortentities = {CF_CLIENT, "r_sortentities", "0", "sort entities before drawing (might be faster)"}

Definition at line 110 of file gl_rmain.c.

110{CF_CLIENT, "r_sortentities", "0", "sort entities before drawing (might be faster)"};

Referenced by GL_Main_Init(), and R_RenderView().

◆ r_speeds

cvar_t r_speeds = {CF_CLIENT, "r_speeds","0", "displays rendering statistics and per-subsystem timings"}

Definition at line 111 of file gl_rmain.c.

111{CF_CLIENT, "r_speeds","0", "displays rendering statistics and per-subsystem timings"};

Referenced by GL_Main_Init(), R_DrawModelSurfaces(), R_TimeReport(), R_TimeReport_BeginFrame(), R_TimeReport_EndFrame(), and VID_Finish().

◆ r_surfacelist

const msurface_t** r_surfacelist = NULL

Definition at line 9969 of file gl_rmain.c.

Referenced by R_DrawModelSurfaces().

◆ r_svbsp

svbsp_t r_svbsp

shadow volume bsp struct with automatically growing nodes buffer

Definition at line 268 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), R_Q1BSP_CallRecursiveGetLightInfo(), R_Q1BSP_RecursiveGetLightInfo_BIH(), and R_Q1BSP_RecursiveGetLightInfo_BSP().

◆ r_test

cvar_t r_test = {CF_CLIENT, "r_test", "0", "internal development use only, leave it alone (usually does nothing anyway)"}

Definition at line 235 of file gl_rmain.c.

235{CF_CLIENT, "r_test", "0", "internal development use only, leave it alone (usually does nothing anyway)"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and RSurf_DrawBatch().

◆ r_texture_black

◆ r_texture_blanknormalmap

◆ r_texture_cubemaps

cubemapinfo_t* r_texture_cubemaps[MAX_CUBEMAPS]

Definition at line 295 of file gl_rmain.c.

Referenced by gl_main_start(), and R_GetCubemap().

◆ r_texture_dds_load

cvar_t r_texture_dds_load = {CF_CLIENT | CF_ARCHIVE, "r_texture_dds_load", "0", "load compressed dds/filename.dds texture instead of filename.tga, if the file exists (requires driver support)"}

Definition at line 156 of file gl_rmain.c.

156{CF_CLIENT | CF_ARCHIVE, "r_texture_dds_load", "0", "load compressed dds/filename.dds texture instead of filename.tga, if the file exists (requires driver support)"};

Referenced by GL_Main_Init(), and gl_main_start().

◆ r_texture_dds_save

cvar_t r_texture_dds_save = {CF_CLIENT | CF_ARCHIVE, "r_texture_dds_save", "0", "save compressed dds/filename.dds texture when filename.tga is loaded, so that it can be loaded instead next time"}

Definition at line 157 of file gl_rmain.c.

157{CF_CLIENT | CF_ARCHIVE, "r_texture_dds_save", "0", "save compressed dds/filename.dds texture when filename.tga is loaded, so that it can be loaded instead next time"};

Referenced by GL_Main_Init(), gl_main_start(), and R_SkinFrame_LoadExternal_SkinFrame().

◆ r_texture_fogattenuation

rtexture_t* r_texture_fogattenuation

◆ r_texture_fogheighttexture

rtexture_t* r_texture_fogheighttexture

◆ r_texture_gammaramps

◆ r_texture_gammaramps_serial

unsigned int r_texture_gammaramps_serial

Definition at line 282 of file gl_rmain.c.

Referenced by R_UpdateVariables().

◆ r_texture_grey128

rtexture_t* r_texture_grey128

◆ r_texture_normalizationcube

rtexture_t* r_texture_normalizationcube

Definition at line 278 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), and R_BuildNormalizationCube().

◆ r_texture_notexture

rtexture_t* r_texture_notexture

Definition at line 276 of file gl_rmain.c.

Referenced by R_BuildNoTexture(), and R_GetCurrentTexture().

◆ r_texture_numcubemaps

int r_texture_numcubemaps

Definition at line 294 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), and R_GetCubemap().

◆ r_texture_reflectcube

rtexture_t* r_texture_reflectcube

Definition at line 284 of file gl_rmain.c.

◆ r_texture_white

◆ r_texture_whitecube

◆ r_textureframe

int r_textureframe = 0

used only by R_GetCurrentTexture, incremented per view and per UI render

Definition at line 45 of file gl_rmain.c.

Referenced by DrawQ_FlushUI(), R_GetCurrentTexture(), and R_RenderView().

◆ r_transparent

cvar_t r_transparent = {CF_CLIENT, "r_transparent", "1", "allows use of transparent surfaces (can be turned off to check performance impact)"}

Definition at line 78 of file gl_rmain.c.

78{CF_CLIENT, "r_transparent", "1", "allows use of transparent surfaces (can be turned off to check performance impact)"};

Referenced by GL_Main_Init(), and R_RenderScene().

◆ r_transparent_alphatocoverage

cvar_t r_transparent_alphatocoverage = {CF_CLIENT, "r_transparent_alphatocoverage", "1", "enables GL_ALPHA_TO_COVERAGE antialiasing technique on alphablend and alphatest surfaces when using vid_samples 2 or higher"}

Definition at line 79 of file gl_rmain.c.

79{CF_CLIENT, "r_transparent_alphatocoverage", "1", "enables GL_ALPHA_TO_COVERAGE antialiasing technique on alphablend and alphatest surfaces when using vid_samples 2 or higher"};

Referenced by GL_Main_Init(), R_GetCurrentTexture(), and R_SetupShader_Surface().

◆ r_transparent_sortarraysize

cvar_t r_transparent_sortarraysize = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortarraysize", "4096", "number of distance-sorting layers"}

Definition at line 143 of file gl_rmain.c.

143{CF_CLIENT | CF_ARCHIVE, "r_transparent_sortarraysize", "4096", "number of distance-sorting layers"};

Referenced by GL_Main_Init(), and R_MeshQueue_RenderTransparent().

◆ r_transparent_sortmaxdist

cvar_t r_transparent_sortmaxdist = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmaxdist", "32768", "upper distance limit for transparent sorting"}

Definition at line 142 of file gl_rmain.c.

142{CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmaxdist", "32768", "upper distance limit for transparent sorting"};

Referenced by GL_Main_Init(), and R_MeshQueue_RenderTransparent().

◆ r_transparent_sortmindist

cvar_t r_transparent_sortmindist = {CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmindist", "0", "lower distance limit for transparent sorting"}

Definition at line 141 of file gl_rmain.c.

141{CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmindist", "0", "lower distance limit for transparent sorting"};

Referenced by GL_Main_Init(), and R_MeshQueue_RenderTransparent().

◆ r_transparent_sortsurfacesbynearest

cvar_t r_transparent_sortsurfacesbynearest = {CF_CLIENT, "r_transparent_sortsurfacesbynearest", "1", "sort entity and world surfaces by nearest point on bounding box instead of using the center of the bounding box, usually reduces sorting artifacts"}

Definition at line 80 of file gl_rmain.c.

80{CF_CLIENT, "r_transparent_sortsurfacesbynearest", "1", "sort entity and world surfaces by nearest point on bounding box instead of using the center of the bounding box, usually reduces sorting artifacts"};

Referenced by GL_Main_Init(), R_Mod_DrawLight(), and R_ProcessTransparentTextureSurfaceList().

◆ r_transparent_useplanardistance

cvar_t r_transparent_useplanardistance = {CF_CLIENT, "r_transparent_useplanardistance", "0", "sort transparent meshes by distance from view plane rather than spherical distance to the chosen point"}

Definition at line 81 of file gl_rmain.c.

81{CF_CLIENT, "r_transparent_useplanardistance", "0", "sort transparent meshes by distance from view plane rather than spherical distance to the chosen point"};

Referenced by GL_Main_Init(), and R_MeshQueue_AddTransparent().

◆ r_transparentdepthmasking

cvar_t r_transparentdepthmasking = {CF_CLIENT | CF_ARCHIVE, "r_transparentdepthmasking", "0", "enables depth writes on transparent meshes whose materially is normally opaque, this prevents seeing the inside of a transparent mesh"}

Definition at line 140 of file gl_rmain.c.

140{CF_CLIENT | CF_ARCHIVE, "r_transparentdepthmasking", "0", "enables depth writes on transparent meshes whose materially is normally opaque, this prevents seeing the inside of a transparent mesh"};

Referenced by GL_Main_Init(), R_DrawSurface_TransparentCallback(), and R_GetCurrentTexture().

◆ r_uniformbufferalignment

int r_uniformbufferalignment = 32

Definition at line 270 of file gl_rmain.c.

Referenced by gl_main_start(), and R_BufferData_Store().

◆ r_usedepthtextures

cvar_t r_usedepthtextures = {CF_CLIENT | CF_ARCHIVE, "r_usedepthtextures", "1", "use depth texture instead of depth renderbuffer where possible, uses less video memory but may render slower (or faster) depending on hardware"}

Definition at line 159 of file gl_rmain.c.

159{CF_CLIENT | CF_ARCHIVE, "r_usedepthtextures", "1", "use depth texture instead of depth renderbuffer where possible, uses less video memory but may render slower (or faster) depending on hardware"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_useinfinitefarclip

cvar_t r_useinfinitefarclip = {CF_CLIENT | CF_ARCHIVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"}

Definition at line 73 of file gl_rmain.c.

73{CF_CLIENT | CF_ARCHIVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"};

Referenced by GL_Main_Init(), and R_SetupView().

◆ r_viewfbo

cvar_t r_viewfbo = {CF_CLIENT | CF_ARCHIVE, "r_viewfbo", "0", "enables use of an 8bit (1) or 16bit (2) or 32bit (3) per component float framebuffer render, which may be at a different resolution than the video mode; the default setting of 0 uses a framebuffer render when required, and renders directly to the screen otherwise"}

Definition at line 160 of file gl_rmain.c.

160{CF_CLIENT | CF_ARCHIVE, "r_viewfbo", "0", "enables use of an 8bit (1) or 16bit (2) or 32bit (3) per component float framebuffer render, which may be at a different resolution than the video mode; the default setting of 0 uses a framebuffer render when required, and renders directly to the screen otherwise"};

Referenced by GL_Main_Init(), R_BlendView_IsTrivial(), R_Bloom_StartFrame(), and VID_Mode().

◆ r_viewscale

cvar_t r_viewscale = {CF_CLIENT | CF_ARCHIVE, "r_viewscale", "1", "scaling factor for resolution of the fbo rendering method, must be > 0, can be above 1 for a costly antialiasing behavior, typical values are 0.5 for 1/4th as many pixels rendered, or 1 for normal rendering"}

Definition at line 162 of file gl_rmain.c.

162{CF_CLIENT | CF_ARCHIVE, "r_viewscale", "1", "scaling factor for resolution of the fbo rendering method, must be > 0, can be above 1 for a costly antialiasing behavior, typical values are 0.5 for 1/4th as many pixels rendered, or 1 for normal rendering"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling

cvar_t r_viewscale_fpsscaling = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling", "0", "change resolution based on framerate"}

Definition at line 163 of file gl_rmain.c.

163{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling", "0", "change resolution based on framerate"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_min

cvar_t r_viewscale_fpsscaling_min = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_min", "0.0625", "worst acceptable quality"}

Definition at line 164 of file gl_rmain.c.

164{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_min", "0.0625", "worst acceptable quality"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_multiply

cvar_t r_viewscale_fpsscaling_multiply = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_multiply", "5", "adjust quality up or down by the frametime difference from 1.0/target, multiplied by this factor"}

Definition at line 165 of file gl_rmain.c.

165{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_multiply", "5", "adjust quality up or down by the frametime difference from 1.0/target, multiplied by this factor"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_stepmax

cvar_t r_viewscale_fpsscaling_stepmax = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepmax", "1.00", "largest adjustment to hit the target framerate (this value prevents wild overshooting of the estimate)"}

Definition at line 167 of file gl_rmain.c.

167{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepmax", "1.00", "largest adjustment to hit the target framerate (this value prevents wild overshooting of the estimate)"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_stepsize

cvar_t r_viewscale_fpsscaling_stepsize = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepsize", "0.01", "smallest adjustment to hit the target framerate (this value prevents minute oscillations)"}

Definition at line 166 of file gl_rmain.c.

166{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_stepsize", "0.01", "smallest adjustment to hit the target framerate (this value prevents minute oscillations)"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_viewscale_fpsscaling_target

cvar_t r_viewscale_fpsscaling_target = {CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_target", "70", "desired framerate"}

Definition at line 168 of file gl_rmain.c.

168{CF_CLIENT | CF_ARCHIVE, "r_viewscale_fpsscaling_target", "70", "desired framerate"};

Referenced by GL_Main_Init(), and R_Bloom_StartFrame().

◆ r_water

cvar_t r_water = {CF_CLIENT | CF_ARCHIVE, "r_water", "0", "whether to use reflections and refraction on water surfaces (note: r_wateralpha must be set below 1)"}

Definition at line 192 of file gl_rmain.c.

192{CF_CLIENT | CF_ARCHIVE, "r_water", "0", "whether to use reflections and refraction on water surfaces (note: r_wateralpha must be set below 1)"};

Referenced by GL_Main_Init(), R_GetCurrentTexture(), R_Water_ProcessPlanes(), and R_Water_StartFrame().

◆ r_water_cameraentitiesonly

cvar_t r_water_cameraentitiesonly = {CF_CLIENT | CF_ARCHIVE, "r_water_cameraentitiesonly", "0", "whether to only show QC-defined reflections/refractions (typically used for camera- or portal-like effects)"}

Definition at line 193 of file gl_rmain.c.

193{CF_CLIENT | CF_ARCHIVE, "r_water_cameraentitiesonly", "0", "whether to only show QC-defined reflections/refractions (typically used for camera- or portal-like effects)"};

Referenced by GL_Main_Init(), and R_Water_ProcessPlanes().

◆ r_water_clippingplanebias

cvar_t r_water_clippingplanebias = {CF_CLIENT | CF_ARCHIVE, "r_water_clippingplanebias", "1", "a rather technical setting which avoids black pixels around water edges"}

Definition at line 194 of file gl_rmain.c.

194{CF_CLIENT | CF_ARCHIVE, "r_water_clippingplanebias", "1", "a rather technical setting which avoids black pixels around water edges"};

Referenced by GL_Main_Init(), and R_SetupView().

◆ r_water_hideplayer

cvar_t r_water_hideplayer = {CF_CLIENT | CF_ARCHIVE, "r_water_hideplayer", "0", "if set to 1 then player will be hidden in refraction views, if set to 2 then player will also be hidden in reflection views, player is always visible in camera views"}

Definition at line 200 of file gl_rmain.c.

200{CF_CLIENT | CF_ARCHIVE, "r_water_hideplayer", "0", "if set to 1 then player will be hidden in refraction views, if set to 2 then player will also be hidden in reflection views, player is always visible in camera views"};

Referenced by GL_Main_Init(), and R_Water_ProcessPlanes().

◆ r_water_lowquality

cvar_t r_water_lowquality = {CF_CLIENT, "r_water_lowquality", "0", "special option to accelerate water rendering: 1 disables all dynamic lights, 2 disables particles too"}

Definition at line 199 of file gl_rmain.c.

199{CF_CLIENT, "r_water_lowquality", "0", "special option to accelerate water rendering: 1 disables all dynamic lights, 2 disables particles too"};

Referenced by GL_Main_Init(), and R_Water_ProcessPlanes().

◆ r_water_reflectdistort

cvar_t r_water_reflectdistort = {CF_CLIENT | CF_ARCHIVE, "r_water_reflectdistort", "0.01", "how much water reflections shimmer"}

Definition at line 197 of file gl_rmain.c.

197{CF_CLIENT | CF_ARCHIVE, "r_water_reflectdistort", "0.01", "how much water reflections shimmer"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_water_refractdistort

cvar_t r_water_refractdistort = {CF_CLIENT | CF_ARCHIVE, "r_water_refractdistort", "0.01", "how much water refractions shimmer"}

Definition at line 196 of file gl_rmain.c.

196{CF_CLIENT | CF_ARCHIVE, "r_water_refractdistort", "0.01", "how much water refractions shimmer"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_water_resolutionmultiplier

cvar_t r_water_resolutionmultiplier = {CF_CLIENT | CF_ARCHIVE, "r_water_resolutionmultiplier", "0.5", "multiplier for screen resolution when rendering refracted/reflected scenes, 1 is full quality, lower values are faster"}

Definition at line 195 of file gl_rmain.c.

195{CF_CLIENT | CF_ARCHIVE, "r_water_resolutionmultiplier", "0.5", "multiplier for screen resolution when rendering refracted/reflected scenes, 1 is full quality, lower values are faster"};

Referenced by GL_Main_Init(), and R_Water_StartFrame().

◆ r_water_scissormode

cvar_t r_water_scissormode = {CF_CLIENT, "r_water_scissormode", "3", "scissor (1) or cull (2) or both (3) water renders"}

Definition at line 198 of file gl_rmain.c.

198{CF_CLIENT, "r_water_scissormode", "3", "scissor (1) or cull (2) or both (3) water renders"};

Referenced by GL_Main_Init(), and R_Water_ProcessPlanes().

◆ r_wateralpha

cvar_t r_wateralpha = {CF_CLIENT | CF_ARCHIVE, "r_wateralpha","1", "opacity of water polygons"}

◆ r_waterscroll

cvar_t r_waterscroll = {CF_CLIENT | CF_ARCHIVE, "r_waterscroll", "1", "makes water scroll around, value controls how much"}

Definition at line 206 of file gl_rmain.c.

206{CF_CLIENT | CF_ARCHIVE, "r_waterscroll", "1", "makes water scroll around, value controls how much"};

Referenced by GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and R_RenderScene().

◆ r_waterscrollmatrix

matrix4x4_t r_waterscrollmatrix

Definition at line 5394 of file gl_rmain.c.

Referenced by R_GetCurrentTexture(), R_RenderScene(), and R_tcMod_ApplyToMatrix().

◆ rsurface

rsurfacestate_t rsurface

Definition at line 6919 of file gl_rmain.c.

Referenced by R_DecalSystem_SplatEntity(), R_DecalSystem_SplatTriangle(), R_DrawCustomSurface_Texture(), R_DrawDebugModel(), R_DrawModelDecals_Entity(), R_DrawModelSurfaces(), R_DrawNoModel(), R_DrawNoModel_TransparentCallback(), R_DrawPortals(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_GL20(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_EvaluateQ3WaveFunc(), R_GetCurrentTexture(), R_Mod_DrawAddWaterPlanes(), R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Mod_GetLightInfo(), R_Model_Sprite_Draw(), R_Model_Sprite_Draw_TransparentCallback(), R_ProcessModelTextureSurfaceList(), R_ProcessTransparentTextureSurfaceList(), R_Q1BSP_DrawLight_TransparentCallback(), R_QueueModelSurfaceList(), R_RenderView(), R_SetupShader_DeferredLight(), R_SetupShader_DepthOrShadow(), R_SetupShader_Surface(), R_Shadow_DrawEntityLight(), R_Shadow_DrawEntityShadow(), R_Shadow_DrawModelShadowMaps(), R_Shadow_DrawWorldLight(), R_Shadow_DrawWorldShadow_ShadowMap(), R_Shadow_RenderLighting(), R_Shadow_RenderLighting_VisibleLighting(), R_Shadow_RenderMode_ActiveLight(), R_Shadow_RenderMode_DrawDeferredLight(), R_Shadow_RenderMode_ShadowMap(), R_Shadow_SetShadowmapParametersForLight(), R_Shadow_SetupEntityLight(), R_tcMod_ApplyToMatrix(), R_TestQ3WaveFunc(), R_Water_AddWaterPlane(), RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), RSurf_DrawBatch(), RSurf_FindWaterPlaneForSurface(), RSurf_FogVertex(), RSurf_PrepareVerticesForBatch(), RSurf_SetupDepthAndCulling(), and RSurf_UploadBuffersForBatch().

◆ shadermodeinfo

Initial value:
=
{
{
{"combined", "glsl", builtinshaderstrings, "#define MODE_GENERIC\n", " generic"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_POSTPROCESS\n", " postprocess"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_DEPTH_OR_SHADOW\n", " depth/shadow"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_FLATCOLOR\n", " flatcolor"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_VERTEXCOLOR\n", " vertexcolor"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTMAP\n", " lightmap"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_MODELSPACE\n", " lightdirectionmap_modelspace"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n", " lightdirectionmap_tangentspace"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP\n", " lightdirectionmap_forced_lightmap"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR\n", " lightdirectionmap_forced_vertexcolor"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTGRID\n", " lightgrid"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTION\n", " lightdirection"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTSOURCE\n", " lightsource"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_REFRACTION\n", " refraction"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_WATER\n", " water"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_DEFERREDGEOMETRY\n", " deferredgeometry"},
{"combined", "glsl", builtinshaderstrings, "#define MODE_DEFERREDLIGHTSOURCE\n", " deferredlightsource"},
},
}
static const char * builtinshaderstrings[]
Definition gl_rmain.c:596

Definition at line 662 of file gl_rmain.c.

663{
664 // SHADERLANGUAGE_GLSL
665 {
666 {"combined", "glsl", builtinshaderstrings, "#define MODE_GENERIC\n", " generic"},
667 {"combined", "glsl", builtinshaderstrings, "#define MODE_POSTPROCESS\n", " postprocess"},
668 {"combined", "glsl", builtinshaderstrings, "#define MODE_DEPTH_OR_SHADOW\n", " depth/shadow"},
669 {"combined", "glsl", builtinshaderstrings, "#define MODE_FLATCOLOR\n", " flatcolor"},
670 {"combined", "glsl", builtinshaderstrings, "#define MODE_VERTEXCOLOR\n", " vertexcolor"},
671 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTMAP\n", " lightmap"},
672 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_MODELSPACE\n", " lightdirectionmap_modelspace"},
673 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n", " lightdirectionmap_tangentspace"},
674 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP\n", " lightdirectionmap_forced_lightmap"},
675 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR\n", " lightdirectionmap_forced_vertexcolor"},
676 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTGRID\n", " lightgrid"},
677 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTDIRECTION\n", " lightdirection"},
678 {"combined", "glsl", builtinshaderstrings, "#define MODE_LIGHTSOURCE\n", " lightsource"},
679 {"combined", "glsl", builtinshaderstrings, "#define MODE_REFRACTION\n", " refraction"},
680 {"combined", "glsl", builtinshaderstrings, "#define MODE_WATER\n", " water"},
681 {"combined", "glsl", builtinshaderstrings, "#define MODE_DEFERREDGEOMETRY\n", " deferredgeometry"},
682 {"combined", "glsl", builtinshaderstrings, "#define MODE_DEFERREDLIGHTSOURCE\n", " deferredlightsource"},
683 },
684};

Referenced by R_GLSL_CompilePermutation(), R_GLSL_DumpShader_f(), and R_InitShaderModeInfo().

◆ shaderpermutationinfo

Definition at line 625 of file gl_rmain.c.

626{
627 {"#define USEDIFFUSE\n", " diffuse"},
628 {"#define USEVERTEXTEXTUREBLEND\n", " vertextextureblend"},
629 {"#define USEVIEWTINT\n", " viewtint"},
630 {"#define USECOLORMAPPING\n", " colormapping"},
631 {"#define USESATURATION\n", " saturation"},
632 {"#define USEFOGINSIDE\n", " foginside"},
633 {"#define USEFOGOUTSIDE\n", " fogoutside"},
634 {"#define USEFOGHEIGHTTEXTURE\n", " fogheighttexture"},
635 {"#define USEFOGALPHAHACK\n", " fogalphahack"},
636 {"#define USEGAMMARAMPS\n", " gammaramps"},
637 {"#define USECUBEFILTER\n", " cubefilter"},
638 {"#define USEGLOW\n", " glow"},
639 {"#define USEBLOOM\n", " bloom"},
640 {"#define USESPECULAR\n", " specular"},
641 {"#define USEPOSTPROCESSING\n", " postprocessing"},
642 {"#define USEREFLECTION\n", " reflection"},
643 {"#define USEOFFSETMAPPING\n", " offsetmapping"},
644 {"#define USEOFFSETMAPPING_RELIEFMAPPING\n", " reliefmapping"},
645 {"#define USESHADOWMAP2D\n", " shadowmap2d"},
646 {"#define USESHADOWMAPVSDCT\n", " shadowmapvsdct"}, // TODO make this a static parm
647 {"#define USESHADOWMAPORTHO\n", " shadowmaportho"},
648 {"#define USEDEFERREDLIGHTMAP\n", " deferredlightmap"},
649 {"#define USEALPHAKILL\n", " alphakill"},
650 {"#define USEREFLECTCUBE\n", " reflectcube"},
651 {"#define USENORMALMAPSCROLLBLEND\n", " normalmapscrollblend"},
652 {"#define USEBOUNCEGRID\n", " bouncegrid"},
653 {"#define USEBOUNCEGRIDDIRECTIONAL\n", " bouncegriddirectional"}, // TODO make this a static parm
654 {"#define USETRIPPY\n", " trippy"},
655 {"#define USEDEPTHRGB\n", " depthrgb"},
656 {"#define USEALPHAGENVERTEX\n", " alphagenvertex"},
657 {"#define USESKELETAL\n", " skeletal"},
658 {"#define USEOCCLUDE\n", " occlude"}
659};

Referenced by R_GLSL_CompilePermutation(), and R_GLSL_DumpShader_f().

◆ shaderstaticparms_count

int shaderstaticparms_count = 0
static

Definition at line 854 of file gl_rmain.c.

Referenced by R_CompileShader_AddStaticParms(), and R_GLSL_CompilePermutation().

◆ shaderstaticparmstrings_list

const char* shaderstaticparmstrings_list[SHADERSTATICPARMS_COUNT]
static

Definition at line 853 of file gl_rmain.c.

Referenced by R_GLSL_CompilePermutation().

◆ suffix

suffixinfo_t suffix[3][6]
static
Initial value:
=
{
{
{"px", false, false, false},
{"nx", false, false, false},
{"py", false, false, false},
{"ny", false, false, false},
{"pz", false, false, false},
{"nz", false, false, false}
},
{
{"posx", false, false, false},
{"negx", false, false, false},
{"posy", false, false, false},
{"negy", false, false, false},
{"posz", false, false, false},
{"negz", false, false, false}
},
{
{"rt", true, false, true},
{"lf", false, true, true},
{"ft", true, true, false},
{"bk", false, false, false},
{"up", true, false, true},
{"dn", true, false, true}
}
}

Definition at line 2878 of file gl_rmain.c.

2879{
2880 {
2881 {"px", false, false, false},
2882 {"nx", false, false, false},
2883 {"py", false, false, false},
2884 {"ny", false, false, false},
2885 {"pz", false, false, false},
2886 {"nz", false, false, false}
2887 },
2888 {
2889 {"posx", false, false, false},
2890 {"negx", false, false, false},
2891 {"posy", false, false, false},
2892 {"negy", false, false, false},
2893 {"posz", false, false, false},
2894 {"negz", false, false, false}
2895 },
2896 {
2897 {"rt", true, false, true},
2898 {"lf", false, true, true},
2899 {"ft", true, true, false},
2900 {"bk", false, false, false},
2901 {"up", true, false, true},
2902 {"dn", true, false, true}
2903 }
2904};

Referenced by R_LoadCubemap().

◆ v_flipped_state

qbool v_flipped_state
extern

Definition at line 21 of file gl_backend.c.

Referenced by GL_CullFace(), and GL_SetMirrorState().

◆ v_glslgamma_2d

cvar_t v_glslgamma_2d
extern

Definition at line 186 of file vid_shared.c.

186{CF_CLIENT | CF_ARCHIVE, "v_glslgamma_2d", "1", "applies GLSL gamma to 2d pictures (HUD, fonts)"};

Referenced by R_SetupShader_Generic(), and VID_Shared_Init().

◆ v_isometric

cvar_t v_isometric
extern

Definition at line 97 of file view.c.

97{CF_CLIENT, "v_isometric", "0", "changes view to isometric (non-perspective)"};

Referenced by R_RenderView(), and V_Init().

◆ viewscalefpsadjusted

float viewscalefpsadjusted = 1.0f

Definition at line 4382 of file gl_rmain.c.

Referenced by R_Bloom_StartFrame().