Skip to content

Commit 23a0c59

Browse files
Merge pull request #45 from zao/fix/integer-dpi-scaling
fix: point-filter window for even DPI factors
2 parents b8503a5 + f5fd6db commit 23a0c59

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

engine/render/r_main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ void r_renderer_c::BeginFrame()
11341134
auto& vid = sys->video->vid;
11351135
int wNew = VirtualScreenWidth();
11361136
int hNew = VirtualScreenHeight();
1137+
bool const wantIntegerScaling = fmodf(vid.dpiScale, 1.0f) < 0.0005f;
11371138
for (int i = 0; i < 2; ++i) {
11381139
auto& rtt = rttMain[i];
11391140
if (rtt.width != wNew || rtt.height != hNew) {
@@ -1144,8 +1145,9 @@ void r_renderer_c::BeginFrame()
11441145
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, wNew, hNew, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
11451146
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
11461147
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1147-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1148-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1148+
GLint const filterMode = wantIntegerScaling ? GL_NEAREST : GL_LINEAR;
1149+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterMode);
1150+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterMode);
11491151

11501152
rtt.width = wNew;
11511153
rtt.height = hNew;

0 commit comments

Comments
 (0)