Skip to content

Commit

Permalink
Fix wireframe and patch stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Dec 14, 2023
1 parent 5eb3d9a commit 8bc3a7e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
19 changes: 19 additions & 0 deletions src/main/java/net/coderbot/iris/gl/IrisRenderSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class IrisRenderSystem {
private static DSAAccess dsaState;
private static boolean hasMultibind;
private static boolean supportsCompute;
private static int polygonMode = GL43C.GL_FILL;
private static int backupPolygonMode = GL43C.GL_FILL;
private static int[] samplers;

public static void initRenderer() {
Expand Down Expand Up @@ -424,6 +426,23 @@ public static void deleteBuffers(int glId) {
GL43C.glDeleteBuffers(glId);
}

public static void setPolygonMode(int mode) {
if (mode != polygonMode) {
polygonMode = mode;
GL43C.glPolygonMode(GL43C.GL_FRONT_AND_BACK, mode);
}
}

public static void overridePolygonMode() {
backupPolygonMode = polygonMode;
setPolygonMode(GL43C.GL_FILL);
}

public static void restorePolygonMode() {
setPolygonMode(backupPolygonMode);
backupPolygonMode = GL43C.GL_FILL;
}

public interface DSAAccess {
void generateMipmaps(int texture, int target);

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/coderbot/iris/mixin/MixinLevelRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mojang.math.Vector3f;
import net.coderbot.iris.Iris;
import net.coderbot.iris.fantastic.WrappingMultiBufferSource;
import net.coderbot.iris.gl.IrisRenderSystem;
import net.coderbot.iris.gl.program.Program;
import net.coderbot.iris.layer.IsOutlineRenderStateShard;
import net.coderbot.iris.layer.OuterWrappedRenderType;
Expand Down Expand Up @@ -89,7 +90,7 @@ public class MixinLevelRenderer {
}

if (Iris.shouldActivateWireframe() && this.minecraft.isLocalServer()) {
GL43C.glPolygonMode(GL43C.GL_FRONT_AND_BACK, GL43C.GL_LINE);
IrisRenderSystem.setPolygonMode(GL43C.GL_LINE);
}
}

Expand All @@ -116,7 +117,7 @@ public class MixinLevelRenderer {
pipeline = null;

if (Iris.shouldActivateWireframe() && this.minecraft.isLocalServer()) {
GL43C.glPolygonMode(GL43C.GL_FRONT_AND_BACK, GL43C.GL_FILL);
IrisRenderSystem.setPolygonMode(GL43C.GL_FILL);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,7 @@ public TranslationUnit parseTranslationUnit(Root rootInstance, String input) {
throw new IllegalArgumentException(
"No #version directive found in source code! See debugging.md for more information.");
}
Version version = Version.fromNumber(Integer.parseInt(matcher.group(1)));
if (version.number >= 200) {
version = Version.GLSL33;
}
transformer.getLexer().version = version;
transformer.getLexer().version = Version.fromNumber(Integer.parseInt(matcher.group(1)));

return super.parseTranslationUnit(rootInstance, input);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.mojang.blaze3d.vertex.VertexBuffer;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.coderbot.iris.fantastic.VertexBufferHelper;
import net.coderbot.iris.gl.IrisRenderSystem;
import org.lwjgl.opengl.GL11;

import org.lwjgl.opengl.GL20C;
Expand Down Expand Up @@ -51,7 +52,9 @@ public void begin() {
}

public void renderQuad() {
IrisRenderSystem.overridePolygonMode();
quad.drawChunkLayer();
IrisRenderSystem.restorePolygonMode();
}

public void end() {
Expand Down

0 comments on commit 8bc3a7e

Please sign in to comment.