From 10c8623caed4a536bcf996c12fe5bdee3ec3221c Mon Sep 17 00:00:00 2001 From: danij Date: Sun, 25 Apr 2010 21:15:23 +0100 Subject: [PATCH] Changed API: Viewwindow is now specified in viewport coordinates (formerly fixed 320x200). Note that game-side we still use the fixed coordinate space for convenience and scale up when calling R_SetViewWindow. Changed API: Before calling game-side drawing routines the engine now configures the orthographic projection in the viewport coordinate space (formerly fixed 320x200). It is now the games responsibility to scale the coordinate space if/as required. Changed All games: Removed ccmd viewsize as its now unnecessary as the cvar view-size can be changed directly from the console. Changed All games: Improved animation between view sizes to include HUD display modes. Changed All games: Aspect correct drawing of the crosshair. --- doomsday/engine/portable/src/dd_loop.c | 10 --- doomsday/engine/portable/src/gl_main.c | 66 ++++++----------- doomsday/engine/portable/src/r_draw.c | 58 ++++----------- doomsday/engine/portable/src/r_main.c | 28 +++++--- doomsday/plugins/common/src/g_controls.c | 8 +-- doomsday/plugins/common/src/g_game.c | 1 - doomsday/plugins/common/src/hu_menu.c | 16 ++--- doomsday/plugins/common/src/hu_pspr.c | 4 +- doomsday/plugins/common/src/m_ctrl.c | 4 +- doomsday/plugins/common/src/r_common.c | 53 ++++++++++++++ doomsday/plugins/common/src/rend_automap.c | 6 +- doomsday/plugins/common/src/x_hair.c | 14 ++-- doomsday/plugins/jdoom/data/conhelp.txt | 4 -- doomsday/plugins/jdoom/include/d_config.h | 1 - doomsday/plugins/jdoom/include/d_refresh.h | 2 - doomsday/plugins/jdoom/src/d_console.c | 30 +------- doomsday/plugins/jdoom/src/d_refresh.c | 71 ++++++------------- doomsday/plugins/jdoom/src/st_stuff.c | 4 +- doomsday/plugins/jdoom64/data/conhelp.txt | 4 -- doomsday/plugins/jdoom64/include/d_refresh.h | 1 - doomsday/plugins/jdoom64/src/d_console.c | 37 +--------- doomsday/plugins/jdoom64/src/d_refresh.c | 69 ++++++------------ doomsday/plugins/jheretic/data/conhelp.txt | 4 -- doomsday/plugins/jheretic/include/h_refresh.h | 2 - doomsday/plugins/jheretic/src/h_console.c | 37 +--------- doomsday/plugins/jheretic/src/h_refresh.c | 68 ++++++------------ doomsday/plugins/jheretic/src/st_stuff.c | 4 +- doomsday/plugins/jhexen/data/conhelp.txt | 4 -- doomsday/plugins/jhexen/include/x_refresh.h | 1 - doomsday/plugins/jhexen/src/hconsole.c | 37 +--------- doomsday/plugins/jhexen/src/hrefresh.c | 70 ++++++------------ doomsday/plugins/jhexen/src/st_stuff.c | 4 +- 32 files changed, 226 insertions(+), 496 deletions(-) diff --git a/doomsday/engine/portable/src/dd_loop.c b/doomsday/engine/portable/src/dd_loop.c index 8d02a5bcbc..b395766eb8 100644 --- a/doomsday/engine/portable/src/dd_loop.c +++ b/doomsday/engine/portable/src/dd_loop.c @@ -214,22 +214,12 @@ void DD_DrawAndBlit(void) R_RenderViewPorts(); - // Set up the basic 320x200 legacy projection for the game. - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0, 320, 200, 0, -1, 1); - // 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)) { gx.G_Drawer2(); } - - // Restore the projection mode that was previously in effect. - glMatrixMode(GL_PROJECTION); - glPopMatrix(); } if(Con_TransitionInProgress()) diff --git a/doomsday/engine/portable/src/gl_main.c b/doomsday/engine/portable/src/gl_main.c index 03fc9c64fa..3eb3877bc7 100644 --- a/doomsday/engine/portable/src/gl_main.c +++ b/doomsday/engine/portable/src/gl_main.c @@ -741,29 +741,12 @@ void GL_SwitchTo3DState(boolean push_state, viewport_t* port) glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); -#if 0 - viewpx = viewwindowx * theWindow->width / 320, viewpy = - viewwindowy * theWindow->height / 200; - // Set the viewport. - if(viewheight != SCREENHEIGHT) - { - viewpw = viewwidth * theWindow->width / 320; - viewph = viewheight * theWindow->height / 200 + 1; - glViewport(viewpx, FLIP(viewpy + viewph - 1), viewpw, viewph); - } - else - { - viewpw = theWindow->width; - viewph = theWindow->height; - } -#endif - memcpy(¤tView, port, sizeof(currentView)); - viewpx = port->x + viewwindowx / 320.0f * port->width; - viewpy = port->y + viewwindowy / 200.0f * port->height; - viewpw = port->width * viewwidth / 320.0f; - viewph = port->height * viewheight / 200.0f; + viewpx = port->x + MIN_OF(viewwindowx, port->width); + viewpy = port->y + MIN_OF(viewwindowy, port->height); + viewpw = MIN_OF(port->width, viewwidth); + viewph = MIN_OF(port->height, viewheight); glViewport(viewpx, FLIP(viewpy + viewph - 1), viewpw, viewph); // The 3D projection matrix. @@ -789,7 +772,7 @@ void GL_Restore2DState(int step, viewport_t* port) { case 1: // After Restore Step 1 normal player sprites are rendered. { - int height = (SCREENWIDTH * viewheight) / viewwidth; + int height = (float)(port->width * viewheight / viewwidth) / port->height * SCREENHEIGHT; glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -810,23 +793,23 @@ void GL_Restore2DState(int step, viewport_t* port) * corrected coordinate space at 4:3, aligned vertically to * the bottom and centered horizontally in the window. */ - glOrtho(0, port->width, port->height, 0, -1, 1); - glTranslatef(port->width/2, port->height, 0); - - if(port->width >= port->height) - glScalef((float)port->height/SCREENHEIGHT, (float)port->height/SCREENHEIGHT, 1); - else - glScalef((float)port->width/SCREENWIDTH, (float)port->width/SCREENWIDTH, 1); - - // Special case: viewport height is greater than width. - // Apply an additional scaling factor to prevent player sprites looking too small. - if(port->height > port->width) - { - float extraScale = (((float)port->height*2)/port->width) / 2; - glScalef(extraScale, extraScale, 1); - } - - glTranslatef(-(SCREENWIDTH/2), -SCREENHEIGHT, 0); + glOrtho(0, port->width, port->height, 0, -1, 1); + glTranslatef(port->width/2, port->height, 0); + + if(port->width >= port->height) + glScalef((float)port->height/SCREENHEIGHT, (float)port->height/SCREENHEIGHT, 1); + else + glScalef((float)port->width/SCREENWIDTH, (float)port->width/SCREENWIDTH, 1); + + // Special case: viewport height is greater than width. + // Apply an additional scaling factor to prevent player sprites looking too small. + if(port->height > port->width) + { + float extraScale = (((float)port->height*2)/port->width) / 2; + glScalef(extraScale, extraScale, 1); + } + + glTranslatef(-(SCREENWIDTH/2), -SCREENHEIGHT, 0); glScalef(1, (float)SCREENHEIGHT/height, 1); } @@ -838,12 +821,9 @@ void GL_Restore2DState(int step, viewport_t* port) glDisable(GL_DEPTH_TEST); break; } - case 2: // After Restore Step 2 nothing special happens. + case 2: // After Restore Step 2 we're back in 2D rendering mode. glViewport(currentView.x, FLIP(currentView.y + currentView.height - 1), currentView.width, currentView.height); - break; - - case 3: // After Restore Step 3 we're back in 2D rendering mode. glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); diff --git a/doomsday/engine/portable/src/r_draw.c b/doomsday/engine/portable/src/r_draw.c index 935c21dffe..148e9ba349 100644 --- a/doomsday/engine/portable/src/r_draw.c +++ b/doomsday/engine/portable/src/r_draw.c @@ -128,48 +128,19 @@ static void drawPatchTiled(lumpnum_t lump, int x, int y, int w, int h) */ void R_DrawViewBorder(void) { - int viewX, viewY, viewW, viewH, border; + int border; const viewport_t* port; - float xScale, yScale; material_t* mat; - if(viewwidth == 320 && viewheight == 200) - return; - port = R_CurrentViewPort(); assert(port); - xScale = (float) port->width / SCREENWIDTH; - yScale = (float) port->height / SCREENHEIGHT; - - viewX = viewwindowx * xScale; - viewY = viewwindowy * yScale; - viewW = viewwidth * xScale; - viewH = viewheight * yScale; - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - - /** - * Use an orthographic projection in native screenspace. Then - * translate and scale the projection to produce an aspect - * corrected coordinate space at 4:3. - */ - glOrtho(0, port->width, port->height, 0, -1, 1); + if(viewwidth == port->width && viewheight == port->height) + return; glMatrixMode(GL_TEXTURE); glPushMatrix(); - // Correct viewport aspect ratio? - if(port->width < SCREENWIDTH || port->height < SCREENHEIGHT) - { - if(port->width >= port->height) - glScalef((float)port->height/SCREENHEIGHT, (float)port->height/SCREENHEIGHT, 1); - else - glScalef((float)port->width/SCREENWIDTH, (float)port->width/SCREENWIDTH, 1); - } - // Scale from viewport space to fixed 320x200 space. if(port->width >= port->height) { @@ -190,16 +161,16 @@ void R_DrawViewBorder(void) { GL_SetMaterial(mat); GL_DrawCutRectTiled(0, 0, port->width, port->height, mat->width, mat->height, 0, 0, - viewX - border, viewY - border, - viewW + 2 * border, viewH + 2 * border); + viewwindowx - border, viewwindowy - border, + viewwidth + 2 * border, viewheight + 2 * border); } if(border != 0) { - drawPatchTiled(borderPatchLumps[BG_TOP], viewX, viewY - border, viewW, border); - drawPatchTiled(borderPatchLumps[BG_BOTTOM], viewX, viewY + viewH , viewW, border); - drawPatchTiled(borderPatchLumps[BG_LEFT], viewX - border, viewY, border, viewH); - drawPatchTiled(borderPatchLumps[BG_RIGHT], viewX + viewW, viewY, border, viewH); + drawPatchTiled(borderPatchLumps[BG_TOP], viewwindowx, viewwindowy - border, viewwidth, border); + drawPatchTiled(borderPatchLumps[BG_BOTTOM], viewwindowx, viewwindowy + viewheight , viewwidth, border); + drawPatchTiled(borderPatchLumps[BG_LEFT], viewwindowx - border, viewwindowy, border, viewheight); + drawPatchTiled(borderPatchLumps[BG_RIGHT], viewwindowx + viewwidth, viewwindowy, border, viewheight); } glMatrixMode(GL_TEXTURE); @@ -207,12 +178,9 @@ void R_DrawViewBorder(void) if(border != 0) { - drawPatch(borderPatchLumps[BG_TOPLEFT], viewX - border, viewY - border, border, border); - drawPatch(borderPatchLumps[BG_TOPRIGHT], viewX + viewW, viewY - border, border, border); - drawPatch(borderPatchLumps[BG_BOTTOMRIGHT], viewX + viewW, viewY + viewH, border, border); - drawPatch(borderPatchLumps[BG_BOTTOMLEFT], viewX - border, viewY + viewH, border, border); + drawPatch(borderPatchLumps[BG_TOPLEFT], viewwindowx - border, viewwindowy - border, border, border); + drawPatch(borderPatchLumps[BG_TOPRIGHT], viewwindowx + viewwidth, viewwindowy - border, border, border); + drawPatch(borderPatchLumps[BG_BOTTOMRIGHT], viewwindowx + viewwidth, viewwindowy + viewheight, border, border); + drawPatch(borderPatchLumps[BG_BOTTOMLEFT], viewwindowx - border, viewwindowy + viewheight, border, border); } - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); } diff --git a/doomsday/engine/portable/src/r_main.c b/doomsday/engine/portable/src/r_main.c index f2ffa48742..0b5d044b94 100644 --- a/doomsday/engine/portable/src/r_main.c +++ b/doomsday/engine/portable/src/r_main.c @@ -862,22 +862,23 @@ void R_RenderPlayerView(int num) if(renderWireframe) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - // Fullscreen viewport. - GL_Restore2DState(2, currentPort); // Do we need to render any 3D psprites? if(psp3d) { GL_SwitchTo3DState(false, currentPort); Rend_Draw3DPlayerSprites(); - GL_Restore2DState(2, currentPort); // Restore viewport. } - // Original matrices and state: back to normal 2D. - GL_Restore2DState(3, currentPort); + + // Restore fullscreen viewport, original matrices and state: back to normal 2D. + GL_Restore2DState(2, currentPort); // Back from wireframe mode? if(renderWireframe) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + // The colored filter. + GL_DrawFilter(); + // Now we can show the viewPlayer's mobj again. if(!(player->shared.flags & DDPF_CHASECAM)) player->shared.mo->ddFlags = oldFlags; @@ -897,9 +898,6 @@ void R_RenderPlayerView(int num) } R_InfoRendVerticesPool(); - - // The colored filter. - GL_DrawFilter(); } /** @@ -969,6 +967,17 @@ void R_RenderViewPorts(void) continue; } + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + /** + * Use an orthographic projection in native screenspace. Then + * translate and scale the projection to produce an aspect + * corrected coordinate space at 4:3. + */ + glOrtho(0, vp->width, vp->height, 0, -1, 1); + // Draw in-window game graphics (layer 0). gx.G_Drawer(0); restoreDefaultGLState(); @@ -980,6 +989,9 @@ void R_RenderViewPorts(void) gx.G_Drawer(1); restoreDefaultGLState(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + // Increment the internal frame count. This does not // affect the FPS counter. frameCount++; diff --git a/doomsday/plugins/common/src/g_controls.c b/doomsday/plugins/common/src/g_controls.c index 38f339dd14..600a10f4f7 100644 --- a/doomsday/plugins/common/src/g_controls.c +++ b/doomsday/plugins/common/src/g_controls.c @@ -409,10 +409,10 @@ DEFCC( CCmdDefaultGameBinds ) "bindevent key-h {impulse showhud}", "bindevent key-backslash-down {impulse showscore}", "bindevent key-backslash-repeat {impulse showscore}", - "bindevent key-minus-down {viewsize -}", - "bindevent key-minus-repeat {viewsize -}", - "bindevent key-equals-down {viewsize +}", - "bindevent key-equals-repeat {viewsize +}", + "bindevent key-minus-down {sub view-size 1}", + "bindevent key-minus-repeat {sub view-size 1}", + "bindevent key-equals-down {add view-size 1}", + "bindevent key-equals-repeat {add view-size 1}", // Player message log: #if !defined(__JHEXEN__) && !defined(__JHERETIC__) diff --git a/doomsday/plugins/common/src/g_game.c b/doomsday/plugins/common/src/g_game.c index 2bfde01689..e76cc9d255 100644 --- a/doomsday/plugins/common/src/g_game.c +++ b/doomsday/plugins/common/src/g_game.c @@ -675,7 +675,6 @@ void G_CommonPostInit(void) XG_Register(); // Register XG classnames. #endif - R_SetViewSize(cfg.screenBlocks); R_SetBorderGfx(borderLumps); Con_Message("P_Init: Init Playloop state.\n"); diff --git a/doomsday/plugins/common/src/hu_menu.c b/doomsday/plugins/common/src/hu_menu.c index a948ec8527..ce2d9d844f 100644 --- a/doomsday/plugins/common/src/hu_menu.c +++ b/doomsday/plugins/common/src/hu_menu.c @@ -3079,7 +3079,7 @@ void M_DrawHUDMenu(void) #if __JHERETIC__ || __JHEXEN__ idx++; #endif - MN_DrawSlider(menu, idx++, 11, cfg.screenBlocks - 3); + MN_DrawSlider(menu, idx++, 11, cfg.setBlocks - 3); #if __JHERETIC__ || __JHEXEN__ idx++; #endif @@ -3321,8 +3321,6 @@ void M_SizeStatusBar(int option, void* context) cfg.statusbarScale--; ST_HUDUnHide(CONSOLEPLAYER, HUE_FORCE); - - R_SetViewSize(cfg.screenBlocks); } void M_StatusBarOpacity(int option, void* context) @@ -3722,20 +3720,18 @@ void M_SizeDisplay(int option, void* context) if(option == RIGHT_DIR) { #if __JDOOM64__ - if(cfg.screenBlocks < 11) + if(cfg.setBlocks < 11) #else - if(cfg.screenBlocks < 13) + if(cfg.setBlocks < 13) #endif { - cfg.screenBlocks++; + cfg.setBlocks++; } } - else if(cfg.screenBlocks > 3) + else if(cfg.setBlocks > 3) { - cfg.screenBlocks--; + cfg.setBlocks--; } - - R_SetViewSize(cfg.screenBlocks); } void M_OpenDCP(int option, void* context) diff --git a/doomsday/plugins/common/src/hu_pspr.c b/doomsday/plugins/common/src/hu_pspr.c index 039602e9c7..a2626fe625 100644 --- a/doomsday/plugins/common/src/hu_pspr.c +++ b/doomsday/plugins/common/src/hu_pspr.c @@ -89,9 +89,11 @@ static float PSpriteSY[NUM_PLAYER_CLASSES][NUM_WEAPON_TYPES] = { */ float HU_PSpriteYOffset(player_t* pl) { - int viewWindowHeight = Get(DD_VIEWWINDOW_HEIGHT); + float viewWindowHeight; float offy = (cfg.plrViewHeight - DEFAULT_PLAYER_VIEWHEIGHT) * 2; + R_GetViewWindow(NULL, NULL, NULL, &viewWindowHeight); + #if __JHERETIC__ if(viewWindowHeight == SCREENHEIGHT) offy += PSpriteSY[pl->morphTics? PCLASS_CHICKEN : pl->class][pl->readyWeapon]; diff --git a/doomsday/plugins/common/src/m_ctrl.c b/doomsday/plugins/common/src/m_ctrl.c index 3693f8f9f4..ff7df807d6 100644 --- a/doomsday/plugins/common/src/m_ctrl.c +++ b/doomsday/plugins/common/src/m_ctrl.c @@ -305,8 +305,8 @@ static controlconfig_t controlConfig[] = { "hud" }, { "show hud", 0, 0, "impulse showhud" }, { "show score", 0, 0, "impulse showscore", CCF_REPEAT }, - { "smaller view", 0, 0, "viewsize -", CCF_REPEAT }, - { "larger view", 0, 0, "viewsize +", CCF_REPEAT }, + { "smaller view", 0, 0, "sub view-size 1", CCF_REPEAT }, + { "larger view", 0, 0, "add view-size 1", CCF_REPEAT }, { "message refresh", 0, 0, "impulse msgrefresh" }, diff --git a/doomsday/plugins/common/src/r_common.c b/doomsday/plugins/common/src/r_common.c index 26300ed0ab..b74b91217c 100644 --- a/doomsday/plugins/common/src/r_common.c +++ b/doomsday/plugins/common/src/r_common.c @@ -135,6 +135,59 @@ void R_SetViewWindowTarget(int x, int y, int w, int h) */ void R_ViewWindowTicker(void) { + int destBlocks = MINMAX_OF(3, cfg.setBlocks, 13); + boolean instantChange = false; + + if(cfg.screenBlocks != destBlocks) + { + int x = 0, y = 0, w = SCREENWIDTH, h = SCREENHEIGHT; + + if(cfg.screenBlocks == 10 && destBlocks > 10 && destBlocks < 13) + { // When going fullscreen, force a hud show event (to reset the timer). + int i; + for(i = 0; i < MAXPLAYERS; ++i) + ST_HUDUnHide(i, HUE_FORCE); + } + else if(cfg.screenBlocks > 10 && destBlocks <= 10) + { // When going to statusbar span, do an instant change. + instantChange = true; + } + + if(destBlocks > cfg.screenBlocks) + cfg.screenBlocks++; + else + cfg.screenBlocks--; + + if(cfg.screenBlocks <= 10) + { +#if __JDOOM__ || __JHERETIC__ || __JHEXEN__ + int statusBarHeight = ST_HEIGHT * cfg.statusbarScale/20.f; +#endif + if(cfg.screenBlocks != 10) + { + w = cfg.screenBlocks * SCREENWIDTH/10; + x = SCREENWIDTH/2 - w/2; +#if __JDOOM__ || __JHERETIC__ || __JHEXEN__ + h = cfg.screenBlocks * (SCREENHEIGHT - statusBarHeight) / 10; + y = (SCREENHEIGHT - statusBarHeight - h) / 2; +#else + h = cfg.screenBlocks * SCREENHEIGHT/10; + y = (SCREENHEIGHT - h) / 2; +#endif + } +#if __JDOOM__ || __JHERETIC__ || __JHEXEN__ + else + { + h -= statusBarHeight; + } +#endif + } + + R_SetViewWindowTarget(x, y, w, h); + if(instantChange) + windowPos = 1; + } + if(targetX == -1) return; // Nothing to do. diff --git a/doomsday/plugins/common/src/rend_automap.c b/doomsday/plugins/common/src/rend_automap.c index f92faa9426..d59982607c 100644 --- a/doomsday/plugins/common/src/rend_automap.c +++ b/doomsday/plugins/common/src/rend_automap.c @@ -1365,10 +1365,10 @@ static void renderMapName(const automap_t* map) x = SCREENXTOFIXX(wx + (ww * .5f)); y = SCREENYTOFIXY(wy + wh); - if(cfg.setBlocks < 13) + if(cfg.screenBlocks < 13) { #if !__JDOOM64__ - if(cfg.setBlocks <= 11 || cfg.automapHudDisplay == 2) + if(cfg.screenBlocks <= 11 || cfg.automapHudDisplay == 2) { // We may need to adjust for the height of the statusbar otherY = ST_Y; otherY += ST_HEIGHT * (1 - (cfg.statusbarScale / 20.0f)); @@ -1376,7 +1376,7 @@ static void renderMapName(const automap_t* map) if(y > otherY) y = otherY; } - else if(cfg.setBlocks == 12) + else if(cfg.screenBlocks == 12) #endif { // We may need to adjust for the height of the HUD icons. otherY = y; diff --git a/doomsday/plugins/common/src/x_hair.c b/doomsday/plugins/common/src/x_hair.c index 30c29faa04..452d091dcd 100644 --- a/doomsday/plugins/common/src/x_hair.c +++ b/doomsday/plugins/common/src/x_hair.c @@ -100,15 +100,17 @@ void X_Drawer(int player) if(xhair == 0 || !(alpha > 0)) return; - scale = .125f + MINMAX_OF(0, cfg.xhairSize, 1) * .125f * 80; centerX = Get(DD_VIEWWINDOW_X) + (Get(DD_VIEWWINDOW_WIDTH) / 2); centerY = Get(DD_VIEWWINDOW_Y) + (Get(DD_VIEWWINDOW_HEIGHT) / 2); + scale = .125f + MINMAX_OF(0, cfg.xhairSize, 1) * .125f * Get(DD_VIEWWINDOW_HEIGHT) * ((float)80/SCREENHEIGHT); DGL_MatrixMode(DGL_PROJECTION); DGL_PushMatrix(); - DGL_LoadIdentity(); - DGL_Ortho(0, 0, 320, 200, -1, 1); + oldLineWidth = DGL_GetFloat(DGL_LINE_WIDTH); + DGL_SetFloat(DGL_LINE_WIDTH, XHAIR_LINE_WIDTH); + DGL_Disable(DGL_TEXTURING); + DGL_Translatef(centerX, centerY, 0); DGL_Scalef(scale, scale, 1); @@ -140,15 +142,13 @@ void X_Drawer(int player) DGL_Color4fv(color); } - oldLineWidth = DGL_GetFloat(DGL_LINE_WIDTH); - DGL_SetFloat(DGL_LINE_WIDTH, XHAIR_LINE_WIDTH); - DGL_Disable(DGL_TEXTURING); - R_DrawVectorGraphic(R_PrepareVectorGraphic(VG_XHAIR1 + (xhair-1))); // Restore the previous state. DGL_Enable(DGL_TEXTURING); DGL_SetFloat(DGL_LINE_WIDTH, oldLineWidth); + + DGL_MatrixMode(DGL_PROJECTION); DGL_PopMatrix(); #undef XHAIR_LINE_WIDTH diff --git a/doomsday/plugins/jdoom/data/conhelp.txt b/doomsday/plugins/jdoom/data/conhelp.txt index 8b429a3696..cd607031d0 100644 --- a/doomsday/plugins/jdoom/data/conhelp.txt +++ b/doomsday/plugins/jdoom/data/conhelp.txt @@ -187,10 +187,6 @@ desc = Cycle gamma correction levels. [togglemsgs] desc = Messages on/off. -[viewsize] -desc = View size adjustment. -inf = Params: viewsize (size)\nFor example, 'viewsize 10'.\nSize can be: +, -, (num). - [warp] desc = Warp to another map. diff --git a/doomsday/plugins/jdoom/include/d_config.h b/doomsday/plugins/jdoom/include/d_config.h index 6c82f09094..1f93996d60 100644 --- a/doomsday/plugins/jdoom/include/d_config.h +++ b/doomsday/plugins/jdoom/include/d_config.h @@ -77,7 +77,6 @@ typedef struct jdoom_config_s { int jumpEnabled; float jumpPower; int airborneMovement; - byte setSizeNeeded; int setBlocks; int screenBlocks; byte deathLookUp; // look up when killed diff --git a/doomsday/plugins/jdoom/include/d_refresh.h b/doomsday/plugins/jdoom/include/d_refresh.h index 6fcb9b5ddc..2bb70bb804 100644 --- a/doomsday/plugins/jdoom/include/d_refresh.h +++ b/doomsday/plugins/jdoom/include/d_refresh.h @@ -39,8 +39,6 @@ extern float quitDarkenOpacity; void D_Display(int layer); void D_Display2(void); -void R_SetViewSize(int blocks); - void R_DrawSpecialFilter(int pnum); void R_DrawMapTitle(void); diff --git a/doomsday/plugins/jdoom/src/d_console.c b/doomsday/plugins/jdoom/src/d_console.c index 4d74d9ec69..56cde3642b 100644 --- a/doomsday/plugins/jdoom/src/d_console.c +++ b/doomsday/plugins/jdoom/src/d_console.c @@ -68,7 +68,6 @@ DEFCC(CCmdPrintPlayerCoords); // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- DEFCC(CCmdScreenShot); -DEFCC(CCmdViewSize); DEFCC(CCmdDoomFont); DEFCC(CCmdConBackground); @@ -89,7 +88,7 @@ cvar_t gameCVars[] = { {"con-zoom", 0, CVT_FLOAT, &consoleZoom, 0.1f, 100.0f}, // View/Refresh - {"view-size", CVF_PROTECTED, CVT_INT, &cfg.screenBlocks, 3, 13}, + {"view-size", 0, CVT_INT, &cfg.setBlocks, 3, 13}, {"hud-title", 0, CVT_BYTE, &cfg.mapTitle, 0, 1}, {"hud-title-author-noiwad", 0, CVT_BYTE, &cfg.hideIWADAuthor, 0, 1}, @@ -203,7 +202,6 @@ cvar_t gameCVars[] = { ccmd_t gameCCmds[] = { {"spy", "", CCmdCycleSpy}, {"screenshot", "", CCmdScreenShot}, - {"viewsize", "s", CCmdViewSize}, // $cheats {"cheat", "s", CCmdCheat}, @@ -311,32 +309,6 @@ DEFCC(CCmdScreenShot) return true; } -/** - * Console command to change the size of the view window. - */ -DEFCC(CCmdViewSize) -{ - int min = 3, max = 13, *val = &cfg.screenBlocks; - - // Adjust/set the value. - if(!stricmp(argv[1], "+")) - (*val)++; - else if(!stricmp(argv[1], "-")) - (*val)--; - else - *val = strtol(argv[1], NULL, 0); - - // Clamp it. - if(*val < min) - *val = min; - if(*val > max) - *val = max; - - // Update the view size if necessary. - R_SetViewSize(cfg.screenBlocks); - return true; -} - /** * Configure the console to use the game's font. */ diff --git a/doomsday/plugins/jdoom/src/d_refresh.c b/doomsday/plugins/jdoom/src/d_refresh.c index ad82a802e2..27cf87854d 100644 --- a/doomsday/plugins/jdoom/src/d_refresh.c +++ b/doomsday/plugins/jdoom/src/d_refresh.c @@ -49,8 +49,6 @@ // MACROS ------------------------------------------------------------------ -#define WINDOWHEIGHT (Get(DD_VIEWWINDOW_HEIGHT)) - // TYPES ------------------------------------------------------------------- // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -198,28 +196,6 @@ void R_DrawMapTitle(void) DGL_PopMatrix(); } -/** - * Do not really change anything here, because Doomsday might be in the - * middle of a refresh. The change will take effect next refresh. - */ -void R_SetViewSize(int blocks) -{ - cfg.setSizeNeeded = true; - - if(cfg.setBlocks != blocks && blocks > 10 && blocks < 13) - { - int i; - - // When going fullscreen, force a hud show event (to reset the timer). - for(i = 0; i < MAXPLAYERS; ++i) - { - ST_HUDUnHide(i, HUE_FORCE); - } - } - - cfg.setBlocks = blocks; -} - static void rendPlayerView(int player) { player_t* plr = &players[player]; @@ -286,30 +262,33 @@ static void rendHUD(int player) // These various HUD's will be drawn unless Doomsday advises not to if(DD_GetInteger(DD_GAME_DRAW_HUD_HINT)) { - automapid_t map = AM_MapForPlayer(player); - boolean redrawsbar = false; + automapid_t map = AM_MapForPlayer(player); + + // Set up the fixed 320x200 projection. + DGL_MatrixMode(DGL_PROJECTION); + DGL_PushMatrix(); + DGL_LoadIdentity(); + DGL_Ortho(0, 0, SCREENWIDTH, SCREENHEIGHT, -1, 1); // Draw HUD displays only visible when the automap is open. if(AM_IsActive(map)) HU_DrawMapCounters(); - if(WINDOWHEIGHT != 200) - redrawsbar = true; - // Do we need to render a full status bar at this point? if(!(AM_IsActive(map) && cfg.automapHudDisplay == 0) && !(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) { - int viewmode = - ((WINDOWHEIGHT == 200)? cfg.setBlocks - 10 : 0); - - ST_Drawer(player, viewmode, redrawsbar); + int viewmode = (cfg.screenBlocks < 10? 0 : cfg.screenBlocks - 10); + ST_Drawer(player, viewmode, true); } HU_Drawer(player); // Map information is shown for a few seconds in the beginning of a map. R_DrawMapTitle(); + + DGL_MatrixMode(DGL_PROJECTION); + DGL_PopMatrix(); } } @@ -322,8 +301,9 @@ static void rendHUD(int player) void D_Display(int layer) { int player = DISPLAYPLAYER; + int vpWidth, vpHeight; player_t* plr = &players[player]; - float x, y, w, h; + float x, y, w, h, xScale, yScale; if(layer != 0) { @@ -331,31 +311,24 @@ void D_Display(int layer) return; } - if(G_GetGameState() == GS_MAP) + R_GetViewPort(player, NULL, NULL, &vpWidth, &vpHeight); + xScale = (float)vpWidth/SCREENWIDTH; + yScale = (float)vpHeight/SCREENHEIGHT; + + if(G_GetGameState() == GS_MAP && cfg.screenBlocks <= 10 && + !(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) // $democam: can be set on every frame. { - // $democam: can be set on every frame. - if(cfg.setBlocks > 10 || (P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) - { // Full screen. - R_SetViewWindowTarget(0, 0, SCREENWIDTH, SCREENHEIGHT); - } - else - { - int w = cfg.setBlocks * 32; - int h = cfg.setBlocks * (SCREENHEIGHT - ST_HEIGHT * cfg.statusbarScale/20) / 10; - R_SetViewWindowTarget(SCREENWIDTH/2 - w/2, (SCREENHEIGHT - ST_HEIGHT * cfg.statusbarScale / 20 - h) / 2, w, h); - } - R_GetViewWindow(&x, &y, &w, &h); } else - { + { // Full screen. x = 0; y = 0; w = SCREENWIDTH; h = SCREENHEIGHT; } - R_SetViewWindow((int) x, (int) y, (int) w, (int) h); + R_SetViewWindow((int) (x * xScale), (int) (y * yScale), (int) (w * xScale), (int) (h * yScale)); switch(G_GetGameState()) { diff --git a/doomsday/plugins/jdoom/src/st_stuff.c b/doomsday/plugins/jdoom/src/st_stuff.c index 24d2097a71..d2abf9a2f9 100644 --- a/doomsday/plugins/jdoom/src/st_stuff.c +++ b/doomsday/plugins/jdoom/src/st_stuff.c @@ -1548,7 +1548,7 @@ void ST_Init(void) */ DEFCC(CCmdStatusBarSize) { - int min = 1, max = 20, *val = &cfg.statusbarScale; + int min = 1, max = 20, *val = &cfg.statusbarScale; if(!stricmp(argv[1], "+")) (*val)++; @@ -1562,8 +1562,6 @@ DEFCC(CCmdStatusBarSize) if(*val > max) *val = max; - // Update the view size if necessary. - R_SetViewSize(cfg.screenBlocks); ST_HUDUnHide(CONSOLEPLAYER, HUE_FORCE); // So the user can see the change. return true; } diff --git a/doomsday/plugins/jdoom64/data/conhelp.txt b/doomsday/plugins/jdoom64/data/conhelp.txt index 74cb2bbe3a..cd07ed4718 100644 --- a/doomsday/plugins/jdoom64/data/conhelp.txt +++ b/doomsday/plugins/jdoom64/data/conhelp.txt @@ -91,10 +91,6 @@ desc = Spy mode: cycle player views in co-op. [screenshot] desc = Takes a screenshot. Saved to DOOM64nn.TGA. - -[viewsize] -desc = View size adjustment. -inf = Params: viewsize (size)\nFor example, 'viewsize 10'.\nSize can be: +, -, (num). [pause] desc = Pause the game. diff --git a/doomsday/plugins/jdoom64/include/d_refresh.h b/doomsday/plugins/jdoom64/include/d_refresh.h index 8d68d5c1ec..e3e084346a 100644 --- a/doomsday/plugins/jdoom64/include/d_refresh.h +++ b/doomsday/plugins/jdoom64/include/d_refresh.h @@ -38,7 +38,6 @@ extern float quitDarkenOpacity; void D_Display(int layer); void D_Display2(void); -void R_SetViewSize(int blocks); void R_DrawSpecialFilter(int pnum); void R_DrawMapTitle(void); diff --git a/doomsday/plugins/jdoom64/src/d_console.c b/doomsday/plugins/jdoom64/src/d_console.c index e52e85285f..75175223b3 100644 --- a/doomsday/plugins/jdoom64/src/d_console.c +++ b/doomsday/plugins/jdoom64/src/d_console.c @@ -70,7 +70,6 @@ DEFCC(CCmdPrintPlayerCoords); // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- DEFCC(CCmdScreenShot); -DEFCC(CCmdViewSize); DEFCC(CCmdDoom64Font); DEFCC(CCmdConBackground); @@ -91,7 +90,7 @@ cvar_t gameCVars[] = { {"con-zoom", 0, CVT_FLOAT, &consoleZoom, 0.1f, 100.0f}, // View/Refresh - {"view-size", CVF_PROTECTED, CVT_INT, &cfg.screenBlocks, 3, 11}, + {"view-size", 0, CVT_INT, &cfg.setBlocks, 3, 11}, {"hud-title", 0, CVT_BYTE, &cfg.mapTitle, 0, 1}, {"hud-title-author-noiwad", 0, CVT_BYTE, &cfg.hideIWADAuthor, 0, 1}, @@ -203,7 +202,6 @@ cvar_t gameCVars[] = { ccmd_t gameCCmds[] = { {"spy", "", CCmdCycleSpy}, {"screenshot", "", CCmdScreenShot}, - {"viewsize", "s", CCmdViewSize}, // $cheats {"god", NULL, CCmdCheatGod}, @@ -310,39 +308,6 @@ DEFCC(CCmdScreenShot) return true; } -/** - * Console command to change the size of the view window. - */ -DEFCC(CCmdViewSize) -{ - int min = 3, max = 11, *val = &cfg.screenBlocks; - - if(argc != 2) - { - Con_Printf("Usage: %s (size)\n", argv[0]); - Con_Printf("Size can be: +, -, (num).\n"); - return true; - } - - // Adjust/set the value - if(!stricmp(argv[1], "+")) - (*val)++; - else if(!stricmp(argv[1], "-")) - (*val)--; - else - *val = strtol(argv[1], NULL, 0); - - // Clamp it - if(*val < min) - *val = min; - if(*val > max) - *val = max; - - // Update the view size if necessary. - R_SetViewSize(cfg.screenBlocks); - return true; -} - /** * Configure the console to use the game's font. */ diff --git a/doomsday/plugins/jdoom64/src/d_refresh.c b/doomsday/plugins/jdoom64/src/d_refresh.c index ae817196fe..f14f2541f7 100644 --- a/doomsday/plugins/jdoom64/src/d_refresh.c +++ b/doomsday/plugins/jdoom64/src/d_refresh.c @@ -52,8 +52,6 @@ // MACROS ------------------------------------------------------------------ -#define WINDOWHEIGHT (Get(DD_VIEWWINDOW_HEIGHT)) - // TYPES ------------------------------------------------------------------- // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -201,26 +199,6 @@ void R_DrawMapTitle(void) DGL_PopMatrix(); } -/** - * Do not really change anything here, because Doomsday might be in the - * middle of a refresh. The change will take effect next refresh. - */ -void R_SetViewSize(int blocks) -{ - cfg.setSizeNeeded = true; - if(cfg.setBlocks > 8) - { - int i; - - // When going fullscreen, force a hud show event (to reset the timer). - for(i = 0; i < MAXPLAYERS; ++i) - { - ST_HUDUnHide(i, HUE_FORCE); - } - } - cfg.setBlocks = blocks; -} - static void rendPlayerView(int player) { player_t* plr = &players[player]; @@ -289,6 +267,12 @@ static void rendHUD(int player) { automapid_t map = AM_MapForPlayer(player); + // Set up the fixed 320x200 projection. + DGL_MatrixMode(DGL_PROJECTION); + DGL_PushMatrix(); + DGL_LoadIdentity(); + DGL_Ortho(0, 0, SCREENWIDTH, SCREENHEIGHT, -1, 1); + // Draw HUD displays only visible when the automap is open. if(AM_IsActive(map)) HU_DrawMapCounters(); @@ -297,21 +281,17 @@ static void rendHUD(int player) if(!(AM_IsActive(map) && cfg.automapHudDisplay == 0) && !(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) { - if(true == (WINDOWHEIGHT == 200)) - { - // Fullscreen. Which mode? - ST_Drawer(player, cfg.setBlocks - 8); - } - else - { - ST_Drawer(player, 0); - } + int viewmode = (cfg.screenBlocks < 8? 0 : cfg.screenBlocks - 8); + ST_Drawer(player, viewmode); } HU_Drawer(player); // Level information is shown for a few seconds in the beginning of a level. R_DrawMapTitle(); + + DGL_MatrixMode(DGL_PROJECTION); + DGL_PopMatrix(); } } @@ -324,8 +304,9 @@ static void rendHUD(int player) void D_Display(int layer) { int player = DISPLAYPLAYER; + int vpWidth, vpHeight; player_t* plr = &players[player]; - float x, y, w, h; + float x, y, w, h, xScale, yScale; if(layer != 0) { @@ -333,32 +314,24 @@ void D_Display(int layer) return; } - if(G_GetGameState() == GS_MAP) - { - // $democam: can be set on every frame. - if(cfg.setBlocks > 10 || (P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) - { - // Full screen. - R_SetViewWindowTarget(0, 0, SCREENWIDTH, SCREENHEIGHT); - } - else - { - int w = cfg.setBlocks * 32; - int h = cfg.setBlocks * 20; - R_SetViewWindowTarget(SCREENWIDTH/2 - w/2, SCREENHEIGHT/2 - h/2, w, h); - } + R_GetViewPort(player, NULL, NULL, &vpWidth, &vpHeight); + xScale = (float)vpWidth/SCREENWIDTH; + yScale = (float)vpHeight/SCREENHEIGHT; + if(G_GetGameState() == GS_MAP && cfg.screenBlocks <= 10 && + !(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) // $democam: can be set on every frame. + { R_GetViewWindow(&x, &y, &w, &h); } else - { + { // Full screen. x = 0; y = 0; w = SCREENWIDTH; h = SCREENHEIGHT; } - R_SetViewWindow((int) x, (int) y, (int) w, (int) h); + R_SetViewWindow((int) (x * xScale), (int) (y * yScale), (int) (w * xScale), (int) (h * yScale)); switch(G_GetGameState()) { diff --git a/doomsday/plugins/jheretic/data/conhelp.txt b/doomsday/plugins/jheretic/data/conhelp.txt index bdd2cceb77..85bf90bbf3 100644 --- a/doomsday/plugins/jheretic/data/conhelp.txt +++ b/doomsday/plugins/jheretic/data/conhelp.txt @@ -92,10 +92,6 @@ desc = Change the viewplayer when not in deathmatch. [screenshot] desc = Take a screenshot. -[viewsize] -desc = Set the view size. -inf = Params: viewsize (size)\nFor example, 'viewsize 10'.\nSize can be: +, -, (num). - [pause] desc = Pause the game (same as pressing the pause key). diff --git a/doomsday/plugins/jheretic/include/h_refresh.h b/doomsday/plugins/jheretic/include/h_refresh.h index 4e09b71067..5a01b995d4 100644 --- a/doomsday/plugins/jheretic/include/h_refresh.h +++ b/doomsday/plugins/jheretic/include/h_refresh.h @@ -41,8 +41,6 @@ extern float quitDarkenOpacity; void H_Display(int layer); void H_Display2(void); -void R_SetViewSize(int blocks); - void R_DrawSpecialFilter(int pnum); void R_DrawMapTitle(int x, int y, float alpha, gamefontid_t font, boolean center); diff --git a/doomsday/plugins/jheretic/src/h_console.c b/doomsday/plugins/jheretic/src/h_console.c index 4fc26be006..aaf58d3c14 100644 --- a/doomsday/plugins/jheretic/src/h_console.c +++ b/doomsday/plugins/jheretic/src/h_console.c @@ -74,7 +74,6 @@ void G_UpdateEyeHeight(cvar_t* unused); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- DEFCC(CCmdScreenShot); -DEFCC(CCmdViewSize); DEFCC(CCmdHereticFont); DEFCC(CCmdConBackground); @@ -91,7 +90,7 @@ cvar_t gameCVars[] = { {"con-zoom", 0, CVT_FLOAT, &consoleZoom, 0.1f, 100.0f}, // View/Refresh - {"view-size", CVF_PROTECTED, CVT_INT, &cfg.screenBlocks, 3, 13}, + {"view-size", 0, CVT_INT, &cfg.setBlocks, 3, 13}, {"hud-title", 0, CVT_BYTE, &cfg.mapTitle, 0, 1}, {"hud-title-author-noiwad", 0, CVT_BYTE, &cfg.hideIWADAuthor, 0, 1}, @@ -191,7 +190,6 @@ cvar_t gameCVars[] = { ccmd_t gameCCmds[] = { {"spy", "", CCmdCycleSpy}, {"screenshot", "", CCmdScreenShot}, - {"viewsize", "s", CCmdViewSize}, // $cheats {"cheat", "s", CCmdCheat}, @@ -302,39 +300,6 @@ DEFCC(CCmdScreenShot) return true; } -/** - * Console command to change the size of the view window. - */ -DEFCC(CCmdViewSize) -{ - int min = 3, max = 13, *val = &cfg.screenBlocks; - - if(argc != 2) - { - Con_Printf("Usage: %s (size)\n", argv[0]); - Con_Printf("Size can be: +, -, (num).\n"); - return true; - } - - // Adjust/set the value - if(!stricmp(argv[1], "+")) - (*val)++; - else if(!stricmp(argv[1], "-")) - (*val)--; - else - *val = strtol(argv[1], NULL, 0); - - // Clamp it - if(*val < min) - *val = min; - if(*val > max) - *val = max; - - // Update the view size if necessary. - R_SetViewSize(cfg.screenBlocks); - return true; -} - /** * Configure the console to use the game's font. */ diff --git a/doomsday/plugins/jheretic/src/h_refresh.c b/doomsday/plugins/jheretic/src/h_refresh.c index fe213c6ee3..cd296b7db7 100644 --- a/doomsday/plugins/jheretic/src/h_refresh.c +++ b/doomsday/plugins/jheretic/src/h_refresh.c @@ -49,8 +49,6 @@ // MACROS ------------------------------------------------------------------ -#define WINDOWHEIGHT Get(DD_VIEWWINDOW_HEIGHT) - // TYPES ------------------------------------------------------------------- // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -156,26 +154,6 @@ void R_DrawMapTitle(int x, int y, float alpha, gamefontid_t font, } } -/** - * Do not really change anything here, because Doomsday might be in the - * middle of a refresh. The change will take effect next refresh. - */ -void R_SetViewSize(int blocks) -{ - cfg.setSizeNeeded = true; - - if(cfg.setBlocks != blocks && blocks > 10 && blocks < 13) - { // Going to/from fullscreen. - int i; - - // Force a hud show event (to reset the timer). - for(i = 0; i < MAXPLAYERS; ++i) - ST_HUDUnHide(i, HUE_FORCE); - } - - cfg.setBlocks = blocks; -} - static void rendPlayerView(int player) { player_t* plr = &players[player]; @@ -242,23 +220,23 @@ static void rendHUD(int player) if(DD_GetInteger(DD_GAME_DRAW_HUD_HINT)) { automapid_t map = AM_MapForPlayer(player); - boolean redrawsbar = false; + + // Set up the fixed 320x200 projection. + DGL_MatrixMode(DGL_PROJECTION); + DGL_PushMatrix(); + DGL_LoadIdentity(); + DGL_Ortho(0, 0, SCREENWIDTH, SCREENHEIGHT, -1, 1); // Draw HUD displays only visible when the automap is open. if(AM_IsActive(map)) HU_DrawMapCounters(); - if((WINDOWHEIGHT != 200)) - redrawsbar = true; - // Do we need to render a full status bar at this point? if(!(AM_IsActive(map) && cfg.automapHudDisplay == 0) && !(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) { - int viewmode = - ((WINDOWHEIGHT == 200)? (cfg.setBlocks - 10) : 0); - - ST_Drawer(player, viewmode, redrawsbar); // $democam + int viewmode = (cfg.screenBlocks < 10? 0 : cfg.screenBlocks - 10); + ST_Drawer(player, viewmode, true); } HU_Drawer(player); @@ -280,6 +258,9 @@ static void rendHUD(int player) R_DrawMapTitle(x, y, alpha, GF_FONTB, true); Draw_EndZoom(); } + + DGL_MatrixMode(DGL_PROJECTION); + DGL_PopMatrix(); } } @@ -292,8 +273,9 @@ static void rendHUD(int player) void H_Display(int layer) { int player = DISPLAYPLAYER; + int vpWidth, vpHeight; player_t* plr = &players[player]; - float x, y, w, h; + float x, y, w, h, xScale, yScale; if(layer != 0) { @@ -301,32 +283,24 @@ void H_Display(int layer) return; } - if(G_GetGameState() == GS_MAP) - { - // $democam: can be set on every frame. - if(cfg.setBlocks > 10 || (P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) - { - // Full screen. - R_SetViewWindowTarget(0, 0, SCREENWIDTH, SCREENHEIGHT); - } - else - { - int w = cfg.setBlocks * 32; - int h = cfg.setBlocks * (SCREENHEIGHT - SBARHEIGHT * cfg.statusbarScale / 20) / 10; - R_SetViewWindowTarget(SCREENWIDTH/2 - w/2, (SCREENHEIGHT - SBARHEIGHT * cfg.statusbarScale / 20 - h) / 2, w, h); - } + R_GetViewPort(player, NULL, NULL, &vpWidth, &vpHeight); + xScale = (float)vpWidth/SCREENWIDTH; + yScale = (float)vpHeight/SCREENHEIGHT; + if(G_GetGameState() == GS_MAP && cfg.screenBlocks <= 10 && + !(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) // $democam: can be set on every frame. + { R_GetViewWindow(&x, &y, &w, &h); } else - { + { // Full screen. x = 0; y = 0; w = SCREENWIDTH; h = SCREENHEIGHT; } - R_SetViewWindow((int) x, (int) y, (int) w, (int) h); + R_SetViewWindow((int) (x * xScale), (int) (y * yScale), (int) (w * xScale), (int) (h * yScale)); switch(G_GetGameState()) { diff --git a/doomsday/plugins/jheretic/src/st_stuff.c b/doomsday/plugins/jheretic/src/st_stuff.c index 3d8c0e35be..c74e41202b 100644 --- a/doomsday/plugins/jheretic/src/st_stuff.c +++ b/doomsday/plugins/jheretic/src/st_stuff.c @@ -1368,7 +1368,7 @@ void ST_Init(void) */ DEFCC(CCmdStatusBarSize) { - int min = 1, max = 20, *val = &cfg.statusbarScale; + int min = 1, max = 20, *val = &cfg.statusbarScale; if(!stricmp(argv[1], "+")) (*val)++; @@ -1379,8 +1379,6 @@ DEFCC(CCmdStatusBarSize) *val = MINMAX_OF(min, *val, max); - // Update the view size if necessary. - R_SetViewSize(cfg.screenBlocks); ST_HUDUnHide(CONSOLEPLAYER, HUE_FORCE); // so the user can see the change. return true; diff --git a/doomsday/plugins/jhexen/data/conhelp.txt b/doomsday/plugins/jhexen/data/conhelp.txt index e8cbae13e8..21a465823a 100644 --- a/doomsday/plugins/jhexen/data/conhelp.txt +++ b/doomsday/plugins/jhexen/data/conhelp.txt @@ -93,10 +93,6 @@ desc = Change the viewplayer when not in deathmatch. [screenshot] desc = Take a screenshot. -[viewsize] -desc = Set the view size. -inf = Params: viewsize (size)\nFor example, 'viewsize 10'.\nSize can be: +, -, (num). - [pause] desc = Pause the game (same as pressing the pause key). diff --git a/doomsday/plugins/jhexen/include/x_refresh.h b/doomsday/plugins/jhexen/include/x_refresh.h index 480a10c0e2..ac530fcdec 100644 --- a/doomsday/plugins/jhexen/include/x_refresh.h +++ b/doomsday/plugins/jhexen/include/x_refresh.h @@ -37,7 +37,6 @@ extern float quitDarkenOpacity; void G_Display(int layer); void G_Display2(void); -void R_SetViewSize(int blocks); void R_SetAllDoomsdayFlags(void); boolean R_GetFilterColor(float rgba[4], int filter); #endif diff --git a/doomsday/plugins/jhexen/src/hconsole.c b/doomsday/plugins/jhexen/src/hconsole.c index 3cb72a381d..be15bc0366 100644 --- a/doomsday/plugins/jhexen/src/hconsole.c +++ b/doomsday/plugins/jhexen/src/hconsole.c @@ -80,7 +80,6 @@ void G_UpdateEyeHeight(cvar_t* unused); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- DEFCC(CCmdScreenShot); -DEFCC(CCmdViewSize); DEFCC(CCmdHexenFont); DEFCC(CCmdConBackground); @@ -97,7 +96,7 @@ cvar_t gameCVars[] = { {"con-zoom", 0, CVT_FLOAT, &consoleZoom, 0.1f, 100.0f}, // View/Refresh - {"view-size", CVF_PROTECTED, CVT_INT, &cfg.screenBlocks, 3, 13}, + {"view-size", 0, CVT_INT, &cfg.setBlocks, 3, 13}, {"hud-title", 0, CVT_BYTE, &cfg.mapTitle, 0, 1}, {"hud-title-author-noiwad", 0, CVT_BYTE, &cfg.hideIWADAuthor, 0, 1}, @@ -176,7 +175,6 @@ cvar_t gameCVars[] = { ccmd_t gameCCmds[] = { {"spy", "", CCmdCycleSpy}, {"screenshot", "", CCmdScreenShot}, - {"viewsize", "s", CCmdViewSize}, // $cheats {"cheat", "s", CCmdCheat}, @@ -289,39 +287,6 @@ DEFCC(CCmdScreenShot) return true; } -/** - * Console command to change the size of the view window. - */ -DEFCC(CCmdViewSize) -{ - int min = 3, max = 13, *val = &cfg.screenBlocks; - - if(argc != 2) - { - Con_Printf("Usage: %s (size)\n", argv[0]); - Con_Printf("Size can be: +, -, (num).\n"); - return true; - } - - // Adjust/set the value - if(!stricmp(argv[1], "+")) - (*val)++; - else if(!stricmp(argv[1], "-")) - (*val)--; - else - *val = strtol(argv[1], NULL, 0); - - // Clamp it - if(*val < min) - *val = min; - if(*val > max) - *val = max; - - // Update the view size if necessary. - R_SetViewSize(cfg.screenBlocks); - return true; -} - /** * Configure the console to use the game's font. */ diff --git a/doomsday/plugins/jhexen/src/hrefresh.c b/doomsday/plugins/jhexen/src/hrefresh.c index 8b6a4c2d51..c27f6d11fd 100644 --- a/doomsday/plugins/jhexen/src/hrefresh.c +++ b/doomsday/plugins/jhexen/src/hrefresh.c @@ -48,8 +48,6 @@ // MACROS ------------------------------------------------------------------ -#define WINDOWHEIGHT (Get(DD_VIEWWINDOW_HEIGHT)) - // TYPES ------------------------------------------------------------------- // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -64,32 +62,12 @@ extern void MN_DrCenterTextA_CS(char *text, int center_x, int y); // PUBLIC DATA DEFINITIONS ------------------------------------------------- -boolean setsizeneeded; float quitDarkenOpacity = 0; // PRIVATE DATA DEFINITIONS ------------------------------------------------ // CODE -------------------------------------------------------------------- -/** - * Don't really change anything here, because i might be in the middle of - * a refresh. The change will take effect next refresh. - */ -void R_SetViewSize(int blocks) -{ - setsizeneeded = true; - - if(cfg.setBlocks != blocks && blocks > 10 && blocks < 13) - { // When going fullscreen, force a hud show event (to reset the timer). - int i; - - for(i = 0; i < MAXPLAYERS; ++i) - ST_HUDUnHide(i, HUE_FORCE); - } - - cfg.setBlocks = blocks; -} - void R_DrawMapTitle(void) { float alpha; @@ -235,6 +213,12 @@ static void rendHUD(int player) { automapid_t map = AM_MapForPlayer(player); + // Set up the fixed 320x200 projection. + DGL_MatrixMode(DGL_PROJECTION); + DGL_PushMatrix(); + DGL_LoadIdentity(); + DGL_Ortho(0, 0, SCREENWIDTH, SCREENHEIGHT, -1, 1); + // Draw HUD displays only visible when the automap is open. if(AM_IsActive(map)) HU_DrawMapCounters(); @@ -243,21 +227,17 @@ static void rendHUD(int player) if(!(AM_IsActive(map) && cfg.automapHudDisplay == 0) && !(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) { - if(true == (WINDOWHEIGHT == 200)) - { - // Fullscreen. Which mode? - ST_Drawer(player, cfg.setBlocks - 10, true); - } - else - { - ST_Drawer(player, 0, true); - } + int viewmode = (cfg.screenBlocks < 10? 0 : cfg.screenBlocks - 10); + ST_Drawer(player, viewmode, true); } HU_Drawer(player); // Map information is shown for a few seconds in the beginning of a map. R_DrawMapTitle(); + + DGL_MatrixMode(DGL_PROJECTION); + DGL_PopMatrix(); } } @@ -270,8 +250,9 @@ static void rendHUD(int player) void G_Display(int layer) { int player = DISPLAYPLAYER; + int vpWidth, vpHeight; player_t* plr = &players[player]; - float x, y, w, h; + float x, y, w, h, xScale, yScale; if(layer != 0) { @@ -279,33 +260,24 @@ void G_Display(int layer) return; } - if(G_GetGameState() == GS_MAP) - { - // $democam: can be set on every frame. - if(cfg.setBlocks > 10 || (P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) - { - // Full screen. - R_SetViewWindowTarget(0, 0, SCREENWIDTH, SCREENHEIGHT); - } - else - { - int w = cfg.setBlocks * 32; - int h = cfg.setBlocks * (SCREENHEIGHT - SBARHEIGHT * cfg.statusbarScale / 20) / 10; - - R_SetViewWindowTarget(SCREENWIDTH/2 - w/2, (SCREENHEIGHT - SBARHEIGHT * cfg.statusbarScale / 20 - h) / 2, w, h); - } + R_GetViewPort(player, NULL, NULL, &vpWidth, &vpHeight); + xScale = (float)vpWidth/SCREENWIDTH; + yScale = (float)vpHeight/SCREENHEIGHT; + if(G_GetGameState() == GS_MAP && cfg.screenBlocks <= 10 && + !(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) // $democam: can be set on every frame. + { R_GetViewWindow(&x, &y, &w, &h); } else - { + { // Full screen. x = 0; y = 0; w = SCREENWIDTH; h = SCREENHEIGHT; } - R_SetViewWindow((int) x, (int) y, (int) w, (int) h); + R_SetViewWindow((int) (x * xScale), (int) (y * yScale), (int) (w * xScale), (int) (h * yScale)); switch(G_GetGameState()) { diff --git a/doomsday/plugins/jhexen/src/st_stuff.c b/doomsday/plugins/jhexen/src/st_stuff.c index 3a7c91ab11..6988f1fb19 100644 --- a/doomsday/plugins/jhexen/src/st_stuff.c +++ b/doomsday/plugins/jhexen/src/st_stuff.c @@ -1739,7 +1739,7 @@ void Draw_TeleportIcon(void) */ DEFCC(CCmdStatusBarSize) { - int min = 1, max = 20, *val = &cfg.statusbarScale; + int min = 1, max = 20, *val = &cfg.statusbarScale; if(!stricmp(argv[1], "+")) (*val)++; @@ -1750,8 +1750,6 @@ DEFCC(CCmdStatusBarSize) *val = MINMAX_OF(min, *val, max); - // Update the view size if necessary. - R_SetViewSize(cfg.screenBlocks); ST_HUDUnHide(CONSOLEPLAYER, HUE_FORCE); // So the user can see the change. return true;