From 084c661fa064e30122d8bc131ebd18b618093716 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 12 Dec 2017 05:13:38 +0000 Subject: [PATCH] New def tokens for "cutscene": "texturefilter", "forcefilter", "forcenofilter" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes the filtering for cutscenes. By default, ANMs are unfiltered and IVFs filtered regardless of the filtering option in the menu. Use “texturefilter” to use the same filtering as textures, “forcenofilter” to never use filtering and “forcefilter” to always use filtering. cutscene { texturefilter } Patch from Fox. git-svn-id: https://svn.eduke32.com/eduke32@6552 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/animvpx.h | 2 +- source/build/include/build.h | 6 ++++++ source/build/src/animvpx.cpp | 15 ++++++++++++--- source/duke3d/src/anim.cpp | 12 ++++++++++-- source/duke3d/src/anim.h | 1 + source/duke3d/src/game.cpp | 16 ++++++++++++++++ 6 files changed, 46 insertions(+), 6 deletions(-) diff --git a/source/build/include/animvpx.h b/source/build/include/animvpx.h index 08440beb1..22bcfcd95 100644 --- a/source/build/include/animvpx.h +++ b/source/build/include/animvpx.h @@ -83,7 +83,7 @@ int32_t animvpx_uninit_codec(animvpx_codec_ctx *codec); extern const char *animvpx_nextpic_errmsg[8]; int32_t animvpx_nextpic(animvpx_codec_ctx *codec, uint8_t **pic); -void animvpx_setup_glstate(void); +void animvpx_setup_glstate(int32_t animvpx_flags); void animvpx_restore_glstate(void); int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect); diff --git a/source/build/include/build.h b/source/build/include/build.h index 56bae5a44..b2af53c12 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1291,6 +1291,12 @@ enum { TEXFILTER_ON = 5, // GL_LINEAR_MIPMAP_LINEAR }; +enum cutsceneflags { + CUTSCENE_FORCEFILTER = 1, + CUTSCENE_FORCENOFILTER = 2, + CUTSCENE_TEXTUREFILTER = 4, +}; + extern int32_t glusetexcache, glusememcache; extern int32_t glmultisample, glnvmultisamplehint; extern int32_t glprojectionhacks; diff --git a/source/build/src/animvpx.cpp b/source/build/src/animvpx.cpp index 4038c9c27..bbf1a1c95 100644 --- a/source/build/src/animvpx.cpp +++ b/source/build/src/animvpx.cpp @@ -400,7 +400,7 @@ static const char *fragprog_src = "}\n"; #endif -void animvpx_setup_glstate(void) +void animvpx_setup_glstate(int32_t animvpx_flags) { #ifdef USE_GLEXT if (glinfo.glsl) @@ -467,8 +467,17 @@ void animvpx_setup_glstate(void) bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); - bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + if ((animvpx_flags & CUTSCENE_TEXTUREFILTER && gltexfiltermode == TEXFILTER_ON) || animvpx_flags & CUTSCENE_FORCEFILTER || + (!(animvpx_flags & CUTSCENE_TEXTUREFILTER) && !(animvpx_flags & CUTSCENE_FORCENOFILTER))) // if no flags, then use filter for IVFs + { + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } + else + { + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } texuploaded = 0; //////////////////// diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index 46890e6f8..c64798b90 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -216,6 +216,8 @@ void Anim_Init(void) } anim->numsounds = numsounds; } + + anim->frameflags = 0; } } @@ -282,7 +284,10 @@ int32_t Anim_Play(const char *fn) return 0; } - animvpx_setup_glstate(); + if (anim) + animvpx_setup_glstate(anim->frameflags); + else + animvpx_setup_glstate(origanim->frameflags); animvpx_codec_ctx codec; @@ -463,7 +468,10 @@ int32_t Anim_Play(const char *fn) P_SetGamePalette(g_player[myconnectindex].ps, ANIMPAL, 8 + 2); #ifdef USE_OPENGL - gltexfiltermode = 0; + if ((anim->frameflags & CUTSCENE_TEXTUREFILTER && gltexfiltermode == TEXFILTER_ON) || anim->frameflags & CUTSCENE_FORCEFILTER) + gltexfiltermode = TEXFILTER_ON; + else + gltexfiltermode = TEXFILTER_OFF; gltexapplyprops(); #endif diff --git a/source/duke3d/src/anim.h b/source/duke3d/src/anim.h index e319ea6fa..63a141c71 100644 --- a/source/duke3d/src/anim.h +++ b/source/duke3d/src/anim.h @@ -35,6 +35,7 @@ typedef struct animsound_t *sounds; uint16_t numsounds; uint8_t framedelay; + uint8_t frameflags; char animlock; } dukeanim_t; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 4f3e8cf3a..6f9b817d3 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -173,6 +173,9 @@ enum gametokens T_RENAMEFILE, T_GLOBALGAMEFLAGS, T_ASPECT, + T_FORCEFILTER, + T_FORCENOFILTER, + T_TEXTUREFILTER, }; void G_HandleSpecialKeys(void) @@ -5194,6 +5197,9 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) { "delay", T_DELAY }, { "aspect", T_ASPECT }, { "sounds", T_SOUND }, + { "forcefilter", T_FORCEFILTER }, + { "forcenofilter", T_FORCENOFILTER }, + { "texturefilter", T_TEXTUREFILTER }, }; do @@ -5308,6 +5314,7 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) { animPtr = Anim_Create(fileName); animPtr->framedelay = 10; + animPtr->frameflags = 0; } int32_t temp; @@ -5337,6 +5344,15 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) parsedefinitions_game_animsounds(pScript, animSoundsEnd, fileName, animPtr); break; } + case T_FORCEFILTER: + animPtr->frameflags |= CUTSCENE_FORCEFILTER; + break; + case T_FORCENOFILTER: + animPtr->frameflags |= CUTSCENE_FORCENOFILTER; + break; + case T_TEXTUREFILTER: + animPtr->frameflags |= CUTSCENE_TEXTUREFILTER; + break; } } }