]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Use the model renderer on the UI - this means q3shaders and other material features...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 1 Jul 2018 08:22:40 +0000 (08:22 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 1 Jul 2018 08:22:40 +0000 (08:22 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12438 d7cf8633-e32d-0410-b094-e92efae38249

15 files changed:
cl_main.c
cl_particles.c
clvm_cmds.c
ft2.c
gl_draw.c
gl_rmain.c
gl_rsurf.c
libcurl.c
model_brush.c
model_shared.c
model_sprite.c
r_lightning.c
r_shadow.c
r_sky.c
render.h

index 8ee778468e0d98f3b0d3c2f6ad8be1d1c02e89fc..4fad1003ec56325bb0092db482fc11e62dab20a4 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -2405,7 +2405,7 @@ static void CL_MeshEntities_Init(void)
                ent = cl_meshentities + i;
                ent->state_current.active = true;
                ent->render.model = cl_meshentitymodels + i;
-               ent->render.alpha = 1;
+               ent->render.alpha = 0.999999f; // not quite 1 so that MATERIALFLAG_ALPHA is always set.
                ent->render.flags = RENDER_SHADOW | RENDER_LIGHT;
                ent->render.framegroupblend[0].lerp = 1;
                ent->render.frameblend[0].lerp = 1;
@@ -2414,6 +2414,18 @@ static void CL_MeshEntities_Init(void)
                VectorSet(ent->render.custommodellight_ambient, 1, 1, 1);
                VectorSet(ent->render.custommodellight_diffuse, 0, 0, 0);
                VectorSet(ent->render.custommodellight_lightdir, 0, 0, 1);
+               VectorSet(ent->render.render_fullbright, 1, 1, 1);
+               VectorSet(ent->render.render_glowmod, 0, 0, 0);
+               VectorSet(ent->render.render_modellight_ambient, 1, 1, 1);
+               VectorSet(ent->render.render_modellight_diffuse, 0, 0, 0);
+               VectorSet(ent->render.render_modellight_specular, 0, 0, 0);
+               VectorSet(ent->render.render_modellight_lightdir, 0, 0, 1);
+               VectorSet(ent->render.render_lightmap_ambient, 0, 0, 0);
+               VectorSet(ent->render.render_lightmap_diffuse, 1, 1, 1);
+               VectorSet(ent->render.render_lightmap_specular, 1, 1, 1);
+               VectorSet(ent->render.render_rtlight_diffuse, 1, 1, 1);
+               VectorSet(ent->render.render_rtlight_specular, 1, 1, 1);
+
                Matrix4x4_CreateIdentity(&ent->render.matrix);
                CL_UpdateRenderEntity(&ent->render);
        }
index 49654d823c3d44482c904bf07eb3fb79ff042e8b..6d99fe0156a5ec8ab63d4d2d1c55d7e96d766b65 100644 (file)
@@ -2325,7 +2325,7 @@ static void R_InitParticleTexture (void)
                Image_WriteTGABGRA ("particles/particlefont.tga", PARTICLEFONTSIZE, PARTICLEFONTSIZE, particletexturedata);
 #endif
 
-               decalskinframe = R_SkinFrame_LoadInternalBGRA("particlefont", TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, particletexturedata, PARTICLEFONTSIZE, PARTICLEFONTSIZE, false);
+               decalskinframe = R_SkinFrame_LoadInternalBGRA("particlefont", TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, particletexturedata, PARTICLEFONTSIZE, PARTICLEFONTSIZE, 0, 0, 0, false);
                particlefonttexture = decalskinframe->base;
 
                Mem_Free(particletexturedata);
index e218878e200f86578cb4309304aeac5c6390291e..51f64b5073ff01a1d77a8f30805aad2fdb859c08 100644 (file)
@@ -3319,7 +3319,7 @@ static void VM_CL_R_PolygonBegin (prvm_prog_t *prog)
        // we need to remember whether this is a 2D or 3D mesh we're adding to
        mod = draw2d ? CL_Mesh_UI() : CL_Mesh_CSQC();
        prog->polygonbegin_model = mod;
-       Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, texname, drawflags, TEXF_ALPHA, MATERIALFLAG_VERTEXCOLOR), draw2d);
+       Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, texname, drawflags, TEXF_ALPHA, MATERIALFLAG_WALL | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX), draw2d);
 }
 
 //void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
