From 180dee59e103dc94d17a4c4121f7963bc33c3ad6 Mon Sep 17 00:00:00 2001 From: FalsePattern Date: Tue, 5 Dec 2023 19:48:02 +0100 Subject: shaders detection --- src/main/java/makamys/neodymium/Compat.java | 40 +++++++++++++--------- .../makamys/neodymium/renderer/NeoRenderer.java | 2 ++ 2 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/main/java/makamys/neodymium/Compat.java b/src/main/java/makamys/neodymium/Compat.java index acb76ca..6343e14 100644 --- a/src/main/java/makamys/neodymium/Compat.java +++ b/src/main/java/makamys/neodymium/Compat.java @@ -44,8 +44,29 @@ public class Compat { return RPLE; } + private static boolean shadersEnabled; + public static boolean isShaders() { - return false; + return shadersEnabled; + } + + public static void updateShadersState() { + try { + Class shaders = Class.forName("shadersmod.client.Shaders"); + try { + String shaderPack = (String)shaders.getMethod("getShaderPackName").invoke(null); + if(shaderPack != null) { + shadersEnabled = true; + return; + } + } catch(Exception e) { + LOGGER.warn("Failed to get shader pack name"); + e.printStackTrace(); + } + } catch (ClassNotFoundException e) { + + } + shadersEnabled = false; } private static void disableTriangulator() { @@ -57,21 +78,6 @@ public class Compat { warns.add(new Warning("Advanced OpenGL is enabled, performance may be poor." + (statusCommand ? " Click here to disable it." : "")).chatAction("neodymium disable_advanced_opengl")); } -// try { -// Class shaders = Class.forName("shadersmod.client.Shaders"); -// try { -// String shaderPack = (String)shaders.getMethod("getShaderPackName").invoke(null); -// if(shaderPack != null) { -// criticalWarns.add(new Warning("A shader pack is enabled, this is not supported.")); -// } -// } catch(Exception e) { -// LOGGER.warn("Failed to get shader pack name"); -// e.printStackTrace(); -// } -// } catch (ClassNotFoundException e) { -// -// } - if(!isGL33Supported) { criticalWarns.add(new Warning("OpenGL 3.3 is not supported.")); } @@ -122,7 +128,7 @@ public class Compat { } return false; } - + private static class OptiFineStubVirtualJar implements IVirtualJar { @Override diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index fcd4c67..ff13dd7 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -412,6 +412,8 @@ public class NeoRenderer { // This means 1 MB of index data per 512 MB of VRAM. MAX_MESHES = Config.VRAMSize * 128; + Compat.updateShadersState(); + attributes = new AttributeSet(); attributes.addAttribute("POS", 3, 4, GL_FLOAT); if (Config.shortUV) { -- cgit