mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-26 15:06:28 +01:00
Track VBO and EBO via vanilla
This commit is contained in:
parent
de6c4270b2
commit
e16b32e116
2 changed files with 21 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue