Skip to content

Commit 3ab4e3e

Browse files
committed
Draw application to a lower-res texture for DPI scaling
1 parent f0a206d commit 3ab4e3e

8 files changed

Lines changed: 322 additions & 94 deletions

File tree

engine/render.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,10 @@ class r_IRenderer {
8686
virtual void DrawStringFormat(float x, float y, int align, int height, const col4_t col, int font, const char* fmt, ...) = 0;
8787
virtual int DrawStringWidth(int height, int font, const char* str) = 0;
8888
virtual int DrawStringCursorIndex(int height, int font, const char* str, int curX, int curY) = 0;
89+
90+
virtual int VirtualScreenWidth() = 0;
91+
virtual int VirtualScreenHeight() = 0;
92+
virtual float VirtualScreenScaleFactor() = 0;
93+
virtual int VirtualMap(int properValue) = 0;
94+
virtual int VirtualUnmap(int mappedValue) =0;
8995
};

engine/render/r_font.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ void r_font_c::DrawTextLine(scp_t pos, int align, int height, col4_t col, const
238238
double width = StringWidthInternal(fh, str) * scale;
239239
switch (align) {
240240
case F_CENTRE:
241-
x = floor((renderer->sys->video->vid.size[0] - width) / 2.0f + pos[X]);
241+
x = floor((renderer->VirtualScreenWidth() - width) / 2.0f + pos[X]);
242242
break;
243243
case F_RIGHT:
244-
x = floor(renderer->sys->video->vid.size[0] - width - pos[X]);
244+
x = floor(renderer->VirtualScreenWidth() - width - pos[X]);
245245
break;
246246
case F_CENTRE_X:
247247
x = floor(pos[X] - width / 2.0f);
@@ -285,7 +285,7 @@ void r_font_c::DrawTextLine(scp_t pos, int align, int height, col4_t col, const
285285
x+= glyph->spLeft * scale;
286286
if (glyph->width) {
287287
double w = glyph->width * scale;
288-
if (x + w >= 0 && x < renderer->sys->video->vid.size[0]) {
288+
if (x + w >= 0 && x < renderer->VirtualScreenWidth()) {
289289
renderer->curLayer->Quad(
290290
glyph->tcLeft, glyph->tcTop, x, y,
291291
glyph->tcRight, glyph->tcTop, x + w, y,

0 commit comments

Comments
 (0)