1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-30 00:57:55 +00:00

Add a shader mod compatibility check to the MonitorRenderer.BEST option.

Will need to fill in the shader mod ids after some testing.
This commit is contained in:
ToadDev
2021-06-10 01:07:29 -07:00
parent f3d22444d3
commit 52bb06d250

View File

@@ -7,9 +7,12 @@ package dan200.computercraft.shared.peripheral.monitor;
import dan200.computercraft.ComputerCraft; import dan200.computercraft.ComputerCraft;
import dan200.computercraft.client.render.TileEntityMonitorRenderer; import dan200.computercraft.client.render.TileEntityMonitorRenderer;
import net.fabricmc.loader.api.FabricLoader;
import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.List;
/** /**
* The render type to use for monitors. * The render type to use for monitors.
@@ -38,6 +41,9 @@ public enum MonitorRenderer
private static boolean initialised = false; private static boolean initialised = false;
private static boolean textureBuffer = false; private static boolean textureBuffer = false;
private static boolean shaderMod = false;
//TODO find out which shader mods do better with VBOs and add them here.
private static List<String> shaderModIds = Arrays.asList("aShaderModThatWouldPreferVBOs");
/** /**
* Get the current renderer to use. * Get the current renderer to use.
@@ -68,19 +74,31 @@ public enum MonitorRenderer
} }
private static MonitorRenderer best() private static MonitorRenderer best()
{
if ( !initialised )
{ {
checkCapabilities(); checkCapabilities();
return textureBuffer ? TBO : VBO; checkForShaderMods();
if ( textureBuffer && shaderMod )
{
ComputerCraft.log.warn("Shader mod detected. Enabling VBO renderer for compatibility.");
}
initialised = true;
}
return textureBuffer && !shaderMod ? TBO : VBO;
} }
private static void checkCapabilities() private static void checkCapabilities()
{ {
if( initialised ) textureBuffer = GL.getCapabilities().OpenGL31;
{
return;
} }
textureBuffer = GL.getCapabilities().OpenGL31; private static void checkForShaderMods()
initialised = true; {
shaderMod = FabricLoader.getInstance().getAllMods().stream()
.map( modContainer -> modContainer.getMetadata().getId() )
.anyMatch( id -> shaderModIds.contains( id ) );
} }
} }