From 8c9d7dd13178781d213c5045c88b9be726f9c707 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 27 Mar 2019 00:50:29 +0100 Subject: [PATCH] - split GetWidth()/GetHeight() into separate functions for screen and UI. For virtualization of the UI size. --- src/am_map.cpp | 16 ++-- src/c_cmds.cpp | 2 +- src/c_console.cpp | 80 +++++++++---------- src/ct_chat.cpp | 6 +- src/d_main.cpp | 20 ++--- src/g_statusbar/hudmessages.cpp | 26 +++--- src/g_statusbar/sbarinfo.cpp | 12 +-- src/g_statusbar/sbarinfo_commands.cpp | 2 +- src/g_statusbar/shared_hud.cpp | 4 +- src/g_statusbar/shared_sbar.cpp | 76 +++++++++--------- src/hu_scores.cpp | 8 +- src/intermission/intermission.cpp | 20 ++--- src/m_misc.cpp | 4 +- src/menu/menu.cpp | 2 +- src/p_acs.cpp | 4 +- src/posix/cocoa/i_video.mm | 4 +- src/r_utility.cpp | 16 ++-- src/rendering/2d/v_2ddrawer.cpp | 6 +- src/rendering/2d/v_draw.cpp | 65 ++++++++------- src/rendering/gl/renderer/gl_renderstate.cpp | 2 +- src/rendering/gl/system/gl_framebuffer.cpp | 10 +-- src/rendering/hwrenderer/scene/hw_weapon.cpp | 2 +- .../hwrenderer/utility/hw_draw2d.cpp | 3 +- .../hwrenderer/utility/hw_vrmodes.cpp | 4 +- src/rendering/polyrenderer/poly_renderer.cpp | 8 +- .../polyrenderer/scene/poly_playersprite.cpp | 2 +- src/rendering/swrenderer/drawers/r_thread.cpp | 4 +- .../swrenderer/plane/r_flatplane.cpp | 2 +- src/rendering/swrenderer/r_swscene.cpp | 12 +-- src/rendering/swrenderer/scene/r_light.cpp | 6 +- src/rendering/swrenderer/scene/r_scene.cpp | 4 +- .../swrenderer/things/r_playersprite.cpp | 2 +- src/s_sound.cpp | 2 +- src/utility/stats.cpp | 6 +- src/v_framebuffer.cpp | 46 +++++------ src/v_video.cpp | 12 +-- src/v_video.h | 29 ++++--- src/wi_stuff.cpp | 4 +- 38 files changed, 271 insertions(+), 262 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index e7708ae23f..666970532a 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1188,11 +1188,11 @@ void DAutomap::findMinMaxBoundaries () void DAutomap::calcMinMaxMtoF() { const double safe_frame = 1.0 - am_emptyspacemargin / 100.0; - double a = safe_frame * (SCREENWIDTH / max_w); + double a = safe_frame * (screen->GetUIWidth() / max_w); double b = safe_frame * (StatusBar->GetTopOfStatusbar() / max_h); min_scale_mtof = a < b ? a : b; - max_scale_mtof = SCREENHEIGHT / (2*PLAYERRADIUS); + max_scale_mtof = screen->GetUIHeight() / (2*PLAYERRADIUS); } //============================================================================= @@ -1275,8 +1275,8 @@ void DAutomap::changeWindowLoc () incx = m_paninc.x; incy = m_paninc.y; - oincx = incx = m_paninc.x * SCREENWIDTH / 320; - oincy = incy = m_paninc.y * SCREENHEIGHT / 200; + oincx = incx = m_paninc.x * screen->GetUIWidth() / 320; + oincy = incy = m_paninc.y * screen->GetUIHeight() / 200; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { rotate(&incx, &incy, players[consoleplayer].camera->Angles.Yaw - 90.); @@ -1306,8 +1306,8 @@ void DAutomap::startDisplay() m_paninc.x = m_paninc.y = 0; mtof_zoommul = 1.; - m_w = FTOM(SCREENWIDTH); - m_h = FTOM(SCREENHEIGHT); + m_w = FTOM(screen->GetUIWidth()); + m_h = FTOM(screen->GetUIHeight()); // find player to center on initially if (!playeringame[pnum = consoleplayer]) @@ -1413,7 +1413,7 @@ void DAutomap::NewResolution() minOutWindowScale(); else if (scale_mtof > max_scale_mtof) maxOutWindowScale(); - f_w = screen->GetWidth(); + f_w = screen->GetUIWidth(); f_h = StatusBar->GetTopOfStatusbar(); activateNewScale(); } @@ -3179,7 +3179,7 @@ void DAutomap::Drawer (int bottom) // [RH] Set f_? here now to handle automap overlaying // and view size adjustments. f_x = f_y = 0; - f_w = screen->GetWidth (); + f_w = screen->GetUIWidth (); f_h = bottom; clearFB(AMColors[AMColors.Background]); diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 3f927a54fb..19e63399d3 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -1199,7 +1199,7 @@ static void PrintSecretString(const char *string, bool thislevel) else colstr = TEXTCOLOR_GREEN; } } - auto brok = V_BreakLines(CurrentConsoleFont, screen->GetWidth()*95/100, string); + auto brok = V_BreakLines(CurrentConsoleFont, screen->GetUIWidth()*95/100, string); for (auto &line : brok) { diff --git a/src/c_console.cpp b/src/c_console.cpp index 1786e94c52..a497ed8471 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -217,14 +217,14 @@ public: else { screen->DrawChar(CurrentConsoleFont, CR_ORANGE, x, y, '\x1c', - DTA_VirtualWidth, screen->GetWidth() / scale, - DTA_VirtualHeight, screen->GetHeight() / scale, + DTA_VirtualWidth, screen->GetUIWidth() / scale, + DTA_VirtualHeight, screen->GetUIHeight() / scale, DTA_KeepRatio, true, TAG_DONE); screen->DrawText(CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->GetCharWidth(0x1c), y, &Text[StartPos], - DTA_VirtualWidth, screen->GetWidth() / scale, - DTA_VirtualHeight, screen->GetHeight() / scale, + DTA_VirtualWidth, screen->GetUIWidth() / scale, + DTA_VirtualHeight, screen->GetUIHeight() / scale, DTA_KeepRatio, true, TAG_DONE); if (cursor) @@ -232,8 +232,8 @@ public: screen->DrawChar(CurrentConsoleFont, CR_YELLOW, x + CurrentConsoleFont->GetCharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->GetCharWidth(0xb), y, '\xb', - DTA_VirtualWidth, screen->GetWidth() / scale, - DTA_VirtualHeight, screen->GetHeight() / scale, + DTA_VirtualWidth, screen->GetUIWidth() / scale, + DTA_VirtualHeight, screen->GetUIHeight() / scale, DTA_KeepRatio, true, TAG_DONE); } } @@ -973,14 +973,14 @@ void C_FlushDisplay () void C_AdjustBottom () { if (gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) - ConBottom = SCREENHEIGHT; - else if (ConBottom > SCREENHEIGHT / 2 || ConsoleState == c_down) - ConBottom = SCREENHEIGHT / 2; + ConBottom = screen->GetUIHeight(); + else if (ConBottom > screen->GetUIHeight() / 2 || ConsoleState == c_down) + ConBottom = screen->GetUIHeight() / 2; } void C_NewModeAdjust () { - C_InitConsole (SCREENWIDTH, SCREENHEIGHT, true); + C_InitConsole (screen->GetUIWidth(), screen->GetUIHeight(), true); C_FlushDisplay (); C_AdjustBottom (); } @@ -1003,16 +1003,16 @@ void C_Ticker() { if (ConsoleState == c_falling) { - ConBottom += (consoletic - lasttic) * (SCREENHEIGHT * 2 / 25); - if (ConBottom >= SCREENHEIGHT / 2) + ConBottom += (consoletic - lasttic) * (screen->GetUIHeight() * 2 / 25); + if (ConBottom >= screen->GetUIHeight() / 2) { - ConBottom = SCREENHEIGHT / 2; + ConBottom = screen->GetUIHeight() / 2; ConsoleState = c_down; } } else if (ConsoleState == c_rising) { - ConBottom -= (consoletic - lasttic) * (SCREENHEIGHT * 2 / 25); + ConBottom -= (consoletic - lasttic) * (screen->GetUIHeight() * 2 / 25); if (ConBottom <= 0) { ConsoleState = c_up; @@ -1097,18 +1097,18 @@ void FNotifyBuffer::Draw() int scale = active_con_scaletext(con_consolefont); if (!center) screen->DrawText (font, color, 0, line, notify.Text, - DTA_VirtualWidth, screen->GetWidth() / scale, - DTA_VirtualHeight, screen->GetHeight() / scale, - DTA_KeepRatio, true, - DTA_Alpha, alpha, TAG_DONE); + DTA_VirtualWidth, screen->GetUIWidth() / scale, + DTA_VirtualHeight, screen->GetUIHeight() / scale, + DTA_KeepRatio, true, + DTA_Alpha, alpha, TAG_DONE); else - screen->DrawText (font, color, (screen->GetWidth() - - SmallFont->StringWidth (notify.Text) * scale) / 2 / scale, - line, notify.Text, - DTA_VirtualWidth, screen->GetWidth() / scale, - DTA_VirtualHeight, screen->GetHeight() / scale, - DTA_KeepRatio, true, - DTA_Alpha, alpha, TAG_DONE); + screen->DrawText (font, color, (screen->GetUIWidth() - + SmallFont->StringWidth (notify.Text) * scale) / 2 / scale, + line, notify.Text, + DTA_VirtualWidth, screen->GetUIWidth() / scale, + DTA_VirtualHeight, screen->GetUIHeight() / scale, + DTA_KeepRatio, true, + DTA_Alpha, alpha, TAG_DONE); line += lineadv; canskip = false; } @@ -1161,32 +1161,32 @@ void C_DrawConsole () visheight = ConBottom; - screen->DrawTexture (conpic, 0, visheight - screen->GetHeight(), - DTA_DestWidth, screen->GetWidth(), - DTA_DestHeight, screen->GetHeight(), + screen->DrawTexture (conpic, 0, visheight - screen->GetUIHeight(), + DTA_DestWidth, screen->GetUIWidth(), + DTA_DestHeight, screen->GetUIHeight(), DTA_ColorOverlay, conshade, DTA_Alpha, (gamestate != GS_FULLCONSOLE) ? (double)con_alpha : 1., DTA_Masked, false, TAG_DONE); - if (conline && visheight < screen->GetHeight()) + if (conline && visheight < screen->GetUIHeight()) { - screen->Clear (0, visheight, screen->GetWidth(), visheight+1, 0, 0); + screen->Clear (0, visheight, screen->GetUIWidth(), visheight+1, 0, 0); } if (ConBottom >= 12) { if (textScale == 1) - screen->DrawText (CurrentConsoleFont, CR_ORANGE, SCREENWIDTH - 8 - + screen->DrawText (CurrentConsoleFont, CR_ORANGE, screen->GetUIWidth() - 8 - CurrentConsoleFont->StringWidth (GetVersionString()), ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4, GetVersionString(), TAG_DONE); else - screen->DrawText(CurrentConsoleFont, CR_ORANGE, SCREENWIDTH / textScale - 8 - + screen->DrawText(CurrentConsoleFont, CR_ORANGE, screen->GetUIWidth() / textScale - 8 - CurrentConsoleFont->StringWidth(GetVersionString()), ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4, GetVersionString(), - DTA_VirtualWidth, screen->GetWidth() / textScale, - DTA_VirtualHeight, screen->GetHeight() / textScale, + DTA_VirtualWidth, screen->GetUIWidth() / textScale, + DTA_VirtualHeight, screen->GetUIHeight() / textScale, DTA_KeepRatio, true, TAG_DONE); } @@ -1217,8 +1217,8 @@ void C_DrawConsole () else { screen->DrawText(CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, - DTA_VirtualWidth, screen->GetWidth() / textScale, - DTA_VirtualHeight, screen->GetHeight() / textScale, + DTA_VirtualWidth, screen->GetUIWidth() / textScale, + DTA_VirtualHeight, screen->GetUIHeight() / textScale, DTA_KeepRatio, true, TAG_DONE); } } @@ -1237,8 +1237,8 @@ void C_DrawConsole () screen->DrawChar (CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE); else screen->DrawChar(CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, - DTA_VirtualWidth, screen->GetWidth() / textScale, - DTA_VirtualHeight, screen->GetHeight() / textScale, + DTA_VirtualWidth, screen->GetUIWidth() / textScale, + DTA_VirtualHeight, screen->GetUIHeight() / textScale, DTA_KeepRatio, true, TAG_DONE); } } @@ -1370,7 +1370,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) case GK_PGUP: if (ev->data3 & (GKM_SHIFT|GKM_CTRL)) { // Scroll console buffer up one page - RowAdjust += (SCREENHEIGHT-4)/active_con_scale() / + RowAdjust += (screen->GetUIHeight()-4)/active_con_scale() / ((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3; } else if (RowAdjust < conbuffer->GetFormattedLineCount()) @@ -1393,7 +1393,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) case GK_PGDN: if (ev->data3 & (GKM_SHIFT|GKM_CTRL)) { // Scroll console buffer down one page - const int scrollamt = (SCREENHEIGHT-4)/active_con_scale() / + const int scrollamt = (screen->GetUIHeight()-4)/active_con_scale() / ((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3; if (RowAdjust < scrollamt) { diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp index e73c64c77f..435bf87366 100644 --- a/src/ct_chat.cpp +++ b/src/ct_chat.cpp @@ -244,11 +244,11 @@ void CT_Drawer (void) scalex = 1; int scale = active_con_scaletext(true); - int screen_width = SCREENWIDTH / scale; - int screen_height= SCREENHEIGHT / scale; + int screen_width = screen->GetUIWidth() / scale; + int screen_height= screen->GetUIHeight() / scale; int st_y = StatusBar->GetTopOfStatusbar() / scale; - y += ((SCREENHEIGHT == viewheight && viewactive) || gamestate != GS_LEVEL) ? screen_height : st_y; + y += ((screen->GetUIHeight() == viewheight && viewactive) || gamestate != GS_LEVEL) ? screen_height : st_y; promptwidth = displayfont->StringWidth (prompt) * scalex; x = displayfont->GetCharWidth (displayfont->GetCursor()) * scalex * 2 + promptwidth; diff --git a/src/d_main.cpp b/src/d_main.cpp index 128623884f..03fff86124 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -703,7 +703,7 @@ void D_Display () { setmodeneeded = false; screen->ToggleFullscreen(fullscreen); - V_OutputResized(screen->GetWidth(), screen->GetHeight()); + V_OutputResized(screen->GetScreenWidth(), screen->GetScreenHeight()); } // change the view size if needed @@ -711,8 +711,8 @@ void D_Display () { if (StatusBar == nullptr) { - viewwidth = SCREENWIDTH; - viewheight = SCREENHEIGHT; + viewwidth = screen->GetScreenWidth(); + viewheight = screen->GetScreenHeight(); setsizeneeded = false; } else @@ -777,7 +777,7 @@ void D_Display () screen->DrawBlend(viewsec); if (automapactive) { - primaryLevel->automap->Drawer ((hud_althud && viewheight == SCREENHEIGHT) ? viewheight : StatusBar->GetTopOfStatusbar()); + primaryLevel->automap->Drawer ((hud_althud && viewheight == screen->GetScreenHeight()) ? viewheight : StatusBar->GetTopOfStatusbar()); } // for timing the statusbar code. @@ -788,7 +788,7 @@ void D_Display () { StatusBar->RefreshViewBorder (); } - if (hud_althud && viewheight == SCREENHEIGHT && screenblocks > 10) + if (hud_althud && viewheight == screen->GetScreenHeight() && screenblocks > 10) { StatusBar->DrawBottomStuff (HUD_AltHud); if (DrawFSHUD || automapactive) StatusBar->DrawAltHUD(); @@ -799,7 +799,7 @@ void D_Display () StatusBar->CallDraw (HUD_AltHud, vp.TicFrac); StatusBar->DrawTopStuff (HUD_AltHud); } - else if (viewheight == SCREENHEIGHT && viewactive && screenblocks > 10) + else if (viewheight == screen->GetScreenHeight() && viewactive && screenblocks > 10) { EHudState state = DrawFSHUD ? HUD_Fullscreen : HUD_None; StatusBar->DrawBottomStuff (state); @@ -853,14 +853,14 @@ void D_Display () FString pstring = GStrings("TXT_BY"); tex = TexMan.GetTextureByName(gameinfo.PauseSign, true); - x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 + + x = (screen->GetUIWidth() - tex->GetDisplayWidth() * CleanXfac)/2 + tex->GetDisplayLeftOffset() * CleanXfac; screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE); if (paused && multiplayer) { pstring << ' ' << players[paused - 1].userinfo.GetName(); screen->DrawText(SmallFont, CR_RED, - (screen->GetWidth() - SmallFont->StringWidth(pstring)*CleanXfac) / 2, + (screen->GetUIWidth() - SmallFont->StringWidth(pstring)*CleanXfac) / 2, (tex->GetDisplayHeight() * CleanYfac) + 4, pstring, DTA_CleanNoMove, true, TAG_DONE); } } @@ -1066,7 +1066,7 @@ void D_PageTicker (void) void D_PageDrawer (void) { - screen->Clear(0, 0, SCREENWIDTH, SCREENHEIGHT, 0, 0); + screen->Clear(0, 0, screen->GetUIWidth(), screen->GetUIHeight(), 0, 0); if (Page.Exists()) { screen->DrawTexture (TexMan.GetTexture(Page, true), 0, 0, @@ -2329,7 +2329,7 @@ void D_DoomMain (void) if (restart) { - C_InitConsole(SCREENWIDTH, SCREENHEIGHT, false); + C_InitConsole(screen->GetScreenWidth(), screen->GetScreenHeight(), false); } nospriterename = false; diff --git a/src/g_statusbar/hudmessages.cpp b/src/g_statusbar/hudmessages.cpp index 82a399084c..c89033dff9 100644 --- a/src/g_statusbar/hudmessages.cpp +++ b/src/g_statusbar/hudmessages.cpp @@ -290,8 +290,8 @@ void DHUDMessage::CalcClipCoords(int hudheight) { // No clipping rectangle set; use the full screen. ClipLeft = 0; ClipTop = 0; - ClipRight = screen->GetWidth(); - ClipBot = screen->GetHeight(); + ClipRight = screen->GetUIWidth(); + ClipBot = screen->GetUIHeight(); } else { @@ -320,7 +320,7 @@ void DHUDMessage::ResetText (const char *text) } else { - width = SCREENWIDTH / active_con_scaletext(AltScale); + width = screen->GetUIWidth() / active_con_scaletext(AltScale); } Lines = V_BreakLines (Font, NoWrap ? INT_MAX : width, (uint8_t *)text); @@ -375,8 +375,8 @@ void DHUDMessage::Draw (int bottom, int visibility) DrawSetup (); - int screen_width = SCREENWIDTH; - int screen_height = SCREENHEIGHT; + int screen_width = screen->GetUIWidth(); + int screen_height = screen->GetUIHeight(); xscale = yscale = 1; if (HUDWidth == 0) { @@ -486,8 +486,8 @@ void DHUDMessage::DoDraw (int linenum, int x, int y, bool clean, int hudheight) { int scale = active_con_scaletext(AltScale); screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_VirtualWidth, SCREENWIDTH / scale, - DTA_VirtualHeight, SCREENHEIGHT / scale, + DTA_VirtualWidth, screen->GetUIWidth() / scale, + DTA_VirtualHeight, screen->GetUIHeight() / scale, DTA_Alpha, Alpha, DTA_RenderStyle, Style, DTA_KeepRatio, true, @@ -579,8 +579,8 @@ void DHUDMessageFadeOut::DoDraw (int linenum, int x, int y, bool clean, int hudh { int scale = active_con_scaletext(AltScale); screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_VirtualWidth, SCREENWIDTH / scale, - DTA_VirtualHeight, SCREENHEIGHT / scale, + DTA_VirtualWidth, screen->GetUIWidth() / scale, + DTA_VirtualHeight, screen->GetUIHeight() / scale, DTA_Alpha, trans, DTA_RenderStyle, Style, DTA_KeepRatio, true, @@ -668,8 +668,8 @@ void DHUDMessageFadeInOut::DoDraw (int linenum, int x, int y, bool clean, int hu { int scale = active_con_scaletext(AltScale); screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_VirtualWidth, SCREENWIDTH / scale, - DTA_VirtualHeight, SCREENHEIGHT / scale, + DTA_VirtualWidth, screen->GetUIWidth() / scale, + DTA_VirtualHeight, screen->GetUIHeight() / scale, DTA_Alpha, trans, DTA_RenderStyle, Style, DTA_KeepRatio, true, @@ -839,8 +839,8 @@ void DHUDMessageTypeOnFadeOut::DoDraw (int linenum, int x, int y, bool clean, in { int scale = active_con_scaletext(AltScale); screen->DrawText (Font, TextColor, x, y, Lines[linenum].Text, - DTA_VirtualWidth, SCREENWIDTH / scale, - DTA_VirtualHeight, SCREENHEIGHT / scale, + DTA_VirtualWidth, screen->GetUIWidth() / scale, + DTA_VirtualHeight, screen->GetUIHeight() / scale, DTA_KeepRatio, true, DTA_TextLen, LineVisible, DTA_Alpha, Alpha, diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index a2d1701fd8..189dd96c22 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -967,11 +967,11 @@ void Popup::close() inline void adjustRelCenter(bool relX, bool relY, const double &x, const double &y, double &outX, double &outY, double ScaleX, double ScaleY) { if(relX) - outX = x + (SCREENWIDTH/(ScaleX*2)); + outX = x + (screen->GetUIWidth()/(ScaleX*2)); else outX = x; if(relY) - outY = y + (SCREENHEIGHT/(ScaleY*2)); + outY = y + (screen->GetUIHeight()/(ScaleY*2)); else outY = y; } @@ -1296,9 +1296,9 @@ public: h *= Scale.Y; if(xright) - rx = SCREENWIDTH + rx; + rx = screen->GetUIWidth() + rx; if(ybot) - ry = SCREENHEIGHT + ry; + ry = screen->GetUIHeight() + ry; // Check for clipping if(clip[0] != 0 || clip[1] != 0 || clip[2] != 0 || clip[3] != 0) @@ -1444,9 +1444,9 @@ public: rh *= Scale.Y; if(xright) - rx = SCREENWIDTH + rx; + rx = screen->GetUIWidth() + rx; if(ybot) - ry = SCREENHEIGHT + ry; + ry = screen->GetUIHeight() + ry; } if(drawshadow) { diff --git a/src/g_statusbar/sbarinfo_commands.cpp b/src/g_statusbar/sbarinfo_commands.cpp index b5a265c655..202c6749bf 100644 --- a/src/g_statusbar/sbarinfo_commands.cpp +++ b/src/g_statusbar/sbarinfo_commands.cpp @@ -1972,7 +1972,7 @@ class CommandAspectRatio : public SBarInfoCommandFlowControl private: int FindRatio() { - float aspect = ActiveRatio(screen->GetWidth(), screen->GetHeight()); + float aspect = ActiveRatio(screen->GetUIWidth(), screen->GetUIHeight()); static std::pair ratioTypes[] = { diff --git a/src/g_statusbar/shared_hud.cpp b/src/g_statusbar/shared_hud.cpp index 7a3350c469..e85990ba70 100644 --- a/src/g_statusbar/shared_hud.cpp +++ b/src/g_statusbar/shared_hud.cpp @@ -107,8 +107,8 @@ void DBaseStatusBar::DrawAltHUD() players[consoleplayer].inventorytics = 0; int scale = GetUIScale(hud_althudscale); - int hudwidth = SCREENWIDTH / scale; - int hudheight = hud_aspectscale ? int(SCREENHEIGHT / (scale*1.2)) : SCREENHEIGHT / scale; + int hudwidth = screen->GetUIWidth() / scale; + int hudheight = hud_aspectscale ? int(screen->GetUIHeight() / (scale*1.2)) : screen->GetUIHeight() / scale; IFVM(AltHud, Draw) { diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 11920dd7c4..bc1509faa6 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -173,7 +173,7 @@ void ST_LoadCrosshair(bool alwaysload) { num = -num; } - size = (SCREENWIDTH < 640) ? 'S' : 'B'; + size = (screen->GetUIWidth() < 640) ? 'S' : 'B'; mysnprintf (name, countof(name), "XHAIR%c%d", size, num); FTextureID texid = TexMan.CheckForTexture(name, ETextureType::MiscPatch, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ShortNameOnly); @@ -396,7 +396,7 @@ void DBaseStatusBar::SetDrawSize(int reltop, int hres, int vres) HorizontalResolution = hres; VerticalResolution = vres; int x, y; - V_CalcCleanFacs(hres, vres, SCREENWIDTH, SCREENHEIGHT, &x, &y); + V_CalcCleanFacs(hres, vres, screen->GetUIWidth(), screen->GetUIHeight(), &x, &y); defaultScale = { (double)x, (double)y }; SetScale(); // recalculate positioning info. @@ -436,8 +436,8 @@ void DBaseStatusBar::SetScale () { ValidateResolution(HorizontalResolution, VerticalResolution); - int w = SCREENWIDTH; - int h = SCREENHEIGHT; + int w = screen->GetUIWidth(); + int h = screen->GetUIHeight(); if (st_scale < 0 || ForcedScale) { // This is the classic fullscreen scale with aspect ratio compensation. @@ -786,7 +786,7 @@ void DBaseStatusBar::RefreshViewBorder () { if (setblocks < 10) { - int Width = screen->GetWidth(); + int Width = screen->GetUIWidth(); if (viewwidth == Width) { return; @@ -811,40 +811,40 @@ void DBaseStatusBar::RefreshBackground () const { int x, x2, y; - float ratio = ActiveRatio (SCREENWIDTH, SCREENHEIGHT); + float ratio = ActiveRatio (screen->GetUIWidth(), screen->GetUIHeight()); x = ST_X; y = SBarTop; - if (x == 0 && y == SCREENHEIGHT) return; + if (x == 0 && y == screen->GetUIHeight()) return; auto tex = GetBorderTexture(primaryLevel); if(!CompleteBorder) { - if(y < SCREENHEIGHT) + if(y < screen->GetUIHeight()) { - screen->DrawBorder (tex, x+1, y, SCREENWIDTH, y+1); - screen->DrawBorder (tex, x+1, SCREENHEIGHT-1, SCREENWIDTH, SCREENHEIGHT); + screen->DrawBorder (tex, x+1, y, screen->GetUIWidth(), y+1); + screen->DrawBorder (tex, x+1, screen->GetUIHeight()-1, screen->GetUIWidth(), screen->GetUIHeight()); } } else { - x = SCREENWIDTH; + x = screen->GetUIWidth(); } if (x > 0) { if(!CompleteBorder) { - x2 = SCREENWIDTH - ST_X; + x2 = screen->GetUIWidth() - ST_X; } else { - x2 = SCREENWIDTH; + x2 = screen->GetUIWidth(); } - screen->DrawBorder (tex, 0, y, x+1, SCREENHEIGHT); - screen->DrawBorder (tex, x2-1, y, SCREENWIDTH, SCREENHEIGHT); + screen->DrawBorder (tex, 0, y, x+1, screen->GetUIHeight()); + screen->DrawBorder (tex, x2-1, y, screen->GetUIWidth(), screen->GetUIHeight()); if (setblocks >= 10) { @@ -852,7 +852,7 @@ void DBaseStatusBar::RefreshBackground () const if (p != NULL) { screen->FlatFill(0, y, x, y + p->GetDisplayHeight(), p, true); - screen->FlatFill(x2, y, SCREENWIDTH, y + p->GetDisplayHeight(), p, true); + screen->FlatFill(x2, y, screen->GetUIWidth(), y + p->GetDisplayHeight(), p, true); } } } @@ -884,7 +884,7 @@ void DBaseStatusBar::DrawCrosshair () if (crosshairscale > 0.0f) { - size = SCREENHEIGHT * crosshairscale / 200.; + size = screen->GetUIHeight() * crosshairscale / 200.; } else { @@ -1044,8 +1044,8 @@ void DBaseStatusBar::DrawLog () { // This uses the same scaling as regular HUD messages auto scale = active_con_scaletext(); - hudwidth = SCREENWIDTH / scale; - hudheight = SCREENHEIGHT / scale; + hudwidth = screen->GetUIWidth() / scale; + hudheight = screen->GetUIHeight() / scale; int linelen = hudwidth<640? Scale(hudwidth,9,10)-40 : 560; auto lines = V_BreakLines (SmallFont, linelen, GStrings(CPlayer->LogText)); @@ -1068,8 +1068,8 @@ void DBaseStatusBar::DrawLog () if (y<0) y=0; w=600; } - screen->Dim(0, 0.5f, Scale(x, SCREENWIDTH, hudwidth), Scale(y, SCREENHEIGHT, hudheight), - Scale(w, SCREENWIDTH, hudwidth), Scale(height, SCREENHEIGHT, hudheight)); + screen->Dim(0, 0.5f, Scale(x, screen->GetUIWidth(), hudwidth), Scale(y, screen->GetUIHeight(), hudheight), + Scale(w, screen->GetUIWidth(), hudwidth), Scale(height, screen->GetUIHeight(), hudheight)); x+=20; y+=10; for (const FBrokenLines &line : lines) @@ -1113,7 +1113,7 @@ void DBaseStatusBar::SetMugShotState(const char *stateName, bool waitTillDone, b void DBaseStatusBar::DrawBottomStuff (EHudState state) { - DrawMessages (HUDMSGLayer_UnderHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_UnderHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : screen->GetUIHeight()); } //--------------------------------------------------------------------------- @@ -1146,9 +1146,9 @@ void DBaseStatusBar::DrawTopStuff (EHudState state) if (automapactive && !viewactive) { - DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_OverMap, (state == HUD_StatusBar) ? GetTopOfStatusbar() : screen->GetUIHeight()); } - DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : SCREENHEIGHT); + DrawMessages (HUDMSGLayer_OverHUD, (state == HUD_StatusBar) ? GetTopOfStatusbar() : screen->GetUIHeight()); primaryLevel->localEventManager->RenderOverlay(state); DrawConsistancy (); @@ -1200,7 +1200,7 @@ void DBaseStatusBar::DrawConsistancy () const } } screen->DrawText (SmallFont, CR_GREEN, - (screen->GetWidth() - SmallFont->StringWidth (conbuff)*CleanXfac) / 2, + (screen->GetUIWidth() - SmallFont->StringWidth (conbuff)*CleanXfac) / 2, 0, conbuff, DTA_CleanNoMove, true, TAG_DONE); } } @@ -1232,7 +1232,7 @@ void DBaseStatusBar::DrawWaiting () const if (buff_p != NULL) { screen->DrawText (SmallFont, CR_ORANGE, - (screen->GetWidth() - SmallFont->StringWidth (conbuff)*CleanXfac) / 2, + (screen->GetUIWidth() - SmallFont->StringWidth (conbuff)*CleanXfac) / 2, SmallFont->GetHeight()*CleanYfac, conbuff, DTA_CleanNoMove, true, TAG_DONE); } } @@ -1430,15 +1430,15 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla switch (flags & DI_SCREEN_HMASK) { default: orgx = 0; break; - case DI_SCREEN_HCENTER: orgx = screen->GetWidth() / 2; break; - case DI_SCREEN_RIGHT: orgx = screen->GetWidth(); break; + case DI_SCREEN_HCENTER: orgx = screen->GetUIWidth() / 2; break; + case DI_SCREEN_RIGHT: orgx = screen->GetUIWidth(); break; } switch (flags & DI_SCREEN_VMASK) { default: orgy = 0; break; - case DI_SCREEN_VCENTER: orgy = screen->GetHeight() / 2; break; - case DI_SCREEN_BOTTOM: orgy = screen->GetHeight(); break; + case DI_SCREEN_VCENTER: orgy = screen->GetUIHeight() / 2; break; + case DI_SCREEN_BOTTOM: orgy = screen->GetUIHeight(); break; } // move stuff in the top right corner a bit down if the fps counter is on. @@ -1509,15 +1509,15 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d switch (flags & DI_SCREEN_HMASK) { default: orgx = 0; break; - case DI_SCREEN_HCENTER: orgx = screen->GetWidth() / 2; break; - case DI_SCREEN_RIGHT: orgx = screen->GetWidth(); break; + case DI_SCREEN_HCENTER: orgx = screen->GetUIWidth() / 2; break; + case DI_SCREEN_RIGHT: orgx = screen->GetUIWidth(); break; } switch (flags & DI_SCREEN_VMASK) { default: orgy = 0; break; - case DI_SCREEN_VCENTER: orgy = screen->GetHeight() / 2; break; - case DI_SCREEN_BOTTOM: orgy = screen->GetHeight(); break; + case DI_SCREEN_VCENTER: orgy = screen->GetUIHeight() / 2; break; + case DI_SCREEN_BOTTOM: orgy = screen->GetUIHeight(); break; } // move stuff in the top right corner a bit down if the fps counter is on. @@ -1659,15 +1659,15 @@ void DBaseStatusBar::TransformRect(double &x, double &y, double &w, double &h, i switch (flags & DI_SCREEN_HMASK) { default: orgx = 0; break; - case DI_SCREEN_HCENTER: orgx = screen->GetWidth() / 2; break; - case DI_SCREEN_RIGHT: orgx = screen->GetWidth(); break; + case DI_SCREEN_HCENTER: orgx = screen->GetUIWidth() / 2; break; + case DI_SCREEN_RIGHT: orgx = screen->GetUIWidth(); break; } switch (flags & DI_SCREEN_VMASK) { default: orgy = 0; break; - case DI_SCREEN_VCENTER: orgy = screen->GetHeight() / 2; break; - case DI_SCREEN_BOTTOM: orgy = screen->GetHeight(); break; + case DI_SCREEN_VCENTER: orgy = screen->GetUIHeight() / 2; break; + case DI_SCREEN_BOTTOM: orgy = screen->GetUIHeight(); break; } // move stuff in the top right corner a bit down if the fps counter is on. diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 26252c7bb4..a9f3f14e8c 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -290,7 +290,7 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER } } - int scorexwidth = SCREENWIDTH / MAX(8, numTeams); + int scorexwidth = screen->GetUIWidth() / MAX(8, numTeams); int numscores = 0; int scorex; @@ -302,7 +302,7 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER } } - scorex = (SCREENWIDTH - scorexwidth * (numscores - 1)) / 2; + scorex = (screen->GetUIWidth() - scorexwidth * (numscores - 1)) / 2; for (i = 0; i < Teams.Size(); ++i) { @@ -331,7 +331,7 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER col3 = col2 + (SmallFont->StringWidth(text_frags) + 8) * CleanXfac; col4 = col3 + maxscorewidth * CleanXfac; col5 = col4 + (maxnamewidth + 8) * CleanXfac; - x = (SCREENWIDTH >> 1) - (((SmallFont->StringWidth(text_delay) * CleanXfac) + col5) >> 1); + x = (screen->GetUIWidth() >> 1) - (((SmallFont->StringWidth(text_delay) * CleanXfac) + col5) >> 1); screen->DrawText (SmallFont, color, x, y, text_color, DTA_CleanNoMove, true, TAG_DONE); @@ -386,7 +386,7 @@ static void HU_DrawTimeRemaining (int y) else mysnprintf (str, countof(str), "Level ends in %d:%02d", minutes, seconds); - screen->DrawText (SmallFont, CR_GREY, SCREENWIDTH/2 - SmallFont->StringWidth (str)/2*CleanXfac, + screen->DrawText (SmallFont, CR_GREY, screen->GetUIWidth()/2 - SmallFont->StringWidth (str)/2*CleanXfac, y, str, DTA_CleanNoMove, true, TAG_DONE); } } diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index a428f7c015..16167ef059 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -168,12 +168,12 @@ void DIntermissionScreen::Drawer () } else { - screen->FlatFill (0,0, SCREENWIDTH, SCREENHEIGHT, TexMan.GetTexture(mBackground), false, true); + screen->FlatFill (0,0, screen->GetUIWidth(), screen->GetUIHeight(), TexMan.GetTexture(mBackground), false, true); } } else { - screen->Clear (0, 0, SCREENWIDTH, SCREENHEIGHT, 0, 0); + screen->Clear (0, 0, screen->GetUIWidth(), screen->GetUIHeight(), 0, 0); } for (unsigned i=0; i < mOverlays.Size(); i++) { @@ -312,20 +312,20 @@ void DIntermissionScreenText::Drawer () int rowheight = SmallFont->GetHeight() * CleanYfac; int rowpadding = (gameinfo.gametype & (GAME_DoomStrifeChex) ? 3 : -1) * CleanYfac; - int cx = (mTextX - 160)*CleanXfac + screen->GetWidth() / 2; - int cy = (mTextY - 100)*CleanYfac + screen->GetHeight() / 2; + int cx = (mTextX - 160)*CleanXfac + screen->GetUIWidth() / 2; + int cy = (mTextY - 100)*CleanYfac + screen->GetUIHeight() / 2; cx = MAX(0, cx); int startx = cx; // Does this text fall off the end of the screen? If so, try to eliminate some margins first. - while (rowpadding > 0 && cy + numrows * (rowheight + rowpadding) - rowpadding > screen->GetHeight()) + while (rowpadding > 0 && cy + numrows * (rowheight + rowpadding) - rowpadding > screen->GetUIHeight()) { rowpadding--; } // If it's still off the bottom, try to center it vertically. - if (cy + numrows * (rowheight + rowpadding) - rowpadding > screen->GetHeight()) + if (cy + numrows * (rowheight + rowpadding) - rowpadding > screen->GetUIHeight()) { - cy = (screen->GetHeight() - (numrows * (rowheight + rowpadding) - rowpadding)) / 2; + cy = (screen->GetUIHeight() - (numrows * (rowheight + rowpadding) - rowpadding)) / 2; // If it's off the top now, you're screwed. It's too tall to fit. if (cy < 0) { @@ -353,7 +353,7 @@ void DIntermissionScreenText::Drawer () pic = SmallFont->GetChar (c, mTextColor, &w); w += kerning; w *= CleanXfac; - if (cx + w > SCREENWIDTH) + if (cx + w > screen->GetUIWidth()) continue; screen->DrawChar(SmallFont, mTextColor, cx, cy, c, DTA_CleanNoMove, true, TAG_DONE); @@ -544,8 +544,8 @@ void DIntermissionScreenCast::Drawer () { if (*name == '$') name = GStrings(name+1); screen->DrawText (SmallFont, CR_UNTRANSLATED, - (SCREENWIDTH - SmallFont->StringWidth (name) * CleanXfac)/2, - (SCREENHEIGHT * 180) / 200, + (screen->GetUIWidth() - SmallFont->StringWidth (name) * CleanXfac)/2, + (screen->GetUIHeight() * 180) / 200, name, DTA_CleanNoMove, true, TAG_DONE); } diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 42938fb809..a39315f49a 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -622,12 +622,12 @@ void M_ScreenShot (const char *filename) if (writepcx) { WritePCXfile(file, buffer.Data(), nullptr, color_type, - screen->GetWidth(), screen->GetHeight(), pitch); + screen->GetScreenWidth(), screen->GetScreenHeight(), pitch); } else { WritePNGfile(file, buffer.Data(), nullptr, color_type, - screen->GetWidth(), screen->GetHeight(), pitch, gamma); + screen->GetScreenWidth(), screen->GetScreenHeight(), pitch, gamma); } delete file; diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index e6cf53a894..8dcfeacbeb 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -872,7 +872,7 @@ static void M_Dim() amount = MIN(1.f, amount*2.f); } - screen->Dim(dimmer, amount, 0, 0, screen->GetWidth(), screen->GetHeight()); + screen->Dim(dimmer, amount, 0, 0, screen->GetUIWidth(), screen->GetUIHeight()); } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index f230f57cbc..199b76c53b 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -9696,11 +9696,11 @@ scriptwait: break; case PCD_GETSCREENWIDTH: - PushToStack (SCREENWIDTH); + PushToStack (screen->GetUIWidth()); break; case PCD_GETSCREENHEIGHT: - PushToStack (SCREENHEIGHT); + PushToStack (screen->GetUIHeight()); break; case PCD_THING_PROJECTILE2: diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index d18099ca10..d24b4b2ac9 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -392,13 +392,13 @@ void SystemGLFrameBuffer::SwapBuffers() int SystemGLFrameBuffer::GetClientWidth() { const int clientWidth = I_GetContentViewSize(m_window).width; - return clientWidth > 0 ? clientWidth : GetWidth(); + return clientWidth > 0 ? clientWidth : GetScreenWidth(); } int SystemGLFrameBuffer::GetClientHeight() { const int clientHeight = I_GetContentViewSize(m_window).height; - return clientHeight > 0 ? clientHeight : GetHeight(); + return clientHeight > 0 ? clientHeight : GetScreenHeight(); } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index c258d0df84..171816a7bd 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -123,7 +123,7 @@ FRenderViewpoint::FRenderViewpoint() TanSin = 0.0; camera = nullptr; sector = nullptr; - FieldOfView = 90.; // Angles in the SCREENWIDTH wide window + FieldOfView = 90.; // Angles in the screen->GetScreenWidth() wide window TicFrac = 0.0; FrameTime = 0; extralight = 0; @@ -264,13 +264,13 @@ void R_ExecuteSetViewSize (FRenderViewpoint &viewpoint, FViewWindow &viewwindow) { setsizeneeded = false; - R_SetWindow (viewpoint, viewwindow, setblocks, SCREENWIDTH, SCREENHEIGHT, StatusBar->GetTopOfStatusbar()); + R_SetWindow (viewpoint, viewwindow, setblocks, screen->GetScreenWidth(), screen->GetScreenHeight(), StatusBar->GetTopOfStatusbar()); // Handle resize, e.g. smaller view windows with border and/or status bar. - viewwindowx = (screen->GetWidth() - viewwidth) >> 1; + viewwindowx = (screen->GetScreenWidth() - viewwidth) >> 1; // Same with base row offset. - viewwindowy = (viewwidth == screen->GetWidth()) ? 0 : (StatusBar->GetTopOfStatusbar() - viewheight) >> 1; + viewwindowy = (viewwidth == screen->GetScreenWidth()) ? 0 : (StatusBar->GetTopOfStatusbar() - viewheight) >> 1; } //========================================================================== @@ -314,8 +314,8 @@ double R_GetGlobVis(const FViewWindow &viewwindow, double vis) { vis = R_ClampVisibility(vis); - double virtwidth = screen->GetWidth(); - double virtheight = screen->GetHeight(); + double virtwidth = screen->GetScreenWidth(); + double virtheight = screen->GetScreenHeight(); if (AspectTallerThanWide(viewwindow.WidescreenRatio)) { @@ -332,14 +332,14 @@ double R_GetGlobVis(const FViewWindow &viewwindow, double vis) double wallVisibility = vis; // Prevent overflow on walls - double maxVisForWall = (InvZtoScale * (screen->GetWidth() * r_Yaspect) / (viewwidth * screen->GetHeight() * viewwindow.FocalTangent)); + double maxVisForWall = (InvZtoScale * (screen->GetScreenWidth() * r_Yaspect) / (viewwidth * screen->GetScreenHeight() * viewwindow.FocalTangent)); maxVisForWall = 32767.0 / maxVisForWall; if (vis < 0 && vis < -maxVisForWall) wallVisibility = -maxVisForWall; else if (vis > 0 && vis > maxVisForWall) wallVisibility = maxVisForWall; - wallVisibility = InvZtoScale * screen->GetWidth() * AspectBaseHeight(viewwindow.WidescreenRatio) / (viewwidth * screen->GetHeight() * 3) * (wallVisibility * viewwindow.FocalTangent); + wallVisibility = InvZtoScale * screen->GetScreenWidth() * AspectBaseHeight(viewwindow.WidescreenRatio) / (viewwidth * screen->GetScreenHeight() * 3) * (wallVisibility * viewwindow.FocalTangent); return wallVisibility / viewwindow.FocalTangent; } diff --git a/src/rendering/2d/v_2ddrawer.cpp b/src/rendering/2d/v_2ddrawer.cpp index 426a293d4d..62fdbc4a30 100644 --- a/src/rendering/2d/v_2ddrawer.cpp +++ b/src/rendering/2d/v_2ddrawer.cpp @@ -554,14 +554,14 @@ void F2DDrawer::AddFlatFill(double left, double top, double right, double bottom if (scaleto320x200) { - float myratio = ActiveRatio (screen->GetWidth(), screen->GetHeight()); + float myratio = ActiveRatio (screen->GetUIWidth(), screen->GetUIHeight()); if (!AspectTallerThanWide(myratio)) { - factor = 240 / screen->GetHeight(); + factor = 240 / screen->GetUIHeight(); } else { - factor = 320 / screen->GetWidth(); + factor = 320 / screen->GetUIWidth(); } } diff --git a/src/rendering/2d/v_draw.cpp b/src/rendering/2d/v_draw.cpp index 52d5b24cc7..29bf0fff07 100644 --- a/src/rendering/2d/v_draw.cpp +++ b/src/rendering/2d/v_draw.cpp @@ -74,15 +74,15 @@ int GetUIScale(int altval) else if (uiscale == 0) { // Default should try to scale to 640x400 - int vscale = screen->GetHeight() / 400; - int hscale = screen->GetWidth() / 640; + int vscale = screen->GetUIHeight() / 400; + int hscale = screen->GetUIWidth() / 640; scaleval = clamp(vscale, 1, hscale); } else scaleval = uiscale; // block scales that result in something larger than the current screen. - int vmax = screen->GetHeight() / 200; - int hmax = screen->GetWidth() / 320; + int vmax = screen->GetUIHeight() / 200; + int hmax = screen->GetUIWidth() / 320; int max = MAX(vmax, hmax); return MAX(1,MIN(scaleval, max)); } @@ -95,15 +95,15 @@ int GetConScale(int altval) else if (uiscale == 0) { // Default should try to scale to 640x400 - int vscale = screen->GetHeight() / 800; - int hscale = screen->GetWidth() / 1280; + int vscale = screen->GetUIHeight() / 800; + int hscale = screen->GetUIWidth() / 1280; scaleval = clamp(vscale, 1, hscale); } else scaleval = uiscale / 2; // block scales that result in something larger than the current screen. - int vmax = screen->GetHeight() / 400; - int hmax = screen->GetWidth() / 640; + int vmax = screen->GetUIHeight() / 400; + int hmax = screen->GetUIWidth() / 640; int max = MAX(vmax, hmax); return MAX(1, MIN(scaleval, max)); } @@ -129,13 +129,13 @@ int CleanXfac_1, CleanYfac_1, CleanWidth_1, CleanHeight_1; DEFINE_ACTION_FUNCTION(_Screen, GetWidth) { PARAM_PROLOGUE; - ACTION_RETURN_INT(screen->GetWidth()); + ACTION_RETURN_INT(screen->GetUIWidth()); } DEFINE_ACTION_FUNCTION(_Screen, GetHeight) { PARAM_PROLOGUE; - ACTION_RETURN_INT(screen->GetHeight()); + ACTION_RETURN_INT(screen->GetUIHeight()); } DEFINE_ACTION_FUNCTION(_Screen, PaletteColor) @@ -268,10 +268,10 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawShape) void DFrameBuffer::SetClipRect(int x, int y, int w, int h) { - clipleft = clamp(x, 0, GetWidth()); - clipwidth = clamp(w, -1, GetWidth() - x); - cliptop = clamp(y, 0, GetHeight()); - clipheight = clamp(h, -1, GetHeight() - y); + clipleft = clamp(x, 0, GetUIWidth()); + clipwidth = clamp(w, -1, GetUIWidth() - x); + cliptop = clamp(y, 0, GetUIHeight()); + clipheight = clamp(h, -1, GetUIHeight() - y); } DEFINE_ACTION_FUNCTION(_Screen, SetClipRect) @@ -359,8 +359,8 @@ bool DFrameBuffer::SetTextureParms(DrawParms *parms, FTexture *img, double xx, d break; case DTA_Clean: - parms->x = (parms->x - 160.0) * CleanXfac + (Width * 0.5); - parms->y = (parms->y - 100.0) * CleanYfac + (Height * 0.5); + parms->x = (parms->x - 160.0) * CleanXfac + (GetUIWidth() * 0.5); + parms->y = (parms->y - 100.0) * CleanYfac + (GetUIHeight() * 0.5); parms->destwidth = parms->texwidth * CleanXfac; parms->destheight = parms->texheight * CleanYfac; break; @@ -389,18 +389,18 @@ bool DFrameBuffer::SetTextureParms(DrawParms *parms, FTexture *img, double xx, d parms->x *= scale.X; if (parms->cleanmode == DTA_HUDRulesC) - parms->x += Width * 0.5; + parms->x += GetUIWidth() * 0.5; else if (xright) - parms->x = Width + parms->x; + parms->x = GetUIWidth() + parms->x; parms->y *= scale.Y; if (ybot) - parms->y = Height + parms->y; + parms->y = GetUIHeight() + parms->y; parms->destwidth = parms->texwidth * scale.X; parms->destheight = parms->texheight * scale.Y; break; } } - if (parms->virtWidth != Width || parms->virtHeight != Height) + if (parms->virtWidth != GetUIWidth() || parms->virtHeight != GetUIHeight()) { VirtualToRealCoords(parms->x, parms->y, parms->destwidth, parms->destheight, parms->virtWidth, parms->virtHeight, parms->virtBottom, !parms->keepratio); @@ -509,10 +509,10 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3 parms->fortext = fortext; parms->windowleft = 0; parms->windowright = INT_MAX; - parms->dClip = this->GetHeight(); + parms->dClip = this->GetUIHeight(); parms->uClip = 0; parms->lClip = 0; - parms->rClip = this->GetWidth(); + parms->rClip = this->GetUIWidth(); parms->left = INT_MAX; parms->top = INT_MAX; parms->destwidth = INT_MAX; @@ -527,8 +527,8 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3 parms->color = 0xffffffff; //parms->shadowAlpha = 0; parms->shadowColor = 0; - parms->virtWidth = this->GetWidth(); - parms->virtHeight = this->GetHeight(); + parms->virtWidth = this->GetUIWidth(); + parms->virtHeight = this->GetUIHeight(); parms->keepratio = false; parms->style.BlendOp = 255; // Dummy "not set" value parms->masked = true; @@ -807,7 +807,7 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3 break; case DTA_ClipBottom: - parms->dClip = MIN(this->GetHeight(), ListGetInt(tags)); + parms->dClip = MIN(this->GetUIHeight(), ListGetInt(tags)); break; case DTA_ClipLeft: @@ -815,7 +815,7 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3 break; case DTA_ClipRight: - parms->rClip = MIN(this->GetWidth(), ListGetInt(tags)); + parms->rClip = MIN(this->GetUIWidth(), ListGetInt(tags)); break; case DTA_ClipTopF: @@ -823,7 +823,7 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3 break; case DTA_ClipBottomF: - parms->dClip = MIN(this->GetHeight(), ListGetDouble(tags)); + parms->dClip = MIN(this->GetUIHeight(), ListGetDouble(tags)); break; case DTA_ClipLeftF: @@ -831,7 +831,7 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3 break; case DTA_ClipRightF: - parms->rClip = MIN(this->GetWidth(), ListGetDouble(tags)); + parms->rClip = MIN(this->GetUIWidth(), ListGetDouble(tags)); break; case DTA_ShadowAlpha: @@ -985,6 +985,8 @@ template bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, doubl void DFrameBuffer::VirtualToRealCoords(double &x, double &y, double &w, double &h, double vwidth, double vheight, bool vbottom, bool handleaspect) const { + auto Width = GetUIWidth(); + auto Height = GetUIHeight(); float myratio = handleaspect ? ActiveRatio (Width, Height) : (4.0f / 3.0f); // if 21:9 AR, map to 16:9 for all callers. @@ -1066,6 +1068,9 @@ void DFrameBuffer::VirtualToRealCoordsInt(int &x, int &y, int &w, int &h, void DFrameBuffer::FillBorder (FTexture *img) { + auto Width = GetUIWidth(); + auto Height = GetUIHeight(); + float myratio = ActiveRatio (Width, Height); // if 21:9 AR, fill borders akin to 16:9, since all fullscreen @@ -1536,11 +1541,11 @@ void DFrameBuffer::DrawBlend(sector_t * viewsector) auto blend = CalcBlend(viewsector, &modulateColor); if (modulateColor != 0xffffffff) { - Dim(modulateColor, 1, 0, 0, GetWidth(), GetHeight(), &LegacyRenderStyles[STYLE_Multiply]); + Dim(modulateColor, 1, 0, 0, GetUIWidth(), GetUIHeight(), &LegacyRenderStyles[STYLE_Multiply]); } const PalEntry bcolor(255, uint8_t(blend.X), uint8_t(blend.Y), uint8_t(blend.Z)); - Dim(bcolor, blend.W, 0, 0, GetWidth(), GetHeight()); + Dim(bcolor, blend.W, 0, 0, GetUIWidth(), GetUIHeight()); } diff --git a/src/rendering/gl/renderer/gl_renderstate.cpp b/src/rendering/gl/renderer/gl_renderstate.cpp index 57f20646ee..b213893305 100644 --- a/src/rendering/gl/renderer/gl_renderstate.cpp +++ b/src/rendering/gl/renderer/gl_renderstate.cpp @@ -558,7 +558,7 @@ void FGLRenderState::ClearScreen() { bool multi = !!glIsEnabled(GL_MULTISAMPLE); - screen->mViewpoints->Set2D(*this, SCREENWIDTH, SCREENHEIGHT); + screen->mViewpoints->Set2D(*this, screen->GetScreenWidth(), screen->GetScreenHeight()); SetColor(0, 0, 0); Apply(); diff --git a/src/rendering/gl/system/gl_framebuffer.cpp b/src/rendering/gl/system/gl_framebuffer.cpp index 6697c89d5e..5456a3dac2 100644 --- a/src/rendering/gl/system/gl_framebuffer.cpp +++ b/src/rendering/gl/system/gl_framebuffer.cpp @@ -150,13 +150,13 @@ void OpenGLFrameBuffer::InitializeState() SetViewportRects(nullptr); - mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight()); + mVertexData = new FFlatVertexBuffer(GetScreenWidth(), GetScreenHeight()); mSkyData = new FSkyVertexBuffer; mViewpoints = new GLViewpointBuffer; mLights = new FLightBuffer(); GLRenderer = new FGLRenderer(this); - GLRenderer->Initialize(GetWidth(), GetHeight()); + GLRenderer->Initialize(GetScreenWidth(), GetScreenHeight()); mDebug = std::make_shared(); mDebug->Update(); @@ -396,7 +396,7 @@ TArray OpenGLFrameBuffer::GetScreenshotBuffer(int &pitch, ESSType &colo const auto &viewport = mOutputLetterbox; // Grab what is in the back buffer. - // We cannot rely on SCREENWIDTH/HEIGHT here because the output may have been scaled. + // We cannot rely on screen->GetWidth()/HEIGHT here because the output may have been scaled. TArray pixels; pixels.Resize(viewport.width * viewport.height * 3); glPixelStorei(GL_PACK_ALIGNMENT, 1); @@ -404,8 +404,8 @@ TArray OpenGLFrameBuffer::GetScreenshotBuffer(int &pitch, ESSType &colo glPixelStorei(GL_PACK_ALIGNMENT, 4); // Copy to screenshot buffer: - int w = SCREENWIDTH; - int h = SCREENHEIGHT; + int w = screen->GetScreenWidth(); + int h = screen->GetScreenHeight(); TArray ScreenshotBuffer(w * h * 3, true); diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index 70940cb51a..e8d9ca77d9 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -444,7 +444,7 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy, // killough 12/98: fix psprite positioning problem ftexturemid = 100.f - sy - r.top - psp->GetYAdjust(screenblocks >= 11); - scale = (SCREENHEIGHT*vw) / (SCREENWIDTH * 200.0f); + scale = (screen->GetScreenHeight()*vw) / (screen->GetScreenWidth() * 200.0f); y1 = viewwindowy + vh / 2 - (ftexturemid * scale); y2 = y1 + (r.height * scale) + 1; diff --git a/src/rendering/hwrenderer/utility/hw_draw2d.cpp b/src/rendering/hwrenderer/utility/hw_draw2d.cpp index 18955c2cd8..b8157a333a 100644 --- a/src/rendering/hwrenderer/utility/hw_draw2d.cpp +++ b/src/rendering/hwrenderer/utility/hw_draw2d.cpp @@ -85,6 +85,7 @@ public: //=========================================================================== // // Draws the 2D stuff. This is the version for OpenGL 3 and later. +// Not that at this point all coodinates are in screen space! // //=========================================================================== @@ -96,7 +97,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) const auto &mScreenViewport = screen->mScreenViewport; state.SetViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); - screen->mViewpoints->Set2D(state, screen->GetWidth(), screen->GetHeight()); + screen->mViewpoints->Set2D(state, screen->GetScreenWidth(), screen->GetScreenHeight()); state.EnableDepthTest(false); state.EnableMultisampling(false); diff --git a/src/rendering/hwrenderer/utility/hw_vrmodes.cpp b/src/rendering/hwrenderer/utility/hw_vrmodes.cpp index ebb2aad9fd..88460af804 100644 --- a/src/rendering/hwrenderer/utility/hw_vrmodes.cpp +++ b/src/rendering/hwrenderer/utility/hw_vrmodes.cpp @@ -109,8 +109,8 @@ void VRMode::AdjustViewport(DFrameBuffer *screen) const VSMatrix VRMode::GetHUDSpriteProjection() const { VSMatrix mat; - int w = screen->GetWidth(); - int h = screen->GetHeight(); + int w = screen->GetScreenWidth(); + int h = screen->GetScreenHeight(); float scaled_w = w / mWeaponProjectionScale; float left_ofs = (w - scaled_w) / 2.f; mat.ortho(left_ofs, left_ofs + scaled_w, (float)h, 0, -1.0f, 1.0f); diff --git a/src/rendering/polyrenderer/poly_renderer.cpp b/src/rendering/polyrenderer/poly_renderer.cpp index b928979c5e..e851196065 100644 --- a/src/rendering/polyrenderer/poly_renderer.cpp +++ b/src/rendering/polyrenderer/poly_renderer.cpp @@ -205,12 +205,12 @@ void PolyRenderer::SetSceneViewport() { int height; if (screenblocks >= 10) - height = SCREENHEIGHT; + height = screen->GetScreenHeight(); else - height = (screenblocks*SCREENHEIGHT / 10) & ~7; + height = (screenblocks*screen->GetScreenHeight() / 10) & ~7; - int bottom = SCREENHEIGHT - (height + viewwindowy - ((height - viewheight) / 2)); - PolyTriangleDrawer::SetViewport(Threads.MainThread()->DrawQueue, viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, RenderTarget); + int bottom = screen->GetScreenHeight() - (height + viewwindowy - ((height - viewheight) / 2)); + PolyTriangleDrawer::SetViewport(Threads.MainThread()->DrawQueue, viewwindowx, screen->GetScreenHeight() - bottom - height, viewwidth, height, RenderTarget); } else // Rendering to camera texture { diff --git a/src/rendering/polyrenderer/scene/poly_playersprite.cpp b/src/rendering/polyrenderer/scene/poly_playersprite.cpp index 3cf04a53d5..c31060f180 100644 --- a/src/rendering/polyrenderer/scene/poly_playersprite.cpp +++ b/src/rendering/polyrenderer/scene/poly_playersprite.cpp @@ -264,7 +264,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p return; } - double yaspectMul = 1.2 * ((double)SCREENHEIGHT / SCREENWIDTH) * r_viewwindow.WidescreenRatio; + double yaspectMul = 1.2 * ((double)screen->GetScreenHeight() / screen->GetScreenWidth()) * r_viewwindow.WidescreenRatio; double pspritexscale = viewwindow.centerxwide / 160.0; double pspriteyscale = pspritexscale * yaspectMul; diff --git a/src/rendering/swrenderer/drawers/r_thread.cpp b/src/rendering/swrenderer/drawers/r_thread.cpp index e8b6eeada2..690db1bb86 100644 --- a/src/rendering/swrenderer/drawers/r_thread.cpp +++ b/src/rendering/swrenderer/drawers/r_thread.cpp @@ -140,8 +140,8 @@ void DrawerThreads::WorkerMain(DrawerThread *thread) // Grab the commands DrawerCommandQueuePtr list = active_commands[thread->current_queue]; thread->current_queue++; - thread->numa_start_y = thread->numa_node * screen->GetHeight() / thread->num_numa_nodes; - thread->numa_end_y = (thread->numa_node + 1) * screen->GetHeight() / thread->num_numa_nodes; + thread->numa_start_y = thread->numa_node * screen->GetScreenHeight() / thread->num_numa_nodes; + thread->numa_end_y = (thread->numa_node + 1) * screen->GetScreenHeight() / thread->num_numa_nodes; if (thread->poly) { thread->poly->numa_start_y = thread->numa_start_y; diff --git a/src/rendering/swrenderer/plane/r_flatplane.cpp b/src/rendering/swrenderer/plane/r_flatplane.cpp index 278fe3e148..0f91320790 100644 --- a/src/rendering/swrenderer/plane/r_flatplane.cpp +++ b/src/rendering/swrenderer/plane/r_flatplane.cpp @@ -96,7 +96,7 @@ namespace swrenderer auto viewport = Thread->Viewport.get(); - // Scale will be unit scale at FocalLengthX (normally SCREENWIDTH/2) distance + // Scale will be unit scale at FocalLengthX (normally screen->GetWidth()/2) distance xstep = cos(planeang) / viewport->FocalLengthX; ystep = -sin(planeang) / viewport->FocalLengthX; diff --git a/src/rendering/swrenderer/r_swscene.cpp b/src/rendering/swrenderer/r_swscene.cpp index 164ffd536c..014f958253 100644 --- a/src/rendering/swrenderer/r_swscene.cpp +++ b/src/rendering/swrenderer/r_swscene.cpp @@ -91,25 +91,25 @@ sector_t *SWSceneDrawer::RenderView(player_t *player) auto &fbtex = FBTexture[FBTextureIndex]; if (fbtex == nullptr || fbtex->GetSystemTexture() == nullptr || - fbtex->GetDisplayWidth() != screen->GetWidth() || - fbtex->GetDisplayHeight() != screen->GetHeight() || + fbtex->GetDisplayWidth() != screen->GetScreenWidth() || + fbtex->GetDisplayHeight() != screen->GetScreenHeight() || (V_IsTrueColor() ? 1:0) != fbtex->GetColorFormat()) { // This manually constructs its own material here. fbtex.reset(); - fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); - fbtex->GetSystemTexture()->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); + fbtex.reset(new FWrapperTexture(screen->GetScreenWidth(), screen->GetScreenHeight(), V_IsTrueColor())); + fbtex->GetSystemTexture()->AllocateBuffer(screen->GetScreenWidth(), screen->GetScreenHeight(), V_IsTrueColor() ? 4 : 1); auto mat = FMaterial::ValidateTexture(fbtex.get(), false); mat->AddTextureLayer(PaletteTexture); Canvas.reset(); - Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); + Canvas.reset(new DCanvas(screen->GetScreenWidth(), screen->GetScreenHeight(), V_IsTrueColor())); } auto buf = fbtex->GetSystemTexture()->MapBuffer(); if (!buf) I_FatalError("Unable to map buffer for software rendering"); SWRenderer->RenderView(player, Canvas.get(), buf); - fbtex->GetSystemTexture()->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); + fbtex->GetSystemTexture()->CreateTexture(nullptr, screen->GetScreenWidth(), screen->GetScreenHeight(), 0, false, 0, "swbuffer"); auto map = swrenderer::CameraLight::Instance()->ShaderColormap(); screen->DrawTexture(fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE); diff --git a/src/rendering/swrenderer/scene/r_light.cpp b/src/rendering/swrenderer/scene/r_light.cpp index 13c19bf93c..194568e1a6 100644 --- a/src/rendering/swrenderer/scene/r_light.cpp +++ b/src/rendering/swrenderer/scene/r_light.cpp @@ -110,7 +110,7 @@ namespace swrenderer BaseVisibility = vis; - MaxVisForWall = (viewport->InvZtoScale * (SCREENWIDTH*r_Yaspect) / (viewwidth*SCREENHEIGHT * viewport->viewwindow.FocalTangent)); + MaxVisForWall = (viewport->InvZtoScale * (screen->GetScreenWidth()*r_Yaspect) / (viewwidth*screen->GetScreenHeight() * viewport->viewwindow.FocalTangent)); MaxVisForWall = 32767.0 / MaxVisForWall; MaxVisForFloor = 32767.0 / (viewheight >> 2) * viewport->FocalLengthY / 160; @@ -122,8 +122,8 @@ namespace swrenderer else WallVisibility = BaseVisibility; - WallVisibility = (viewport->InvZtoScale * SCREENWIDTH*AspectBaseHeight(viewport->viewwindow.WidescreenRatio) / - (viewwidth*SCREENHEIGHT * 3)) * (WallVisibility * viewport->viewwindow.FocalTangent); + WallVisibility = (viewport->InvZtoScale * screen->GetScreenWidth()*AspectBaseHeight(viewport->viewwindow.WidescreenRatio) / + (viewwidth*screen->GetScreenHeight() * 3)) * (WallVisibility * viewport->viewwindow.FocalTangent); // Prevent overflow on floors/ceilings. Note that the calculation of // MaxVisForFloor means that planes less than two units from the player's diff --git a/src/rendering/swrenderer/scene/r_scene.cpp b/src/rendering/swrenderer/scene/r_scene.cpp index 5621561125..d5a331ffb6 100644 --- a/src/rendering/swrenderer/scene/r_scene.cpp +++ b/src/rendering/swrenderer/scene/r_scene.cpp @@ -98,8 +98,8 @@ namespace swrenderer R_ExecuteSetViewSize(MainThread()->Viewport->viewpoint, MainThread()->Viewport->viewwindow); - int width = SCREENWIDTH; - int height = SCREENHEIGHT; + int width = screen->GetScreenWidth(); + int height = screen->GetScreenHeight(); float trueratio; ActiveRatio(width, height, &trueratio); viewport->SetViewport(player->camera->Level, MainThread(), width, height, trueratio); diff --git a/src/rendering/swrenderer/things/r_playersprite.cpp b/src/rendering/swrenderer/things/r_playersprite.cpp index 94e127ad1a..03dc1bead6 100644 --- a/src/rendering/swrenderer/things/r_playersprite.cpp +++ b/src/rendering/swrenderer/things/r_playersprite.cpp @@ -261,7 +261,7 @@ namespace swrenderer auto viewport = Thread->Viewport.get(); double pspritexscale = viewport->viewwindow.centerxwide / 160.0; - double pspriteyscale = pspritexscale * viewport->BaseYaspectMul * ((double)SCREENHEIGHT / SCREENWIDTH) * r_viewwindow.WidescreenRatio; + double pspriteyscale = pspritexscale * viewport->BaseYaspectMul * ((double)screen->GetScreenHeight() / screen->GetScreenWidth()) * r_viewwindow.WidescreenRatio; double pspritexiscale = 1 / pspritexscale; int tleft = tex->GetDisplayLeftOffset(); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 4027adc2d9..27caf4cf88 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -210,7 +210,7 @@ void S_NoiseDebug (void) // Display the oldest channel first. for (chan = Channels; chan->NextChan != NULL; chan = chan->NextChan) { } - while (y < SCREENHEIGHT - 16) + while (y < screen->GetUIHeight() - 16) { char temp[32]; diff --git a/src/utility/stats.cpp b/src/utility/stats.cpp index 817d1fe8b6..b0ffab3069 100644 --- a/src/utility/stats.cpp +++ b/src/utility/stats.cpp @@ -88,7 +88,7 @@ void FStat::PrintStat () int textScale = active_con_scale(); int fontheight = NewConsoleFont->GetHeight() + 1; - int y = SCREENHEIGHT / textScale; + int y = screen->GetUIHeight() / textScale; int count = 0; for (FStat *stat = FirstStat; stat != NULL; stat = stat->m_Next) @@ -106,8 +106,8 @@ void FStat::PrintStat () if (stattext[i] == '\n') y -= fontheight; } screen->DrawText(NewConsoleFont, CR_GREEN, 5 / textScale, y, stattext, - DTA_VirtualWidth, screen->GetWidth() / textScale, - DTA_VirtualHeight, screen->GetHeight() / textScale, + DTA_VirtualWidth, screen->GetUIWidth() / textScale, + DTA_VirtualHeight, screen->GetUIHeight() / textScale, DTA_KeepRatio, true, TAG_DONE); count++; } diff --git a/src/v_framebuffer.cpp b/src/v_framebuffer.cpp index ec53fc7e86..6591b2c59f 100644 --- a/src/v_framebuffer.cpp +++ b/src/v_framebuffer.cpp @@ -104,8 +104,8 @@ DFrameBuffer::~DFrameBuffer() void DFrameBuffer::SetSize(int width, int height) { - Width = ViewportScaledWidth(width, height); - Height = ViewportScaledHeight(width, height); + UIWidth = ScreenWidth = ViewportScaledWidth(width, height); + UIHeight = ScreenHeight = ViewportScaledHeight(width, height); } //========================================================================== @@ -114,9 +114,9 @@ void DFrameBuffer::SetSize(int width, int height) // //========================================================================== -void V_DrawPaletteTester(int paletteno) +void DFrameBuffer::DrawPaletteTester(int paletteno) { - int blocksize = screen->GetHeight() / 50; + int blocksize = screen->GetUIHeight() / 50; int t = paletteno; int k = 0; @@ -127,7 +127,7 @@ void V_DrawPaletteTester(int paletteno) int palindex = (t > 1) ? translationtables[TRANSLATION_Standard][t - 2]->Remap[k] : k; PalEntry pe = GPalette.BaseColors[palindex]; k++; - screen->Dim(pe, 1.f, j*blocksize, i*blocksize, blocksize, blocksize); + Dim(pe, 1.f, j*blocksize, i*blocksize, blocksize, blocksize); } } } @@ -156,11 +156,11 @@ void DFrameBuffer::DrawRateStuff () int textScale = active_con_scale(); chars = mysnprintf (fpsbuff, countof(fpsbuff), "%2llu ms (%3llu fps)", (unsigned long long)howlong, (unsigned long long)LastCount); - rate_x = Width / textScale - NewConsoleFont->StringWidth(&fpsbuff[0]); - Clear (rate_x * textScale, 0, Width, NewConsoleFont->GetHeight() * textScale, GPalette.BlackIndex, 0); + rate_x = UIWidth / textScale - NewConsoleFont->StringWidth(&fpsbuff[0]); + Clear (rate_x * textScale, 0, UIWidth, NewConsoleFont->GetHeight() * textScale, GPalette.BlackIndex, 0); DrawText (NewConsoleFont, CR_WHITE, rate_x, 0, (char *)&fpsbuff[0], - DTA_VirtualWidth, screen->GetWidth() / textScale, - DTA_VirtualHeight, screen->GetHeight() / textScale, + DTA_VirtualWidth, UIWidth / textScale, + DTA_VirtualHeight, UIHeight / textScale, DTA_KeepRatio, true, TAG_DONE); uint32_t thisSec = (uint32_t)(ms/1000); @@ -185,14 +185,14 @@ void DFrameBuffer::DrawRateStuff () if (tics > 20) tics = 20; int i; - for (i = 0; i < tics*2; i += 2) Clear(i, Height-1, i+1, Height, 255, 0); - for ( ; i < 20*2; i += 2) Clear(i, Height-1, i+1, Height, 0, 0); + for (i = 0; i < tics*2; i += 2) Clear(i, UIHeight-1, i+1, UIHeight, 255, 0); + for ( ; i < 20*2; i += 2) Clear(i, UIHeight-1, i+1, UIHeight, 0, 0); } // draws the palette for debugging if (vid_showpalette) { - V_DrawPaletteTester(vid_showpalette); + DrawPaletteTester(vid_showpalette); } } @@ -212,7 +212,7 @@ void DFrameBuffer::Update() int clientHeight = ViewportScaledHeight(initialWidth, initialHeight); if (clientWidth < 320) clientWidth = 320; if (clientHeight < 200) clientHeight = 200; - if (clientWidth > 0 && clientHeight > 0 && (GetWidth() != clientWidth || GetHeight() != clientHeight)) + if (clientWidth > 0 && clientHeight > 0 && (GetScreenWidth() != clientWidth || GetScreenHeight() != clientHeight)) { SetVirtualSize(clientWidth, clientHeight); V_OutputResized(clientWidth, clientHeight); @@ -325,13 +325,13 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) int height, width; if (screenblocks >= 10) { - height = GetHeight(); - width = GetWidth(); + height = GetScreenHeight(); + width = GetScreenWidth(); } else { - height = (screenblocks*GetHeight() / 10) & ~7; - width = (screenblocks*GetWidth() / 10); + height = (screenblocks*GetScreenHeight() / 10) & ~7; + width = (screenblocks*GetScreenWidth() / 10); } // Back buffer letterbox for the final output @@ -344,8 +344,8 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) clientWidth = 160; clientHeight = 120; } - int screenWidth = GetWidth(); - int screenHeight = GetHeight(); + int screenWidth = GetScreenWidth(); + int screenHeight = GetScreenHeight(); float scaleX, scaleY; if (ViewportIsScaled43()) { @@ -397,12 +397,12 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) int DFrameBuffer::ScreenToWindowX(int x) { - return mScreenViewport.left + (int)round(x * mScreenViewport.width / (float)GetWidth()); + return mScreenViewport.left + (int)round(x * mScreenViewport.width / (float)GetScreenWidth()); } int DFrameBuffer::ScreenToWindowY(int y) { - return mScreenViewport.top + mScreenViewport.height - (int)round(y * mScreenViewport.height / (float)GetHeight()); + return mScreenViewport.top + mScreenViewport.height - (int)round(y * mScreenViewport.height / (float)GetScreenHeight()); } void DFrameBuffer::ScaleCoordsFromWindow(int16_t &x, int16_t &y) @@ -412,6 +412,6 @@ void DFrameBuffer::ScaleCoordsFromWindow(int16_t &x, int16_t &y) int letterboxWidth = mOutputLetterbox.width; int letterboxHeight = mOutputLetterbox.height; - x = int16_t((x - letterboxX) * Width / letterboxWidth); - y = int16_t((y - letterboxY) * Height / letterboxHeight); + x = int16_t((x - letterboxX) * GetScreenWidth() / letterboxWidth); + y = int16_t((y - letterboxY) * GetScreenHeight() / letterboxHeight); } diff --git a/src/v_video.cpp b/src/v_video.cpp index 212ae1f0ae..46d16ecc30 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -544,7 +544,7 @@ void V_UpdateModeSize (int width, int height) // The optimal scale will always be to fit a virtual 640 pixel wide display onto the screen. // Exceptions are made for a few ranges where the available virtual width is > 480. - int w = screen->GetWidth(); + int w = screen->GetScreenWidth(); int factor; if (w < 640) factor = 1; else if (w >= 1024 && w < 1280) factor = 2; @@ -599,7 +599,7 @@ bool IVideo::SetResolution () screen->InitializeState(); screen->SetGamma(); - V_UpdateModeSize(screen->GetWidth(), screen->GetHeight()); + V_UpdateModeSize(screen->GetScreenWidth(), screen->GetScreenHeight()); return true; } @@ -678,11 +678,11 @@ void V_Init2() I_InitGraphics(); Video->SetResolution(); // this only fails via exceptions. - Printf ("Resolution: %d x %d\n", SCREENWIDTH, SCREENHEIGHT); + Printf ("Resolution: %d x %d\n", screen->GetScreenWidth(), screen->GetScreenHeight()); // init these for the scaling menu - menu_resolution_custom_width = SCREENWIDTH; - menu_resolution_custom_height = SCREENHEIGHT; + menu_resolution_custom_width = screen->GetScreenWidth(); + menu_resolution_custom_height = screen->GetScreenHeight(); screen->SetGamma (); FBaseCVar::ResetColors (); @@ -758,7 +758,7 @@ float ActiveRatio(int width, int height, float *trueratio) DEFINE_ACTION_FUNCTION(_Screen, GetAspectRatio) { - ACTION_RETURN_FLOAT(ActiveRatio(screen->GetWidth(), screen->GetHeight(), nullptr)); + ACTION_RETURN_FLOAT(ActiveRatio(screen->GetScreenWidth(), screen->GetScreenHeight(), nullptr)); } // Tries to guess the physical dimensions of the screen based on the diff --git a/src/v_video.h b/src/v_video.h index 27e30ddf18..12e265cd44 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -356,8 +356,10 @@ protected: F2DDrawer m2DDrawer; private: - int Width = 0; - int Height = 0; + int ScreenWidth = 0; + int ScreenHeight = 0; + int UIWidth = 0; + int UIHeight = 0; protected: int clipleft = 0, cliptop = 0, clipwidth = -1, clipheight = -1; @@ -391,11 +393,15 @@ public: void SetSize(int width, int height); void SetVirtualSize(int width, int height) { - Width = width; - Height = height; + ScreenWidth = width; + ScreenHeight = height; + UIWidth = width; + UIHeight = height; } - inline int GetWidth() const { return Width; } - inline int GetHeight() const { return Height; } + inline int GetScreenWidth() const { return ScreenWidth; } + inline int GetScreenHeight() const { return ScreenHeight; } + inline int GetUIWidth() const { return UIWidth; } + inline int GetUIHeight() const { return UIHeight; } FVector2 SceneScale() const { @@ -564,6 +570,7 @@ public: protected: void DrawRateStuff (); + void DrawPaletteTester(int paletteno); private: @@ -576,10 +583,6 @@ private: // This is the screen updated by I_FinishUpdate. extern DFrameBuffer *screen; -#define SCREENWIDTH (screen->GetWidth ()) -#define SCREENHEIGHT (screen->GetHeight ()) -#define SCREENPITCH (screen->GetPitch ()) - EXTERN_CVAR (Float, Gamma) @@ -652,9 +655,9 @@ public: savedyfac = CleanYfac; savedwidth = CleanWidth; savedheight = CleanHeight; - V_CalcCleanFacs(320, 200, screen->GetWidth(), screen->GetHeight(), &CleanXfac, &CleanYfac); - CleanWidth = screen->GetWidth() / CleanXfac; - CleanHeight = screen->GetHeight() / CleanYfac; + V_CalcCleanFacs(320, 200, screen->GetScreenWidth(), screen->GetScreenHeight(), &CleanXfac, &CleanYfac); + CleanWidth = screen->GetScreenWidth() / CleanXfac; + CleanHeight = screen->GetScreenHeight() / CleanYfac; } ~ScaleOverrider() diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index 7fd1336133..d247f10c9b 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -604,12 +604,12 @@ void DInterBackground::drawBackground(int state, bool drawsplat, bool snl_pointe } else { - screen->FlatFill(0, 0, SCREENWIDTH, SCREENHEIGHT, background, false, true); + screen->FlatFill(0, 0, screen->GetUIWidth(), screen->GetUIHeight(), background, false, true); } } else { - screen->Clear(0, 0, SCREENWIDTH, SCREENHEIGHT, 0, 0); + screen->Clear(0, 0, screen->GetUIWidth(), screen->GetUIHeight(), 0, 0); } for (i = 0; i