Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/Multiloader-1.21.3' into…
Browse files Browse the repository at this point in the history
… Multiloader-1.21.4
  • Loading branch information
fayer3 committed Dec 9, 2024
2 parents 41609a4 + 5c71415 commit c8ef386
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
import org.vivecraft.client_vr.provider.ControllerType;
import org.vivecraft.client_vr.provider.MCVR;
import org.vivecraft.client_vr.render.helpers.RenderHelper;

public abstract class TwoHandedScreen extends Screen {
protected ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
Expand Down Expand Up @@ -76,7 +77,7 @@ public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPar
this.lastHoveredButtonId2 = abstractwidget1;
}

((GuiExtension) this.minecraft.gui).vivecraft$drawMouseMenuQuad((int) d0, (int) d1);
((GuiExtension) this.minecraft.gui).vivecraft$drawMouseMenuQuad((int) d2, (int) d3);
RenderHelper.drawMouseMenuQuad(guiGraphics, (int) d0, (int) d1);
RenderHelper.drawMouseMenuQuad(guiGraphics, (int) d2, (int) d3);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.vivecraft.client_vr.render.ShaderHelper;
import org.vivecraft.client_vr.render.VRShaders;
import org.vivecraft.client_vr.settings.VRSettings;
import org.vivecraft.client_xr.render_pass.RenderPassManager;
import org.vivecraft.client_xr.render_pass.WorldRenderPass;
import org.vivecraft.mod_compat_vr.ShadersHelper;
import org.vivecraft.mod_compat_vr.resolutioncontrol.ResolutionControlHelper;
Expand Down Expand Up @@ -483,6 +484,12 @@ public void setupRenderConfiguration() throws Exception {
this.reinitFrameBuffers("gfx setting change");
}

if (this.resizeFrameBuffers || this.reinitFramebuffers) {
// resize mirror
RenderPassManager.INSTANCE.vanillaRenderTarget.resize(((WindowExtension) (Object) Minecraft.getInstance().getWindow()).vivecraft$getActualScreenWidth(), ((WindowExtension) (Object) Minecraft.getInstance().getWindow()).vivecraft$getActualScreenHeight());
}


if (this.resizeFrameBuffers && !this.reinitFramebuffers) {
resizeFrameBuffers = false;
Tuple<Integer, Integer> tuple = this.getRenderTextureSizes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
import com.mojang.math.Axis;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.ShaderProgram;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.Vec3i;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -260,6 +258,7 @@ public static void drawScreen(DeltaTracker.Timer timer, Screen screen, GuiGraphi
GlStateManager.DestFactor.ONE);

screen.render(guiGraphics, 0, 0, timer.getRealtimeDeltaTicks());
guiGraphics.flush();

RenderSystem.blendFuncSeparate(
GlStateManager.SourceFactor.SRC_ALPHA,
Expand All @@ -275,6 +274,12 @@ public static void drawScreen(DeltaTracker.Timer timer, Screen screen, GuiGraphi
main.unbindRead();
}

public static void drawMouseMenuQuad(GuiGraphics guiGraphics, int mouseX, int mouseY) {
float size = 15.0F * Math.max(ClientDataHolderVR.getInstance().vrSettings.menuCrosshairScale, 1.0F / (float) mc.getWindow().getGuiScale());

guiGraphics.blitSprite(RenderType::crosshair, Gui.CROSSHAIR_SPRITE, (int) (mouseX - size * 0.5F + 1), (int) (mouseY - size * 0.5F + 1), (int) size, (int) size);
}


public static void drawSizedQuad(float displayWidth, float displayHeight, float size) {
drawSizedQuad(displayWidth, displayHeight, size, new float[]{1, 1, 1, 1});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public static void renderAndSubmit(boolean renderLevel, DeltaTracker.Timer timer
RenderSystem.enableCull();

Profiler.get().push("gui cursor");
GuiGraphics guiGraphics = new GuiGraphics(mc, mc.renderBuffers().bufferSource());
// draw cursor on Gui Layer
if (mc.screen != null || !mc.mouseHandler.isMouseGrabbed()) {
Matrix4fStack poseStack = RenderSystem.getModelViewStack();
Expand All @@ -251,7 +252,9 @@ public static void renderAndSubmit(boolean renderLevel, DeltaTracker.Timer timer

int x = (int) (Minecraft.getInstance().mouseHandler.xpos() * (double) Minecraft.getInstance().getWindow().getGuiScaledWidth() / (double) Minecraft.getInstance().getWindow().getScreenWidth());
int y = (int) (Minecraft.getInstance().mouseHandler.ypos() * (double) Minecraft.getInstance().getWindow().getGuiScaledHeight() / (double) Minecraft.getInstance().getWindow().getScreenHeight());
((GuiExtension) mc.gui).vivecraft$drawMouseMenuQuad(x, y);

RenderHelper.drawMouseMenuQuad(guiGraphics, x, y);
guiGraphics.flush();

poseStack.popMatrix();
}
Expand All @@ -266,13 +269,11 @@ public static void renderAndSubmit(boolean renderLevel, DeltaTracker.Timer timer
mc.mainRenderTarget.unbindRead();

Profiler.get().popPush("2D Keyboard");
GuiGraphics guiGraphics = new GuiGraphics(mc, mc.renderBuffers().bufferSource());
if (KeyboardHandler.Showing && !dataHolder.vrSettings.physicalKeyboard) {
mc.mainRenderTarget = KeyboardHandler.Framebuffer;
mc.mainRenderTarget.clear();
mc.mainRenderTarget.bindWrite(true);
RenderHelper.drawScreen(timer, KeyboardHandler.UI, guiGraphics);
guiGraphics.flush();
}

Profiler.get().popPush("Radial Menu");
Expand All @@ -281,7 +282,6 @@ public static void renderAndSubmit(boolean renderLevel, DeltaTracker.Timer timer
mc.mainRenderTarget.clear();
mc.mainRenderTarget.bindWrite(true);
RenderHelper.drawScreen(timer, RadialHandler.UI, guiGraphics);
guiGraphics.flush();
}
Profiler.get().pop();
checkGLError("post 2d ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,17 @@ public abstract class MinecraftVRMixin implements MinecraftExtension {
instance.blitToScreen(width, height);
} else {
Profiler.get().popPush("vrMirror");
// use the vanilla main target as the mirror target
RenderPassManager.setVanillaRenderPass();
this.mainRenderTarget.clear();
this.mainRenderTarget.bindWrite(false);

this.vivecraft$copyToMirror();
this.vivecraft$drawNotifyMirror();

this.mainRenderTarget.unbindWrite();
this.mainRenderTarget.blitToScreen(this.mainRenderTarget.width, this.mainRenderTarget.height);
RenderPassManager.setGUIRenderPass();
this.vivecraft$checkGLError("post-mirror ");
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.21.4
enabled_platforms=fabric,forge,neoforge

archives_base_name=vivecraft
mod_version=1.1.14-b1
mod_version=1.1.14-b2
maven_group=org.vivecraft

architectury_version=15.0.1
Expand Down

0 comments on commit c8ef386

Please sign in to comment.