Skip to content

Commit

Permalink
Merge pull request #45 from zao/fix/integer-dpi-scaling
Browse files Browse the repository at this point in the history
fix: point-filter window for even DPI factors
  • Loading branch information
LocalIdentity authored Mar 23, 2024
2 parents b8503a5 + f5fd6db commit 23a0c59
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions engine/render/r_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ void r_renderer_c::BeginFrame()
auto& vid = sys->video->vid;
int wNew = VirtualScreenWidth();
int hNew = VirtualScreenHeight();
bool const wantIntegerScaling = fmodf(vid.dpiScale, 1.0f) < 0.0005f;
for (int i = 0; i < 2; ++i) {
auto& rtt = rttMain[i];
if (rtt.width != wNew || rtt.height != hNew) {
Expand All @@ -1144,8 +1145,9 @@ void r_renderer_c::BeginFrame()
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, wNew, hNew, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint const filterMode = wantIntegerScaling ? GL_NEAREST : GL_LINEAR;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterMode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterMode);

rtt.width = wNew;
rtt.height = hNew;
Expand Down

0 comments on commit 23a0c59

Please sign in to comment.