diff --git a/ft2.c b/ft2.c
index c7bb663325bd8801ed5187892c55c1f749e95714..01823f4af4768ce3be4f17902ca32368cdaf4aec 100644 (file)
--- a/ft2.c
+++ b/ft2.c
@@ -1619,7 +1619,7 @@ static qboolean Font_LoadMap(ft2_font_t *font, ft2_font_map_t *mapstart, Uchar _
                int w = map->glyphSize * FONT_CHARS_PER_LINE;
                int h = map->glyphSize * FONT_CHAR_LINES;
                // update the pic returned by Draw_CachePic_Flags earlier to contain our texture
-               map->pic = Draw_NewPic(map_identifier, w, h, data, r_font_use_alpha_textures.integer ? TEXTYPE_ALPHA : TEXTYPE_RGBA, TEXF_ALPHA | (r_font_compress.integer > 0 ? TEXF_COMPRESS : 0));
+               map->pic = Draw_NewPic(map_identifier, w, h, data, r_font_use_alpha_textures.integer ? TEXTYPE_ALPHA : TEXTYPE_RGBA, TEXF_ALPHA | TEXF_CLAMP | (r_font_compress.integer > 0 ? TEXF_COMPRESS : 0));
 
                if (r_font_diskcache.integer >= 1)
                {
index c61fa3669f8b64745e8e8b789296c61cd38fa4c9..3f400e4ade4088cdeb82fc52514ded53605696e8 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -116,6 +116,8 @@ cachepic_t *Draw_CachePic_Flags(const char *path, unsigned int cachepicflags)
                                }
                                if (!pic->skinframe || !pic->skinframe->base)
                                {
+                                       if (pic->flags & CACHEPICFLAG_FAILONMISSING)
+                                               return NULL;
                                        Con_DPrintf("Draw_CachePic(\"%s\"): frame %i: reloading pic\n", path, draw_frame);
                                        goto reload;
                                }
@@ -295,7 +297,7 @@ cachepic_t *Draw_NewPic(const char *picname, int width, int height, unsigned cha
        pic->flags |= (texflags & TEXF_FORCENEAREST) ? CACHEPICFLAG_NEAREST : 0;
        pic->width = width;
        pic->height = height;
-       pic->skinframe = R_SkinFrame_LoadInternalBGRA(picname, texflags | TEXF_FORCE_RELOAD, pixels_bgra, width, height, vid.sRGB2D);
+       pic->skinframe = R_SkinFrame_LoadInternalBGRA(picname, texflags | TEXF_FORCE_RELOAD, pixels_bgra, width, height, 0, 0, 0, vid.sRGB2D);
        pic->lastusedframe = draw_frame;
        return pic;
 }
@@ -792,7 +794,7 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo
                width = pic->width;
        if (height == 0)
                height = pic->height;
-       surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, pic->name, flags, pic->texflags, MATERIALFLAG_VERTEXCOLOR), true);
+       surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, pic->name, flags, pic->texflags, MATERIALFLAG_WALL | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX), true);
        e0 = Mod_Mesh_IndexForVertex(mod, surf, x        , y         , 0, 0, 0, -1, 0, 0, 0, 0, red, green, blue, alpha);
        e1 = Mod_Mesh_IndexForVertex(mod, surf, x + width, y         , 0, 0, 0, -1, 1, 0, 0, 0, red, green, blue, alpha);
        e2 = Mod_Mesh_IndexForVertex(mod, surf, x + width, y + height, 0, 0, 0, -1, 1, 1, 0, 0, red, green, blue, alpha);
@@ -820,7 +822,7 @@ void DrawQ_RotPic(float x, float y, cachepic_t *pic, float width, float height,
                width = pic->width;
        if (height == 0)
                height = pic->height;
-       surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, pic->name, flags, pic->texflags, MATERIALFLAG_VERTEXCOLOR), true);
+       surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, pic->name, flags, pic->texflags, MATERIALFLAG_WALL | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX), true);
        e0 = Mod_Mesh_IndexForVertex(mod, surf, x - cosaf *          org_x  - cosar *           org_y , y - sinaf *          org_x  - sinar *           org_y , 0, 0, 0, -1, 0, 0, 0, 0, red, green, blue, alpha);
        e1 = Mod_Mesh_IndexForVertex(mod, surf, x + cosaf * (width - org_x) - cosar *           org_y , y + sinaf * (width - org_x) - sinar *           org_y , 0, 0, 0, -1, 1, 0, 0, 0, red, green, blue, alpha);
        e2 = Mod_Mesh_IndexForVertex(mod, surf, x + cosaf * (width - org_x) + cosar * (height - org_y), y + sinaf * (width - org_x) + sinar * (height - org_y), 0, 0, 0, -1, 1, 1, 0, 0, red, green, blue, alpha);
