Skip to content

Commit

Permalink
Refactor|libcommon: Unified view port drawing, moved crosshair to HUD…
Browse files Browse the repository at this point in the history
… layer

Also, in Oculus Rift mode, don’t assume that automap covers the full
view.
  • Loading branch information
skyjake committed Nov 12, 2013
1 parent d0953e9 commit d1ad10f
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 58 deletions.
3 changes: 3 additions & 0 deletions doomsday/plugins/common/include/r_common.h
Expand Up @@ -72,6 +72,9 @@ void R_CycleGammaLevel(void);

void R_StatusBarSize(int player, Size2Raw *statusBarSize);

void G_DrawViewPort(int port, RectRaw const *portGeometry,
RectRaw const *windowGeometry, int player, int layer);

#ifdef __cplusplus
} // extern "C"
#endif
Expand Down
69 changes: 69 additions & 0 deletions doomsday/plugins/common/src/r_common.c
Expand Up @@ -46,6 +46,7 @@
#include "p_player.h"
#include "g_common.h"
#include "g_controls.h"
#include "x_hair.h"

#include "r_common.h"

Expand Down Expand Up @@ -292,3 +293,71 @@ void R_UpdateConsoleView(int player)
R_SetViewAngle(player, mo->angle + (int) (ANGLE_MAX * -G_GetLookOffset(player)));
R_SetViewPitch(player, plr->plr->lookDir);
}

static void rendHUD(int player, const RectRaw* portGeometry)
{
if(player < 0 || player >= MAXPLAYERS) return;
if(G_GameState() != GS_MAP) return;
if(IS_CLIENT && (!Get(DD_GAME_READY) || !Get(DD_GOTFRAME))) return;
if(!DD_GetInteger(DD_GAME_DRAW_HUD_HINT)) return; // The engine advises not to draw any HUD displays.

ST_Drawer(player);
HU_DrawScoreBoard(player);
Hu_MapTitleDrawer(portGeometry);
}

