Minor cleanups, mostly just formatting. DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@4752 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2014-11-22 12:34:29 +00:00
parent 1bbb077fca
commit d73f7f113d
3 changed files with 88 additions and 95 deletions

View file

@ -1292,30 +1292,28 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
pth->skyface = facen;
pth->hicr = hicr;
if (glinfo.texcompr && glusetexcompr && glusetexcache && !(hicr->flags & HICR_NOSAVE))
if (!gotcache)
if (!gotcache && glinfo.texcompr && glusetexcompr && glusetexcache && !(hicr->flags & HICR_NOSAVE))
{
const int32_t nonpow2 = check_nonpow2(siz.x) || check_nonpow2(siz.y);
// save off the compressed version
cachead.quality = (hicr->flags & HICR_NOCOMPRESS) ? 0 : r_downsize;
cachead.xdim = tsiz.x>>cachead.quality;
cachead.ydim = tsiz.y>>cachead.quality;
cachead.xdim = tsiz.x >> cachead.quality;
cachead.ydim = tsiz.y >> cachead.quality;
// handle nocompress:
cachead.flags = nonpow2*CACHEAD_NONPOW2 |
(hasalpha != 255 ? CACHEAD_HASALPHA : 0) |
cachead.flags = nonpow2 * CACHEAD_NONPOW2 | (hasalpha != 255 ? CACHEAD_HASALPHA : 0) |
(hicr->flags & HICR_NOCOMPRESS ? CACHEAD_NOCOMPRESS : 0);
/// OSD_Printf("Caching \"%s\"\n", fn);
texcache_writetex(fn, picfillen+(dapalnum<<8), dameth, effect, &cachead);
/// OSD_Printf("Caching \"%s\"\n", fn);
texcache_writetex(fn, picfillen + (dapalnum << 8), dameth, effect, &cachead);
if (willprint)
{
int32_t etime = getticks()-startticks;
if (etime>=MIN_CACHETIME_PRINT)
int32_t etime = getticks() - startticks;
if (etime >= MIN_CACHETIME_PRINT)
OSD_Printf("Load tile %4d: p%d-m%d-e%d %s... cached... %d ms\n", dapic, dapalnum, dameth, effect,
willprint==2 ? fn : "", etime);
willprint == 2 ? fn : "", etime);
willprint = 0;
}
else

View file

