rename GlProxy to GLProxy
This commit is contained in:
@@ -26,7 +26,7 @@ import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.builders.worldGeneration.LodGenWorker;
|
||||
import com.seibel.lod.core.objects.lod.LodDimension;
|
||||
import com.seibel.lod.core.objects.math.Mat4f;
|
||||
import com.seibel.lod.core.render.GlProxy;
|
||||
import com.seibel.lod.core.render.GLProxy;
|
||||
import com.seibel.lod.core.render.LodRenderer;
|
||||
import com.seibel.lod.core.util.DetailDistanceUtil;
|
||||
import com.seibel.lod.core.util.SingletonHandler;
|
||||
@@ -159,8 +159,8 @@ public class ClientApi
|
||||
/** This event is called once during the first frame Minecraft renders in the world. */
|
||||
public void firstFrameSetup()
|
||||
{
|
||||
// make sure the GlProxy is created before the LodBufferBuilder needs it
|
||||
GlProxy.getInstance();
|
||||
// make sure the GLProxy is created before the LodBufferBuilder needs it
|
||||
GLProxy.getInstance();
|
||||
|
||||
firstTimeSetupComplete = true;
|
||||
}
|
||||
|
||||
+12
-12
@@ -40,7 +40,7 @@ import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.enums.LodDirection;
|
||||
import com.seibel.lod.core.enums.config.GpuUploadMethod;
|
||||
import com.seibel.lod.core.enums.config.VanillaOverdraw;
|
||||
import com.seibel.lod.core.enums.rendering.GlProxyContext;
|
||||
import com.seibel.lod.core.enums.rendering.GLProxyContext;
|
||||
import com.seibel.lod.core.objects.Box;
|
||||
import com.seibel.lod.core.objects.PosToRenderContainer;
|
||||
import com.seibel.lod.core.objects.lod.LodDimension;
|
||||
@@ -48,7 +48,7 @@ import com.seibel.lod.core.objects.lod.LodRegion;
|
||||
import com.seibel.lod.core.objects.lod.RegionPos;
|
||||
import com.seibel.lod.core.objects.opengl.LodBufferBuilder;
|
||||
import com.seibel.lod.core.objects.opengl.LodVertexBuffer;
|
||||
import com.seibel.lod.core.render.GlProxy;
|
||||
import com.seibel.lod.core.render.GLProxy;
|
||||
import com.seibel.lod.core.render.LodRenderer;
|
||||
import com.seibel.lod.core.util.DataPointUtil;
|
||||
import com.seibel.lod.core.util.DetailDistanceUtil;
|
||||
@@ -525,9 +525,9 @@ public class LodBufferBuilderFactory
|
||||
long regionMemoryRequired;
|
||||
int numberOfBuffers;
|
||||
|
||||
GlProxy glProxy = GlProxy.getInstance();
|
||||
GlProxyContext oldContext = glProxy.getGlContext();
|
||||
glProxy.setGlContext(GlProxyContext.LOD_BUILDER);
|
||||
GLProxy glProxy = GLProxy.getInstance();
|
||||
GLProxyContext oldContext = glProxy.getGlContext();
|
||||
glProxy.setGlContext(GLProxyContext.LOD_BUILDER);
|
||||
|
||||
|
||||
previousRegionWidth = numbRegionsWide;
|
||||
@@ -650,7 +650,7 @@ public class LodBufferBuilderFactory
|
||||
int drawableId = drawableStorageBufferIds[x][z][i];
|
||||
|
||||
// make sure the buffers are deleted in a openGL context
|
||||
GlProxy.getInstance().recordOpenGlCall(() ->
|
||||
GLProxy.getInstance().recordOpenGlCall(() ->
|
||||
{
|
||||
GL15.glDeleteBuffers(buildableId);
|
||||
GL15.glDeleteBuffers(drawableId);
|
||||
@@ -692,7 +692,7 @@ public class LodBufferBuilderFactory
|
||||
drawableId = 0;
|
||||
|
||||
|
||||
GlProxy.getInstance().recordOpenGlCall(() ->
|
||||
GLProxy.getInstance().recordOpenGlCall(() ->
|
||||
{
|
||||
if (buildableId != 0)
|
||||
GL15.glDeleteBuffers(buildableId);
|
||||
@@ -752,13 +752,13 @@ public class LodBufferBuilderFactory
|
||||
/** Upload all buildableBuffers to the GPU. */
|
||||
private void uploadBuffers(boolean fullRegen, LodDimension lodDim)
|
||||
{
|
||||
GlProxy glProxy = GlProxy.getInstance();
|
||||
GLProxy glProxy = GLProxy.getInstance();
|
||||
|
||||
try
|
||||
{
|
||||
// make sure we are uploading to the builder context,
|
||||
// this helps prevent interference (IE stuttering) with the Minecraft context.
|
||||
glProxy.setGlContext(GlProxyContext.LOD_BUILDER);
|
||||
glProxy.setGlContext(GLProxyContext.LOD_BUILDER);
|
||||
|
||||
// determine the upload method
|
||||
GpuUploadMethod uploadMethod = CONFIG.client().graphics().advancedGraphics().getGpuUploadMethod();
|
||||
@@ -804,7 +804,7 @@ public class LodBufferBuilderFactory
|
||||
// close the context so it can be re-used later.
|
||||
// I'm guessing we can't just leave it because the executor service
|
||||
// does something that invalidates the OpenGL context.
|
||||
glProxy.setGlContext(GlProxyContext.NONE);
|
||||
glProxy.setGlContext(GLProxyContext.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -813,7 +813,7 @@ public class LodBufferBuilderFactory
|
||||
boolean allowBufferExpansion, GpuUploadMethod uploadMethod)
|
||||
{
|
||||
// this shouldn't happen, but just to be safe
|
||||
if (vbo.id != -1 && GlProxy.getInstance().getGlContext() == GlProxyContext.LOD_BUILDER)
|
||||
if (vbo.id != -1 && GLProxy.getInstance().getGlContext() == GLProxyContext.LOD_BUILDER)
|
||||
{
|
||||
// this is how many points will be rendered
|
||||
vbo.vertexCount = (uploadBuffer.capacity() / (Float.BYTES * 3) + (Byte.BYTES * 4)); // TODO make this change with the LodTemplate
|
||||
@@ -882,7 +882,7 @@ public class LodBufferBuilderFactory
|
||||
ByteBuffer vboBuffer;
|
||||
|
||||
// map buffer range is better since it can be explicitly unsynchronized
|
||||
if (GlProxy.getInstance().mapBufferRangeSupported)
|
||||
if (GLProxy.getInstance().mapBufferRangeSupported)
|
||||
vboBuffer = GL30.glMapBufferRange(GL30.GL_ARRAY_BUFFER, 0, uploadBuffer.capacity(), GL30.GL_MAP_WRITE_BIT | GL30.GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
else
|
||||
vboBuffer = GL15.glMapBuffer(GL30.GL_ARRAY_BUFFER, uploadBuffer.capacity());
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ package com.seibel.lod.core.enums.rendering;
|
||||
* @author James Seibel
|
||||
* @version 10-1-2021
|
||||
*/
|
||||
public enum GlProxyContext
|
||||
public enum GLProxyContext
|
||||
{
|
||||
/** Minecraft's render thread */
|
||||
MINECRAFT,
|
||||
@@ -33,7 +33,7 @@ public enum GlProxyContext
|
||||
/** The context we send buffers to the GPU on */
|
||||
LOD_BUILDER,
|
||||
|
||||
/** A context that can be used for miscellaneous tasks, owned by the GlProxy */
|
||||
/** A context that can be used for miscellaneous tasks, owned by the GLProxy */
|
||||
PROXY_WORKER,
|
||||
|
||||
/** used to un-bind threads */
|
||||
@@ -21,8 +21,8 @@ package com.seibel.lod.core.objects.opengl;
|
||||
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
import com.seibel.lod.core.enums.rendering.GlProxyContext;
|
||||
import com.seibel.lod.core.render.GlProxy;
|
||||
import com.seibel.lod.core.enums.rendering.GLProxyContext;
|
||||
import com.seibel.lod.core.render.GLProxy;
|
||||
|
||||
/**
|
||||
* This is a container for a OpenGL
|
||||
@@ -38,7 +38,7 @@ public class LodVertexBuffer implements AutoCloseable
|
||||
|
||||
public LodVertexBuffer()
|
||||
{
|
||||
if (GlProxy.getInstance().getGlContext() == GlProxyContext.NONE)
|
||||
if (GLProxy.getInstance().getGlContext() == GLProxyContext.NONE)
|
||||
throw new IllegalStateException("Thread [" +Thread.currentThread().getName() + "] tried to create a [" + LodVertexBuffer.class.getSimpleName() + "] outside a OpenGL contex.");
|
||||
|
||||
this.id = GL15.glGenBuffers();
|
||||
@@ -50,7 +50,7 @@ public class LodVertexBuffer implements AutoCloseable
|
||||
{
|
||||
if (this.id >= 0)
|
||||
{
|
||||
GlProxy.getInstance().recordOpenGlCall(() -> GL15.glDeleteBuffers(this.id));
|
||||
GLProxy.getInstance().recordOpenGlCall(() -> GL15.glDeleteBuffers(this.id));
|
||||
this.id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
+25
-25
@@ -32,7 +32,7 @@ import org.lwjgl.opengl.GLCapabilities;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.api.ClientApi;
|
||||
import com.seibel.lod.core.enums.rendering.GlProxyContext;
|
||||
import com.seibel.lod.core.enums.rendering.GLProxyContext;
|
||||
import com.seibel.lod.core.render.shader.LodShader;
|
||||
import com.seibel.lod.core.render.shader.LodShaderProgram;
|
||||
import com.seibel.lod.core.util.SingletonHandler;
|
||||
@@ -52,14 +52,14 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
|
||||
* @author James Seibel
|
||||
* @version 11-20-2021
|
||||
*/
|
||||
public class GlProxy
|
||||
public class GLProxy
|
||||
{
|
||||
private static final IMinecraftWrapper MC = SingletonHandler.get(IMinecraftWrapper.class);
|
||||
|
||||
private static ExecutorService workerThread = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat(GlProxy.class.getSimpleName() + "-Worker-Thread").build());
|
||||
private static ExecutorService workerThread = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat(GLProxy.class.getSimpleName() + "-Worker-Thread").build());
|
||||
|
||||
|
||||
private static GlProxy instance = null;
|
||||
private static GLProxy instance = null;
|
||||
|
||||
/** Minecraft's GLFW window */
|
||||
public final long minecraftGlContext;
|
||||
@@ -93,14 +93,14 @@ public class GlProxy
|
||||
|
||||
|
||||
|
||||
private GlProxy()
|
||||
private GLProxy()
|
||||
{
|
||||
ClientApi.LOGGER.error("Creating " + GlProxy.class.getSimpleName() + "... If this is the last message you see in the log there must have been a OpenGL error.");
|
||||
ClientApi.LOGGER.error("Creating " + GLProxy.class.getSimpleName() + "... If this is the last message you see in the log there must have been a OpenGL error.");
|
||||
|
||||
// getting Minecraft's context has to be done on the render thread,
|
||||
// where the GL context is
|
||||
if (GLFW.glfwGetCurrentContext() == 0L)
|
||||
throw new IllegalStateException(GlProxy.class.getSimpleName() + " was created outside the render thread!");
|
||||
throw new IllegalStateException(GLProxy.class.getSimpleName() + " was created outside the render thread!");
|
||||
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ public class GlProxy
|
||||
// get any GPU related capabilities //
|
||||
//==================================//
|
||||
|
||||
setGlContext(GlProxyContext.LOD_BUILDER);
|
||||
setGlContext(GLProxyContext.LOD_BUILDER);
|
||||
|
||||
ClientApi.LOGGER.info("Lod Render OpenGL version [" + GL11.glGetString(GL11.GL_VERSION) + "].");
|
||||
|
||||
@@ -152,7 +152,7 @@ public class GlProxy
|
||||
{
|
||||
// Note: as of MC 1.17 this shouldn't happen since MC
|
||||
// requires OpenGL 3.3, but just in case.
|
||||
String errorMessage = ModInfo.READABLE_NAME + " was initializing " + GlProxy.class.getSimpleName() + " and discoverd this GPU doesn't support OpenGL 2.0 or greater.";
|
||||
String errorMessage = ModInfo.READABLE_NAME + " was initializing " + GLProxy.class.getSimpleName() + " and discoverd this GPU doesn't support OpenGL 2.0 or greater.";
|
||||
MC.crashMinecraft(errorMessage + " Sorry I couldn't tell you sooner :(", new UnsupportedOperationException("This GPU doesn't support OpenGL 2.0 or greater."));
|
||||
}
|
||||
|
||||
@@ -179,8 +179,8 @@ public class GlProxy
|
||||
// shader setup //
|
||||
//==============//
|
||||
|
||||
//setGlContext(GlProxyContext.LOD_RENDER);
|
||||
setGlContext(GlProxyContext.MINECRAFT);
|
||||
//setGlContext(GLProxyContext.LOD_RENDER);
|
||||
setGlContext(GLProxyContext.MINECRAFT);
|
||||
|
||||
createShaderProgram();
|
||||
|
||||
@@ -197,11 +197,11 @@ public class GlProxy
|
||||
//==========//
|
||||
|
||||
// Since this is created on the render thread, make sure the Minecraft context is used in the end
|
||||
setGlContext(GlProxyContext.MINECRAFT);
|
||||
setGlContext(GLProxyContext.MINECRAFT);
|
||||
|
||||
|
||||
// GlProxy creation success
|
||||
ClientApi.LOGGER.error(GlProxy.class.getSimpleName() + " creation successful. OpenGL smiles upon you this day.");
|
||||
// GLProxy creation success
|
||||
ClientApi.LOGGER.error(GLProxy.class.getSimpleName() + " creation successful. OpenGL smiles upon you this day.");
|
||||
}
|
||||
|
||||
/** Creates all required shaders */
|
||||
@@ -252,9 +252,9 @@ public class GlProxy
|
||||
* A wrapper function to make switching contexts easier. <br>
|
||||
* Does nothing if the calling thread is already using newContext.
|
||||
*/
|
||||
public void setGlContext(GlProxyContext newContext)
|
||||
public void setGlContext(GLProxyContext newContext)
|
||||
{
|
||||
GlProxyContext currentContext = getGlContext();
|
||||
GLProxyContext currentContext = getGlContext();
|
||||
|
||||
// we don't have to change the context, we are already there.
|
||||
if (currentContext == newContext)
|
||||
@@ -294,19 +294,19 @@ public class GlProxy
|
||||
}
|
||||
|
||||
/** Returns this thread's OpenGL context. */
|
||||
public GlProxyContext getGlContext()
|
||||
public GLProxyContext getGlContext()
|
||||
{
|
||||
long currentContext = GLFW.glfwGetCurrentContext();
|
||||
|
||||
|
||||
if (currentContext == lodBuilderGlContext)
|
||||
return GlProxyContext.LOD_BUILDER;
|
||||
return GLProxyContext.LOD_BUILDER;
|
||||
else if (currentContext == minecraftGlContext)
|
||||
return GlProxyContext.MINECRAFT;
|
||||
return GLProxyContext.MINECRAFT;
|
||||
else if (currentContext == proxyWorkerGlContext)
|
||||
return GlProxyContext.PROXY_WORKER;
|
||||
return GLProxyContext.PROXY_WORKER;
|
||||
else if (currentContext == 0L)
|
||||
return GlProxyContext.NONE;
|
||||
return GLProxyContext.NONE;
|
||||
else
|
||||
// hopefully this shouldn't happen
|
||||
throw new IllegalStateException(Thread.currentThread().getName() +
|
||||
@@ -318,10 +318,10 @@ public class GlProxy
|
||||
}
|
||||
|
||||
|
||||
public static GlProxy getInstance()
|
||||
public static GLProxy getInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new GlProxy();
|
||||
instance = new GLProxy();
|
||||
|
||||
return instance;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ public class GlProxy
|
||||
try
|
||||
{
|
||||
// set up the context...
|
||||
setGlContext(GlProxyContext.PROXY_WORKER);
|
||||
setGlContext(GLProxyContext.PROXY_WORKER);
|
||||
// ...run the actual code...
|
||||
renderCall.run();
|
||||
}
|
||||
@@ -360,7 +360,7 @@ public class GlProxy
|
||||
finally
|
||||
{
|
||||
// ...and make sure the context is released when the thread finishes
|
||||
setGlContext(GlProxyContext.NONE);
|
||||
setGlContext(GLProxyContext.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class LodRenderer
|
||||
|
||||
profiler.push("LOD setup");
|
||||
|
||||
GlProxy glProxy = GlProxy.getInstance();
|
||||
GLProxy glProxy = GLProxy.getInstance();
|
||||
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ public class LodRenderer
|
||||
|
||||
// bind the buffer we are going to draw
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, glBufferId);
|
||||
GL30.glBindVertexArray(GlProxy.getInstance().vertexArrayObjectId);
|
||||
GL30.glBindVertexArray(GLProxy.getInstance().vertexArrayObjectId);
|
||||
|
||||
// let OpenGL know how our buffer is set up
|
||||
int vertexByteCount = (Float.BYTES * 3) + (Byte.BYTES * 4);
|
||||
|
||||
Reference in New Issue
Block a user