diff options
3 files changed, 41 insertions, 12 deletions
diff --git a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java index f3a4301..791dd5d 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java +++ b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java @@ -30,10 +30,13 @@ abstract class MixinRenderGlobal { } } - @Inject(method = "renderSortedRenderers", at = @At(value = "HEAD")) - public void preRenderSortedRenderers(int startRenderer, int numRenderers, int renderPass, double partialTickTime, CallbackInfoReturnable cir) { + @Inject(method = "renderSortedRenderers", + at = @At(value = "HEAD"), + cancellable = true, + require = 1) + public void preRenderSortedRenderers(int startRenderer, int numRenderers, int renderPass, double partialTickTime, CallbackInfoReturnable<Integer> cir) { if(Neodymium.isActive()) { - Neodymium.renderer.preRenderSortedRenderers(renderPass, partialTickTime, sortedWorldRenderers); + cir.setReturnValue(Neodymium.renderer.preRenderSortedRenderers(renderPass, partialTickTime, sortedWorldRenderers)); } } diff --git a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java index 42cedfe..6ddf377 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java +++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java @@ -10,11 +10,14 @@ import makamys.neodymium.renderer.NeoRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.entity.EntityLivingBase; + +import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Collections; @@ -90,6 +93,25 @@ abstract class MixinWorldRenderer implements IWorldRenderer { ChunkMesh.setCaptureTarget(cm); } } + + @Redirect(method = "preRenderBlocks", + at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glNewList(II)V"), + require = 1) + private void noNewList(int list, int mode) { + if (!Neodymium.isActive()) { + GL11.glNewList(list, mode); + } + } + + @Redirect(method = "postRenderBlocks", + at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glEndList()V"), + require = 1) + private void noEndList() { + if (!Neodymium.isActive()) + GL11.glEndList(); + } @Inject(method = "postRenderBlocks", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()I")) private void prePostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) { diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 0cc7692..7d5928d 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -104,7 +104,8 @@ public class NeoRenderer { Vector4f transformedOrigin = new Vector4f(); - public void preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer[] sortedWorldRenderers) { + public int preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer[] sortedWorldRenderers) { + int rendered = 0; if (hasInited) { if (renderPass == 0) { renderedMeshes = 0; @@ -149,11 +150,12 @@ public class NeoRenderer { if (rendererActive && renderWorld) { Minecraft.getMinecraft().entityRenderer.enableLightmap((double) alpha); - render(renderPass, alpha); + rendered += render(renderPass, alpha); Minecraft.getMinecraft().entityRenderer.disableLightmap((double) alpha); } } + return rendered; } public void onRenderTickEnd() { @@ -285,18 +287,17 @@ public class NeoRenderer { Matrix4f modelViewMatrixInv = new Matrix4f(); Matrix4f projMatrix = new Matrix4f(); - private void render(int pass, double alpha) { - int shader = getShaderProgram(pass); - - if (shader == 0) return; - - glBindVertexArray(VAO); - + private int render(int pass, double alpha) { if (!Compat.isShaders()) { + int shader = getShaderProgram(pass); + + if (shader == 0) return 0; glUseProgram(shader); updateUniforms(alpha, pass); } + glBindVertexArray(VAO); + if (isWireframeEnabled()) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } @@ -308,9 +309,11 @@ public class NeoRenderer { int oldLimit = piFirst[pass].limit(); + int rendered = 0; int order = pass == 0 ? 1 : -1; for (int regionI = order == 1 ? 0 : loadedRegionsList.size() - 1; regionI >= 0 && regionI < loadedRegionsList.size(); regionI += order) { NeoRegion.RenderData region = loadedRegionsList.get(regionI).getRenderData(); + rendered += region.batchLimit[pass] - region.batchFirst[pass]; Util.setPositionAndLimit(piFirst[pass], region.batchFirst[pass], region.batchLimit[pass]); Util.setPositionAndLimit(piCount[pass], region.batchFirst[pass], region.batchLimit[pass]); @@ -344,6 +347,7 @@ public class NeoRenderer { } glBindVertexArray(0); + return rendered; } private void updateGLValues() { |