@@ -1271,7 +1273,7 @@ float DrawQ_String_Scale(float startx, float starty, const char *text, size_t ma
                                        u = 0.0625f * thisw - (1.0f / tw);
                                        v = 0.0625f - (1.0f / th);
                                }
-                               surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, fnt->pic->name, flags, TEXF_ALPHA | TEXF_CLAMP, MATERIALFLAG_VERTEXCOLOR), true);
+                               surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, fnt->pic->name, flags, TEXF_ALPHA | TEXF_CLAMP, MATERIALFLAG_WALL | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX), true);
                                e0 = Mod_Mesh_IndexForVertex(mod, surf, x         , y   , 10, 0, 0, -1, s  , t  , 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
                                e1 = Mod_Mesh_IndexForVertex(mod, surf, x+dw*thisw, y   , 10, 0, 0, -1, s+u, t  , 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
                                e2 = Mod_Mesh_IndexForVertex(mod, surf, x+dw*thisw, y+dh, 10, 0, 0, -1, s+u, t+v, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
@@ -1312,7 +1314,7 @@ float DrawQ_String_Scale(float startx, float starty, const char *text, size_t ma
                                }
                                else
                                        kx = ky = 0;
-                               surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, map->pic->name, flags, TEXF_ALPHA | TEXF_CLAMP, MATERIALFLAG_VERTEXCOLOR), true);
+                               surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, map->pic->name, flags, TEXF_ALPHA | TEXF_CLAMP, MATERIALFLAG_WALL | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX), true);
                                e0 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmin, y + dh * map->glyphs[mapch].vymin, 10, 0, 0, -1, map->glyphs[mapch].txmin, map->glyphs[mapch].tymin, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
                                e1 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmax, y + dh * map->glyphs[mapch].vymin, 10, 0, 0, -1, map->glyphs[mapch].txmax, map->glyphs[mapch].tymin, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
                                e2 = Mod_Mesh_IndexForVertex(mod, surf, x + dw * map->glyphs[mapch].vxmax, y + dh * map->glyphs[mapch].vymax, 10, 0, 0, -1, map->glyphs[mapch].txmax, map->glyphs[mapch].tymax, 0, 0, DrawQ_Color[0], DrawQ_Color[1], DrawQ_Color[2], DrawQ_Color[3]);
@@ -1416,7 +1418,7 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height
                width = pic->width;
        if (height == 0)
                height = pic->height;
-       surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, pic->name, flags, pic->texflags, MATERIALFLAG_VERTEXCOLOR), true);
+       surf = Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, pic->name, flags, pic->texflags, MATERIALFLAG_WALL | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX), true);
        e0 = Mod_Mesh_IndexForVertex(mod, surf, x        , y         , 0, 0, 0, -1, s1, t1, 0, 0, r1, g1, b1, a1);
        e1 = Mod_Mesh_IndexForVertex(mod, surf, x + width, y         , 0, 0, 0, -1, s2, t2, 0, 0, r2, g2, b2, a2);
        e2 = Mod_Mesh_IndexForVertex(mod, surf, x + width, y + height, 0, 0, 0, -1, s4, t4, 0, 0, r4, g4, b4, a4);
@@ -1442,7 +1444,7 @@ void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, f
                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, r, g, b, alpha);
        e1 = Mod_Mesh_IndexForVertex(mod, surf, x2 - offsetx, y2 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r, g, b, alpha);
        e2 = Mod_Mesh_IndexForVertex(mod, surf, x2 + offsetx, y2 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r, g, b, alpha);
