Skip to content

Commit

Permalink
Fix storage presets rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Oct 8, 2023
1 parent 8918e5f commit 3682c4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.GameRenderer;
import org.lwjgl.opengl.GL30;

/**
Expand Down Expand Up @@ -44,18 +46,19 @@ public static void drawExtraFramebuffer(GuiGraphics graphics) {

// Render the custom framebuffer's contents with transparency into the main buffer
RenderSystem.setShaderTexture(0, framebuffer.getColorTextureId());
/*Window window = Minecraft.getInstance().getWindow();
graphics.blit(
framebuffer.getColorTextureId(),
0, // x
0, // y
window.getGuiScaledWidth(), // width
window.getGuiScaledHeight(), // height
0, // left-most coordinate of the texture region
framebuffer.height, // top-most coordinate of the texture region
framebuffer.width, // width of the texture region
-framebuffer.height // height of the texture region
);*/
Window window = Minecraft.getInstance().getWindow();
int width = window.getGuiScaledWidth();
int height = window.getGuiScaledHeight();
RenderSystem.setShaderTexture(0, framebuffer.getColorTextureId());
RenderSystem.setShader(GameRenderer::getPositionTexShader);
final var matrix4f = graphics.pose().last().pose();
BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.vertex(matrix4f, 0, 0, 0).uv(0, 1).endVertex();
bufferBuilder.vertex(matrix4f, 0, height, 0).uv(0, 0).endVertex();
bufferBuilder.vertex(matrix4f, width, height, 0).uv(1, 0).endVertex();
bufferBuilder.vertex(matrix4f, width, 0, 0).uv(1, 1).endVertex();
BufferUploader.drawWithShader(bufferBuilder.end());
}

public static void postInject() {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ loader_version=0.14.22
#Fabric api
fabric_version=0.89.3+1.20.2
# Mod Properties
mod_version=2.2.2
mod_version=2.2.3
maven_group=org.samo_lego
archives_base_name=clientstorage
# Dependencies
Expand Down

0 comments on commit 3682c4a

Please sign in to comment.