Skip to content

Commit

Permalink
Fixed|Client|InFine: Finale/intermission stretch scaling, HOM around …
Browse files Browse the repository at this point in the history
…view

This commit addresses various issues related to stretch scaling:

- "rend-finale-stretch" was not being applied at all, presumably due
  to the unfinished UI2/InFine refactoring. Now that the UI2 drawer
  is exclusively used for drawing InFine (with the old engine UI gone),
  we can just apply a bordered projection there and not worry about
  what kind of UI page is actually being drawn.

- Scissor was not disabled immediately after ending a bordered
  projection, meaning that a mask applied at the time would not
  be visible.

- Color buffer clearing is needed if there are finales to draw that
  aren't stretched.

IssueID #1719
  • Loading branch information
skyjake committed Apr 22, 2014
1 parent 37db819 commit 3abc509
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 7 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/include/ui/fi_main.h
Expand Up @@ -36,6 +36,8 @@ void FI_Shutdown(void);

void FI_Ticker(void);

scalemode_t FI_ScaleMode();

#ifdef __cplusplus
} // extern "C"
#endif
Expand Down
8 changes: 8 additions & 0 deletions doomsday/client/include/ui/ui2_main.h
Expand Up @@ -40,6 +40,14 @@ void UI_Shutdown(void);
void UI2_Ticker(timespan_t ticLength);
void UI2_Drawer(void);

int UI_PageCount();

/**
* Determines if the currently running InFine script is drawn stretched over the
* entire view.
*/
bool FI_IsStretchedToView();

#ifdef __cplusplus
} // extern "C"
#endif
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/gl/gl_draw.cpp
Expand Up @@ -442,7 +442,7 @@ DENG_EXTERN_C void GL_EndBorderedProjection(dgl_borderedprojectionstate_t* bp)
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

GLState::pop();
GLState::pop().apply();

glMatrixMode(GL_MODELVIEW);
glPopMatrix();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/viewports.cpp
Expand Up @@ -981,7 +981,7 @@ static void clearViewPorts()
{
GLbitfield bits = GL_DEPTH_BUFFER_BIT;

if(fx::Bloom::isEnabled())
if(fx::Bloom::isEnabled() || (UI_PageCount() > 0 && !FI_IsStretchedToView()))
{
/*
* Parts of the previous frame might leak in the bloom unless we clear the color
Expand Down
7 changes: 6 additions & 1 deletion doomsday/client/src/ui/fi_main.cpp
Expand Up @@ -89,7 +89,12 @@ static byte scaleMode = SCALEMODE_SMART_STRETCH;

void FI_Register(void)
{
C_VAR_BYTE("rend-finale-stretch", &scaleMode, 0, SCALEMODE_FIRST, SCALEMODE_LAST);
C_VAR_BYTE("rend-finale-stretch", &scaleMode, 0, SCALEMODE_FIRST, SCALEMODE_LAST);
}

scalemode_t FI_ScaleMode()
{
return scalemode_t(scaleMode);
}

static finale_t* finalesById(finaleid_t id)
Expand Down
35 changes: 32 additions & 3 deletions doomsday/client/src/ui/ui2_main.cpp
Expand Up @@ -36,8 +36,8 @@

#ifdef __CLIENT__
# include "MaterialSnapshot"

# include "gl/gl_texmanager.h"
# include "ui/clientwindow.h"
#endif

using namespace de;
Expand Down Expand Up @@ -328,6 +328,11 @@ void UI_Shutdown(void)
inited = false;
}

int UI_PageCount()
{
return numPages;
}

void UI2_Ticker(timespan_t ticLength)
{
#ifdef __CLIENT__
Expand Down Expand Up @@ -833,9 +838,28 @@ static void setupModelParamsForFIObject(rendmodelparams_t *params,
}
#endif

#ifdef __CLIENT__

static void setupProjectionForFinale(dgl_borderedprojectionstate_t *bp)
{
GL_ConfigureBorderedProjection(bp, BPF_OVERDRAW_CLIP,
SCREENWIDTH, SCREENHEIGHT,
DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT,
FI_ScaleMode());
}

bool FI_IsStretchedToView()
{
dgl_borderedprojectionstate_t bp;
setupProjectionForFinale(&bp);
return (bp.scaleMode == SCALEMODE_STRETCH);
}

void UI2_Drawer(void)
{
//borderedprojectionstate_t borderedProjection;
if(!numPages) return;

dgl_borderedprojectionstate_t bp;
//dd_bool bordered;

LOG_AS("UI2_Drawer");
Expand All @@ -845,7 +869,9 @@ void UI2_Drawer(void)
return;
}

/// @todo need to refactor.
setupProjectionForFinale(&bp);
GL_BeginBorderedProjection(&bp);

/*bordered = (FI_ScriptActive() && FI_ScriptCmdExecuted());
if(bordered)
{
Expand All @@ -860,9 +886,12 @@ void UI2_Drawer(void)
page->drawer(page);
}

GL_EndBorderedProjection(&bp);

//if(bordered)
// GL_EndBorderedProjection(&borderedProjection);
}
#endif

void FIData_PicThink(fi_object_t *obj)
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/doom/src/wi_stuff.c
Expand Up @@ -1374,7 +1374,7 @@ void WI_Drawer(void)
}
/// kludge end.

GL_ConfigureBorderedProjection(&bp, BPF_OVERDRAW_MASK|BPF_OVERDRAW_CLIP,
GL_ConfigureBorderedProjection(&bp, BPF_OVERDRAW_MASK | BPF_OVERDRAW_CLIP,
SCREENWIDTH, SCREENHEIGHT, Get(DD_WINDOW_WIDTH), Get(DD_WINDOW_HEIGHT), cfg.inludeScaleMode);
GL_BeginBorderedProjection(&bp);

Expand Down

0 comments on commit 3abc509

Please sign in to comment.