Fix Optifine shaders not rendering
This commit is contained in:
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.api.internal;
|
||||
|
||||
import com.seibel.distanthorizons.core.Initializer;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.generation.DhLightingEngine;
|
||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
@@ -30,6 +31,7 @@ import com.seibel.distanthorizons.core.util.objects.Pair;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPools;
|
||||
import com.seibel.distanthorizons.core.world.*;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -45,9 +47,10 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
/** Contains code and variables used by both {@link ClientApi} and {@link ServerApi} */
|
||||
public class SharedApi
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
public static final SharedApi INSTANCE = new SharedApi();
|
||||
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||
private static final Set<DhChunkPos> UPDATING_CHUNK_SET = ConcurrentHashMap.newKeySet();
|
||||
|
||||
|
||||
@@ -88,6 +91,7 @@ public class SharedApi
|
||||
{
|
||||
ThreadPools.shutdownThreadPools();
|
||||
DebugRenderer.clearRenderables();
|
||||
MC_RENDER.clearTargetFrameBuffer();
|
||||
|
||||
// recommend that the garbage collector cleans up any objects from the old world and thread pools
|
||||
System.gc();
|
||||
|
||||
+18
-3
@@ -231,6 +231,12 @@ public class LodRenderer
|
||||
return;
|
||||
}
|
||||
|
||||
if (AbstractOptifineAccessor.optifinePresent() && MC_RENDER.getTargetFrameBuffer() == -1)
|
||||
{
|
||||
// wait for MC to finish setting up their renderer
|
||||
return;
|
||||
}
|
||||
|
||||
if (!renderLock.tryLock())
|
||||
{
|
||||
// never lock the render thread, if the lock isn't available don't wait for it
|
||||
@@ -298,8 +304,17 @@ public class LodRenderer
|
||||
// Bind LOD frame buffer
|
||||
this.framebuffer.bind();
|
||||
|
||||
// Clear LOD framebuffer and depth buffers
|
||||
GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (this.usingMcFrameBuffer)
|
||||
{
|
||||
// don't clear the color texture, that removes the sky
|
||||
GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
|
||||
GL32.glEnable(GL32.GL_DEPTH_TEST);
|
||||
GL32.glDepthFunc(GL32.GL_LESS);
|
||||
@@ -514,7 +529,7 @@ public class LodRenderer
|
||||
if (AbstractOptifineAccessor.optifinePresent())
|
||||
{
|
||||
// use MC/Optifine's default FrameBuffer so shaders won't remove the LODs
|
||||
int currentFrameBufferId = GL32.glGetInteger(GL32.GL_FRAMEBUFFER_BINDING);
|
||||
int currentFrameBufferId = MC_RENDER.getTargetFrameBuffer();
|
||||
this.framebuffer = new DhFramebuffer(currentFrameBufferId);
|
||||
this.usingMcFrameBuffer = true;
|
||||
}
|
||||
|
||||
+7
@@ -75,11 +75,18 @@ public interface IMinecraftRenderWrapper extends IBindable
|
||||
int getScreenWidth();
|
||||
int getScreenHeight();
|
||||
|
||||
/** @return -1 if no valid framebuffer is available yet */
|
||||
int getTargetFrameBuffer();
|
||||
int getDepthTextureId();
|
||||
int getTargetFrameBufferViewportWidth();
|
||||
int getTargetFrameBufferViewportHeight();
|
||||
|
||||
/**
|
||||
* generally shouldn't be needed, the frame buffer should generally stay the same
|
||||
* but in case something goes wrong this allows for re-getting the buffer ID.
|
||||
*/
|
||||
void clearTargetFrameBuffer();
|
||||
|
||||
/**
|
||||
* This method returns the ChunkPos of all chunks that Minecraft
|
||||
* is going to render this frame.
|
||||
|
||||
Reference in New Issue
Block a user