Skip to content

Commit

Permalink
It finally works
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Aug 10, 2023
1 parent 01f231f commit 6642488
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/net/coderbot/iris/mixin/MixinWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class MixinWindow {
@Inject(method = "<init>", 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.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private ImmutableSet<Integer> invert(ImmutableSet<Integer> 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);
Expand Down

0 comments on commit 6642488

Please sign in to comment.