Skip to content

Commit

Permalink
Fixed|PostFX: Clear view effects when needed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
skyjake committed Mar 28, 2015
1 parent 9ea6960 commit 517cd8b
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 7 deletions.
6 changes: 6 additions & 0 deletions doomsday/apps/api/api_gl.h
Expand Up @@ -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);

Expand Down Expand Up @@ -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__
Expand Down
3 changes: 2 additions & 1 deletion doomsday/apps/api/apis.h
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions doomsday/apps/client/src/client/cl_main.cpp
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -1487,7 +1487,7 @@ bool App_ChangeGame(Game &game, bool allowReload)
Rend_ParticleLoadSystemTextures();
}

GL_SetFilter(false);
GL_ResetViewEffects();

if(!game.isNull())
{
Expand Down
4 changes: 3 additions & 1 deletion doomsday/apps/client/src/gl/dgl_common.cpp
Expand Up @@ -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) =
{
Expand Down Expand Up @@ -1005,5 +1006,6 @@ DENG_DECLARE_API(GL) =
GL_ConfigureBorderedProjection2,
GL_ConfigureBorderedProjection,
GL_BeginBorderedProjection,
GL_EndBorderedProjection
GL_EndBorderedProjection,
GL_ResetViewEffects
};
8 changes: 8 additions & 0 deletions doomsday/apps/client/src/gl/gl_draw.cpp
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/plugins/common/src/d_netcl.cpp
Expand Up @@ -647,7 +647,7 @@ void NetCl_Intermission(reader_s *msg)
ST_CloseAll(i, true/*fast*/);
}

GL_SetFilter(false);
GL_ResetViewEffects();

#if __JHEXEN__
SN_StopAllSequences();
Expand Down
3 changes: 2 additions & 1 deletion doomsday/apps/plugins/common/src/g_game.cpp
Expand Up @@ -1405,7 +1405,7 @@ static void runGameAction()

if(!IS_DEDICATED)
{
GL_SetFilter(false);
GL_ResetViewEffects();
}

// Go to an intermission?
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions doomsday/apps/plugins/common/src/gamesession.cpp
Expand Up @@ -29,6 +29,7 @@
#include <de/game/SavedSession>
#include <doomsday/defs/episode.h>
#include "acs/system.h"
#include "api_gl.h"
#include "d_netsv.h"
#include "g_common.h"
#include "g_game.h"
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 517cd8b

Please sign in to comment.