Skip to content

Commit

Permalink
Slightly reorganised the view drawing order so that when the player v…
Browse files Browse the repository at this point in the history
…iew is completely hidden (e.g. if the automap is fullscreen an opaque) the view border is still drawn. Also fixed a very minor issue with the view border not being drawn during the first few frames in a net game.

The automap now considers it's parent window to be the player view window and not the viewport.
  • Loading branch information
danij committed May 24, 2007
1 parent d7e099e commit c9a1d5d
Show file tree
Hide file tree
Showing 16 changed files with 277 additions and 196 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/dd_api.h
Expand Up @@ -96,7 +96,7 @@ typedef struct {
void (*BeginFrame) (void);
void (*EndFrame) (void);
void (*G_Drawer) (void);
void (*MN_Drawer) (void);
void (*G_Drawer2) (void);
void (*ConsoleBackground) (int *width, int *height);
void (*R_Init) (void);

Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/r_main.h
Expand Up @@ -56,6 +56,7 @@ void R_Update(void);
void R_Shutdown(void);
void R_SetupWorldFrame(void);
void R_RenderPlayerView(ddplayer_t *player);
void R_RenderPlayerViewBorder(void);
void R_ResetViewer(void);
void R_ViewWindow(int x, int y, int w, int h);
void R_NewSharpWorld(void);
Expand Down
13 changes: 8 additions & 5 deletions doomsday/engine/portable/src/dd_loop.c
Expand Up @@ -191,14 +191,17 @@ void DD_DrawAndBlit(void)
// Update the world ready for drawing view(s) of it.
R_SetupWorldFrame();

// Draw the game graphics.
// Draw in-window game graphics.
gx.G_Drawer();

// Menu is not drawn if the UI fading is in effect.
if(!UI_IsActive() || UI_Alpha() >= 1.0)
// Draw the view border.
R_RenderPlayerViewBorder();

// Draw any over/outside view window game graphics (e.g. fullscreen
// menus and other displays).
if(gx.G_Drawer2 && (!UI_IsActive() || UI_Alpha() >= 1.0))
{
// Draw Menu
gx.MN_Drawer();
gx.G_Drawer2();
}

// Restore the projection mode that was previously in effect.
Expand Down
44 changes: 25 additions & 19 deletions doomsday/engine/portable/src/r_main.c
Expand Up @@ -573,6 +573,29 @@ void R_SetupFrame(ddplayer_t *player)
M_CrossProduct(viewfrontvec, viewupvec, viewsidevec);
}

/**
* Draw the border around the view window.
*/
void R_RenderPlayerViewBorder(void)
{
// View border?
if(BorderNeedRefresh)
{
R_DrawViewBorder();
BorderNeedRefresh = false;
BorderTopRefresh = false;
UpdateState |= I_FULLSCRN;
}
else if(BorderTopRefresh)
{
if(viewwindowx > 0)
R_DrawTopBorder();

BorderTopRefresh = false;
UpdateState |= I_MESSAGES;
}
}

/**
* Draw the view of the player inside the view window.
*/
Expand Down Expand Up @@ -651,31 +674,14 @@ void R_RenderPlayerView(ddplayer_t *player)
Con_Printf("Tris: %-4i (Mdl=%-4i)\n", i, modelTriCount);
modelTriCount = 0;
}

if(rendInfoLums)
{
Con_Printf("LumObjs: %-4i\n", DL_GetNumLuminous());
}

R_InfoRendPolys();

// View border?
if(BorderNeedRefresh)
{
R_DrawViewBorder();
BorderNeedRefresh = false;
BorderTopRefresh = false;
UpdateState |= I_FULLSCRN;
}
else if(BorderTopRefresh)
{
if(viewwindowx > 0)
R_DrawTopBorder();

BorderTopRefresh = false;
UpdateState |= I_MESSAGES;
}

// The colored filter.
if(GL_DrawFilter())
BorderNeedRefresh = true;
GL_DrawFilter();
}
13 changes: 8 additions & 5 deletions doomsday/plugins/common/src/am_map.c
Expand Up @@ -1790,11 +1790,15 @@ static void mapWindowTicker(automap_t *map)
win = &map->window;

// Get the view window dimensions.
newX = newY = 0;
newWidth = Get(DD_SCREEN_WIDTH);
newHeight = Get(DD_SCREEN_HEIGHT);
R_GetViewWindow(&newX, &newY, &newWidth, &newHeight);
// Scale to screen space.
newX = FIXXTOSCREENX(newX);
newY = FIXYTOSCREENY(newY);
newWidth = FIXXTOSCREENX(newWidth);
newHeight = FIXYTOSCREENY(newHeight);

