X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=gl_draw.c;h=c7e69946a48fbf6feb0f6e9d1befaf6390049002;hp=0b15ad291e024bcb3b80383a31f5cddc294beb14;hb=c254ce3c4b01b2f7f41ea719d78a64d064465d19;hpb=90a141660eecdb9cfe07bebeb7b07ac4f1ee448f diff --git a/gl_draw.c b/gl_draw.c index 0b15ad29..c7e69946 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -105,23 +105,19 @@ cachepic_t *Draw_CachePic_Flags(const char *path, unsigned int cachepicflags) if (!strcmp(path, pic->name)) { // if it was created (or replaced) by Draw_NewPic, just return it - if (pic->flags & CACHEPICFLAG_NEWPIC) + if (!(pic->flags & CACHEPICFLAG_NEWPIC)) { - if (pic->skinframe) - R_SkinFrame_MarkUsed(pic->skinframe); - pic->lastusedframe = draw_frame; - return pic; - } - if (!((pic->texflags ^ texflags) & ~(TEXF_COMPRESS | TEXF_MIPMAP))) // ignore TEXF_COMPRESS when comparing, because fallback pics remove the flag, and ignore TEXF_MIPMAP because QC specifies that - { - if (!pic->skinframe || !pic->skinframe->base) + // reload the pic if texflags changed in important ways + // ignore TEXF_COMPRESS when comparing, because fallback pics remove the flag, and ignore TEXF_MIPMAP because QC specifies that + if (!pic->skinframe || !pic->skinframe->base || ((pic->texflags ^ texflags) & ~(TEXF_COMPRESS | TEXF_MIPMAP))) goto reload; if (!(cachepicflags & CACHEPICFLAG_NOTPERSISTENT)) pic->autoload = false; // caller is making this pic persistent - R_SkinFrame_MarkUsed(pic->skinframe); - pic->lastusedframe = draw_frame; - return pic; } + if (pic->skinframe) + R_SkinFrame_MarkUsed(pic->skinframe); + pic->lastusedframe = draw_frame; + return pic; } } @@ -147,8 +143,16 @@ reload: pic->autoload = (cachepicflags & CACHEPICFLAG_NOTPERSISTENT) != 0; pic->lastusedframe = draw_frame; - // load high quality image (this falls back to low quality too) - pic->skinframe = R_SkinFrame_LoadExternal(pic->name, texflags | TEXF_FORCE_RELOAD, (cachepicflags & CACHEPICFLAG_QUIET) == 0, (cachepicflags & CACHEPICFLAG_FAILONMISSING) == 0); + if (pic->skinframe) + { + // reload image after it was unloaded or texflags changed significantly + R_SkinFrame_LoadExternal_SkinFrame(pic->skinframe, pic->name, texflags | TEXF_FORCE_RELOAD, (cachepicflags & CACHEPICFLAG_QUIET) == 0, (cachepicflags & CACHEPICFLAG_FAILONMISSING) == 0); + } + else + { + // load high quality image (this falls back to low quality too) + pic->skinframe = R_SkinFrame_LoadExternal(pic->name, texflags | TEXF_FORCE_RELOAD, (cachepicflags & CACHEPICFLAG_QUIET) == 0, (cachepicflags & CACHEPICFLAG_FAILONMISSING) == 0); + } // get the dimensions of the image we loaded (if it was successful) if (pic->skinframe && pic->skinframe->base) @@ -262,6 +266,7 @@ cachepic_t *Draw_NewPic(const char *picname, int width, int height, unsigned cha R_SkinFrame_PurgeSkinFrame(pic->skinframe); + pic->autoload = false; pic->flags = CACHEPICFLAG_NEWPIC; // disable texflags checks in Draw_CachePic pic->flags |= (texflags & TEXF_CLAMP) ? 0 : CACHEPICFLAG_NOCLAMP; pic->flags |= (texflags & TEXF_FORCENEAREST) ? CACHEPICFLAG_NEAREST : 0; @@ -759,6 +764,8 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo int e0, e1, e2, e3; if (!pic) pic = Draw_CachePic("white"); + // make sure pic is loaded - we don't use the texture here, Mod_Mesh_GetTexture looks up the skinframe by name + Draw_GetPicTexture(pic); if (width == 0) width = pic->width; if (height == 0) @@ -785,15 +792,17 @@ void DrawQ_RotPic(float x, float y, cachepic_t *pic, float width, float height, int e0, e1, e2, e3; if (!pic) pic = Draw_CachePic("white"); + // make sure pic is loaded - we don't use the texture here, Mod_Mesh_GetTexture looks up the skinframe by name + Draw_GetPicTexture(pic); if (width == 0) 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); - 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), sinaf*(width - org_x) + sinar * (height - org_y), 0, 0, 0, -1, 1, 1, 0, 0, red, green, blue, alpha); - e3 = Mod_Mesh_IndexForVertex(mod, surf, x - cosaf * org_x + cosar * (height - org_y), y - sinaf * org_x + sinar * (height - org_y), 0, 0, 0, -1, 0, 1, 0, 0, red, green, blue, alpha); + 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); + e3 = Mod_Mesh_IndexForVertex(mod, surf, x - cosaf * org_x + cosar * (height - org_y), y - sinaf * org_x + sinar * (height - org_y), 0, 0, 0, -1, 0, 1, 0, 0, red, green, blue, alpha); Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2); Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3); } @@ -1379,6 +1388,8 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height int e0, e1, e2, e3; if (!pic) pic = Draw_CachePic("white"); + // make sure pic is loaded - we don't use the texture here, Mod_Mesh_GetTexture looks up the skinframe by name + Draw_GetPicTexture(pic); if (width == 0) width = pic->width; if (height == 0) @@ -1487,7 +1498,7 @@ void DrawQ_FlushUI(void) GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else GL_BlendFunc(GL_ONE, GL_ZERO); - R_SetupShader_Generic(tex->currentskinframe->base, NULL, GL_MODULATE, 1, (tex->currentmaterialflags & MATERIALFLAG_CUSTOMBLEND) ? false : true, true, false); + 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); }