From 536bff2fe76474ce9df5457a623f28be93c6e705 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 30 Sep 2021 21:41:49 -0500 Subject: [PATCH] Hopefully fix the OpenGL context switching error --- .../bufferBuilding/LodBufferBuilder.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java index 9c13026d6..9e79784a7 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java @@ -549,10 +549,17 @@ public class LodBufferBuilder try { - // make sure we are uploading to a different OpenGL context, + // make sure we are uploading to the builder context, // to prevent interference (IE stuttering) with the Minecraft context. - glProxy.setGlContext(GlProxyContext.LOD_BUILDER); + // But only set the context once, we don't need to set it multiple times. + if (glProxy.getGlContext() != GlProxyContext.LOD_BUILDER) + { + glProxy.setGlContext(GlProxyContext.LOD_BUILDER); + ClientProxy.LOGGER.info(Thread.currentThread().getName() + ": setting OpenGL context to: [" + GlProxyContext.LOD_BUILDER + "]"); + } + + // actually upload the buffers for (int x = 0; x < buildableVbos.length; x++) { for (int z = 0; z < buildableVbos.length; z++) @@ -574,11 +581,6 @@ public class LodBufferBuilder ClientProxy.LOGGER.error(LodBufferBuilder.class.getSimpleName() + " - UploadBuffers failed: " + e.getMessage()); e.printStackTrace(); } - finally - { - // make sure the context is disabled - glProxy.setGlContext(GlProxyContext.NONE); - } } /**