@@ -1494,7 +1496,6 @@ void DrawQ_RecalcView(void)
 
 void DrawQ_FlushUI(void)
 {
-       int i;
        dp_model_t *mod = CL_Mesh_UI();
        if (mod->num_surfaces == 0)
                return;
@@ -1506,23 +1507,12 @@ void DrawQ_FlushUI(void)
        }
 
        // TODO: render the mesh using R_Q1BSP_Draw or similar, for full material support.
+       r_refdef.view.colorscale = 1;
+       r_textureframe++; // used only by R_GetCurrentTexture
        GL_DepthMask(false);
-       R_Mesh_PrepareVertices_Generic_Arrays(mod->surfmesh.num_vertices, mod->surfmesh.data_vertex3f, mod->surfmesh.data_lightmapcolor4f, mod->surfmesh.data_texcoordtexture2f);
-       for (i = 0; i < mod->num_surfaces; i++)
-       {
-               msurface_t *surf = mod->data_surfaces + i;
-               texture_t *tex = surf->texture;
-               if (tex->currentmaterialflags & MATERIALFLAG_CUSTOMBLEND)
-                       GL_BlendFunc(tex->customblendfunc[0], tex->customblendfunc[1]);
-               else if (tex->currentmaterialflags & MATERIALFLAG_ADD)
-                       GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
-               else if (tex->currentmaterialflags & MATERIALFLAG_ALPHA)
-                       GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-               else
-                       GL_BlendFunc(GL_ONE, GL_ZERO);
-               R_SetupShader_Generic(tex->currentskinframe->base, (tex->currentmaterialflags & MATERIALFLAG_CUSTOMBLEND) ? false : true, true, false);
-               R_Mesh_Draw(surf->num_firstvertex, surf->num_vertices, surf->num_firsttriangle, surf->num_triangles, mod->surfmesh.data_element3i, NULL, 0, mod->surfmesh.data_element3s, NULL, 0);
-       }
+
+       Mod_Mesh_Finalize(mod);
+       R_DrawModelSurfaces(&cl_meshentities[MESH_UI].render, false, false, false, false, false, true);
 
        Mod_Mesh_Reset(mod);
 }
index abb360d4e51f22af72326544c107e3a56df77eda..11489141bef549b84d8d503afad9df8aeee41a95 100644 (file)
@@ -42,7 +42,7 @@ __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
 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;
@@ -2185,6 +2185,7 @@ skinframe_t *R_SkinFrame_FindNextByName( skinframe_t *last, const char *name ) {
 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];
 
@@ -2192,7 +2193,11 @@ skinframe_t *R_SkinFrame_Find(const char *name, int textureflags, int comparewid
 
        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)
@@ -2202,7 +2207,7 @@ skinframe_t *R_SkinFrame_Find(const char *name, int textureflags, int comparewid
                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;
@@ -2210,11 +2215,7 @@ skinframe_t *R_SkinFrame_Find(const char *name, int textureflags, int comparewid
                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;
@@ -2263,12 +2264,11 @@ skinframe_t *R_SkinFrame_LoadExternal(const char *name, int textureflags, qboole
                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);
 }
 
@@ -2487,8 +2487,7 @@ skinframe_t *R_SkinFrame_LoadExternal_SkinFrame(skinframe_t *skinframe, const ch
        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;
@@ -2498,7 +2497,7 @@ skinframe_t *R_SkinFrame_LoadInternalBGRA(const char *name, int textureflags, co
                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;
@@ -2568,7 +2567,7 @@ skinframe_t *R_SkinFrame_LoadInternalQuake(const char *name, int textureflags, i
                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;
@@ -2807,7 +2806,7 @@ skinframe_t *R_SkinFrame_LoadNoTexture(void)
                }
        }
 
-       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)
@@ -2816,7 +2815,7 @@ skinframe_t *R_SkinFrame_LoadInternalUsingTexture(const char *name, int texturef
        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;
@@ -9048,10 +9047,12 @@ static void R_DrawTextureSurfaceList_DepthOnly(int texturenumsurfaces, const msu
        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)
        {
@@ -9080,7 +9081,7 @@ static void R_ProcessModelTextureSurfaceList(int texturenumsurfaces, const msurf
        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;
@@ -9121,7 +9122,7 @@ static void R_QueueModelSurfaceList(entity_render_t *ent, int numsurfaces, const
                                ;
                }
                // 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();
 }
@@ -10069,7 +10070,7 @@ static void R_DrawDebugModel(void)
 
 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;
@@ -10141,6 +10142,12 @@ void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean wr
                                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
@@ -10167,7 +10174,7 @@ void R_DrawModelSurfaces(entity_render_t *ent, qboolean skysurfaces, qboolean wr
                }
        }
 
-       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)
@@ -10214,7 +10221,7 @@ void R_DebugLine(vec3_t start, vec3_t end)
                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);
