From 517cd8b8a2383e4b2f4fe70c54f43fb29b97dc73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sat, 28 Mar 2015 13:09:47 +0200 Subject: [PATCH] Fixed|PostFX: Clear view effects when needed The PostFX shader was not being reset when a game was unloaded, or when a savegame was loaded. The public GL API was bumped with a new function for reseting all view effects (color filter, post-processing shader, full bright flag). IssueID #2004 --- doomsday/apps/api/api_gl.h | 6 ++++++ doomsday/apps/api/apis.h | 3 ++- doomsday/apps/client/src/client/cl_main.cpp | 3 +-- doomsday/apps/client/src/dd_main.cpp | 2 +- doomsday/apps/client/src/gl/dgl_common.cpp | 4 +++- doomsday/apps/client/src/gl/gl_draw.cpp | 8 ++++++++ doomsday/apps/plugins/common/src/d_netcl.cpp | 2 +- doomsday/apps/plugins/common/src/g_game.cpp | 3 ++- doomsday/apps/plugins/common/src/gamesession.cpp | 7 +++++++ 9 files changed, 31 insertions(+), 7 deletions(-) diff --git a/doomsday/apps/api/api_gl.h b/doomsday/apps/api/api_gl.h index a417710572..22f4abfb0a 100644 --- a/doomsday/apps/api/api_gl.h +++ b/doomsday/apps/api/api_gl.h @@ -338,6 +338,11 @@ DENG_API_TYPEDEF(GL) void (*ConfigureBorderedProjection)(dgl_borderedprojectionstate_t* bp, int flags, int width, int height, int availWidth, int availHeight, scalemode_t overrideMode); void (*BeginBorderedProjection)(dgl_borderedprojectionstate_t* bp); void (*EndBorderedProjection)(dgl_borderedprojectionstate_t* bp); + + /** + * Disable the color filter and clear PostFX (for consoleplayer). + */ + void (*ResetViewEffects)(); } DENG_API_T(GL); @@ -415,6 +420,7 @@ DENG_API_T(GL); #define GL_ConfigureBorderedProjection _api_GL.ConfigureBorderedProjection #define GL_BeginBorderedProjection _api_GL.BeginBorderedProjection #define GL_EndBorderedProjection _api_GL.EndBorderedProjection +#define GL_ResetViewEffects _api_GL.ResetViewEffects #endif #if defined __DOOMSDAY__ && defined __CLIENT__ diff --git a/doomsday/apps/api/apis.h b/doomsday/apps/api/apis.h index d01c7f9d87..7238a763e1 100644 --- a/doomsday/apps/api/apis.h +++ b/doomsday/apps/api/apis.h @@ -100,7 +100,8 @@ enum { DE_API_GL_v1 = 800, // 1.10 DE_API_GL_v2 = 801, // 1.13 - DE_API_GL = DE_API_GL_v2, + DE_API_GL_v3 = 802, // 1.15 + DE_API_GL = DE_API_GL_v3, DE_API_INFINE_v1 = 900, // 1.10 DE_API_INFINE = DE_API_INFINE_v1, diff --git a/doomsday/apps/client/src/client/cl_main.cpp b/doomsday/apps/client/src/client/cl_main.cpp index 0b897294fa..24ac663682 100644 --- a/doomsday/apps/client/src/client/cl_main.cpp +++ b/doomsday/apps/client/src/client/cl_main.cpp @@ -108,8 +108,7 @@ void Cl_CleanUp() Cl_ResetTransTables(); // Reset any view effects. - GL_SetFilter(false); - Con_Executef(CMDS_DDAY, true, "postfx %i none", consolePlayer); + GL_ResetViewEffects(); // Forget all packets we've received but haven't yet handled. N_ClearMessages(); diff --git a/doomsday/apps/client/src/dd_main.cpp b/doomsday/apps/client/src/dd_main.cpp index 4bd5ad3524..8ba419ba21 100644 --- a/doomsday/apps/client/src/dd_main.cpp +++ b/doomsday/apps/client/src/dd_main.cpp @@ -1487,7 +1487,7 @@ bool App_ChangeGame(Game &game, bool allowReload) Rend_ParticleLoadSystemTextures(); } - GL_SetFilter(false); + GL_ResetViewEffects(); if(!game.isNull()) { diff --git a/doomsday/apps/client/src/gl/dgl_common.cpp b/doomsday/apps/client/src/gl/dgl_common.cpp index dbea87cab1..17ede5ad10 100644 --- a/doomsday/apps/client/src/gl/dgl_common.cpp +++ b/doomsday/apps/client/src/gl/dgl_common.cpp @@ -929,6 +929,7 @@ DENG_EXTERN_C void GL_ConfigureBorderedProjection2(dgl_borderedprojectionstate_t DENG_EXTERN_C void GL_ConfigureBorderedProjection(dgl_borderedprojectionstate_t* bp, int flags, int width, int height, int availWidth, int availHeight, scalemode_t overrideMode); DENG_EXTERN_C void GL_BeginBorderedProjection(dgl_borderedprojectionstate_t* bp); DENG_EXTERN_C void GL_EndBorderedProjection(dgl_borderedprojectionstate_t* bp); +DENG_EXTERN_C void GL_ResetViewEffects(); DENG_DECLARE_API(GL) = { @@ -1005,5 +1006,6 @@ DENG_DECLARE_API(GL) = GL_ConfigureBorderedProjection2, GL_ConfigureBorderedProjection, GL_BeginBorderedProjection, - GL_EndBorderedProjection + GL_EndBorderedProjection, + GL_ResetViewEffects }; diff --git a/doomsday/apps/client/src/gl/gl_draw.cpp b/doomsday/apps/client/src/gl/gl_draw.cpp index 4aeb629ac0..3aae737fda 100644 --- a/doomsday/apps/client/src/gl/gl_draw.cpp +++ b/doomsday/apps/client/src/gl/gl_draw.cpp @@ -300,6 +300,14 @@ DENG_EXTERN_C void GL_SetFilter(dd_bool enabled) drawFilter = CPP_BOOL(enabled); } +#undef GL_ResetViewEffects +DENG_EXTERN_C void GL_ResetViewEffects() +{ + GL_SetFilter(false); + Con_Executef(CMDS_DDAY, true, "postfx %i none", consolePlayer); + DD_SetInteger(DD_FULLBRIGHT, false); +} + #undef GL_SetFilterColor DENG_EXTERN_C void GL_SetFilterColor(float r, float g, float b, float a) { diff --git a/doomsday/apps/plugins/common/src/d_netcl.cpp b/doomsday/apps/plugins/common/src/d_netcl.cpp index 8fcbb0ae9d..c899248bc6 100644 --- a/doomsday/apps/plugins/common/src/d_netcl.cpp +++ b/doomsday/apps/plugins/common/src/d_netcl.cpp @@ -647,7 +647,7 @@ void NetCl_Intermission(reader_s *msg) ST_CloseAll(i, true/*fast*/); } - GL_SetFilter(false); + GL_ResetViewEffects(); #if __JHEXEN__ SN_StopAllSequences(); diff --git a/doomsday/apps/plugins/common/src/g_game.cpp b/doomsday/apps/plugins/common/src/g_game.cpp index 85f6995410..83bdf5c07e 100644 --- a/doomsday/apps/plugins/common/src/g_game.cpp +++ b/doomsday/apps/plugins/common/src/g_game.cpp @@ -1405,7 +1405,7 @@ static void runGameAction() if(!IS_DEDICATED) { - GL_SetFilter(false); + GL_ResetViewEffects(); } // Go to an intermission? @@ -2358,6 +2358,7 @@ D_CMD(LoadSession) if(Hu_IsMessageActive()) return false; S_LocalSound(SFX_QUICKLOAD_PROMPT, nullptr); + // Compose the confirmation message. String const &existingDescription = COMMON_GAMESESSION->savedUserDescription(sslot->saveName()); AutoStr *msg = Str_Appendf(AutoStr_NewStd(), QLPROMPT, diff --git a/doomsday/apps/plugins/common/src/gamesession.cpp b/doomsday/apps/plugins/common/src/gamesession.cpp index 408a810718..d70fb67557 100644 --- a/doomsday/apps/plugins/common/src/gamesession.cpp +++ b/doomsday/apps/plugins/common/src/gamesession.cpp @@ -29,6 +29,7 @@ #include #include #include "acs/system.h" +#include "api_gl.h" #include "d_netsv.h" #include "g_common.h" #include "g_game.h" @@ -1013,9 +1014,15 @@ void GameSession::end() { if(!hasBegun()) return; + // Reset state of relevant subsystems. #if __JHEXEN__ Game_ACScriptSystem().reset(); #endif + if(!IS_DEDICATED) + { + GL_ResetViewEffects(); + } + Session::removeSaved(internalSavePath); d->inProgress = false;