@ -1143,8 +1143,6 @@ static void destroy_window_resources()
#ifdef USE_OPENGL
void sdlayer_setvideomode_opengl(void)
{
char *p;
polymost_glreset();
bglEnable(GL_TEXTURE_2D);
@ -1192,31 +1190,32 @@ void sdlayer_setvideomode_opengl(void)
glinfo.texcompr = 0;
// process the extensions string and flag stuff we recognize
p = Bstrdup(glinfo.extensions);
glinfo.clamptoedge = !!Bstrstr(glinfo.extensions, "GL_EXT_texture_edge_clamp") ||
!!Bstrstr(glinfo.extensions, "GL_SGIS_texture_edge_clamp");
glinfo.bgra = !!Bstrstr(glinfo.extensions, "GL_EXT_bgra");
glinfo.texcompr =
!!Bstrstr(glinfo.extensions, "GL_ARB_texture_compression") && Bstrcmp(glinfo.vendor, "ATI Technologies Inc.");
glinfo.texnpot = !!Bstrstr(glinfo.extensions, "GL_ARB_texture_non_power_of_two");
glinfo.multisample = !!Bstrstr(glinfo.extensions, "GL_ARB_multisample");
glinfo.nvmultisamplehint = !!Bstrstr(glinfo.extensions, "GL_NV_multisample_filter_hint");
glinfo.arbfp = !!Bstrstr(glinfo.extensions, "GL_ARB_fragment_program");
glinfo.depthtex = !!Bstrstr(glinfo.extensions, "GL_ARB_depth_texture");
glinfo.shadow = !!Bstrstr(glinfo.extensions, "GL_ARB_shadow");
glinfo.fbos = !!Bstrstr(glinfo.extensions, "GL_EXT_framebuffer_object");
glinfo.rect =
!!Bstrstr(glinfo.extensions, "GL_NV_texture_rectangle") || !!Bstrstr(glinfo.extensions, "GL_EXT_texture_rectangle");
glinfo.multitex = !!Bstrstr(glinfo.extensions, "GL_ARB_multitexture");
glinfo.envcombine = !!Bstrstr(glinfo.extensions, "GL_ARB_texture_env_combine");
glinfo.vbos = !!Bstrstr(glinfo.extensions, "GL_ARB_vertex_buffer_object");
glinfo.sm4 = !!Bstrstr(glinfo.extensions, "GL_EXT_gpu_shader4");
glinfo.occlusionqueries = !!Bstrstr(glinfo.extensions, "GL_ARB_occlusion_query");
glinfo.glsl = !!Bstrstr(glinfo.extensions, "GL_ARB_shader_objects");
glinfo.debugoutput = !!Bstrstr(glinfo.extensions, "GL_ARB_debug_output");
glinfo.clamptoedge = !!Bstrstr(p, "GL_EXT_texture_edge_clamp") || !!Bstrstr(p, "GL_SGIS_texture_edge_clamp");
glinfo.bgra = !!Bstrstr(p, "GL_EXT_bgra");
glinfo.texcompr = !!Bstrstr(p, "GL_ARB_texture_compression") && Bstrcmp(glinfo.vendor, "ATI Technologies Inc.");
glinfo.texnpot = !!Bstrstr(p, "GL_ARB_texture_non_power_of_two");
glinfo.multisample = !!Bstrstr(p, "GL_ARB_multisample");
glinfo.nvmultisamplehint = !!Bstrstr(p, "GL_NV_multisample_filter_hint");
glinfo.arbfp = !!Bstrstr(p, "GL_ARB_fragment_program");
glinfo.depthtex = !!Bstrstr(p, "GL_ARB_depth_texture");
glinfo.shadow = !!Bstrstr(p, "GL_ARB_shadow");
glinfo.fbos = !!Bstrstr(p, "GL_EXT_framebuffer_object");
glinfo.rect = !!Bstrstr(p, "GL_NV_texture_rectangle") || !!Bstrstr(p, "GL_EXT_texture_rectangle");
glinfo.multitex = !!Bstrstr(p, "GL_ARB_multitexture");
glinfo.envcombine = !!Bstrstr(p, "GL_ARB_texture_env_combine");
glinfo.vbos = !!Bstrstr(p, "GL_ARB_vertex_buffer_object");
glinfo.sm4 = !!Bstrstr(p, "GL_EXT_gpu_shader4");
glinfo.occlusionqueries = !!Bstrstr(p, "GL_ARB_occlusion_query");
glinfo.glsl = !!Bstrstr(p, "GL_ARB_shader_objects");
glinfo.debugoutput = !!Bstrstr(p, "GL_ARB_debug_output");
if (Bstrstr(p, "GL_EXT_texture_filter_anisotropic"))
if (Bstrstr(glinfo.extensions, "GL_EXT_texture_filter_anisotropic"))
bglGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glinfo.maxanisotropy);
if (Bstrstr(p, "WGL_3DFX_gamma_control"))
if (Bstrstr(glinfo.extensions, "WGL_3DFX_gamma_control"))
{
static int32_t warnonce;
// 3dfx cards have issues with fog
@ -1650,13 +1649,10 @@ int32_t setgamma(void)
#if !defined(__APPLE__) && !defined(__ANDROID__)
extern struct sdlappicon sdlappicon;
static SDL_Surface *loadappicon(void)
static inline SDL_Surface *loadappicon(void)
{
SDL_Surface *surf;
surf = SDL_CreateRGBSurfaceFrom((void *)sdlappicon.pixels, sdlappicon.width, sdlappicon.height, 32,
SDL_Surface *surf = SDL_CreateRGBSurfaceFrom((void *)sdlappicon.pixels, sdlappicon.width, sdlappicon.height, 32,
sdlappicon.width * 4, 0xffl, 0xff00l, 0xff0000l, 0xff000000l);
return surf;
}
#endif

View file

@ -95,7 +95,7 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
int32_t tilestat;
pthtyp *pth;
const int32_t j = dapicnum&(GLTEXCACHEADSIZ-1);
const int32_t j = dapicnum & (GLTEXCACHEADSIZ - 1);
hicreplctyp *si = usehightile ? hicfindsubst(dapicnum, dapalnum) : NULL;
if (drawingskybox && usehightile)
@ -107,8 +107,8 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
if (!si)
{
if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS)) return NULL;
return hicprecaching ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
return (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS) || hicprecaching) ?
NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
}
/* if palette > 0 && replacement found
@ -118,57 +118,56 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
*/
// load a replacement
for (pth=texcache.list[j]; pth; pth=pth->next)
for (pth = texcache.list[j]; pth; pth = pth->next)
{
if (pth->picnum == dapicnum && pth->palnum == si->palnum &&
(si->palnum>0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
(pth->flags & (PTH_CLAMPED + PTH_HIGHTILE + PTH_SKYBOX))
== (TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox>0)*PTH_SKYBOX) &&
(drawingskybox>0 ? (pth->skyface == drawingskybox) : 1)
)
(si->palnum > 0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
(pth->flags & (PTH_CLAMPED + PTH_HIGHTILE + PTH_SKYBOX)) ==
(TO_PTH_CLAMPED(dameth) + PTH_HIGHTILE + (drawingskybox > 0) * PTH_SKYBOX) &&
(drawingskybox > 0 ? (pth->skyface == drawingskybox) : 1))
{
if (pth->flags & PTH_INVALIDATED)
{
pth->flags &= ~PTH_INVALIDATED;
tilestat = gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 0,
(si->palnum>0) ? 0 : hictinting[dapalnum].f); // reload tile
(si->palnum > 0) ? 0 : hictinting[dapalnum].f); // reload tile
if (!tilestat)
continue;
if (tilestat)
{
if (tilestat == -2) // bad filename
hicclearsubst(dapicnum, dapalnum);
if (drawingskybox) return NULL;
return hicprecaching ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
}
return (pth);
}
}
return(pth);
}
}
pth = (pthtyp *)Xcalloc(1,sizeof(pthtyp));
pth = (pthtyp *)Xcalloc(1, sizeof(pthtyp));
// possibly fetch an already loaded multitexture :_)
if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS) && texcache_fetchmulti(pth, si, dapicnum, dameth))
return pth;
tilestat = gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 1, (si->palnum>0) ? 0 : hictinting[dapalnum].f);
tilestat =
gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 1, (si->palnum > 0) ? 0 : hictinting[dapalnum].f);
if (tilestat)
if (!tilestat)
{
if (tilestat == -2) // bad filename
hicclearsubst(dapicnum, dapalnum);
Bfree(pth);
if (drawingskybox) return NULL;
return hicprecaching ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
pth->next = texcache.list[j];
pth->palnum = si->palnum;
texcache.list[j] = pth;
return pth;
}
pth->palnum = si->palnum;
pth->next = texcache.list[j];
texcache.list[j] = pth;
if (tilestat == -2) // bad filename
hicclearsubst(dapicnum, dapalnum);
return(pth);
Bfree(pth);
return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
}
static void texcache_closefiles(void)
@ -183,14 +182,15 @@ static void texcache_closefiles(void)
void texcache_freeptrs(void)
{
int32_t i;
texcache.iptrcnt = 0;
if (texcache.iptrs)
for (i = 0; i < texcache.numentries; i++)
if (!texcache.iptrs)
return;
for (int i = 0; i < texcache.numentries; i++)
if (texcache.iptrs[i])
{
int32_t ii;
for (ii = texcache.numentries-1; ii >= 0; ii--)
for (int ii = texcache.numentries - 1; ii >= 0; ii--)
if (i != ii && texcache.iptrs[ii] == texcache.iptrs[i])
{
/*OSD_Printf("removing duplicate cacheptr %d\n",ii);*/
@ -201,7 +201,6 @@ void texcache_freeptrs(void)
texcache.iptrs[i] = NULL;
}
texcache.iptrcnt = 0;
DO_FREE_AND_NULL(texcache.iptrs);
}