mempool_t *r_main_mempool;
rtexturepool_t *r_main_texturepool;
-static int r_textureframe = 0; ///< used only by R_GetCurrentTexture
+int r_textureframe = 0; ///< used only by R_GetCurrentTexture, incremented per view and per UI render
static qboolean r_loadnormalmap;
static qboolean r_loadgloss;
skinframe_t *R_SkinFrame_Find(const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qboolean add)
{
skinframe_t *item;
+ int compareflags = textureflags & TEXF_IMPORTANTBITS;
int hashindex;
char basename[MAX_QPATH];
hashindex = CRC_Block((unsigned char *)basename, strlen(basename)) & (SKINFRAME_HASH - 1);
for (item = r_skinframe.hash[hashindex];item;item = item->next)
- if (!strcmp(item->basename, basename) && (comparecrc < 0 || (item->textureflags == textureflags && item->comparewidth == comparewidth && item->compareheight == compareheight && item->comparecrc == comparecrc)))
+ if (!strcmp(item->basename, basename) &&
+ item->textureflags == compareflags &&
+ item->comparewidth == comparewidth &&
+ item->compareheight == compareheight &&
+ item->comparecrc == comparecrc)
break;
if (!item)
item = (skinframe_t *)Mem_ExpandableArray_AllocRecord(&r_skinframe.array);
memset(item, 0, sizeof(*item));
strlcpy(item->basename, basename, sizeof(item->basename));
- item->textureflags = textureflags & ~TEXF_FORCE_RELOAD;
+ item->textureflags = compareflags;
item->comparewidth = comparewidth;
item->compareheight = compareheight;
item->comparecrc = comparecrc;
r_skinframe.hash[hashindex] = item;
}
else if (textureflags & TEXF_FORCE_RELOAD)
- {
- if (!add)
- return NULL;
R_SkinFrame_PurgeSkinFrame(item);
- }
R_SkinFrame_MarkUsed(item);
return item;
return NULL;
// return an existing skinframe if already loaded
- // if loading of the first image fails, don't make a new skinframe as it
- // would cause all future lookups of this to be missing
- skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, -1, false);
+ skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, 0, false);
if (skinframe && skinframe->base)
return skinframe;
+ // if the skinframe doesn't exist this will create it
return R_SkinFrame_LoadExternal_SkinFrame(skinframe, name, textureflags, complain, fallbacknotexture);
}
return skinframe;
}
-// this is only used by .spr32 sprites, HL .spr files, HL .bsp files
-skinframe_t *R_SkinFrame_LoadInternalBGRA(const char *name, int textureflags, const unsigned char *skindata, int width, int height, qboolean sRGB)
+skinframe_t *R_SkinFrame_LoadInternalBGRA(const char *name, int textureflags, const unsigned char *skindata, int width, int height, int comparewidth, int compareheight, int comparecrc, qboolean sRGB)
{
int i;
skinframe_t *skinframe;
return NULL;
// if already loaded just return it, otherwise make a new skinframe
- skinframe = R_SkinFrame_Find(name, textureflags, width, height, (!(textureflags & TEXF_FORCE_RELOAD) && skindata) ? CRC_Block(skindata, width*height*4) : -1, true);
+ skinframe = R_SkinFrame_Find(name, textureflags, comparewidth, compareheight, comparecrc, true);
if (skinframe->base)
return skinframe;
textureflags &= ~TEXF_FORCE_RELOAD;
return NULL;
// if already loaded just return it, otherwise make a new skinframe
- skinframe = R_SkinFrame_Find(name, textureflags, width, height, (!(textureflags & TEXF_FORCE_RELOAD) && skindata) ? CRC_Block(skindata, width*height) : -1, true);
+ skinframe = R_SkinFrame_Find(name, textureflags, width, height, skindata ? CRC_Block(skindata, width*height) : 0, true);
if (skinframe->base)
return skinframe;
//textureflags &= ~TEXF_FORCE_RELOAD;
}
}
- return R_SkinFrame_LoadInternalBGRA("notexture", TEXF_FORCENEAREST, pix[0][0], 16, 16, false);
+ return R_SkinFrame_LoadInternalBGRA("notexture", TEXF_FORCENEAREST, pix[0][0], 16, 16, 0, 0, 0, false);
}
skinframe_t *R_SkinFrame_LoadInternalUsingTexture(const char *name, int textureflags, rtexture_t *tex, int width, int height, qboolean sRGB)
if (cls.state == ca_dedicated)
return NULL;
// if already loaded just return it, otherwise make a new skinframe
- skinframe = R_SkinFrame_Find(name, textureflags, width, height, (textureflags & TEXF_FORCE_RELOAD) ? -1 : 0, true);
+ skinframe = R_SkinFrame_Find(name, textureflags, width, height, 0, true);
if (skinframe->base)
return skinframe;
textureflags &= ~TEXF_FORCE_RELOAD;
{
case RENDERPATH_GL32:
case RENDERPATH_GLES2:
- Cvar_SetValueQuick(&r_textureunits, vid.texunits);
+ Cvar_SetValueQuick(&r_textureunits, MAX_TEXTUREUNITS);
Cvar_SetValueQuick(&gl_combine, 1);
Cvar_SetValueQuick(&r_glsl, 1);
r_loadnormalmap = true;
RSurf_DrawBatch();
}
-static void R_ProcessModelTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist, qboolean writedepth, qboolean depthonly, qboolean prepass)
+static void R_ProcessModelTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist, qboolean writedepth, qboolean depthonly, qboolean prepass, qboolean ui)
{
CHECKGLERROR
- if (depthonly)
+ if (ui)
+ R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth, prepass);
+ else if (depthonly)
R_DrawTextureSurfaceList_DepthOnly(texturenumsurfaces, texturesurfacelist);
else if (prepass)
{
CHECKGLERROR
}
-static void R_QueueModelSurfaceList(entity_render_t *ent, int numsurfaces, const msurface_t **surfacelist, int flagsmask, qboolean writedepth, qboolean depthonly, qboolean prepass)
+static void R_QueueModelSurfaceList(entity_render_t *ent, int numsurfaces, const msurface_t **surfacelist, int flagsmask, qboolean writedepth, qboolean depthonly, qboolean prepass, qboolean ui)
{
int i, j;
texture_t *texture;
;
}
// render the range of surfaces
- R_ProcessModelTextureSurfaceList(j - i, surfacelist + i, writedepth, depthonly, prepass);
+ R_ProcessModelTextureSurfaceList(j - i, surfacelist + i, writedepth, depthonly, prepass, ui);
}
R_FrameData_ReturnToMark();
}
int r_maxsurfacelist = 0;
const msurface_t **r_surfacelist = NULL;
-void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean writedepth, qboolean depthonly, qboolean debug, qboolean prepass)
+void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean writedepth, qboolean depthonly, qboolean debug, qboolean prepass, qboolean ui)
{
int i, j, endj, flagsmask;
dp_model_t *model = ent->model;
r_surfacelist[numsurfacelist++] = surfaces + j;
}
}
+ else if (ui)
+ {
+ // for ui we have to preserve the order of surfaces
+ for (i = 0; i < model->nummodelsurfaces; i++)
+ r_surfacelist[numsurfacelist++] = surfaces + model->firstmodelsurface + i;
+ }
else
{
// add all surfaces
}
}
- R_QueueModelSurfaceList(ent, numsurfacelist, r_surfacelist, flagsmask, writedepth, depthonly, prepass);
+ R_QueueModelSurfaceList(ent, numsurfacelist, r_surfacelist, flagsmask, writedepth, depthonly, prepass, ui);
// add to stats if desired
if (r_speeds.integer && !skysurfaces && !depthonly)
offsetx = 0.5f * width * vid_conwidth.value / vid.width;
offsety = 0;
}
- surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, "white", 0, 0, MATERIALFLAG_VERTEXCOLOR), true);
+ surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, "white", 0, 0, MATERIALFLAG_WALL | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX), true);
e0 = Mod_Mesh_IndexForVertex(mod, surf, x1 - offsetx, y1 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r1, g1, b1, alpha1);
e1 = Mod_Mesh_IndexForVertex(mod, surf, x2 - offsetx, y2 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r2, g2, b2, alpha2);
e2 = Mod_Mesh_IndexForVertex(mod, surf, x2 + offsetx, y2 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r2, g2, b2, alpha2);