Skip to content

Commit b899dde

Browse files
committed
Fixes
1 parent 50e0634 commit b899dde

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import java.util.Random;
4343
import java.util.concurrent.atomic.AtomicInteger;
4444

45+
import static org.lwjgl.opengl.GL11.GL_VIEWPORT;
46+
import static org.lwjgl.opengl.GL11.glGetIntegerv;
4547
import static org.lwjgl.opengl.GL11C.*;
4648
import static org.lwjgl.opengl.GL30C.GL_DRAW_FRAMEBUFFER_BINDING;
4749
import static org.lwjgl.opengl.GL30C.glBindFramebuffer;
@@ -174,37 +176,39 @@ public void renderOpaque(ChunkRenderMatrices matrices, double cameraX, double ca
174176
TimingStatistics.all.start();
175177
TimingStatistics.main.start();
176178

179+
180+
181+
int oldFB = GL11.glGetInteger(GL_DRAW_FRAMEBUFFER_BINDING);
182+
int boundFB = oldFB;
183+
184+
//var target = DefaultTerrainRenderPasses.CUTOUT.getTarget();
185+
//boundFB = ((net.minecraft.client.texture.GlTexture) target.getColorAttachment()).getOrCreateFramebuffer(((GlBackend) RenderSystem.getDevice()).getFramebufferManager(), target.getDepthAttachment());
186+
if (boundFB == 0) {
187+
throw new IllegalStateException("Cannot use the default framebuffer as cannot source from it");
188+
}
189+
177190
//this.autoBalanceSubDivSize();
178191

179192
var projection = computeProjectionMat(matrices.projection());//RenderSystem.getProjectionMatrix();
180193
//var projection = new Matrix4f(matrices.projection());
181194

195+
int[] dims = new int[4];
196+
glGetIntegerv(GL_VIEWPORT, dims);
182197
var viewport = this.renderer.getViewport();
183198
viewport
184199
.setProjection(projection)
185200
.setModelView(new Matrix4f(matrices.modelView()))
186201
.setCamera(cameraX, cameraY, cameraZ)
187-
.setScreenSize(MinecraftClient.getInstance().getFramebuffer().textureWidth, MinecraftClient.getInstance().getFramebuffer().textureHeight)
202+
.setScreenSize(dims[2], dims[3])
188203
.update();
189204
viewport.frameId++;
190205

191-
192-
193-
int oldFB = GL11.glGetInteger(GL_DRAW_FRAMEBUFFER_BINDING);
194-
int boundFB = oldFB;
195-
196-
var target = DefaultTerrainRenderPasses.CUTOUT.getTarget();
197-
//boundFB = ((net.minecraft.client.texture.GlTexture) target.getColorAttachment()).getOrCreateFramebuffer(((GlBackend) RenderSystem.getDevice()).getFramebufferManager(), target.getDepthAttachment());
198-
if (boundFB == 0) {
199-
throw new IllegalStateException("Cannot use the default framebuffer as cannot source from it");
200-
}
201-
202206
TimingStatistics.E.start();
203207
this.chunkBoundRenderer.render(viewport);
204208
TimingStatistics.E.stop();
205209

206210
TimingStatistics.F.start();
207-
this.postProcessing.setup(target.textureWidth, target.textureHeight, boundFB);
211+
this.postProcessing.setup(viewport.width, viewport.height, boundFB);
208212
TimingStatistics.F.stop();
209213

210214
this.renderer.renderFarAwayOpaque(viewport, this.chunkBoundRenderer.getDepthBoundTexture(), startTime);

0 commit comments

Comments
 (0)