|
42 | 42 | import java.util.Random; |
43 | 43 | import java.util.concurrent.atomic.AtomicInteger; |
44 | 44 |
|
| 45 | +import static org.lwjgl.opengl.GL11.GL_VIEWPORT; |
| 46 | +import static org.lwjgl.opengl.GL11.glGetIntegerv; |
45 | 47 | import static org.lwjgl.opengl.GL11C.*; |
46 | 48 | import static org.lwjgl.opengl.GL30C.GL_DRAW_FRAMEBUFFER_BINDING; |
47 | 49 | import static org.lwjgl.opengl.GL30C.glBindFramebuffer; |
@@ -174,37 +176,39 @@ public void renderOpaque(ChunkRenderMatrices matrices, double cameraX, double ca |
174 | 176 | TimingStatistics.all.start(); |
175 | 177 | TimingStatistics.main.start(); |
176 | 178 |
|
| 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 | + |
177 | 190 | //this.autoBalanceSubDivSize(); |
178 | 191 |
|
179 | 192 | var projection = computeProjectionMat(matrices.projection());//RenderSystem.getProjectionMatrix(); |
180 | 193 | //var projection = new Matrix4f(matrices.projection()); |
181 | 194 |
|
| 195 | + int[] dims = new int[4]; |
| 196 | + glGetIntegerv(GL_VIEWPORT, dims); |
182 | 197 | var viewport = this.renderer.getViewport(); |
183 | 198 | viewport |
184 | 199 | .setProjection(projection) |
185 | 200 | .setModelView(new Matrix4f(matrices.modelView())) |
186 | 201 | .setCamera(cameraX, cameraY, cameraZ) |
187 | | - .setScreenSize(MinecraftClient.getInstance().getFramebuffer().textureWidth, MinecraftClient.getInstance().getFramebuffer().textureHeight) |
| 202 | + .setScreenSize(dims[2], dims[3]) |
188 | 203 | .update(); |
189 | 204 | viewport.frameId++; |
190 | 205 |
|
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 | | - |
202 | 206 | TimingStatistics.E.start(); |
203 | 207 | this.chunkBoundRenderer.render(viewport); |
204 | 208 | TimingStatistics.E.stop(); |
205 | 209 |
|
206 | 210 | TimingStatistics.F.start(); |
207 | | - this.postProcessing.setup(target.textureWidth, target.textureHeight, boundFB); |
| 211 | + this.postProcessing.setup(viewport.width, viewport.height, boundFB); |
208 | 212 | TimingStatistics.F.stop(); |
209 | 213 |
|
210 | 214 | this.renderer.renderFarAwayOpaque(viewport, this.chunkBoundRenderer.getDepthBoundTexture(), startTime); |
|
0 commit comments