Skip to content

Commit e15fb87

Browse files
committed
fix: correct initial macOS OpenGL framebuffer size
1 parent 9116dc2 commit e15fb87

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

common/src/main/java/me/flashyreese/mods/sodiumextra/client/util/MacReducedResolution.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public static boolean shouldReduceFramebuffer(int framebufferWidth, int framebuf
4040
return isEnabled() && backend != Backend.OPENGL && isHighDpiFramebuffer(framebufferWidth, framebufferHeight, windowWidth, windowHeight);
4141
}
4242

43+
public static boolean shouldUseWindowSizeForInitialFramebuffer() {
44+
return isEnabled() && backend == Backend.OPENGL;
45+
}
46+
4347
public static GpuSurface.Configuration reduceSurfaceConfiguration(GpuSurface.Configuration config) {
4448
if (!isEnabled() || backend != Backend.VULKAN || !isHighDpiFramebuffer(config.width(), config.height(), windowWidth, windowHeight)) {
4549
return config;

common/src/main/java/me/flashyreese/mods/sodiumextra/mixin/reduce_resolution_on_mac/MixinWindow.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,27 @@ public class MixinWindow {
3535

3636
@Inject(at = @At(value = "RETURN"), method = "refreshFramebufferSize")
3737
private void afterUpdateFrameBufferSize(CallbackInfo ci) {
38-
this.scaleFramebufferSize();
38+
this.scaleInitialFramebufferSize();
3939
}
4040

4141
@Inject(method = "onFramebufferResize", at = @At(value = "FIELD", target = "Lcom/mojang/blaze3d/platform/Window;framebufferHeight:I", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER))
4242
private void afterFramebufferResize(long handle, int newWidth, int newHeight, CallbackInfo ci) {
4343
this.scaleFramebufferSize();
4444
}
4545

46+
@Unique
47+
private void scaleInitialFramebufferSize() {
48+
MacReducedResolution.rememberWindowSize(this.width, this.height);
49+
50+
if (MacReducedResolution.shouldUseWindowSizeForInitialFramebuffer()) {
51+
this.framebufferWidth = Math.max(1, this.width);
52+
this.framebufferHeight = Math.max(1, this.height);
53+
return;
54+
}
55+
56+
this.scaleFramebufferSize();
57+
}
58+
4659
@Unique
4760
private void scaleFramebufferSize() {
4861
MacReducedResolution.rememberWindowSize(this.width, this.height);

0 commit comments

Comments
 (0)