void G_DrawViewPort(int port, RectRaw const *portGeometry,
RectRaw const *windowGeometry, int player, int layer)
{
switch(G_GameState())
{
case GS_MAP: {
player_t* plr = players + player;
boolean isAutomapObscuring = ST_AutomapObscures2(player, windowGeometry);

if(IS_CLIENT && (!Get(DD_GAME_READY) || !Get(DD_GOTFRAME)))
return;

if(Con_GetInteger("rend-vr-mode") == 9) // Oculus Rift mode
{
// Automap will not cover the full view.
isAutomapObscuring = false;
}

switch(layer)
{
case 0: // Primary layer (3D view).
if(!isAutomapObscuring)
{
G_RendPlayerView(player);
#ifndef __JHEXEN__
G_RendSpecialFilter(player, windowGeometry);
#endif
}
break;

default: // HUD layer.
// Crosshair.
if(!isAutomapObscuring && !(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) // $democam
{
X_Drawer(player);
}

// Other HUD elements.
rendHUD(player, portGeometry);
break;
}
break; }

case GS_STARTUP:
if(layer == 0)
{
DGL_DrawRectf2Color(0, 0, portGeometry->size.width, portGeometry->size.height,
0, 0, 0, 1);
}
break;

default:
break;
}
}
3 changes: 3 additions & 0 deletions doomsday/plugins/doom/include/d_refresh.h
Expand Up @@ -36,6 +36,9 @@ DENG_EXTERN_C float quitDarkenOpacity;
extern "C" {
#endif

void G_RendPlayerView(int player);
void G_RendSpecialFilter(int player, RectRaw const *region);

void D_DrawViewPort(int port, const RectRaw* portGeometry, const RectRaw* windowGeometry, int player, int layer);
void D_DrawWindow(const Size2Raw* windowSize);
void D_EndFrame(void);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/doom/src/d_api.c
Expand Up @@ -215,7 +215,7 @@ game_export_t* GetGameAPI(void)
gx.Shutdown = D_Shutdown;
gx.TryShutdown = G_TryShutdown;
gx.Ticker = G_Ticker;
gx.DrawViewPort = D_DrawViewPort;
gx.DrawViewPort = G_DrawViewPort;
gx.DrawWindow = D_DrawWindow;
gx.FinaleResponder = FI_PrivilegedResponder;
gx.PrivilegedResponder = G_PrivilegedResponder;
Expand Down
51 changes: 2 additions & 49 deletions doomsday/plugins/doom/src/d_refresh.c
Expand Up @@ -47,7 +47,7 @@ float quitDarkenOpacity = 0;
* Draws a special filter over the screen (e.g. the inversing filter used
* when in god mode).
*/
static void rendSpecialFilter(int player, const RectRaw* region)
void G_RendSpecialFilter(int player, const RectRaw* region)
{
player_t* plr = players + player;
float max = 30, str, r, g, b;
Expand Down Expand Up @@ -242,7 +242,7 @@ void R_UpdateViewFilter(int player)
#undef RADIATIONPAL
}

static void rendPlayerView(int player)
void G_RendPlayerView(int player)
{
player_t* plr = &players[player];
float pspriteOffsetY;
Expand Down Expand Up @@ -274,53 +274,6 @@ static void rendPlayerView(int player)
R_RenderPlayerView(player);
}

static void rendHUD(int player, const RectRaw* portGeometry)
{
if(player < 0 || player >= MAXPLAYERS) return;
if(G_GameState() != GS_MAP) return;
if(IS_CLIENT && (!Get(DD_GAME_READY) || !Get(DD_GOTFRAME))) return;
if(!DD_GetInteger(DD_GAME_DRAW_HUD_HINT)) return; // The engine advises not to draw any HUD displays.

ST_Drawer(player);
HU_DrawScoreBoard(player);
Hu_MapTitleDrawer(portGeometry);
}

void D_DrawViewPort(int port, const RectRaw* portGeometry,
const RectRaw* windowGeometry, int player, int layer)
{
if(layer != 0)
{
rendHUD(player, portGeometry);
return;
}

switch(G_GameState())
{
case GS_MAP: {
player_t* plr = players + player;

if(!ST_AutomapObscures2(player, windowGeometry))
{
if(IS_CLIENT && (!Get(DD_GAME_READY) || !Get(DD_GOTFRAME))) return;

rendPlayerView(player);
rendSpecialFilter(player, windowGeometry);

// Crosshair.
if(!(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) // $democam
X_Drawer(player);
}
break;
}
case GS_STARTUP:
DGL_DrawRectf2Color(0, 0, portGeometry->size.width, portGeometry->size.height, 0, 0, 0, 1);
break;

default: break;
}
}

void D_DrawWindow(const Size2Raw* windowSize)
{
if(G_GameState() == GS_INTERMISSION)
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/doom64/include/d_refresh.h
Expand Up @@ -37,6 +37,9 @@ DENG_EXTERN_C float quitDarkenOpacity;
extern "C" {
#endif

void G_RendPlayerView(int player);
void G_RendSpecialFilter(int player, RectRaw const *region);

void D_DrawViewPort(int port, const RectRaw* portGeometry, const RectRaw* windowGeometry, int player, int layer);
void D_DrawWindow(const Size2Raw* windowSize);
void D_EndFrame(void);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/doom64/src/d_api.c
Expand Up @@ -144,7 +144,7 @@ game_export_t* GetGameAPI(void)
gx.Shutdown = D_Shutdown;
gx.TryShutdown = G_TryShutdown;
gx.Ticker = G_Ticker;
gx.DrawViewPort = D_DrawViewPort;
gx.DrawViewPort = G_DrawViewPort;
gx.DrawWindow = D_DrawWindow;
gx.FinaleResponder = FI_PrivilegedResponder;
gx.PrivilegedResponder = G_PrivilegedResponder;
Expand Down
6 changes: 4 additions & 2 deletions doomsday/plugins/doom64/src/d_refresh.c
Expand Up @@ -76,7 +76,7 @@ float quitDarkenOpacity = 0;
* Draws a special filter over the screen (eg the inversing filter used
* when in god mode).
*/
static void rendSpecialFilter(int player, const RectRaw* region)
void G_RendSpecialFilter(int player, const RectRaw* region)
{
player_t* plr = players + player;
const int filter = plr->powers[PT_INVULNERABILITY];
Expand Down Expand Up @@ -211,7 +211,7 @@ void R_UpdateViewFilter(int player)
#undef RADIATIONPAL
}

static void rendPlayerView(int player)
void G_RendPlayerView(int player)
{
player_t* plr = &players[player];
float pspriteOffsetY;
Expand Down Expand Up @@ -243,6 +243,7 @@ static void rendPlayerView(int player)
R_RenderPlayerView(player);
}

#if 0
static void rendHUD(int player, const RectRaw* portGeometry)
{
if(player < 0 || player >= MAXPLAYERS) return;
Expand Down Expand Up @@ -289,6 +290,7 @@ void D_DrawViewPort(int port, const RectRaw* portGeometry,
default: break;
}
}
#endif

void D_DrawWindow(const Size2Raw* windowSize)
{
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/heretic/include/h_refresh.h
Expand Up @@ -37,6 +37,9 @@ DENG_EXTERN_C float quitDarkenOpacity;
extern "C" {
#endif

void G_RendPlayerView(int player);
void G_RendSpecialFilter(int player, RectRaw const *region);

void H_DrawViewPort(int port, const RectRaw* portGeometry, const RectRaw* windowGeometry, int player, int layer);
void H_DrawWindow(const Size2Raw* windowSize);
void H_EndFrame(void);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/heretic/src/h_api.c
Expand Up @@ -168,7 +168,7 @@ game_export_t* GetGameAPI(void)
gx.TryShutdown = G_TryShutdown;
gx.Shutdown = H_Shutdown;
gx.Ticker = G_Ticker;
gx.DrawViewPort = H_DrawViewPort;
gx.DrawViewPort = G_DrawViewPort;
gx.DrawWindow = H_DrawWindow;
gx.FinaleResponder = FI_PrivilegedResponder;
gx.PrivilegedResponder = G_PrivilegedResponder;
Expand Down
6 changes: 4 additions & 2 deletions doomsday/plugins/heretic/src/h_refresh.c
Expand Up @@ -55,7 +55,7 @@ float quitDarkenOpacity = 0;
/**
* Draws a special filter over the screen.
*/
static void rendSpecialFilter(int player, const RectRaw* region)
void G_RendSpecialFilter(int player, const RectRaw* region)
{
player_t* plr = players + player;
const struct filter_s {
Expand Down Expand Up @@ -162,7 +162,7 @@ void R_UpdateViewFilter(int player)
}
}

static void rendPlayerView(int player)
void G_RendPlayerView(int player)
{
player_t* plr = &players[player];
float pspriteOffsetY;
Expand Down Expand Up @@ -193,6 +193,7 @@ static void rendPlayerView(int player)
R_RenderPlayerView(player);
}

#if 0
static void rendHUD(int player, const RectRaw* portGeometry)
{
if(player < 0 || player >= MAXPLAYERS) return;
Expand Down Expand Up @@ -239,6 +240,7 @@ void H_DrawViewPort(int port, const RectRaw* portGeometry,
default: break;
}
}
#endif

void H_DrawWindow(const Size2Raw* windowSize)
{
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/hexen/include/x_refresh.h
Expand Up @@ -36,6 +36,8 @@ DENG_EXTERN_C float quitDarkenOpacity;
extern "C" {
#endif

void G_RendPlayerView(int player);

void X_DrawViewPort(int port, const RectRaw* portGeometry, const RectRaw* windowGeometry, int player, int layer);
void X_DrawWindow(const Size2Raw* windowSize);
void X_EndFrame(void);
Expand Down
4 changes: 3 additions & 1 deletion doomsday/plugins/hexen/src/hrefresh.c
Expand Up @@ -178,7 +178,7 @@ void R_UpdateViewFilter(int player)
}
}

static void rendPlayerView(int player)
void G_RendPlayerView(int player)
{
player_t* plr = &players[player];
boolean special200 = false;
Expand Down Expand Up @@ -226,6 +226,7 @@ static void rendPlayerView(int player)
}
}

#if 0
static void rendHUD(int player, const RectRaw* portGeometry)
{
if(player < 0 || player >= MAXPLAYERS) return;
Expand Down Expand Up @@ -271,6 +272,7 @@ void X_DrawViewPort(int port, const RectRaw* portGeometry,
default: break;
}
}
#endif

void X_DrawWindow(const Size2Raw* windowSize)
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/hexen/src/x_api.c
Expand Up @@ -188,7 +188,7 @@ game_export_t* GetGameAPI(void)
gx.TryShutdown = G_TryShutdown;
gx.Shutdown = X_Shutdown;
gx.Ticker = G_Ticker;
gx.DrawViewPort = X_DrawViewPort;
gx.DrawViewPort = G_DrawViewPort;
gx.DrawWindow = X_DrawWindow;
gx.FinaleResponder = FI_PrivilegedResponder;
gx.PrivilegedResponder = G_PrivilegedResponder;
Expand Down

0 comments on commit d1ad10f

Please sign in to comment.