diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferType.java b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferType.java index b2371c440..53a0ab9ac 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/buffer/GlBufferType.java @@ -8,6 +8,7 @@ import org.lwjgl.opengl.GL40; import org.lwjgl.opengl.GL42; import org.lwjgl.opengl.GL43; +import com.jozufozu.flywheel.mixin.BufferUploaderAccessor; import com.mojang.blaze3d.platform.GlStateManager; public enum GlBufferType { @@ -34,9 +35,19 @@ public enum GlBufferType { public void bind(int buffer) { GlStateManager._glBindBuffer(glEnum, buffer); + + switch (this.glEnum) { + case GL15C.GL_ELEMENT_ARRAY_BUFFER -> BufferUploaderAccessor.flywheel$setLastEBO(buffer); + case GL15C.GL_ARRAY_BUFFER -> BufferUploaderAccessor.flywheel$setLastVBO(buffer); + } } public void unbind() { GlStateManager._glBindBuffer(glEnum, 0); + + switch (this.glEnum) { + case GL15C.GL_ELEMENT_ARRAY_BUFFER -> BufferUploaderAccessor.flywheel$setLastEBO(0); + case GL15C.GL_ARRAY_BUFFER -> BufferUploaderAccessor.flywheel$setLastVBO(0); + } } } diff --git a/src/main/java/com/jozufozu/flywheel/mixin/BufferUploaderAccessor.java b/src/main/java/com/jozufozu/flywheel/mixin/BufferUploaderAccessor.java index 8ee045d05..64b81bd2b 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/BufferUploaderAccessor.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/BufferUploaderAccessor.java @@ -5,12 +5,20 @@ import org.spongepowered.asm.mixin.gen.Accessor; import com.mojang.blaze3d.vertex.BufferUploader; -import net.minecraft.client.renderer.ShaderInstance; - @Mixin(BufferUploader.class) public interface BufferUploaderAccessor { @Accessor("lastVertexArrayObject") static void flywheel$setLastVAO(int id) { throw new AssertionError(); } + + @Accessor("lastVertexBufferObject") + static void flywheel$setLastVBO(int id) { + throw new AssertionError(); + } + + @Accessor("lastIndexBufferObject") + static void flywheel$setLastEBO(int id) { + throw new AssertionError(); + } }