index 06badd70f45197c4b27d5edc862d61ef4b3dd103..58c4695992ec205fce3da31ef90e413d7c3625b4 100644 (file)
@@ -604,7 +604,7 @@ void R_Q1BSP_DrawSky(entity_render_t *ent)
 {
        if (ent->model == NULL)
                return;
-       R_DrawModelSurfaces(ent, true, true, false, false, false);
+       R_DrawModelSurfaces(ent, true, true, false, false, false, false);
 }
 
 void R_Q1BSP_DrawAddWaterPlanes(entity_render_t *ent)
@@ -652,7 +652,7 @@ void R_Q1BSP_Draw(entity_render_t *ent)
        dp_model_t *model = ent->model;
        if (model == NULL)
                return;
-       R_DrawModelSurfaces(ent, false, true, false, false, false);
+       R_DrawModelSurfaces(ent, false, true, false, false, false, false);
 }
 
 void R_Q1BSP_DrawDepth(entity_render_t *ent)
@@ -666,7 +666,7 @@ void R_Q1BSP_DrawDepth(entity_render_t *ent)
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(true);
 //     R_Mesh_ResetTextureState();
-       R_DrawModelSurfaces(ent, false, false, true, false, false);
+       R_DrawModelSurfaces(ent, false, false, true, false, false, false);
        GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
 }
 
@@ -674,7 +674,7 @@ void R_Q1BSP_DrawDebug(entity_render_t *ent)
 {
        if (ent->model == NULL)
                return;
-       R_DrawModelSurfaces(ent, false, false, false, true, false);
+       R_DrawModelSurfaces(ent, false, false, false, true, false, false);
 }
 
 void R_Q1BSP_DrawPrepass(entity_render_t *ent)
@@ -682,7 +682,7 @@ void R_Q1BSP_DrawPrepass(entity_render_t *ent)
        dp_model_t *model = ent->model;
        if (model == NULL)
                return;
-       R_DrawModelSurfaces(ent, false, true, false, false, true);
+       R_DrawModelSurfaces(ent, false, true, false, false, true, false);
 }
 
 typedef struct r_q1bsp_getlightinfo_s
index a1b569007bf3f1b7596a84cf22079c2df3adc049..de205748dbd01855e5bc1bcc47d9990a78835f00 100644 (file)
--- a/libcurl.c
+++ b/libcurl.c
@@ -615,7 +615,7 @@ static void Curl_EndDownload(downloadinfo *di, CurlStatus status, CURLcode error
 
                pixels = decode_image(di, content_type);
                if(pixels)
-                       R_SkinFrame_LoadInternalBGRA(p, TEXF_FORCE_RELOAD | TEXF_MIPMAP | TEXF_ALPHA, pixels, image_width, image_height, false); // TODO what sRGB argument to put here?
+                       R_SkinFrame_LoadInternalBGRA(p, TEXF_FORCE_RELOAD | TEXF_MIPMAP | TEXF_ALPHA, pixels, image_width, image_height, 0, 0, 0, false); // TODO what sRGB argument to put here?
                else
                        CLEAR_AND_RETRY();
        }
index 7305b912baaf61138ed9fd05995fdc11ed0fc8d8..9eb87f13caca65e8535a6704c7a8621c543b9bba 100644 (file)
@@ -1636,8 +1636,8 @@ static void R_Q1BSP_LoadSplitSky (unsigned char *src, int width, int height, int
                }
        }
 
-       loadmodel->brush.solidskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_solidtexture", 0         , (unsigned char *) solidpixels, w, h, vid.sRGB3D);
-       loadmodel->brush.alphaskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_alphatexture", TEXF_ALPHA, (unsigned char *) alphapixels, w, h, vid.sRGB3D);
+       loadmodel->brush.solidskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_solidtexture", 0         , (unsigned char *) solidpixels, w, h, 0, 0, 0, vid.sRGB3D);
+       loadmodel->brush.alphaskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_alphatexture", TEXF_ALPHA, (unsigned char *) alphapixels, w, h, 0, 0, 0, vid.sRGB3D);
        Mem_Free(solidpixels);
        Mem_Free(alphapixels);
 }
