diff --git a/source/blood/src/menu.cpp b/source/blood/src/menu.cpp index 57ea6757b..ca9e3124e 100644 --- a/source/blood/src/menu.cpp +++ b/source/blood/src/menu.cpp @@ -1546,7 +1546,7 @@ void SetVideoMode(CGameMenuItemChain *pItem) UNREFERENCED_PARAMETER(pItem); resolution_t p = { xres, yres, fullscreen, bpp, 0 }; int32_t prend = videoGetRenderMode(); - int32_t pvsync = vsync; + int32_t pvsync = vid_vsync; int32_t nResolution = itemOptionsDisplayModeResolution.m_nFocus; resolution_t n = { gResolution[nResolution].xdim, gResolution[nResolution].ydim, @@ -1565,13 +1565,13 @@ void SetVideoMode(CGameMenuItemChain *pItem) else { onvideomodechange(p.bppmax > 8); - vsync = videoSetVsync(pvsync); + vid_vsync = videoSetVsync(pvsync); } } else onvideomodechange(n.bppmax > 8); viewResizeView(gViewSize); - vsync = videoSetVsync(nvsync); + vid_vsync = videoSetVsync(nvsync); gSetup.fullscreen = fullscreen; gSetup.xdim = xres; gSetup.ydim = yres; @@ -1612,7 +1612,7 @@ void SetupVideoModeMenu(CGameMenuItemChain *pItem) #endif for (int i = 0; i < 3; i++) { - if (vsync == nVSyncValues[i]) + if (vid_vsync == nVSyncValues[i]) { itemOptionsDisplayModeVSync.m_nFocus = i; break; @@ -1667,7 +1667,7 @@ void SetupVideoPolymostMenu(CGameMenuItemChain *pItem) itemOptionsDisplayPolymostTextureMode.m_nFocus = 0; for (int i = 0; i < 2; i++) { - if (nTextureModeValues[i] == gltexfiltermode) + if (nTextureModeValues[i] == hw_texfilter) { itemOptionsDisplayPolymostTextureMode.m_nFocus = i; break; @@ -1676,36 +1676,36 @@ void SetupVideoPolymostMenu(CGameMenuItemChain *pItem) itemOptionsDisplayPolymostAnisotropy.m_nFocus = 0; for (int i = 0; i < 6; i++) { - if (nAnisotropyValues[i] == glanisotropy) + if (nAnisotropyValues[i] == hw_anisotropy) { itemOptionsDisplayPolymostAnisotropy.m_nFocus = i; break; } } - itemOptionsDisplayPolymostTrueColorTextures.at20 = usehightile; + itemOptionsDisplayPolymostTrueColorTextures.at20 = hw_hightile; itemOptionsDisplayPolymostTexQuality.m_nFocus = r_downsize; itemOptionsDisplayPolymostPreloadCache.at20 = r_precache; - itemOptionsDisplayPolymostDetailTex.at20 = r_detailmapping; - itemOptionsDisplayPolymostGlowTex.at20 = r_glowmapping; - itemOptionsDisplayPolymost3DModels.at20 = usemodels; + itemOptionsDisplayPolymostDetailTex.at20 = hw_detailmapping; + itemOptionsDisplayPolymostGlowTex.at20 = hw_glowmapping; + itemOptionsDisplayPolymost3DModels.at20 = hw_models; itemOptionsDisplayPolymostDeliriumBlur.at20 = gDeliriumBlur; } void UpdateTextureMode(CGameMenuItemZCycle *pItem) { - gltexfiltermode = nTextureModeValues[pItem->m_nFocus]; + hw_texfilter = nTextureModeValues[pItem->m_nFocus]; gltexapplyprops(); } void UpdateAnisotropy(CGameMenuItemZCycle *pItem) { - glanisotropy = nAnisotropyValues[pItem->m_nFocus]; + hw_anisotropy = nAnisotropyValues[pItem->m_nFocus]; gltexapplyprops(); } void UpdateTrueColorTextures(CGameMenuItemZBool *pItem) { - usehightile = pItem->at20; + hw_hightile = pItem->at20; } #endif @@ -1732,17 +1732,17 @@ void UpdatePreloadCache(CGameMenuItemZBool *pItem) void UpdateDetailTex(CGameMenuItemZBool *pItem) { - r_detailmapping = pItem->at20; + hw_detailmapping = pItem->at20; } void UpdateGlowTex(CGameMenuItemZBool *pItem) { - r_glowmapping = pItem->at20; + hw_glowmapping = pItem->at20; } void Update3DModels(CGameMenuItemZBool *pItem) { - usemodels = pItem->at20; + hw_models = pItem->at20; } void UpdateDeliriumBlur(CGameMenuItemZBool *pItem) @@ -1753,13 +1753,13 @@ void UpdateDeliriumBlur(CGameMenuItemZBool *pItem) void PreDrawDisplayPolymost(CGameMenuItem *pItem) { if (pItem == &itemOptionsDisplayPolymostTexQuality) - pItem->bEnable = usehightile; + pItem->bEnable = hw_hightile; else if (pItem == &itemOptionsDisplayPolymostPreloadCache) - pItem->bEnable = usehightile; + pItem->bEnable = hw_hightile; else if (pItem == &itemOptionsDisplayPolymostDetailTex) - pItem->bEnable = usehightile; + pItem->bEnable = hw_hightile; else if (pItem == &itemOptionsDisplayPolymostGlowTex) - pItem->bEnable = usehightile; + pItem->bEnable = hw_hightile; } #endif diff --git a/source/blood/src/osdcmd.cpp b/source/blood/src/osdcmd.cpp index 3e4d06668..87c123405 100644 --- a/source/blood/src/osdcmd.cpp +++ b/source/blood/src/osdcmd.cpp @@ -770,11 +770,6 @@ int32_t registerosdcommands(void) { char buffer[256]; -// -// if (VOLUMEONE) -// OSD_RegisterFunction("changelevel","changelevel : warps to the given level", osdcmd_changelevel); -// else -// { OSD_RegisterFunction("changelevel","changelevel : warps to the given level", osdcmd_changelevel); OSD_RegisterFunction("map","map : loads the given user map", osdcmd_map); OSD_RegisterFunction("demo","demo : starts the given demo", osdcmd_demo); diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index e2d35947d..e3a52d9cb 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -2283,11 +2283,11 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t case 7: { #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pTSprite->picnum, pTSprite->pal) >= 0 && !(spriteext[nSprite].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(pTSprite->picnum, pTSprite->pal) >= 0 && !(spriteext[nSprite].flags&SPREXT_NOTMD)) break; #endif // Can be overridden by def script - if (usevoxels && gDetail >= 4 && videoGetRenderMode() != REND_POLYMER && tiletovox[pTSprite->picnum] == -1 && voxelIndex[pTSprite->picnum] != -1) + if (r_voxels && gDetail >= 4 && videoGetRenderMode() != REND_POLYMER && tiletovox[pTSprite->picnum] == -1 && voxelIndex[pTSprite->picnum] != -1) { if ((pTSprite->flags&kHitagRespawn) == 0) { @@ -2312,7 +2312,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t nAnim--; } - if ((pTSprite->cstat&48) != 48 && usevoxels && videoGetRenderMode() != REND_POLYMER) + if ((pTSprite->cstat&48) != 48 && r_voxels && videoGetRenderMode() != REND_POLYMER) { int nAnimTile = pTSprite->picnum + animateoffs_replace(pTSprite->picnum, 32768+pTSprite->owner); @@ -3562,7 +3562,7 @@ void viewLoadingScreenWide(void) { videoClearScreen(0); #ifdef USE_OPENGL - if ((blood_globalflags&BLOOD_FORCE_WIDELOADSCREEN) || (bLoadScreenCrcMatch && !(usehightile && h_xsize[kLoadScreen]))) + if ((blood_globalflags&BLOOD_FORCE_WIDELOADSCREEN) || (bLoadScreenCrcMatch && !(hw_hightile && h_xsize[kLoadScreen]))) #else if ((blood_globalflags&BLOOD_FORCE_WIDELOADSCREEN) || bLoadScreenCrcMatch) #endif diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index ea3e0da83..658f16d9d 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -21,7 +21,6 @@ extern char quitevent, appactive; extern char modechange; extern char nogl; -extern int32_t vsync; extern int32_t swapcomplete; extern int32_t r_borderless; extern int32_t r_displayindex; @@ -34,7 +33,6 @@ extern uint32_t r_screenxy; extern int32_t xres, yres, bpp, fullscreen, bytesperline, refreshfreq; extern intptr_t frameplace; extern char offscreenrendering; -extern int32_t nofog; void calc_ylookup(int32_t bpl, int32_t lastyidx); diff --git a/source/build/include/build.h b/source/build/include/build.h index e116fd3c5..ee7c6da5e 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -30,6 +30,7 @@ static_assert('\xff' == 255, "Char must be unsigned!"); #include "vfs.h" #include "cache1d.h" #include "textures.h" +#include "c_cvars.h" enum rendmode_t { REND_CLASSIC, @@ -850,11 +851,10 @@ extern float debug1, debug2; #endif extern int16_t tiletovox[MAXTILES]; -extern int32_t usevoxels, voxscale[MAXVOXELS]; +extern int32_t voxscale[MAXVOXELS]; extern char g_haveVoxels; #ifdef USE_OPENGL -extern int32_t usemodels, usehightile; extern int32_t rendmode; #endif extern uint8_t globalr, globalg, globalb; @@ -1290,9 +1290,6 @@ enum cutsceneflags { extern int32_t benchmarkScreenshot; #ifdef USE_OPENGL -extern int32_t glanisotropy; -extern int32_t gltexfiltermode; -extern int32_t r_useindexedcolortextures; enum { TEXFILTER_OFF = 0, // GL_NEAREST @@ -1305,17 +1302,20 @@ extern int32_t gltexmaxsize; void gltexapplyprops (void); void texcache_invalidate(void); -# ifdef USE_GLEXT -extern int32_t r_detailmapping; -extern int32_t r_glowmapping; -# endif +EXTERN_CVAR(Bool, hw_detailmapping) +EXTERN_CVAR(Bool, hw_glowmapping) +EXTERN_CVAR(Bool, hw_animsmoothing) +EXTERN_CVAR(Bool, hw_hightile) +EXTERN_CVAR(Bool, hw_models) +EXTERN_CVAR(Float, hw_shadescale) +EXTERN_CVAR(Int, vid_vsync) +EXTERN_CVAR(Int, hw_anisotropy) +EXTERN_CVAR(Int, hw_texfilter) +EXTERN_CVAR(Bool, hw_useindexedcolortextures) +EXTERN_CVAR(Bool, hw_parallaxskypanning) +EXTERN_CVAR(Bool, r_voxels) -# ifdef USE_GLEXT -extern int32_t r_vbocount; -# endif -extern int32_t r_animsmoothing; extern int32_t r_parallaxskyclamping; -extern int32_t r_parallaxskypanning; extern int32_t r_downsize; extern int32_t r_downsizevar; extern int32_t mdtims, omdtims; @@ -1379,9 +1379,9 @@ static FORCE_INLINE bool tilehasmodelorvoxel(int const tilenume, int pal) UNREFERENCED_PARAMETER(pal); return #ifdef USE_OPENGL - (videoGetRenderMode() >= REND_POLYMOST && mdinited && usemodels && tile2model[Ptile2tile(tilenume, pal)].modelid != -1) || + (videoGetRenderMode() >= REND_POLYMOST && mdinited && hw_models && tile2model[Ptile2tile(tilenume, pal)].modelid != -1) || #endif - (videoGetRenderMode() <= REND_POLYMOST && usevoxels && tiletovox[tilenume] != -1); + (videoGetRenderMode() <= REND_POLYMOST && r_voxels && tiletovox[tilenume] != -1); } int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume, diff --git a/source/build/include/osd.h b/source/build/include/osd.h index 761a8ab27..67191ea4e 100644 --- a/source/build/include/osd.h +++ b/source/build/include/osd.h @@ -5,6 +5,7 @@ #ifndef osd_h_ #define osd_h_ +#include #include "vfs.h" #include "mutex.h" diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index 2be804aca..d8997b24f 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -21,12 +21,6 @@ extern float gcosang, gsinang, gcosang2, gsinang2; extern float gchang, gshang, gctang, gstang; extern float gvrcorrection; -struct glfiltermodes { - const char *name; -}; -#define NUMGLFILTERMODES 6 -extern struct glfiltermodes glfiltermodes[NUMGLFILTERMODES]; - extern void Polymost_prepare_loadboard(void); void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...); @@ -63,8 +57,6 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba extern float curpolygonoffset; -extern float shadescale; -extern int32_t shadescale_unbounded; extern uint8_t alphahackarray[MAXTILES]; extern int32_t r_scenebrightness; diff --git a/source/build/src/animvpx.cpp b/source/build/src/animvpx.cpp index e29fe99af..411d118f5 100644 --- a/source/build/src/animvpx.cpp +++ b/source/build/src/animvpx.cpp @@ -362,7 +362,7 @@ void animvpx_setup_glstate(int32_t animvpx_flags) texture = GLInterface.NewTexture(); - if ((animvpx_flags & CUTSCENE_TEXTUREFILTER && gltexfiltermode == TEXFILTER_ON) || animvpx_flags & CUTSCENE_FORCEFILTER || + if ((animvpx_flags & CUTSCENE_TEXTUREFILTER && hw_texfilter == TEXFILTER_ON) || animvpx_flags & CUTSCENE_FORCEFILTER || (!(animvpx_flags & CUTSCENE_TEXTUREFILTER) && !(animvpx_flags & CUTSCENE_FORCENOFILTER))) // if no flags, then use filter for IVFs { sampler = SamplerClampXY; diff --git a/source/build/src/baselayer.cpp b/source/build/src/baselayer.cpp index e7205ccad..1fe23fa2b 100644 --- a/source/build/src/baselayer.cpp +++ b/source/build/src/baselayer.cpp @@ -201,7 +201,6 @@ void makeasmwriteable(void) { } -int32_t vsync=0; int32_t g_logFlushWindow = 1; #ifdef USE_OPENGL @@ -218,67 +217,6 @@ struct glinfo_t glinfo = // Used to register the game's / editor's osdcmd_vidmode() functions here. int32_t (*baselayer_osdcmd_vidmode_func)(osdcmdptr_t parm); -static int osdfunc_setrendermode(osdcmdptr_t parm) -{ - if (parm->numparms != 1) - return OSDCMD_SHOWHELP; - - int32_t m = Bstrtol(parm->parms[0], NULL, 10); - - if (m != REND_CLASSIC && m != REND_POLYMOST && m != REND_POLYMER) - return OSDCMD_SHOWHELP; - - if ((m==REND_CLASSIC) != (bpp==8) && baselayer_osdcmd_vidmode_func) - { - // Mismatch between video mode and requested renderer, do auto switch. - osdfuncparm_t parm; - char arg[4]; - - const char *ptrptr[1]; - ptrptr[0] = arg; - - Bmemset(&parm, 0, sizeof(parm)); - - if (m==REND_CLASSIC) - Bmemcpy(&arg, "8", 2); - else - Bmemcpy(&arg, "32", 3); - - // CAUTION: we assume that the osdcmd_vidmode function doesn't use any - // other member! - parm.numparms = 1; - parm.parms = ptrptr; - - baselayer_osdcmd_vidmode_func(&parm); - } - - videoSetRenderMode(m); - - char const *renderer = "other"; - - switch (videoGetRenderMode()) - { - case REND_CLASSIC: -#ifdef NOASM - renderer = "classic software (C)"; -#else - renderer = "classic software (ASM)"; -#endif - break; - case REND_POLYMOST: - renderer = "polygonal OpenGL"; - break; -#ifdef POLYMER - case REND_POLYMER: - renderer = "great justice (Polymer)"; - break; -#endif - } - - OSD_Printf("Rendering method changed to %s\n", renderer); - - return OSDCMD_OK; -} #ifdef DEBUGGINGAIDS static int osdcmd_hicsetpalettetint(osdcmdptr_t parm) @@ -311,21 +249,6 @@ int osdcmd_glinfo(osdcmdptr_t UNUSED(parm)) } #endif -static int osdcmd_cvar_set_baselayer(osdcmdptr_t parm) -{ - int32_t r = osdcmd_cvar_set(parm); - - if (r != OSDCMD_OK) return r; - - if (!Bstrcasecmp(parm->name, "vid_gamma") || !Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast")) - { - videoSetPalette(GAMMA_CALC,0,0); - - return r; - } - - return r; -} int32_t baselayer_init(void) { @@ -336,36 +259,8 @@ int32_t baselayer_init(void) #else # define SCREENASPECT_CVAR_TYPE (CVAR_UINT) #endif - static osdcvardata_t cvars_engine[] = - { - { "lz4compressionlevel","adjust LZ4 compression level used for savegames",(void *) &lz4CompressionLevel, CVAR_INT, 1, 32 }, - { "r_borderless", "borderless windowed mode: 0: never 1: always 2: if resolution matches desktop", (void *) &r_borderless, CVAR_INT|CVAR_RESTARTVID, 0, 2 }, - { "r_displayindex","index of output display",(void *)&r_displayindex, CVAR_INT|CVAR_RESTARTVID, 0, 10 }, - { "r_usenewaspect","enable/disable new screen aspect ratio determination code",(void *) &r_usenewaspect, CVAR_BOOL, 0, 1 }, - { "r_screenaspect","if using r_usenewaspect and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9", - (void *) &r_screenxy, SCREENASPECT_CVAR_TYPE, 0, 9999 }, - { "r_fpgrouscan","use floating-point numbers for slope rendering",(void *) &r_fpgrouscan, CVAR_BOOL, 0, 1 }, - { "r_novoxmips","turn off/on the use of mipmaps when rendering 8-bit voxels",(void *) &novoxmips, CVAR_BOOL, 0, 1 }, - { "r_voxels","enable/disable automatic sprite->voxel rendering",(void *) &usevoxels, CVAR_BOOL, 0, 1 }, -#ifdef YAX_ENABLE - { "r_tror_nomaskpass", "enable/disable additional pass in TROR software rendering", (void *)&r_tror_nomaskpass, CVAR_BOOL, 0, 1 }, -#endif - { "r_windowpositioning", "enable/disable window position memory", (void *) &windowpos, CVAR_BOOL, 0, 1 }, - { "vid_gamma","adjusts gamma component of gamma ramp",(void *) &g_videoGamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, - { "vid_contrast","adjusts contrast component of gamma ramp",(void *) &g_videoContrast, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, - { "vid_brightness","adjusts brightness component of gamma ramp",(void *) &g_videoBrightness, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, - }; - - for (auto & i : cvars_engine) - OSD_RegisterCvar(&i, (i.flags & CVAR_FUNCPTR) ? osdcmd_cvar_set_baselayer : osdcmd_cvar_set); #ifdef USE_OPENGL - OSD_RegisterFunction("setrendermode","setrendermode : sets the engine's rendering mode.\n" - "Mode numbers are:\n" - " 0 - Classic Build software\n" - " 3 - Polygonal OpenGL\n" - , - osdfunc_setrendermode); # ifdef DEBUGGINGAIDS OSD_RegisterFunction("hicsetpalettetint","hicsetpalettetint: sets palette tinting values",osdcmd_hicsetpalettetint); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 8740e75da..3b67f370f 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -96,7 +96,6 @@ static TArray> voxelmemory; void (*loadvoxel_replace)(int32_t voxindex) = NULL; int16_t tiletovox[MAXTILES]; -int32_t usevoxels = 1; #ifdef USE_OPENGL static char *voxfilenames[MAXVOXELS]; #endif @@ -5176,7 +5175,7 @@ static void classicDrawSprite(int32_t snum) if ((cstat&48)==48) vtilenum = tilenum; // if the game wants voxels, it gets voxels - else if ((cstat & 48) != 32 && usevoxels && tiletovox[tilenum] != -1 && spritenum != -1 && !(spriteext[spritenum].flags&SPREXT_NOTMD)) + else if ((cstat & 48) != 32 && r_voxels && tiletovox[tilenum] != -1 && spritenum != -1 && !(spriteext[spritenum].flags&SPREXT_NOTMD)) { vtilenum = tiletovox[tilenum]; cstat |= 48; @@ -8876,7 +8875,7 @@ void renderDrawMasks(void) const int32_t xs = tspriteptr[i]->x-globalposx, ys = tspriteptr[i]->y-globalposy; const int32_t yp = dmulscale6(xs,cosviewingrangeglobalang,ys,sinviewingrangeglobalang); #ifdef USE_OPENGL - const int32_t modelp = (usemodels && tile2model[tspriteptr[i]->picnum].modelid >= 0); + const int32_t modelp = (hw_models && tile2model[tspriteptr[i]->picnum].modelid >= 0); #endif if (yp > (4<<8)) diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 7fb6c378c..8978b57c3 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -533,7 +533,7 @@ void updateanimation(md2model_t *m, tspriteptr_t tspr, uint8_t lpal) OSD_Printf("1: c > n\n"); #endif - int32_t const smoothdurationp = (r_animsmoothing && (tile2model[tile].smoothduration != 0)); + int32_t const smoothdurationp = (hw_animsmoothing && (tile2model[tile].smoothduration != 0)); spritesmooth_t * const smooth = &spritesmooth[((unsigned)tspr->owner < MAXSPRITES+MAXUNIQHUDID) ? tspr->owner : MAXSPRITES+MAXUNIQHUDID-1]; spriteext_t * const sprext = &spriteext[((unsigned)tspr->owner < MAXSPRITES+MAXUNIQHUDID) ? tspr->owner : MAXSPRITES+MAXUNIQHUDID-1]; @@ -630,7 +630,7 @@ void updateanimation(md2model_t *m, tspriteptr_t tspr, uint8_t lpal) { if (i > j-65536) i = j-65536; } else { if (i >= j) { i -= j; if (i >= j) i %= j; } } - if (r_animsmoothing && smooth->mdsmooth) + if (hw_animsmoothing && smooth->mdsmooth) { m->nframe = anim ? anim->startframe : smooth->mdcurframe; m->cframe = smooth->mdoldframe; @@ -665,7 +665,7 @@ void updateanimation(md2model_t *m, tspriteptr_t tspr, uint8_t lpal) #endif m->nframe = m->cframe+1; - if (anim && m->nframe > anim->endframe) // VERIFY: (!(r_animsmoothing && smooth->mdsmooth)) implies (anim!=NULL) ? + if (anim && m->nframe > anim->endframe) // VERIFY: (!(hw_animsmoothing && smooth->mdsmooth)) implies (anim!=NULL) ? m->nframe = anim->startframe; smooth->mdoldframe = m->cframe; @@ -1617,7 +1617,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) GLInterface.SetCull(Cull_Back, winding); // tinting - pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; + pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; auto h = hictinting[globalpal]; GLInterface.SetTinting(h.f, PalEntry(h.sr, h.sg, h.sb), PalEntry(h.r, h.g, h.b)); @@ -1740,14 +1740,14 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) // The data lookup here is one incredible mess. Thanks to whoever cooked this up... :( if (!(tspr->extra&TSPR_EXTRA_MDHACK)) { - det = tex = r_detailmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, DETAILPAL, surfi, nullptr) : nullptr; + det = tex = hw_detailmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, DETAILPAL, surfi, nullptr) : nullptr; if (det) { for (auto sk = m->skinmap; sk; sk = sk->next) if ((int32_t) sk->palette == DETAILPAL && sk->skinnum == tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum && sk->surfnum == surfi) detscale = sk->param; } - glow = r_glowmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, GLOWPAL, surfi, nullptr) : 0; + glow = hw_glowmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, GLOWPAL, surfi, nullptr) : 0; } GLInterface.SetModelTexture(tex, globalpal, xpanning, ypanning, det, detscale, glow); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 03162211c..c3b5489d4 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -16,20 +16,71 @@ Ken Silverman's official web site: http://www.advsys.net/ken #include "textures.h" #include "bitmap.h" #include "../../glbackend/glbackend.h" +#include "c_cvars.h" +#include "gamecvars.h" +CVAR(Bool, hw_detailmapping, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, hw_glowmapping, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, hw_polygonmode, 0, 0) +CVARD(Bool, hw_animsmoothing, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model animation smoothing") +CVARD(Bool, hw_hightile, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable hightile texture rendering") +CVARD(Bool, hw_models, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model rendering") +CVARD(Bool, hw_parallaxskypanning, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable parallaxed floor/ceiling panning when drawing a parallaxing sky") +//{ "r_projectionhack", "enable/disable projection hack", (void*)&glprojectionhacks, CVAR_INT, 0, 2 }, What is this? +CVARD(Bool, hw_shadeinterpolate, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable shade interpolation") +CVARD(Float, hw_shadescale, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "multiplier for shading") +CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable indexed color texture rendering") + +CUSTOM_CVAR(Int, vid_vsync, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + static bool recursion; + if (!recursion) + { + recursion = true; + self = videoSetVsync(self); + recursion = false; + } +} + +CUSTOM_CVARD(Int, hw_texfilter, TEXFILTER_ON, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "changes the texture filtering settings") +{ + static const char* const glfiltermodes[] = + { + "NEAREST", + "LINEAR", + "NEAREST_MIPMAP_NEAREST", + "LINEAR_MIPMAP_NEAREST", + "NEAREST_MIPMAP_LINEAR", + "LINEAR_MIPMAP_LINEAR", + "LINEAR_MIPMAP_LINEAR with NEAREST mag" + }; + + if (self < 0 || self > 6) self = 0; + else + { + gltexapplyprops(); + OSD_Printf("Texture filtering mode changed to %s\n", glfiltermodes[hw_texfilter]); + } +} + +CUSTOM_CVARD(Int, hw_anisotropy, 4, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "changes the OpenGL texture anisotropy setting") +{ + gltexapplyprops(); +} + + +//{ "r_yshearing", "enable/disable y-shearing", (void*)&r_yshearing, CVAR_BOOL, 0, 1 }, disabled because not fully functional + +// For testing - will be removed later. +CVAR(Int, skytile, 0, 0) extern char textfont[2048], smalltextfont[2048]; bool playing_rr; bool playing_blood; -int skytile; int32_t rendmode=0; -int32_t usemodels=1; -int32_t usehightile=1; - -int fixpalette = 0, fixpalswap = 0; typedef struct { float x, cy[2], fy[2]; int32_t tag; int16_t n, p, ctag, ftag; } vsptyp; #define VSPMAX 2048 //<- careful! @@ -54,9 +105,6 @@ static float dxb1[MAXWALLSB], dxb2[MAXWALLSB]; #define SOFTROTMAT 0 -float shadescale = 1.0f; -int32_t shadescale_unbounded = 0; - int32_t r_pogoDebug = 0; int32_t polymostcenterhoriz = 100; @@ -81,34 +129,16 @@ int psectnum, pwallnum, pbottomwall, pisbottomwall, psearchstat; static int32_t drawpoly_srepeat = 0, drawpoly_trepeat = 0; #define MAX_DRAWPOLY_VERTS 8 -struct glfiltermodes glfiltermodes[NUMGLFILTERMODES] = -{ - {"NEAREST"}, - {"LINEAR"}, - {"NEAREST_MIPMAP_NEAREST"}, - {"LINEAR_MIPMAP_NEAREST"}, - {"NEAREST_MIPMAP_LINEAR"}, - {"LINEAR_MIPMAP_LINEAR"} -}; - -int32_t glanisotropy = 0; // 0 = maximum supported by card -int32_t gltexfiltermode = TEXFILTER_OFF; - -int32_t r_polygonmode = 0; // 0:GL_FILL,1:GL_LINE,2:GL_POINT //FUK static int32_t lastglpolygonmode = 0; //FUK #ifdef USE_GLEXT int32_t glmultisample = 0, glnvmultisamplehint = 0; -int32_t r_detailmapping = 1; -int32_t r_glowmapping = 1; #endif int32_t glprojectionhacks = 2; static FHardwareTexture *polymosttext = 0; int32_t glrendmode = REND_POLYMOST; -int32_t r_shadeinterpolate = 1; -int32_t r_animsmoothing = 1; int32_t r_downsize = 0; int32_t r_downsizevar = -1; int32_t r_scenebrightness = 0; @@ -122,8 +152,6 @@ int32_t r_yshearing = 0; // used for fogcalc static float fogresult, fogresult2; -int32_t r_useindexedcolortextures = -1; - static inline float float_trans(uint32_t maskprops, uint8_t blend) { switch (maskprops) @@ -140,7 +168,6 @@ char ptempbuf[MAXWALLSB<<1]; // polymost ART sky control int32_t r_parallaxskyclamping = 1; -int32_t r_parallaxskypanning = 1; #define MIN_CACHETIME_PRINT 10 @@ -166,11 +193,11 @@ void gltexapplyprops(void) if (GLInterface.glinfo.maxanisotropy > 1.f) { - if (glanisotropy <= 0 || glanisotropy > GLInterface.glinfo.maxanisotropy) - glanisotropy = (int32_t)GLInterface.glinfo.maxanisotropy; + if (hw_anisotropy <= 0 || hw_anisotropy > GLInterface.glinfo.maxanisotropy) + hw_anisotropy = (int32_t)GLInterface.glinfo.maxanisotropy; } - GLInterface.mSamplers->SetTextureFilterMode(gltexfiltermode, glanisotropy); + GLInterface.mSamplers->SetTextureFilterMode(hw_texfilter, hw_anisotropy); // do not force switch indexed textures with the filter. } @@ -308,12 +335,12 @@ static float get_projhack_ratio(void) static void resizeglcheck(void) { //FUK - if (lastglpolygonmode != r_polygonmode) + if (lastglpolygonmode != hw_polygonmode) { - lastglpolygonmode = r_polygonmode; - GLInterface.SetWireframe(r_polygonmode == 1); + lastglpolygonmode = hw_polygonmode; + GLInterface.SetWireframe(hw_polygonmode == 1); } - if (r_polygonmode) //FUK + if (hw_polygonmode) //FUK { GLInterface.ClearScreen(1, 1, 1, true); } @@ -403,7 +430,7 @@ int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall) auto tex = TileFiles.tiles[wall->picnum]; auto si = tex->FindReplacement(wall->pal); - if (si && usehightile) tex = si->faces[0]; + if (si && hw_hightile) tex = si->faces[0]; if (tex->Get8BitPixels()) return false; return tex && tex->GetTranslucency(); } @@ -416,7 +443,7 @@ int32_t polymost_spriteHasTranslucency(uspritetype const * const tspr) auto tex = TileFiles.tiles[tspr->picnum]; auto si = tex->FindReplacement(tspr->shade, 0); - if (si && usehightile) tex = si->faces[0]; + if (si && hw_hightile) tex = si->faces[0]; if (tex->Get8BitPixels()) return false; return tex && tex->GetTranslucency(); } @@ -2017,7 +2044,7 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i xtex.u = otex.d * (t * double(((uint64_t)xdimscale * yxaspect) * viewingrange)) * (1.0 / (16384.0 * 65536.0 * 65536.0 * 5.0 * 1024.0)); ytex.v = vv[1]; - otex.v = r_parallaxskypanning ? vv[0] + dd*(float)global_cf_ypanning*(float)ti*(1.f/256.f) : vv[0]; + otex.v = hw_parallaxskypanning ? vv[0] + dd*(float)global_cf_ypanning*(float)ti*(1.f/256.f) : vv[0]; float x0 = xys[0].x, x1 = xys[0].x; @@ -2028,7 +2055,7 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i } int const npot = (1<<(picsiz[globalpicnum]&15)) != tilesiz.x; - int const xpanning = (r_parallaxskypanning?global_cf_xpanning:0); + int const xpanning = (hw_parallaxskypanning?global_cf_xpanning:0); GLInterface.SetClamp((npot || xpanning != 0) ? 0 : 2); @@ -2322,7 +2349,7 @@ static void polymost_drawalls(int32_t const bunch) skyzbufferhack = 1; - //if (!usehightile || !hicfindskybox(globalpicnum, globalpal)) + //if (!hw_hightile || !hicfindskybox(globalpicnum, globalpal)) { float const ghorizbak = ghoriz; pow2xsplit = 0; @@ -2580,7 +2607,7 @@ static void polymost_drawalls(int32_t const bunch) skyzbufferhack = 1; - //if (!usehightile || !hicfindskybox(globalpicnum, globalpal)) + //if (!hw_hightile || !hicfindskybox(globalpicnum, globalpal)) { float const ghorizbak = ghoriz; pow2xsplit = 0; @@ -3046,11 +3073,11 @@ void polymost_scansector(int32_t sectnum) vec2_t const s = { spr->x-globalposx, spr->y-globalposy }; if ((spr->cstat&48) || - (usemodels && tile2model[spr->picnum].modelid>=0) || + (hw_models && tile2model[spr->picnum].modelid>=0) || ((s.x * gcosang) + (s.y * gsinang) > 0)) { if ((spr->cstat&(64+48))!=(64+16) || - (usevoxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) || + (r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) || dmulscale6(sintable[(spr->ang+512)&2047],-s.x, sintable[spr->ang&2047],-s.y) > 0) if (renderAddTsprite(z, sectnum)) break; @@ -3319,7 +3346,7 @@ void polymost_drawrooms() ghoriz = fix16_to_float(qglobalhoriz); ghorizcorrect = fix16_to_float((100-polymostcenterhoriz)*divscale16(xdimenscale, viewingrange)); - GLInterface.SetShadeInterpolate(r_shadeinterpolate); + GLInterface.SetShadeInterpolate(hw_shadeinterpolate); //global cos/sin height angle if (r_yshearing) @@ -3945,7 +3972,7 @@ void polymost_drawsprite(int32_t snum) if ((globalorientation & 48) != 48) // only non-voxel sprites should do this { - int const flag = usehightile && h_xsize[globalpicnum]; + int const flag = hw_hightile && h_xsize[globalpicnum]; off = { (int32_t)tspr->xoffset + (flag ? h_xoffs[globalpicnum] : picanm[globalpicnum].xofs), (int32_t)tspr->yoffset + (flag ? h_yoffs[globalpicnum] : picanm[globalpicnum].yofs) }; } @@ -3964,14 +3991,14 @@ void polymost_drawsprite(int32_t snum) while (!(spriteext[spritenum].flags & SPREXT_NOTMD)) { - if (usemodels && tile2model[Ptile2tile(tspr->picnum, tspr->pal)].modelid >= 0 && + if (hw_models && tile2model[Ptile2tile(tspr->picnum, tspr->pal)].modelid >= 0 && tile2model[Ptile2tile(tspr->picnum, tspr->pal)].framenum >= 0) { if (polymost_mddraw(tspr)) return; break; // else, render as flat sprite } - if (usevoxels && (tspr->cstat & 48) != 48 && tiletovox[tspr->picnum] >= 0 && voxmodels[tiletovox[tspr->picnum]]) + if (r_voxels && (tspr->cstat & 48) != 48 && tiletovox[tspr->picnum] >= 0 && voxmodels[tiletovox[tspr->picnum]]) { if (polymost_voxdraw(voxmodels[tiletovox[tspr->picnum]], tspr)) return; break; // else, render as flat sprite @@ -4002,7 +4029,7 @@ void polymost_drawsprite(int32_t snum) vec2_16_t const oldsiz = tilesiz[globalpicnum]; vec2_t tsiz = { oldsiz.x, oldsiz.y }; - if (usehightile && h_xsize[globalpicnum]) + if (hw_hightile && h_xsize[globalpicnum]) tsiz = { h_xsize[globalpicnum], h_ysize[globalpicnum] }; if (tsiz.x <= 0 || tsiz.y <= 0) @@ -4723,7 +4750,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 int8_t dashade, uint8_t dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, int32_t uniqid) { - if (usemodels && tile2model[picnum].hudmem[(dastat&4)>>2]) + if (hw_models && tile2model[picnum].hudmem[(dastat&4)>>2]) { polymost_dorotatespritemodel(sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, uniqid); return; @@ -5346,229 +5373,10 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba return 0; } -// This is for testing the shade map calculator needed for true color shading. -void palookupinfo() -{ - auto pal = basepaltable[0]; - int black = -1, white = -1; - int brightness = 0; - int brightest = -1, darkest = -1; - int brightlum = 0, darklum = 255; - for (int i = 0; i < 765; i += 3) - { - if (pal[i] == 0 && pal[i + 1] == 0 && pal[i + 2] == 0) black = i; - if (pal[i] == 255 && pal[i + 1] == 255 && pal[i + 2] == 255) white = i/3; - int lumi = Luminance(pal[i], pal[i + 1], pal[i + 2]); - brightness += lumi; - if (lumi < darklum) - { - darklum = lumi; - darkest = i; - } - if (lumi > brightlum) - { - brightlum = lumi; - brightest = i; - } - } - brightness /= 255; - OSD_Printf("Black at index %d, white at index %d, avg. luminance %d\n", black, white, brightness); - if (black == -1) - { - OSD_Printf("No black found - using nearest color %02x %02x %02x\n", pal[darkest], pal[darkest + 1], pal[darkest + 2]); - black = darkest; - } - if (white == -1) - { - OSD_Printf("No white found - using nearest color %02x %02x %02x\n", pal[brightest], pal[brightest + 1], pal[brightest + 2]); - white = brightest; - } - - - for (int i = 0; i < 256; i++) - { - if (palookup[i] == nullptr || (i > 0 && palookup[i] == palookup[0])) - { - // Either the same as the base of not present. - continue; - } - OSD_Printf("palookup[%d]:\n", i); - - float lum0 = 0; - TArray blacks, whites; - TArray abslum, rellum, fadelum; - for (int j = 0; j < numshades - 1; j++) // do not count the last one, it doesn't look correct in most lookups - this value needs to be extrapolated from the rest. - { - int map = palookup[i][j * 256 + black] * 3; - PalEntry blackmap(pal[map], pal[map + 1], pal[map + 2]); - map = palookup[i][j * 256 + white] * 3; - PalEntry whitemap(pal[map], pal[map + 1], pal[map + 2]); - - blacks.Push(blackmap); - whites.Push(whitemap); - - float mylum = 0; - int palcnt = 0; - for (int k = 0; k < 255; k++) - { - if (!IsPaletteIndexFullbright(i)) - { - map = palookup[i][j * 256 + k] * 3; - mylum += Luminance(pal[map], pal[map + 1], pal[map + 2]); - palcnt++; - } - } - mylum /= 255 * palcnt; - if (j == 0) - { - lum0 = mylum; - if (lum0 == 0) lum0 = 1; // for always-black palettes. - } - abslum.Push(mylum); - rellum.Push(mylum / lum0); - fadelum.Push((mylum - blackmap.Luminance() / 255.f) / lum0); - } - TArray interlum; - auto lastblack = blacks.Last(); - auto& array = (lastblack.r < 6 && lastblack.g < 6 && lastblack.b < 6) ? rellum : fadelum; - float range = array[0] - array.Last(); - for (int i = 0; i < numshades - 1; i++) - { - float interval = array[0] - i * range / (numshades-2); - interlum.Push(interval); - } - OSD_Printf(" fades to %02x %02x %02x\n", lastblack.r, lastblack.g, lastblack.b); - for (int i = 0; i < numshades - 1; i++) - { - OSD_Printf(" Shade %d: relative luminance = %2.4f, interpolated luminance: %2.4f\n", i, array[i], interlum[i]); - } - OSD_Printf("-------------------------\n"); - } -} - -// Console commands by JBF -static int32_t gltexturemode(osdcmdptr_t parm) -{ - int32_t m; - char *p; - - if (parm->numparms != 1) - { - OSD_Printf("Current texturing mode is %s\n", glfiltermodes[gltexfiltermode].name); - OSD_Printf(" Vaild modes are:\n"); - for (m = 0; m < NUMGLFILTERMODES; m++) - OSD_Printf(" %d - %s\n", m, glfiltermodes[m].name); - - return OSDCMD_OK; - } - - m = Bstrtoul(parm->parms[0], &p, 10); - if (p == parm->parms[0]) - { - // string - for (m = 0; m < NUMGLFILTERMODES; m++) - { - if (!Bstrcasecmp(parm->parms[0], glfiltermodes[m].name)) - break; - } - - if (m == NUMGLFILTERMODES) - m = gltexfiltermode; // no change - } - else - { - m = clamp(m, 0, NUMGLFILTERMODES-1); - } - - gltexfiltermode = m; - gltexapplyprops(); - - OSD_Printf("Texture filtering mode changed to %s\n", glfiltermodes[gltexfiltermode].name); - - return OSDCMD_OK; -} - -static int osdcmd_cvar_set_polymost(osdcmdptr_t parm) -{ - int32_t r = osdcmd_cvar_set(parm); - - if (xdim == 0 || ydim == 0 || bpp == 0) // video not set up yet - { - - return r; - } - - if (r == OSDCMD_OK) - { - if (!Bstrcasecmp(parm->name, "r_palookupinfo")) - palookupinfo(); - - else if (!Bstrcasecmp(parm->name, "r_swapinterval")) - vsync = videoSetVsync(vsync); - else if (!Bstrcasecmp(parm->name, "r_downsize")) - { - if (r_downsizevar == -1) - r_downsizevar = r_downsize; - - if (in3dmode() && r_downsize != r_downsizevar) - { - videoResetMode(); - if (videoSetGameMode(fullscreen,xres,yres,bpp,upscalefactor)) - OSD_Printf("restartvid: Reset failed...\n"); - } - - r_downsizevar = r_downsize; - } - else if (!Bstrcasecmp(parm->name, "r_anisotropy")) - gltexapplyprops(); - else if (!Bstrcasecmp(parm->name, "r_texfilter")) - gltexturemode(parm); - } - - return r; -} - -int r_palookupinfo; void polymost_initosdfuncs(void) { - uint32_t i; - - static osdcvardata_t cvars_polymost[] = - { -#ifdef USE_GLEXT - { "r_detailmapping","enable/disable detail mapping",(void *) &r_detailmapping, CVAR_BOOL, 0, 1 }, - { "r_glowmapping","enable/disable glow mapping",(void *) &r_glowmapping, CVAR_BOOL, 0, 1 }, -#endif - { "r_polygonmode","debugging feature",(void *) &r_polygonmode, CVAR_INT | CVAR_NOSAVE, 0, 3 }, - - { "r_animsmoothing","enable/disable model animation smoothing",(void *) &r_animsmoothing, CVAR_BOOL, 0, 1 }, - { "r_anisotropy", "changes the OpenGL texture anisotropy setting", (void *) &glanisotropy, CVAR_INT|CVAR_FUNCPTR, 0, 16 }, - { "r_hightile","enable/disable hightile texture rendering",(void *) &usehightile, CVAR_BOOL, 0, 1 }, - { "r_models", "enable/disable model rendering", (void *)&usemodels, CVAR_BOOL, 0, 1 }, - { "r_nofog", "enable/disable GL fog", (void *)&nofog, CVAR_BOOL, 0, 1}, - { "r_parallaxskyclamping","enable/disable parallaxed floor/ceiling sky texture clamping", (void *) &r_parallaxskyclamping, CVAR_BOOL, 0, 1 }, - { "r_parallaxskypanning","enable/disable parallaxed floor/ceiling panning when drawing a parallaxing sky", (void *) &r_parallaxskypanning, CVAR_BOOL, 0, 1 }, - { "r_projectionhack", "enable/disable projection hack", (void *) &glprojectionhacks, CVAR_INT, 0, 2 }, - { "r_shadeinterpolate", "enable/disable shade interpolation", (void *) &r_shadeinterpolate, CVAR_BOOL, 0, 1 }, - { "r_shadescale","multiplier for shading",(void *) &shadescale, CVAR_FLOAT, 0, 10 }, - { "r_shadescale_unbounded","enable/disable allowance of complete blackness",(void *) &shadescale_unbounded, CVAR_BOOL, 0, 1 }, - { "r_swapinterval","sets the GL swap interval (VSync)",(void *) &vsync, CVAR_INT|CVAR_FUNCPTR, -1, 1 }, - { "r_texfilter", "changes the texture filtering settings (may require restart)", (void *) &gltexfiltermode, CVAR_INT|CVAR_FUNCPTR, 0, 5 }, - { "r_useindexedcolortextures", "enable/disable indexed color texture rendering", (void *) &r_useindexedcolortextures, CVAR_INT, 0, 1 }, - { "r_yshearing", "enable/disable y-shearing", (void*)&r_yshearing, CVAR_BOOL, 0, 1 }, - - // For testing - will be removed later. - { "r_palookupinfo", "", (void*)&r_palookupinfo, CVAR_INT|CVAR_FUNCPTR, 0, 1 }, - { "fixpalette", "", (void*)& fixpalette, CVAR_INT, 0, 256 }, - { "fixpalswap", "", (void*)& fixpalswap, CVAR_INT, 0, 256 }, - { "skytile", "", (void*)&skytile, CVAR_INT, 0, 30720 }, - - }; - - for (i=0; iSetTextureFilterMode(gltexfiltermode, glanisotropy); + GLInterface.mSamplers->SetTextureFilterMode(hw_texfilter, hw_anisotropy); } diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index fbe9d3588..45d5e2d88 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1078,7 +1078,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) float pc[4]; - pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; + pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; auto& h = hictinting[globalpal]; GLInterface.SetTinting(h.f, PalEntry(h.sr, h.sg, h.sb), PalEntry(h.r, h.g, h.b)); diff --git a/source/common/gamecvars.cpp b/source/common/gamecvars.cpp index d6af4ee08..7ce9b1a6b 100644 --- a/source/common/gamecvars.cpp +++ b/source/common/gamecvars.cpp @@ -367,11 +367,10 @@ CUSTOM_CVARD(String, wchoice, "3457860291", CVAR_ARCHIVE | CVAR_NOINITCALL | CVA } -#if 0 +CVARD(Bool, r_voxels, true, CVAR_ARCHIVE, "enable/disable automatic sprite->voxel rendering") -// These I don't care about. -//{ "r_upscalefactor", "increase performance by rendering at upscalefactor less than the screen resolution and upscale to the full resolution in the software renderer", (void *)&ud.detail, CVAR_INT|CVAR_FUNCPTR, 1, 16 }, -//{ "r_upscalefactor", "increase performance by rendering at upscalefactor less than the screen resolution and upscale to the full resolution in the software renderer", (void *)&gUpscaleFactor, CVAR_INT|CVAR_FUNCPTR, 1, 16 + +#if 0 // These have to wait until the HUD code is cleaned up (no idea which may survive and which won't.) /* @@ -425,4 +424,20 @@ CUSTOM_CVARD(String, wchoice, "3457860291", CVAR_ARCHIVE | CVAR_NOINITCALL | CVA } */ + /* Baselayer CVARs. Some are pointless, some not worth bothering before the backend is swappewd out, the only relevant one was r_voxels. + static osdcvardata_t cvars_engine[] = + { + { "lz4compressionlevel","adjust LZ4 compression level used for savegames",(void *) &lz4CompressionLevel, CVAR_INT, 1, 32 }, + { "r_borderless", "borderless windowed mode: 0: never 1: always 2: if resolution matches desktop", (void *) &r_borderless, CVAR_INT|CVAR_RESTARTVID, 0, 2 }, + { "r_displayindex","index of output display",(void *)&r_displayindex, CVAR_INT|CVAR_RESTARTVID, 0, 10 }, + { "r_usenewaspect","enable/disable new screen aspect ratio determination code",(void *) &r_usenewaspect, CVAR_BOOL, 0, 1 }, + { "r_screenaspect","if using r_usenewaspect and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9", + (void *) &r_screenxy, SCREENASPECT_CVAR_TYPE, 0, 9999 }, + { "r_windowpositioning", "enable/disable window position memory", (void *) &windowpos, CVAR_BOOL, 0, 1 }, + //{ "vid_gamma","adjusts gamma component of gamma ramp",(void *) &g_videoGamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, + //{ "vid_contrast","adjusts contrast component of gamma ramp",(void *) &g_videoContrast, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, + //{ "vid_brightness","adjusts brightness component of gamma ramp",(void *) &g_videoBrightness, CVAR_FLOAT|CVAR_FUNCPTR, 0, 10 }, + }; + */ + #endif diff --git a/source/common/gamecvars.h b/source/common/gamecvars.h index e1d4f9f9d..cffb64262 100644 --- a/source/common/gamecvars.h +++ b/source/common/gamecvars.h @@ -64,6 +64,8 @@ EXTERN_CVAR(Float, r_ambientlight) EXTERN_CVAR(Bool, r_shadows) EXTERN_CVAR(Bool, r_rotatespritenowidescreen) EXTERN_CVAR(Bool, r_precache) +EXTERN_CVAR(Bool, r_voxels) + EXTERN_CVAR(Bool, in_joystick) EXTERN_CVAR(Bool, in_mouse) diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index d793edfee..cb7a6f481 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -419,7 +419,7 @@ int32_t Anim_Play(const char *fn) // ANM playback --- v v v --- #ifdef USE_OPENGL - int32_t ogltexfiltermode = gltexfiltermode; + int32_t ogltexfiltermode = hw_texfilter; #endif TArray buffer; auto fr = kopenFileReader(fn, 0); @@ -459,11 +459,8 @@ int32_t Anim_Play(const char *fn) P_SetGamePalette(g_player[myconnectindex].ps, ANIMPAL, 8 + 2); #ifdef USE_OPENGL - if ((anim->frameflags & CUTSCENE_TEXTUREFILTER && gltexfiltermode == TEXFILTER_ON) || anim->frameflags & CUTSCENE_FORCEFILTER) - gltexfiltermode = TEXFILTER_ON; - else - gltexfiltermode = TEXFILTER_OFF; - gltexapplyprops(); + if ((anim->frameflags & CUTSCENE_TEXTUREFILTER && hw_texfilter == TEXFILTER_ON) || anim->frameflags & CUTSCENE_FORCEFILTER) + hw_texfilter = TEXFILTER_ON; #endif ototalclock = totalclock; @@ -553,7 +550,7 @@ int32_t Anim_Play(const char *fn) end_anim_restore_gl: #ifdef USE_OPENGL - gltexfiltermode = ogltexfiltermode; + hw_texfilter = ogltexfiltermode; gltexapplyprops(); #endif end_anim: diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index 3d36f8107..51f2ce65e 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -552,7 +552,7 @@ enum UserdefsLabel_t USERDEFS_M_ORIGIN_Y, USERDEFS_PLAYERBEST, USERDEFS_MUSICTOGGLE, - USERDEFS_USEVOXELS, + USERDEF_USEVOXELS, USERDEFS_USEHIGHTILE, USERDEFS_USEMODELS, USERDEFS_GAMETYPEFLAGS, diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index d5cf24755..a6c014629 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -1281,9 +1281,9 @@ const memberlabel_t UserdefsLabels[]= { "m_origin_y", USERDEFS_M_ORIGIN_Y, 0, 0, -1 }, { "playerbest", USERDEFS_PLAYERBEST, 0, 0, -1 }, { "musictoggle", USERDEFS_MUSICTOGGLE, 0, 0, -1 }, - { "usevoxels", USERDEFS_USEVOXELS, 0, 0, -1 }, - { "usehightile", USERDEFS_USEHIGHTILE, 0, 0, -1 }, - { "usemodels", USERDEFS_USEMODELS, 0, 0, -1 }, + { "r_voxels", USERDEF_USEVOXELS, 0, 0, -1 }, + { "hw_hightile", USERDEFS_USEHIGHTILE, 0, 0, -1 }, + { "hw_models", USERDEFS_USEMODELS, 0, 0, -1 }, { "gametypeflags", USERDEFS_GAMETYPEFLAGS, 0, 0, -1 }, { "m_gametypeflags", USERDEFS_M_GAMETYPEFLAGS, 0, 0, -1 }, { "globalflags", USERDEFS_GLOBALFLAGS, 0, 0, -1 }, @@ -1475,18 +1475,10 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2) case USERDEFS_M_ORIGIN_X: labelNum = ud.returnvar[0]; break; case USERDEFS_M_ORIGIN_Y: labelNum = ud.returnvar[1]; break; case USERDEFS_PLAYERBEST: labelNum = ud.playerbest; break; - case USERDEFS_MUSICTOGGLE: labelNum = mus_enabled; break; - case USERDEFS_USEVOXELS: labelNum = usevoxels; break; - case USERDEFS_USEHIGHTILE: -#ifdef USE_OPENGL - labelNum = usehightile; break; -#endif - case USERDEFS_USEMODELS: -#ifdef USE_OPENGL - labelNum = usemodels; break; -#else - labelNum = 0; break; -#endif + case USERDEFS_MUSICTOGGLE: labelNum = mus_enabled; break; + case USERDEF_USEVOXELS: labelNum = r_voxels; break; + case USERDEFS_USEHIGHTILE: labelNum = hw_hightile; break; + case USERDEFS_USEMODELS: labelNum = hw_models; break; case USERDEFS_GAMETYPEFLAGS: labelNum = g_gametypeFlags[ud.coop]; break; case USERDEFS_M_GAMETYPEFLAGS: labelNum = g_gametypeFlags[ud.m_coop]; break; case USERDEFS_GLOBALFLAGS: labelNum = globalflags; break; @@ -1504,7 +1496,7 @@ int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2) case USERDEFS_SCREENAREA_Y2: labelNum = ud.returnvar[2]; break; case USERDEFS_SCREENFADE: labelNum = ud.screenfade; break; case USERDEFS_MENUBACKGROUND: labelNum = ud.menubackground; break; - case USERDEFS_STATUSBARFLAGS: labelNum = 0/*ud.statusbarflags*/; break; + case USERDEFS_STATUSBARFLAGS: labelNum = ud.statusbarflags; break; case USERDEFS_STATUSBARRANGE: labelNum = ud.statusbarrange; break; case USERDEFS_STATUSBARCUSTOM: labelNum = hud_custom; break; case USERDEFS_HUDONTOP: labelNum = ud.hudontop; break; diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 1c6b4fc89..529ff3e39 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -556,7 +556,7 @@ static MenuOption_t MEO_DISPLAYSETUP_ASPECTRATIO = MAKE_MENUOPTION(&MF_Redfont, static MenuEntry_t ME_DISPLAYSETUP_ASPECTRATIO = MAKE_MENUENTRY( "Widescreen:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_DISPLAYSETUP_ASPECTRATIO, Option ); #endif -static MenuOption_t MEO_DISPLAYSETUP_VOXELS = MAKE_MENUOPTION(&MF_Redfont, &MEOS_OffOn, &usevoxels); +static MenuOption_t MEO_DISPLAYSETUP_VOXELS = MAKE_MENUOPTION(&MF_Redfont, &MEOS_OffOn, &r_voxels.Value); static MenuEntry_t ME_DISPLAYSETUP_VOXELS = MAKE_MENUENTRY( "Voxels:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_DISPLAYSETUP_VOXELS, Option ); static MenuRangeInt32_t MEO_DISPLAYSETUP_FOV = MAKE_MENURANGE( &r_fov.Value, &MF_Redfont, 70, 120, 0, 11, 1 ); @@ -571,13 +571,13 @@ static MenuEntry_t ME_DISPLAYSETUP_FOV = MAKE_MENUENTRY( "FOV:", &MF_Redfont, &M static char const *MEOSN_DISPLAYSETUP_TEXFILTER[] = { "Classic", "Filtered" }; static int32_t MEOSV_DISPLAYSETUP_TEXFILTER[] = { TEXFILTER_OFF, TEXFILTER_ON }; static MenuOptionSet_t MEOS_DISPLAYSETUP_TEXFILTER = MAKE_MENUOPTIONSET( MEOSN_DISPLAYSETUP_TEXFILTER, MEOSV_DISPLAYSETUP_TEXFILTER, 0x2 ); -static MenuOption_t MEO_DISPLAYSETUP_TEXFILTER = MAKE_MENUOPTION( &MF_Redfont, &MEOS_DISPLAYSETUP_TEXFILTER, &gltexfiltermode ); +static MenuOption_t MEO_DISPLAYSETUP_TEXFILTER = MAKE_MENUOPTION( &MF_Redfont, &MEOS_DISPLAYSETUP_TEXFILTER, &hw_texfilter.Value ); static MenuEntry_t ME_DISPLAYSETUP_TEXFILTER = MAKE_MENUENTRY( "Texture Mode:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_DISPLAYSETUP_TEXFILTER, Option ); static char const *MEOSN_DISPLAYSETUP_ANISOTROPY[] = { "Max", "None", "2x", "4x", "8x", "16x", }; static int32_t MEOSV_DISPLAYSETUP_ANISOTROPY[] = { 0, 1, 2, 4, 8, 16, }; static MenuOptionSet_t MEOS_DISPLAYSETUP_ANISOTROPY = MAKE_MENUOPTIONSET( MEOSN_DISPLAYSETUP_ANISOTROPY, MEOSV_DISPLAYSETUP_ANISOTROPY, 0x0 ); -static MenuOption_t MEO_DISPLAYSETUP_ANISOTROPY = MAKE_MENUOPTION(&MF_Redfont, &MEOS_DISPLAYSETUP_ANISOTROPY, &glanisotropy); +static MenuOption_t MEO_DISPLAYSETUP_ANISOTROPY = MAKE_MENUOPTION(&MF_Redfont, &MEOS_DISPLAYSETUP_ANISOTROPY, &hw_anisotropy.Value); static MenuEntry_t ME_DISPLAYSETUP_ANISOTROPY = MAKE_MENUENTRY( "Anisotropy:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_DISPLAYSETUP_ANISOTROPY, Option ); #endif # endif @@ -1024,7 +1024,7 @@ static MenuEntry_t *MEL_INTERNAL_JOYSTICKAXIS_DIGITAL[] = { }; #ifdef USE_OPENGL -static MenuOption_t MEO_RENDERERSETUP_HIGHTILE = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &usehightile ); +static MenuOption_t MEO_RENDERERSETUP_HIGHTILE = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &hw_hightile.Value ); static MenuEntry_t ME_RENDERERSETUP_HIGHTILE = MAKE_MENUENTRY( "True color textures:", &MF_Bluefont, &MEF_SmallOptions, &MEO_RENDERERSETUP_HIGHTILE, Option ); static char const *MEOSN_RENDERERSETUP_TEXQUALITY [] = { "Full", "Half", "Barf", }; @@ -1040,12 +1040,12 @@ static char const *MEOSN_RENDERERSETUP_TEXCACHE[] = { "Off", "On", "Compr.", }; static MenuOptionSet_t MEOS_RENDERERSETUP_TEXCACHE = MAKE_MENUOPTIONSET( MEOSN_RENDERERSETUP_TEXCACHE, NULL, 0x2 ); # endif # ifdef USE_GLEXT -static MenuOption_t MEO_RENDERERSETUP_DETAILTEX = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &r_detailmapping ); +static MenuOption_t MEO_RENDERERSETUP_DETAILTEX = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &hw_detailmapping.Value ); static MenuEntry_t ME_RENDERERSETUP_DETAILTEX = MAKE_MENUENTRY( "Detail textures:", &MF_Bluefont, &MEF_SmallOptions, &MEO_RENDERERSETUP_DETAILTEX, Option ); -static MenuOption_t MEO_RENDERERSETUP_GLOWTEX = MAKE_MENUOPTION(&MF_Bluefont, &MEOS_NoYes, &r_glowmapping); +static MenuOption_t MEO_RENDERERSETUP_GLOWTEX = MAKE_MENUOPTION(&MF_Bluefont, &MEOS_NoYes, &hw_glowmapping.Value); static MenuEntry_t ME_RENDERERSETUP_GLOWTEX = MAKE_MENUENTRY("Glow textures:", &MF_Bluefont, &MEF_SmallOptions, &MEO_RENDERERSETUP_GLOWTEX, Option); # endif -static MenuOption_t MEO_RENDERERSETUP_MODELS = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &usemodels ); +static MenuOption_t MEO_RENDERERSETUP_MODELS = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &hw_models.Value ); static MenuEntry_t ME_RENDERERSETUP_MODELS = MAKE_MENUENTRY( "3D models:", &MF_Bluefont, &MEF_SmallOptions, &MEO_RENDERERSETUP_MODELS, Option ); #endif @@ -2022,9 +2022,9 @@ static void Menu_Pre(MenuID_t cm) #ifdef TEXFILTER_MENU_OPTIONS if (videoGetRenderMode() != REND_CLASSIC) { - //POGOTODO: allow setting anisotropy again while r_useindexedcolortextures is set when support is added down the line - // don't allow setting anisotropy while in POLYMOST and r_useindexedcolortextures is enabled - MenuEntry_DisableOnCondition(&ME_DISPLAYSETUP_ANISOTROPY, videoGetRenderMode() == REND_POLYMOST && r_useindexedcolortextures); + //POGOTODO: allow setting anisotropy again while hw_useindexedcolortextures is set when support is added down the line + // don't allow setting anisotropy while in POLYMOST and hw_useindexedcolortextures is enabled + MenuEntry_DisableOnCondition(&ME_DISPLAYSETUP_ANISOTROPY, videoGetRenderMode() == REND_POLYMOST && hw_useindexedcolortextures); for (i = (int32_t) ARRAY_SIZE(MEOSV_DISPLAYSETUP_ANISOTROPY) - 1; i >= 0; --i) { @@ -2041,11 +2041,11 @@ static void Menu_Pre(MenuID_t cm) case MENU_POLYMER: case MENU_POLYMOST: - MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_TEXQUALITY, !usehightile); - MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_PRECACHE, !usehightile); + MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_TEXQUALITY, !hw_hightile); + MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_PRECACHE, !hw_hightile); # ifdef USE_GLEXT - MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_DETAILTEX, !usehightile); - MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_GLOWTEX, !usehightile); + MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_DETAILTEX, !hw_hightile); + MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_GLOWTEX, !hw_hightile); # endif #endif break; @@ -2093,7 +2093,7 @@ static void Menu_Pre(MenuID_t cm) MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_APPLY, (xres == resolution[nr].xdim && yres == resolution[nr].ydim && videoGetRenderMode() == newrendermode && fullscreen == newfullscreen - && vsync == newvsync && r_borderless == newborderless + && vid_vsync == newvsync && r_borderless == newborderless ) || (newrendermode != REND_CLASSIC && resolution[nr].bppmax <= 8)); MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_BORDERLESS, newfullscreen); @@ -3174,7 +3174,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) { resolution_t p = { xres, yres, fullscreen, bpp, 0 }; int32_t prend = videoGetRenderMode(); - int32_t pvsync = vsync; + int32_t pvsync = vid_vsync; int pborderless = r_borderless; resolution_t n = { resolution[newresolution].xdim, resolution[newresolution].ydim, @@ -3198,13 +3198,13 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) else { onvideomodechange(p.bppmax > 8); - vsync = videoSetVsync(pvsync); + vid_vsync = videoSetVsync(pvsync); } } else { videoSetRenderMode(newrendermode); - vsync = videoSetVsync(newvsync); + vid_vsync = videoSetVsync(newvsync); onvideomodechange(n.bppmax > 8); } @@ -4234,7 +4234,7 @@ static void Menu_AboutToStartDisplaying(Menu_t * m) } newrendermode = videoGetRenderMode(); newfullscreen = fullscreen; - newvsync = vsync; + newvsync = vid_vsync; newborderless = r_borderless; break; diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index 05c5f37ef..0f9ec5989 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -1799,7 +1799,7 @@ static void G_DrawTileScaled(int drawX, int drawY, int tileNum, int drawShade, i #endif #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(tileNum,drawPal) >= 0) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(tileNum,drawPal) >= 0) drawYOffset += (224<<16)-weapsc(224<<16); #endif rotatesprite(weapsc(drawX<<16) + (drawXOffset-weapsc(drawXOffset)), @@ -1831,7 +1831,7 @@ static void G_DrawWeaponTile(int weaponX, int weaponY, int weaponTile, int weapo { if (weaponTile >= CHAINGUN + 1 && weaponTile <= CHAINGUN + 4) { - if (!usemodels || md_tilehasmodel(weaponTile, weaponPal) < 0) + if (!hw_models || md_tilehasmodel(weaponTile, weaponPal) < 0) { // HACK: Draw the upper part of the chaingun two screen // pixels (not texels; multiplied by weapon scale) lower diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index 9909991c2..24125f576 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -41,9 +41,9 @@ #include "bitmap.h" #include "../../glbackend/glbackend.h" -// External CVARs. -extern int r_detailmapping, r_glowmapping, usehightile, r_useindexedcolortextures; -extern int fixpalette, fixpalswap; +// Test CVARs. +CVAR(Int, fixpalette, 0, 0) +CVAR(Int, fixpalswap, 0, 0) template @@ -165,12 +165,12 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int GLInterface.SetPalette(usepalette); GLInterface.SetPalswap(usepalswap); - TextureType = r_useindexedcolortextures? TT_INDEXED : TT_TRUECOLOR; + TextureType = hw_useindexedcolortextures? TT_INDEXED : TT_TRUECOLOR; int lookuppal = 0; VSMatrix texmat; - auto rep = usehightile? tex->FindReplacement(palette) : nullptr; + auto rep = hw_hightile? tex->FindReplacement(palette) : nullptr; if (rep) { // Hightile replacements have only one texture representation and it is always the base. @@ -180,7 +180,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int else { // Only look up the palette if we really want to use it (i.e. when creating a true color texture of an ART tile.) - if (!r_useindexedcolortextures) lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false); + if (!hw_useindexedcolortextures) lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false); } // Load the main texture @@ -206,7 +206,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int } // Also load additional layers needed for this texture. - if (r_detailmapping && usehightile) + if (hw_detailmapping && hw_hightile) { float detscalex = detscale, detscaley = detscale; if (!(method & DAMETH_MODEL)) @@ -237,7 +237,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int if (MatrixChange & 2) GLInterface.SetMatrix(Matrix_Detail, &texmat); } } - if (r_glowmapping && usehightile) + if (hw_glowmapping && hw_hightile) { if (!(method & DAMETH_MODEL)) { diff --git a/source/rr/src/anim.cpp b/source/rr/src/anim.cpp index 673fa5b5d..5077eb95c 100644 --- a/source/rr/src/anim.cpp +++ b/source/rr/src/anim.cpp @@ -449,7 +449,7 @@ int32_t Anim_Play(const char *fn) // ANM playback --- v v v --- #ifdef USE_OPENGL - int32_t ogltexfiltermode = gltexfiltermode; + int32_t ogltexfiltermode = hw_texfilter; #endif auto fr = kopenFileReader(fn, 0); @@ -579,7 +579,7 @@ int32_t Anim_Play(const char *fn) end_anim_restore_gl: #ifdef USE_OPENGL - gltexfiltermode = ogltexfiltermode; + hw_texfilter = ogltexfiltermode; gltexapplyprops(); #endif end_anim: diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index b10ea0264..291791cb8 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -4788,7 +4788,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura continue; case CHAIR3__STATIC: #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { t->cstat &= ~4; break; @@ -5098,7 +5098,7 @@ default_case1: else if (sprite[pSprite->owner].picnum == MAMA) { #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0 && + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0 && !(spriteext[i].flags & SPREXT_NOTMD)) { int32_t v = getangle(t->xvel, t->zvel >> 4); @@ -5117,7 +5117,7 @@ default_case1: case EMPTYBIKE__STATICRR: if (!RRRA) goto default_case2; #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { t->cstat &= ~4; break; @@ -5129,7 +5129,7 @@ default_case1: case EMPTYBOAT__STATICRR: if (!RRRA) goto default_case2; #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { t->cstat &= ~4; break; @@ -5140,7 +5140,7 @@ default_case1: break; case RPG__STATIC: #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags & SPREXT_NOTMD)) { int32_t v = getangle(t->xvel, t->zvel>>4); @@ -5156,7 +5156,7 @@ default_case1: case RPG2__STATICRR: if (!RRRA) goto default_case2; #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags & SPREXT_NOTMD)) { int32_t v = getangle(t->xvel, t->zvel>>4); @@ -5172,7 +5172,7 @@ default_case1: case RECON__STATIC: #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { t->cstat &= ~4; break; @@ -5198,7 +5198,7 @@ default_case1: g_player[playerNum].ps->q16ang + mulscale16((((g_player[playerNum].ps->q16ang + 1024 - g_player[playerNum].ps->oq16ang) & 2047) - 1024), smoothratio)); #ifdef USE_OPENGL - if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0) + if (bpp > 8 && hw_models && md_tilehasmodel(t->picnum, t->pal) >= 0) { static int32_t targetang = 0; @@ -5295,7 +5295,7 @@ default_case1: if (pSprite->owner == -1) { #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(pSprite->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { frameOffset = 0; t->cstat &= ~4; @@ -5349,7 +5349,7 @@ default_case1: } #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(pSprite->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { frameOffset = 0; t->cstat &= ~4; @@ -5391,7 +5391,7 @@ PALONLY: scrofs_action = 0; curframe = 0; #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(pSprite->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { frameOffset = 0; t->cstat &= ~4; @@ -5418,7 +5418,7 @@ PALONLY: scrofs_action = 0; curframe = 0; #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(pSprite->picnum, t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { frameOffset = 0; t->cstat &= ~4; @@ -5537,7 +5537,7 @@ default_case2: l = klabs(l); #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(pSprite->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { frameOffset = 0; t->cstat &= ~4; @@ -5676,7 +5676,7 @@ skip: #ifdef USE_OPENGL if (videoGetRenderMode() >= REND_POLYMOST) { - if (usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0) + if (hw_models && md_tilehasmodel(t->picnum,t->pal) >= 0) { tsprShadow->yrepeat = 0; // 512:trans reverse @@ -5859,7 +5859,7 @@ rrcoolexplosion1: break; case PLAYERONWATER__STATIC: #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum,pSprite->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(pSprite->picnum,pSprite->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { frameOffset = 0; t->cstat &= ~4; @@ -5920,7 +5920,7 @@ rrcoolexplosion1: case CAMERA1__STATIC: case RAT__STATIC: #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(pSprite->picnum,pSprite->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(pSprite->picnum,pSprite->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { t->cstat &= ~4; break; diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp index a2226d5c6..5433a8cdb 100644 --- a/source/rr/src/menus.cpp +++ b/source/rr/src/menus.cpp @@ -551,13 +551,13 @@ static MenuEntry_t ME_DISPLAYSETUP_FOV = MAKE_MENUENTRY( "FOV:", &MF_Redfont, &M static char const *MEOSN_DISPLAYSETUP_TEXFILTER[] = { "Classic", "Filtered" }; static int32_t MEOSV_DISPLAYSETUP_TEXFILTER[] = { TEXFILTER_OFF, TEXFILTER_ON }; static MenuOptionSet_t MEOS_DISPLAYSETUP_TEXFILTER = MAKE_MENUOPTIONSET( MEOSN_DISPLAYSETUP_TEXFILTER, MEOSV_DISPLAYSETUP_TEXFILTER, 0x2 ); -static MenuOption_t MEO_DISPLAYSETUP_TEXFILTER = MAKE_MENUOPTION( &MF_Redfont, &MEOS_DISPLAYSETUP_TEXFILTER, &gltexfiltermode ); +static MenuOption_t MEO_DISPLAYSETUP_TEXFILTER = MAKE_MENUOPTION( &MF_Redfont, &MEOS_DISPLAYSETUP_TEXFILTER, &hw_texfilter.Value); static MenuEntry_t ME_DISPLAYSETUP_TEXFILTER = MAKE_MENUENTRY( "Texture Mode:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_DISPLAYSETUP_TEXFILTER, Option ); static char const *MEOSN_DISPLAYSETUP_ANISOTROPY[] = { "Max", "None", "2x", "4x", "8x", "16x", }; static int32_t MEOSV_DISPLAYSETUP_ANISOTROPY[] = { 0, 1, 2, 4, 8, 16, }; static MenuOptionSet_t MEOS_DISPLAYSETUP_ANISOTROPY = MAKE_MENUOPTIONSET( MEOSN_DISPLAYSETUP_ANISOTROPY, MEOSV_DISPLAYSETUP_ANISOTROPY, 0x0 ); -static MenuOption_t MEO_DISPLAYSETUP_ANISOTROPY = MAKE_MENUOPTION(&MF_Redfont, &MEOS_DISPLAYSETUP_ANISOTROPY, &glanisotropy); +static MenuOption_t MEO_DISPLAYSETUP_ANISOTROPY = MAKE_MENUOPTION(&MF_Redfont, &MEOS_DISPLAYSETUP_ANISOTROPY, &hw_anisotropy.Value); static MenuEntry_t ME_DISPLAYSETUP_ANISOTROPY = MAKE_MENUENTRY( "Anisotropy:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_DISPLAYSETUP_ANISOTROPY, Option ); # endif @@ -984,7 +984,7 @@ static MenuEntry_t *MEL_INTERNAL_JOYSTICKAXIS_DIGITAL[] = { }; #ifdef USE_OPENGL -static MenuOption_t MEO_RENDERERSETUP_HIGHTILE = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &usehightile ); +static MenuOption_t MEO_RENDERERSETUP_HIGHTILE = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &hw_hightile.Value ); static MenuEntry_t ME_RENDERERSETUP_HIGHTILE = MAKE_MENUENTRY( "True color textures:", &MF_Bluefont, &MEF_SmallOptions, &MEO_RENDERERSETUP_HIGHTILE, Option ); static char const *MEOSN_RENDERERSETUP_TEXQUALITY [] = { "Full", "Half", "Barf", }; @@ -1000,12 +1000,12 @@ static char const *MEOSN_RENDERERSETUP_TEXCACHE[] = { "Off", "On", "Compr.", }; static MenuOptionSet_t MEOS_RENDERERSETUP_TEXCACHE = MAKE_MENUOPTIONSET( MEOSN_RENDERERSETUP_TEXCACHE, NULL, 0x2 ); # endif # ifdef USE_GLEXT -static MenuOption_t MEO_RENDERERSETUP_DETAILTEX = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &r_detailmapping ); +static MenuOption_t MEO_RENDERERSETUP_DETAILTEX = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &hw_detailmapping.Value); static MenuEntry_t ME_RENDERERSETUP_DETAILTEX = MAKE_MENUENTRY( "Detail textures:", &MF_Bluefont, &MEF_SmallOptions, &MEO_RENDERERSETUP_DETAILTEX, Option ); -static MenuOption_t MEO_RENDERERSETUP_GLOWTEX = MAKE_MENUOPTION(&MF_Bluefont, &MEOS_NoYes, &r_glowmapping); +static MenuOption_t MEO_RENDERERSETUP_GLOWTEX = MAKE_MENUOPTION(&MF_Bluefont, &MEOS_NoYes, &hw_glowmapping.Value); static MenuEntry_t ME_RENDERERSETUP_GLOWTEX = MAKE_MENUENTRY("Glow textures:", &MF_Bluefont, &MEF_SmallOptions, &MEO_RENDERERSETUP_GLOWTEX, Option); # endif -static MenuOption_t MEO_RENDERERSETUP_MODELS = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &usemodels ); +static MenuOption_t MEO_RENDERERSETUP_MODELS = MAKE_MENUOPTION( &MF_Bluefont, &MEOS_NoYes, &hw_models.Value ); static MenuEntry_t ME_RENDERERSETUP_MODELS = MAKE_MENUENTRY( "3D models:", &MF_Bluefont, &MEF_SmallOptions, &MEO_RENDERERSETUP_MODELS, Option ); #endif @@ -1991,11 +1991,11 @@ static void Menu_Pre(MenuID_t cm) if (videoGetRenderMode() != REND_CLASSIC) { - //POGOTODO: allow setting anisotropy again while r_useindexedcolortextures is set when support is added down the line - // don't allow setting anisotropy or changing palette emulation while in POLYMOST and r_useindexedcolortextures is enabled - MenuEntry_DisableOnCondition(&ME_DISPLAYSETUP_ANISOTROPY, videoGetRenderMode() == REND_POLYMOST && r_useindexedcolortextures); + //POGOTODO: allow setting anisotropy again while hw_useindexedcolortextures is set when support is added down the line + // don't allow setting anisotropy or changing palette emulation while in POLYMOST and hw_useindexedcolortextures is enabled + MenuEntry_DisableOnCondition(&ME_DISPLAYSETUP_ANISOTROPY, videoGetRenderMode() == REND_POLYMOST && hw_useindexedcolortextures); #ifdef EDUKE32_SIMPLE_MENU - MenuEntry_DisableOnCondition(&ME_DISPLAYSETUP_PALETTEEMULATION, videoGetRenderMode() == REND_POLYMOST && r_useindexedcolortextures); + MenuEntry_DisableOnCondition(&ME_DISPLAYSETUP_PALETTEEMULATION, videoGetRenderMode() == REND_POLYMOST && hw_useindexedcolortextures); #endif for (i = (int32_t) ARRAY_SIZE(MEOSV_DISPLAYSETUP_ANISOTROPY) - 1; i >= 0; --i) @@ -2011,11 +2011,11 @@ static void Menu_Pre(MenuID_t cm) case MENU_POLYMER: case MENU_POLYMOST: - MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_TEXQUALITY, !usehightile); - MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_PRECACHE, !usehightile); + MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_TEXQUALITY, !hw_hightile); + MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_PRECACHE, !hw_hightile); # ifdef USE_GLEXT - MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_DETAILTEX, !usehightile); - MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_GLOWTEX, !usehightile); + MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_DETAILTEX, !hw_hightile); + MenuEntry_DisableOnCondition(&ME_RENDERERSETUP_GLOWTEX, !hw_hightile); # endif break; #endif @@ -2030,7 +2030,7 @@ static void Menu_Pre(MenuID_t cm) MenuEntry_DisableOnCondition(&ME_VIDEOSETUP_APPLY, (xres == resolution[nr].xdim && yres == resolution[nr].ydim && videoGetRenderMode() == newrendermode && fullscreen == newfullscreen - && vsync == newvsync + && vid_vsync == newvsync ) || (newrendermode != REND_CLASSIC && resolution[nr].bppmax <= 8)); @@ -3576,7 +3576,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) { resolution_t p = { xres, yres, fullscreen, bpp, 0 }; int32_t prend = videoGetRenderMode(); - int32_t pvsync = vsync; + int32_t pvsync = vid_vsync; resolution_t n = { resolution[newresolution].xdim, resolution[newresolution].ydim, (resolution[newresolution].flags & RES_FS) ? newfullscreen : 0, @@ -3594,7 +3594,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) else { onvideomodechange(p.bppmax > 8); - vsync = videoSetVsync(pvsync); + vid_vsync = videoSetVsync(pvsync); } } else onvideomodechange(n.bppmax > 8); @@ -3602,7 +3602,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) g_restorePalette = -1; G_UpdateScreenArea(); videoSetRenderMode(nrend); - vsync = videoSetVsync(nvsync); + vid_vsync = videoSetVsync(nvsync); ud.setup.fullscreen = fullscreen; ud.setup.xdim = xres; ud.setup.ydim = yres; @@ -4571,7 +4571,7 @@ static void Menu_AboutToStartDisplaying(Menu_t * m) } newrendermode = videoGetRenderMode(); newfullscreen = fullscreen; - newvsync = vsync; + newvsync = vid_vsync; break; case MENU_ADVSOUND: diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp index c0088b958..017f630d9 100644 --- a/source/rr/src/player.cpp +++ b/source/rr/src/player.cpp @@ -1481,7 +1481,7 @@ static void G_DrawTileScaled(int drawX, int drawY, int tileNum, int drawShade, i #endif #ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST && usemodels && md_tilehasmodel(tileNum,drawPal) >= 0) + if (videoGetRenderMode() >= REND_POLYMOST && hw_models && md_tilehasmodel(tileNum,drawPal) >= 0) drawYOffset += (224<<16)-weapsc(224<<16); #endif rotatesprite(weapsc(drawX<<16) + (drawXOffset-weapsc(drawXOffset)), @@ -1513,7 +1513,7 @@ static void G_DrawWeaponTile(int weaponX, int weaponY, int weaponTile, int weapo { if (!RR && weaponTile >= CHAINGUN + 1 && weaponTile <= CHAINGUN + 4) { - if (!usemodels || md_tilehasmodel(weaponTile, weaponPal) < 0) + if (!hw_models || md_tilehasmodel(weaponTile, weaponPal) < 0) { // HACK: Draw the upper part of the chaingun two screen // pixels (not texels; multiplied by weapon scale) lower diff --git a/source/sw/src/jsector.cpp b/source/sw/src/jsector.cpp index d3175bef1..30fb946c7 100644 --- a/source/sw/src/jsector.cpp +++ b/source/sw/src/jsector.cpp @@ -1078,7 +1078,7 @@ JAnalyzeSprites(uspritetype * tspr) // Take care of autosizing DoAutoSize(tspr); - if (videoGetRenderMode() >= REND_POLYMOST && md_tilehasmodel(tspr->picnum, 0) >= 0 && usemodels) return; + if (videoGetRenderMode() >= REND_POLYMOST && md_tilehasmodel(tspr->picnum, 0) >= 0 && hw_models) return; // Check for voxels //if (bVoxelsOn) diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index cf892df56..f6e56a08a 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -4786,7 +4786,7 @@ unsigned char palette_data[256][3]; // Global palette array // V E R T I C A L R E T R A C E V A R I A B L E S ////////////////////////////////////////// -#define VGA_INPUT_STATUS_1 0x3DA // VGA status register 1, bit 3 is the vsync +#define VGA_INPUT_STATUS_1 0x3DA // VGA status register 1, bit 3 is the vid_vsync // 1 = retrace in progress // 0 = no retrace #define VGA_VSYNC_MASK 0x08 // Masks off unwanted bits of status register. @@ -4805,7 +4805,7 @@ WaitForVsync(void) while (inp(VGA_INPUT_STATUS_1) & VGA_VSYNC_MASK) ; // Retrace in progress, wait. - // Wait for vsync, and exit. + // Wait for vid_vsync, and exit. while (!inp(VGA_INPUT_STATUS_1) & VGA_VSYNC_MASK) ; }