diff --git a/src/main/java/net/coderbot/iris/mixin/MixinWindow.java b/src/main/java/net/coderbot/iris/mixin/MixinWindow.java index 58163ab380..2e02d0295e 100644 --- a/src/main/java/net/coderbot/iris/mixin/MixinWindow.java +++ b/src/main/java/net/coderbot/iris/mixin/MixinWindow.java @@ -16,6 +16,8 @@ public class MixinWindow { @Inject(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwCreateWindow(IILjava/lang/CharSequence;JJ)J")) private void iris$enableDebugContext(WindowEventHandler arg, ScreenManager arg2, DisplayData arg3, String string, String string2, CallbackInfo ci) { if (Iris.getIrisConfig().areDebugOptionsEnabled()) { + GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 4); + GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 6); GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GLFW.GLFW_TRUE); GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_NO_ERROR, GLFW.GLFW_FALSE); Iris.logger.info("OpenGL debug context activated."); diff --git a/src/main/java/net/coderbot/iris/rendertarget/RenderTarget.java b/src/main/java/net/coderbot/iris/rendertarget/RenderTarget.java index 032aafb3eb..deb70bb3d2 100644 --- a/src/main/java/net/coderbot/iris/rendertarget/RenderTarget.java +++ b/src/main/java/net/coderbot/iris/rendertarget/RenderTarget.java @@ -14,6 +14,7 @@ import java.nio.ByteBuffer; public class RenderTarget { + private static final double LOG2 = Math.log(2); private InternalTextureFormat internalFormat; private final PixelFormat format; private final PixelType type; @@ -67,19 +68,18 @@ public void setMipmapping(boolean enabled) { } private void resizeTexture(boolean alt, int width, int height) { - if (this.mainTexture != 0) GlStateManager._deleteTexture(mainTexture); - if (this.altTexture != 0) GlStateManager._deleteTexture(altTexture); - if (alt) { this.altTexture = IrisRenderSystem.createTexture(GL46C.GL_TEXTURE_2D); } else { this.mainTexture = IrisRenderSystem.createTexture(GL46C.GL_TEXTURE_2D); } - GL46C.glTextureStorage2D(alt ? altTexture : mainTexture, 4, internalFormat.getGlFormat(), width, height); + GL46C.glTextureStorage2D(alt ? altTexture : mainTexture, (int) (1 + Math.floor(Math.log(Math.max(width, height)) / LOG2)), internalFormat.getGlFormat(), width, height); } void resize(Vector2i textureScaleOverride) { + if (this.mainTexture != 0) GlStateManager._deleteTexture(mainTexture); + if (this.altTexture != 0) GlStateManager._deleteTexture(altTexture); this.resize(textureScaleOverride.x, textureScaleOverride.y); } diff --git a/src/main/java/net/coderbot/iris/rendertarget/RenderTargets.java b/src/main/java/net/coderbot/iris/rendertarget/RenderTargets.java index b6c1cec0ad..f80a2a8f1f 100644 --- a/src/main/java/net/coderbot/iris/rendertarget/RenderTargets.java +++ b/src/main/java/net/coderbot/iris/rendertarget/RenderTargets.java @@ -233,7 +233,7 @@ private ImmutableSet invert(ImmutableSet base, int[] relevant) } private GlFramebufferFromTargets createEmptyFramebuffer() { - GlFramebufferFromTargets framebuffer = new GlFramebufferFromTargets(new int[0], ImmutableSet.of()); + GlFramebufferFromTargets framebuffer = new GlFramebufferFromTargets(new int[] { 0 }, ImmutableSet.of()); ownedFramebuffers.add(framebuffer); framebuffer.addDepthAttachment(currentDepthTexture);