@@ -1910,7 +1910,7 @@ static void Mod_Q1BSP_LoadTextures(sizebuf_t *sb)
                                                {
                                                        tx->width = image_width;
                                                        tx->height = image_height;
-                                                       skinframe = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_ALPHA | TEXF_MIPMAP | TEXF_ISWORLD | TEXF_PICMIP, pixels, image_width, image_height, true);
+                                                       skinframe = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_ALPHA | TEXF_MIPMAP | TEXF_ISWORLD | TEXF_PICMIP, pixels, image_width, image_height, image_width, image_height, CRC_Block(pixels, image_width * image_height * 4), true);
                                                }
                                                if (freepixels)
                                                        Mem_Free(freepixels);
@@ -1924,9 +1924,9 @@ static void Mod_Q1BSP_LoadTextures(sizebuf_t *sb)
                        }
                        // LordHavoc: some Tenebrae textures get replaced by black
                        if (!strncmp(tx->name, "*glassmirror", 12)) // Tenebrae
-                               tx->materialshaderpass->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_MIPMAP | TEXF_ALPHA, zerotrans, 1, 1, false);
+                               tx->materialshaderpass->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_MIPMAP | TEXF_ALPHA, zerotrans, 1, 1, 0, 0, 0, false);
                        else if (!strncmp(tx->name, "mirror", 6)) // Tenebrae
-                               tx->materialshaderpass->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, 0, zeroopaque, 1, 1, false);
+                               tx->materialshaderpass->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, 0, zeroopaque, 1, 1, 0, 0, 0, false);
                        tx->currentskinframe = tx->materialshaderpass->skinframes[0];
                }
 
index 572c1682a506c04d6d9f99ed60da10c3103cfb7f..6901e5546429e83f74de9fe9cdd7a5b2ca9f2578 100644 (file)
@@ -2404,7 +2404,7 @@ nothing                GL_ZERO GL_ONE
                                firstpostlayer = rgbgenvertexlayer + 1;
                                // special case for rgbgen vertex if MATERIALFLAG_VERTEXCOLOR is expected on this material
                                if (defaultmaterialflags & MATERIALFLAG_VERTEXCOLOR)
-                                       texture->basematerialflags |= MATERIALFLAG_VERTEXCOLOR;
+                                       texture->basematerialflags |= MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX;
                        }
                        else if (rgbgendiffuselayer >= 0)
                        {
index 23604f729e096ce5f2ec6c53ad680b07cfbe18d9..215d681c32e837e4291e3120b2ff64655ff0a58f 100644 (file)
@@ -235,7 +235,7 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version
                                                }
                                                else //if (version == SPRITEHL_VERSION || version == SPRITE_VERSION)
                                                        Image_Copy8bitBGRA(datapointer, pixels, width*height, palette ? palette : palette_bgra_transparent);
-                                               skinframe = R_SkinFrame_LoadInternalBGRA(name, texflags, pixels, width, height, false);
+                                               skinframe = R_SkinFrame_LoadInternalBGRA(name, texflags, pixels, width, height, 0, 0, 0, false);
                                                // texflags |= TEXF_COMPRESS;
                                                Mem_Free(pixels);
                                        }
index e3d050124e50ab1ec192336a744a3d77f5c12e77..bbffbef441122a8c5b52e3762e586901048d48fa 100644 (file)
@@ -74,8 +74,8 @@ static void CL_Beams_SetupBuiltinTexture(void)
                }
        }
 