if(newWidth != win->height || newHeight != win->width)
if(newX != win->x || newY != win->y ||
newWidth != win->height || newHeight != win->width)
{
if(map->fullScreenMode)
{
Expand Down Expand Up @@ -3169,7 +3173,6 @@ void AM_Drawer(int viewplayer)

drawLevelName();
restoreGLStateFromMap();
HU_DrawMapCounters();
}

// ------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion doomsday/plugins/common/src/r_common.c
Expand Up @@ -174,7 +174,6 @@ boolean R_MapObscures(int playerid, int x, int y, int w, int h)

boolean retVal = false;

// Perhaps the automap completely obscures the view?
if(AM_IsMapActive(displayplayer))
{
float alpha;
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/doom64tc/src/d_api.c
Expand Up @@ -4,7 +4,7 @@
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2006 Jaakko Keränen <skyjake@dengine.net>
*\author Copyright © 2006 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006-2007 Daniel Swanson <danij@dengine.net>
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -53,8 +53,8 @@ void D_Ticker(void);

// Drawing
void D_Display(void);
void D_Display2(void);
void D_EndFrame(void);
void M_Drawer(void);

// Input responders
boolean M_Responder(event_t *ev);
Expand Down Expand Up @@ -200,7 +200,7 @@ game_export_t *GetGameAPI(game_import_t *imports)
gx.Shutdown = D_Shutdown;
gx.Ticker = D_Ticker;
gx.G_Drawer = D_Display;
gx.MN_Drawer = M_Drawer;
gx.G_Drawer2 = D_Display2;
gx.PrivilegedResponder = (boolean (*)(event_t *)) G_PrivilegedResponder;
gx.FallbackResponder = M_Responder;
gx.G_Responder = G_Responder;
Expand Down
88 changes: 53 additions & 35 deletions doomsday/plugins/doom64tc/src/d_refresh.c
Expand Up @@ -236,17 +236,13 @@ void D_Display(void)
{
static boolean viewactivestate = false;
static boolean menuactivestate = false;
static int fullscreenmode = 0;
static gamestate_t oldgamestate = -1;
int ay;
boolean redrawsbar;
player_t *player = &players[displayplayer];
boolean iscam = (player->plr->flags & DDPF_CAMERA) != 0; // $democam
float x, y, w, h;
boolean mapHidesView;

redrawsbar = false;

// $democam: can be set on every frame
if(cfg.setblocks > 10 || iscam)
{
Expand Down Expand Up @@ -310,9 +306,55 @@ void D_Display(void)
// Draw the automap?
AM_Drawer(displayplayer);

// Need to update the borders?
if(oldgamestate != GS_LEVEL ||
((Get(DD_VIEWWINDOW_WIDTH) != 320 || menuactive ||
!R_IsFullScreenViewWindow())))
{
// Update the borders.
GL_Update(DDUF_BORDER);
}

break;

default:
break;
}

GL_Update(DDUF_FULLSCREEN);

menuactivestate = menuactive;
viewactivestate = viewactive;
oldgamestate = wipegamestate = G_GetGameState();

// Draw pause pic (but not if InFine active).
if(paused && !fi_active)
{
//if(AM_IsMapActive(displayplayer))
ay = 4;
//else
// ay = viewwindowy + 4;

WI_DrawPatch(SCREENWIDTH /2, ay, 1, 1, 1, 1, W_GetNumForName("M_PAUSE"),
NULL, false, ALIGN_CENTER);
}
}

void D_Display2(void)
{
// Do buffered drawing.
switch(G_GetGameState())
{
case GS_LEVEL:
// These various HUD's will be drawn unless Doomsday advises not to
if(DD_GetInteger(DD_GAME_DRAW_HUD_HINT))
{
boolean redrawsbar = false;

// Draw HUD displays only visible when the automap is open.
if(AM_IsMapActive(displayplayer))
HU_DrawMapCounters();

// Level information is shown for a few seconds in the
// beginning of a level.
R_DrawLevelTitle();
Expand All @@ -323,6 +365,9 @@ void D_Display(void)
// Do we need to render a full status bar at this point?
if(!(AM_IsMapActive(displayplayer) && cfg.automapHudDisplay == 0 ))
{
player_t *player = &players[displayplayer];
boolean iscam = (player->plr->flags & DDPF_CAMERA) != 0; // $democam

if(!iscam)
{
if(true == (viewheight == 200))
Expand All @@ -335,22 +380,9 @@ void D_Display(void)
ST_Drawer(0 , redrawsbar);
}
}
fullscreenmode = viewheight == 200;
}

HU_Drawer();
}

// Need to update the borders?
if(oldgamestate != GS_LEVEL ||
((Get(DD_VIEWWINDOW_WIDTH) != 320 || menuactive ||
!R_IsFullScreenViewWindow() ||
!mapHidesView)))
{
// Update the borders.
GL_Update(DDUF_BORDER);
}

break;

case GS_INTERMISSION:
Expand All @@ -360,31 +392,17 @@ void D_Display(void)
case GS_WAITING:
gl.Clear(DGL_COLOR_BUFFER_BIT);
M_WriteText2(5, 188, "WAITING... PRESS ESC FOR MENU", hu_font_a, 1, 0, 0, 1);
break;

default:
break;
}

GL_Update(DDUF_FULLSCREEN);

menuactivestate = menuactive;
viewactivestate = viewactive;
oldgamestate = wipegamestate = G_GetGameState();

// Draw pause pic (but not if InFine active).
if(paused && !fi_active)
{
//if(AM_IsMapActive(displayplayer))
ay = 4;
//else
// ay = viewwindowy + 4;

WI_DrawPatch(SCREENWIDTH /2, ay, 1, 1, 1, 1, W_GetNumForName("M_PAUSE"),
NULL, false, ALIGN_CENTER);
}

// InFine is drawn whenever active.
FI_Drawer();

// The menu is drawn whenever active.
M_Drawer();
}

/*
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jdoom/src/d_api.c
Expand Up @@ -53,8 +53,8 @@ void D_Ticker(void);

// Drawing
void D_Display(void);
void D_Display2(void);
void D_EndFrame(void);
void M_Drawer(void);

// Input responders
boolean M_Responder(event_t *ev);
Expand Down Expand Up @@ -200,7 +200,7 @@ game_export_t *GetGameAPI(game_import_t * imports)
gx.Shutdown = D_Shutdown;
gx.Ticker = D_Ticker;
gx.G_Drawer = D_Display;
gx.MN_Drawer = M_Drawer;
gx.G_Drawer2 = D_Display2;
gx.PrivilegedResponder = (boolean (*)(event_t *)) G_PrivilegedResponder;
gx.FallbackResponder = M_Responder;
gx.G_Responder = G_Responder;
Expand Down

0 comments on commit c9a1d5d

Please sign in to comment.