diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/VertexBuffer.java b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/VertexBuffer.java index 9a998d1b5..1393a915f 100644 --- a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/VertexBuffer.java +++ b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/VertexBuffer.java @@ -11,14 +11,16 @@ public class VertexBuffer implements AutoCloseable { private int id; private int vertexCount; private VertexFormat format; + private int drawMode; public VertexBuffer() { this.id = GL15.glGenBuffers(); } - public VertexBuffer(VertexFormat format) { + public VertexBuffer(VertexFormat format, int drawMode) { this(); this.format = format; + this.drawMode = drawMode; } public void bind() { @@ -50,16 +52,16 @@ public class VertexBuffer implements AutoCloseable { } } - public void draw(FloatBuffer floatBuffer, int mode) { + public void draw(FloatBuffer floatBuffer) { GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glMultMatrix(floatBuffer); - draw(mode); + draw(); GL11.glPopMatrix(); } - public void draw(int mode) { - GL11.glDrawArrays(mode, 0, this.vertexCount); + public void draw() { + GL11.glDrawArrays(drawMode, 0, this.vertexCount); } public void setupState() { @@ -72,11 +74,11 @@ public class VertexBuffer implements AutoCloseable { format.clearBufferState(); unbind(); } - public void render(int mode) { + public void render() { if(format == null) throw new IllegalStateException("No format specified for VBO render"); bind(); format.setupBufferState(0L); - draw(mode); + draw(); format.clearBufferState(); unbind(); } diff --git a/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java b/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java index 96d324690..618580494 100644 --- a/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java +++ b/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java @@ -770,11 +770,15 @@ public class GLStateManager { } public static void glCallList(int list) { - GL11.glCallList(list); - if(glListChanges.containsKey(list)) { - for(Map.Entry, ISettableState> entry : glListChanges.get(list)) { - // Set the stack to the cached state at the end of the call list compilation - ((ISettableState)entry.getKey()).set(entry.getValue()); + if(list < 0) { + VBOManager.get(list).render(); + } else { + GL11.glCallList(list); + if(glListChanges.containsKey(list)) { + for(Map.Entry, ISettableState> entry : glListChanges.get(list)) { + // Set the stack to the cached state at the end of the call list compilation + ((ISettableState)entry.getKey()).set(entry.getValue()); + } } } } diff --git a/src/main/java/com/gtnewhorizons/angelica/glsm/TessellatorManager.java b/src/main/java/com/gtnewhorizons/angelica/glsm/TessellatorManager.java index e8ee6a30b..6ef52428f 100644 --- a/src/main/java/com/gtnewhorizons/angelica/glsm/TessellatorManager.java +++ b/src/main/java/com/gtnewhorizons/angelica/glsm/TessellatorManager.java @@ -9,6 +9,8 @@ import net.minecraft.client.renderer.Tessellator; import java.nio.ByteBuffer; import java.util.List; +import org.lwjgl.opengl.GL11; + @SuppressWarnings("unused") public class TessellatorManager { private static final ThreadLocal capturingTessellator = ThreadLocal.withInitial(CapturingTessellator::new); @@ -76,7 +78,7 @@ public class TessellatorManager { * uploads the buffer to a new VertexBuffer, and clears the quads. */ public static VertexBuffer stopCapturingToVBO(VertexFormat format) { - return new VertexBuffer(format).upload(stopCapturingToBuffer(format)); + return new VertexBuffer(format, GL11.GL_QUADS).upload(stopCapturingToBuffer(format)); } static { diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinModelRenderer.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinModelRenderer.java index 8aa1fb9d0..16dbcfc31 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinModelRenderer.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinModelRenderer.java @@ -4,7 +4,6 @@ import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat; import com.gtnewhorizons.angelica.glsm.TessellatorManager; import com.gtnewhorizons.angelica.glsm.VBOManager; import net.minecraft.client.model.ModelRenderer; -import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -29,13 +28,4 @@ public class MixinModelRenderer { public void stopCapturingVBO() { VBOManager.registerVBO(this.displayList, TessellatorManager.stopCapturingToVBO(DefaultVertexFormat.POSITION_TEXTURE_NORMAL)); } - - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glCallList(I)V", remap = false)) - public void renderVBO(int list) { - VBOManager.get(list).render(GL11.GL_QUADS); - } - @Redirect(method = "renderWithRotation", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glCallList(I)V", remap = false)) - public void renderWithRotationVBO(int list) { - VBOManager.get(list).render(GL11.GL_QUADS); - } } diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinRenderGlobal.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinRenderGlobal.java index 0250ae4f7..733bc4b5f 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinRenderGlobal.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinRenderGlobal.java @@ -11,7 +11,6 @@ import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.RenderGlobal; import net.minecraft.client.renderer.Tessellator; import net.minecraftforge.client.IRenderHandler; -import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @@ -72,11 +71,6 @@ public class MixinRenderGlobal { VBOManager.registerVBO(glSkyList2, TessellatorManager.stopCapturingToVBO(DefaultVertexFormat.POSITION)); } - @Redirect(method="renderSky(F)V", at = @At(value="INVOKE", target="Lorg/lwjgl/opengl/GL11;glCallList(I)V"), remap = false) - public void renderSky(int list) { - VBOManager.get(list).render(GL11.GL_QUADS); - } - /** * @author mitchej123 * @reason VBO Clouds diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinWavefrontObject.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinWavefrontObject.java index 6e47f116a..8fadf7633 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinWavefrontObject.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/vbo/MixinWavefrontObject.java @@ -48,7 +48,7 @@ public abstract class MixinWavefrontObject implements IModelCustomExt { if(vertexBuffer == null) { rebuildVBO(); } - vertexBuffer.render(GL11.GL_QUADS); + vertexBuffer.render(); } /** diff --git a/src/main/java/com/gtnewhorizons/angelica/render/CloudRenderer.java b/src/main/java/com/gtnewhorizons/angelica/render/CloudRenderer.java index 39094f710..5ac13bdcf 100644 --- a/src/main/java/com/gtnewhorizons/angelica/render/CloudRenderer.java +++ b/src/main/java/com/gtnewhorizons/angelica/render/CloudRenderer.java @@ -333,7 +333,7 @@ public class CloudRenderer implements IResourceManagerReloadListener { // Depth pass to prevent insides rendering from the outside. GLStateManager.glColorMask(false, false, false, false); - vbo.draw(GL11.GL_QUADS); + vbo.draw(); // Full render. if (!mc.gameSettings.anaglyph) { @@ -356,14 +356,14 @@ public class CloudRenderer implements IResourceManagerReloadListener { GLStateManager.disableTexture(); GLStateManager.glDepthMask(false); GLStateManager.disableFog(); - vbo.draw(GL11.GL_QUADS); + vbo.draw(); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GLStateManager.glDepthMask(true); GLStateManager.enableTexture(); GLStateManager.enableFog(); } - vbo.draw(GL11.GL_QUADS); + vbo.draw(); vbo.cleanupState(); // Unbind buffer and disable pointers. // Disable our coloring. diff --git a/src/main/java/net/coderbot/iris/pipeline/HorizonRenderer.java b/src/main/java/net/coderbot/iris/pipeline/HorizonRenderer.java index 5be2c4072..e678bdeaa 100644 --- a/src/main/java/net/coderbot/iris/pipeline/HorizonRenderer.java +++ b/src/main/java/net/coderbot/iris/pipeline/HorizonRenderer.java @@ -157,7 +157,7 @@ public class HorizonRenderer { vertexBuffer.bind(); GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); - vertexBuffer.draw(floatBuffer, GL11.GL_QUADS); + vertexBuffer.draw(floatBuffer); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); vertexBuffer.unbind(); }