From eb3455452b57b9a9d5309d70e8b11088d12be2e0 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 26 Jul 2021 20:26:24 -0500 Subject: [PATCH] Fix getting the GPU's fancy fog capabilities --- src/main/java/com/seibel/lod/LodMain.java | 20 ------------------- .../com/seibel/lod/render/LodRenderer.java | 19 ++++++++++++++++-- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/seibel/lod/LodMain.java b/src/main/java/com/seibel/lod/LodMain.java index 68c9f062f..c4177f297 100644 --- a/src/main/java/com/seibel/lod/LodMain.java +++ b/src/main/java/com/seibel/lod/LodMain.java @@ -17,15 +17,11 @@ */ package com.seibel.lod; -import org.lwjgl.opengl.GL; - import com.seibel.lod.handlers.LodConfig; import com.seibel.lod.proxy.ClientProxy; -import com.seibel.lod.render.LodRenderer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.DeferredWorkQueue; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; @@ -55,22 +51,6 @@ public class LodMain private void init(final FMLCommonSetupEvent event) { ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, LodConfig.clientSpec); - - - Thread setFancyFog = new Thread(() -> - { - LodRenderer.fancyFogAvailable = GL.getCapabilities().GL_NV_fog_distance; - - if (!LodRenderer.fancyFogAvailable) - { - ClientProxy.LOGGER.info("This GPU does not support GL_NV_fog_distance. This means that fancy fog options will not be available."); - } - }); - - // This will be run on the main thread when it is able. - // If it wasn't run on the main thread GL.getCapabilities() - // would fail. - DeferredWorkQueue.runLater(setFancyFog); } diff --git a/src/main/java/com/seibel/lod/render/LodRenderer.java b/src/main/java/com/seibel/lod/render/LodRenderer.java index 3eaf261d4..81f902225 100644 --- a/src/main/java/com/seibel/lod/render/LodRenderer.java +++ b/src/main/java/com/seibel/lod/render/LodRenderer.java @@ -22,6 +22,7 @@ import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.util.HashSet; +import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.NVFogDistance; @@ -87,7 +88,7 @@ public class LodRenderer public static final int MAX_ALOCATEABLE_DIRECT_MEMORY = 64 * 1024 * 1024; /** Does this computer's GPU support fancy fog? */ - public static boolean fancyFogAvailable = false; + private static Boolean fancyFogAvailable = null; @@ -174,6 +175,20 @@ public class LodRenderer profiler = newProfiler; profiler.push("LOD setup"); + + // only check the GPU capability's once + if (fancyFogAvailable == null) + { + // see if this GPU can run fancy fog + fancyFogAvailable = GL.getCapabilities().GL_NV_fog_distance; + + if (!LodRenderer.fancyFogAvailable) + { + ClientProxy.LOGGER.info("This GPU does not support GL_NV_fog_distance. This means that fancy fog options will not be available."); + } + } + + ClientPlayerEntity player = mc.player; // should LODs be regenerated? @@ -405,7 +420,7 @@ public class LodRenderer // determine the fog distance mode to use - int glFogDistanceMode = NVFogDistance.GL_EYE_RADIAL_NV; + int glFogDistanceMode; if (fogQuality == FogQuality.FANCY) { // fancy fog (fragment distance based fog)