diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilderFactory.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilderFactory.java
index 0c774f12e..21a999bda 100644
--- a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilderFactory.java
+++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilderFactory.java
@@ -36,7 +36,6 @@ import org.lwjgl.opengl.GL30;
import org.lwjgl.opengl.GL45;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import com.mojang.blaze3d.systems.RenderSystem;
import com.seibel.lod.config.LodConfig;
import com.seibel.lod.enums.LodDirection;
import com.seibel.lod.enums.config.GpuUploadMethod;
@@ -649,7 +648,7 @@ public class LodBufferBuilderFactory
// called we aren't worried about stuttering anyway.
// This way we don't have to worry about what context this
// was called from (if any).
- RenderSystem.recordRenderCall(() ->
+ GlProxy.getInstance().recordOpenGlCall(() ->
{
GL15.glDeleteBuffers(buildableId);
GL15.glDeleteBuffers(drawableId);
@@ -691,7 +690,7 @@ public class LodBufferBuilderFactory
drawableId = 0;
- RenderSystem.recordRenderCall(() ->
+ GlProxy.getInstance().recordOpenGlCall(() ->
{
if (buildableId != 0)
GL15.glDeleteBuffers(buildableId);
diff --git a/src/main/java/com/seibel/lod/proxy/GlProxy.java b/src/main/java/com/seibel/lod/proxy/GlProxy.java
index 75a3824b9..72a41ffd6 100644
--- a/src/main/java/com/seibel/lod/proxy/GlProxy.java
+++ b/src/main/java/com/seibel/lod/proxy/GlProxy.java
@@ -26,6 +26,7 @@ import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;
import org.lwjgl.opengl.GLCapabilities;
+import com.mojang.blaze3d.systems.IRenderCall;
import com.mojang.blaze3d.systems.RenderSystem;
import com.seibel.lod.ModInfo;
import com.seibel.lod.enums.rendering.GlProxyContext;
@@ -46,7 +47,7 @@ import com.seibel.lod.wrappers.MinecraftWrapper;
* https://gamedev.stackexchange.com/questions/91995/edit-vbo-data-or-create-a-new-one
*
* @author James Seibel
- * @version 11-8-2021
+ * @version 11-13-2021
*/
public class GlProxy
{
@@ -273,12 +274,22 @@ public class GlProxy
break;
}
-
GLFW.glfwMakeContextCurrent(contextPointer);
GL.setCapabilities(newGlCapabilities);
}
+ /**
+ * Asynchronously calls the given runnable on a valid OpenGL context.
+ * Useful for creating/destroying OpenGL objects in a thread
+ * that doesn't normally have access to a OpenGL context.
+ */
+ public void recordOpenGlCall(IRenderCall renderCall) //(Runnable renderCall)
+ {
+ // TODO this shouldn't rely on Minecraft's RenderSystem and should just run
+ // on a executer thread with a separate context
+ RenderSystem.recordRenderCall(renderCall);
+ }
diff --git a/src/main/java/com/seibel/lod/wrappers/LightMapWrapper.java b/src/main/java/com/seibel/lod/wrappers/LightMapWrapper.java
index 9831a5a95..a52ddf51a 100644
--- a/src/main/java/com/seibel/lod/wrappers/LightMapWrapper.java
+++ b/src/main/java/com/seibel/lod/wrappers/LightMapWrapper.java
@@ -2,7 +2,11 @@ package com.seibel.lod.wrappers;
import net.minecraft.client.renderer.texture.NativeImage;
-
+/**
+ *
+ * @author Leonardo Amato
+ * @version 11-13-2021
+ */
public class LightMapWrapper
{
static NativeImage lightMap = null;