-       skinframe = R_SkinFrame_LoadInternalBGRA("lightningbeam", TEXF_FORCELINEAR, data, texwidth, texheight, false);
-       Mod_LoadCustomMaterial(r_main_mempool, &cl_beams_builtintexture, "cl_beams_builtintexture", 0, MATERIALFLAG_WALL | MATERIALFLAG_ADD | MATERIALFLAG_BLENDED | MATERIALFLAG_NOCULLFACE | MATERIALFLAG_VERTEXCOLOR, skinframe);
+       skinframe = R_SkinFrame_LoadInternalBGRA("lightningbeam", TEXF_FORCELINEAR, data, texwidth, texheight, 0, 0, 0, false);
+       Mod_LoadCustomMaterial(r_main_mempool, &cl_beams_builtintexture, "cl_beams_builtintexture", 0, MATERIALFLAG_WALL | MATERIALFLAG_ADD | MATERIALFLAG_BLENDED | MATERIALFLAG_NOCULLFACE | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX, skinframe);
        Mem_Free(data);
 }
 
index b26d9e9d789d16c296a700315676e5659c6c81b5..527a0bef559537e634a6e79237f16c7adc37df63 100644 (file)
@@ -1202,7 +1202,7 @@ static void R_Shadow_MakeTextures_MakeCorona(void)
                        pixels[y][x][3] = 255;
                }
        }
-       r_shadow_lightcorona = R_SkinFrame_LoadInternalBGRA("lightcorona", TEXF_FORCELINEAR, &pixels[0][0][0], 32, 32, false);
+       r_shadow_lightcorona = R_SkinFrame_LoadInternalBGRA("lightcorona", TEXF_FORCELINEAR, &pixels[0][0][0], 32, 32, 0, 0, 0, false);
 }
 
 static unsigned int R_Shadow_MakeTextures_SamplePoint(float x, float y, float z)
diff --git a/r_sky.c b/r_sky.c
index 17754782640d899399fe729128c639de793cb2ac..7f941b478f56bbe75d6027f35d3251b3f0cd09df 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -127,7 +127,7 @@ static int R_LoadSkyBox(void)
                        }
                        temp = (unsigned char *)Mem_Alloc(tempmempool, image_width*image_height*4);
                        Image_CopyMux (temp, image_buffer, image_width, image_height, suffix[j][i].flipx, suffix[j][i].flipy, suffix[j][i].flipdiagonal, 4, 4, indices);
-                       skyboxskinframe[i] = R_SkinFrame_LoadInternalBGRA(va(vabuf, sizeof(vabuf), "skyboxside%d", i), TEXF_CLAMP | (gl_texturecompression_sky.integer ? TEXF_COMPRESS : 0), temp, image_width, image_height, vid.sRGB3D);
+                       skyboxskinframe[i] = R_SkinFrame_LoadInternalBGRA(va(vabuf, sizeof(vabuf), "skyboxside%d", i), TEXF_CLAMP | (gl_texturecompression_sky.integer ? TEXF_COMPRESS : 0), temp, image_width, image_height, 0, 0, 0, vid.sRGB3D);
                        Mem_Free(image_buffer);
                        Mem_Free(temp);
                        success++;
index e42b607b69e696b024e6a6a0de29ceee53abc754..b22cae4857dcd49d5c76b3a20b11cec5965a164b 100644 (file)
--- a/render.h
+++ b/render.h
@@ -230,7 +230,7 @@ skinframe_t *R_SkinFrame_FindNextByName( skinframe_t *last, const char *name );
 skinframe_t *R_SkinFrame_Find(const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qboolean add);
 skinframe_t *R_SkinFrame_LoadExternal(const char *name, int textureflags, qboolean complain, qboolean fallbacknotexture);
 skinframe_t *R_SkinFrame_LoadExternal_SkinFrame(skinframe_t *skinframe, const char *name, int textureflags, qboolean complain, qboolean fallbacknotexture);
-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);
 skinframe_t *R_SkinFrame_LoadInternalQuake(const char *name, int textureflags, int loadpantsandshirt, int loadglowtexture, const unsigned char *skindata, int width, int height);
 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);
 skinframe_t *R_SkinFrame_LoadMissing(void);
@@ -531,8 +531,9 @@ void RSurf_ActiveModelEntity(const entity_render_t *ent, qboolean wantnormals, q
 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, qboolean wantnormals, qboolean wanttangents);
 void RSurf_SetupDepthAndCulling(void);
 
+extern int r_textureframe; ///< used only by R_GetCurrentTexture, incremented per view and per UI render
 texture_t *R_GetCurrentTexture(texture_t *t);
-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);
 void R_DrawCustomSurface(skinframe_t *skinframe, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass);
 void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass);