1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 20:20:30 +00:00

Correctly bind VBOs before drawing them

Caused by 4228011b84. While correct on
1.18, this isn't correct on 1.19 - I clearly messed up the merge here.

Fixes #1183, possibly #1184 - haven't been able to reproduce.
This commit is contained in:
Jonathan Coates 2022-10-16 09:50:17 +01:00
parent bc79100a2f
commit c8e15f201c
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

View File

@ -8,10 +8,7 @@ package dan200.computercraft.client.render;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.MemoryTracker; import com.mojang.blaze3d.platform.MemoryTracker;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.*;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f; import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f; import com.mojang.math.Matrix4f;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
@ -214,11 +211,14 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
RenderTypes.TERMINAL.setupRenderState(); RenderTypes.TERMINAL.setupRenderState();
// Render background geometry // Render background geometry
backgroundBuffer.bind();
backgroundBuffer.drawWithShader( matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader() ); backgroundBuffer.drawWithShader( matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader() );
// Render foreground geometry with glPolygonOffset enabled. // Render foreground geometry with glPolygonOffset enabled.
GL11.glPolygonOffset( -1.0f, -10.0f ); GL11.glPolygonOffset( -1.0f, -10.0f );
GL11.glEnable( GL11.GL_POLYGON_OFFSET_FILL ); GL11.glEnable( GL11.GL_POLYGON_OFFSET_FILL );
foregroundBuffer.bind();
foregroundBuffer.drawWithShader( foregroundBuffer.drawWithShader(
matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader(), matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader(),
// As mentioned in the above comment, render the extra cursor quad if it is visible this frame. Each // As mentioned in the above comment, render the extra cursor quad if it is visible this frame. Each
@ -231,6 +231,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
GL11.glPolygonOffset( 0.0f, -0.0f ); GL11.glPolygonOffset( 0.0f, -0.0f );
GL11.glDisable( GL11.GL_POLYGON_OFFSET_FILL ); GL11.glDisable( GL11.GL_POLYGON_OFFSET_FILL );
RenderTypes.TERMINAL.clearRenderState(); RenderTypes.TERMINAL.clearRenderState();
VertexBuffer.unbind();
RenderSystem.setInverseViewRotationMatrix( oldInverseRotation ); RenderSystem.setInverseViewRotationMatrix( oldInverseRotation );