diff --git a/src/main/java/com/seibel/lod/core/render/GLProxy.java b/src/main/java/com/seibel/lod/core/render/GLProxy.java index 133c2a9dc..634627054 100644 --- a/src/main/java/com/seibel/lod/core/render/GLProxy.java +++ b/src/main/java/com/seibel/lod/core/render/GLProxy.java @@ -107,6 +107,8 @@ public class GLProxy // this must be created on minecraft's render context to work correctly ClientApi.LOGGER.info("Creating " + GLProxy.class.getSimpleName() + "... If this is the last message you see in the log there must have been a OpenGL error."); + + ClientApi.LOGGER.info("Lod Render OpenGL version [" + GL11.glGetString(GL11.GL_VERSION) + "]."); // getting Minecraft's context has to be done on the render thread, // where the GL context is @@ -121,11 +123,11 @@ public class GLProxy minecraftGlContext = GLFW.glfwGetCurrentContext(); minecraftGlCapabilities = GL.getCapabilities(); - // crash the game if the GPU doesn't support OpenGL 3.3 - if (!minecraftGlCapabilities.OpenGL33) + // crash the game if the GPU doesn't support OpenGL 3.2 + if (!minecraftGlCapabilities.OpenGL32) { // Note: as of MC 1.17 this shouldn't happen since MC - // requires OpenGL 3.3, but for older MC version this will warn the player. + // requires OpenGL 3.2, but for older MC version this will warn the player. String errorMessage = ModInfo.READABLE_NAME + " was initializing " + GLProxy.class.getSimpleName() + " and discovered this GPU doesn't support OpenGL 3.3 or greater."; MC.crashMinecraft(errorMessage + " Sorry I couldn't tell you sooner :(", new UnsupportedOperationException("This GPU doesn't support OpenGL 3.3 or greater.")); } @@ -162,7 +164,6 @@ public class GLProxy setGlContext(GLProxyContext.LOD_BUILDER); - ClientApi.LOGGER.info("Lod Render OpenGL version [" + GL11.glGetString(GL11.GL_VERSION) + "]."); // get specific capabilities diff --git a/src/main/java/com/seibel/lod/core/render/LodRenderProgram.java b/src/main/java/com/seibel/lod/core/render/LodRenderProgram.java index 5677c4cc0..288891249 100644 --- a/src/main/java/com/seibel/lod/core/render/LodRenderProgram.java +++ b/src/main/java/com/seibel/lod/core/render/LodRenderProgram.java @@ -21,10 +21,6 @@ package com.seibel.lod.core.render; import java.awt.Color; -import org.lwjgl.opengl.GL20; -import org.lwjgl.opengl.GL42; -import org.lwjgl.opengl.GL43; - import com.seibel.lod.core.enums.rendering.FogDistance; import com.seibel.lod.core.enums.rendering.FogDrawMode; import com.seibel.lod.core.objects.math.Mat4f; diff --git a/src/main/java/com/seibel/lod/core/render/LodRenderer.java b/src/main/java/com/seibel/lod/core/render/LodRenderer.java index 22b80020f..b0a8eb212 100644 --- a/src/main/java/com/seibel/lod/core/render/LodRenderer.java +++ b/src/main/java/com/seibel/lod/core/render/LodRenderer.java @@ -22,7 +22,7 @@ package com.seibel.lod.core.render; import java.awt.Color; import java.util.HashSet; -import org.lwjgl.opengl.GL33; +import org.lwjgl.opengl.GL32; import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.api.ClientApi; @@ -160,7 +160,7 @@ public class LodRenderer } // get MC's shader program - int currentProgram = GL33.glGetInteger(GL33.GL_CURRENT_PROGRAM); + int currentProgram = GL32.glGetInteger(GL32.GL_CURRENT_PROGRAM); GLProxy glProxy = GLProxy.getInstance(); if (canVanillaFogBeDisabled && CONFIG.client().graphics().fogQuality().getDisableVanillaFog()) @@ -224,16 +224,16 @@ public class LodRenderer /*---------Set GL State--------*/ // set the required open GL settings if (CONFIG.client().advanced().debugging().getDebugMode() == DebugMode.SHOW_DETAIL_WIREFRAME) - GL33.glPolygonMode(GL33.GL_FRONT_AND_BACK, GL33.GL_LINE); + GL32.glPolygonMode(GL32.GL_FRONT_AND_BACK, GL32.GL_LINE); else - GL33.glPolygonMode(GL33.GL_FRONT_AND_BACK, GL33.GL_FILL); + GL32.glPolygonMode(GL32.GL_FRONT_AND_BACK, GL32.GL_FILL); - GL33.glEnable(GL33.GL_CULL_FACE); - GL33.glEnable(GL33.GL_DEPTH_TEST); + GL32.glEnable(GL32.GL_CULL_FACE); + GL32.glEnable(GL32.GL_DEPTH_TEST); // enable transparent rendering - GL33.glBlendFunc(GL33.GL_SRC_ALPHA, GL33.GL_ONE_MINUS_SRC_ALPHA); - GL33.glEnable(GL33.GL_BLEND); + GL32.glBlendFunc(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA); + GL32.glEnable(GL32.GL_BLEND); /*---------Bind required objects--------*/ // Setup LodRenderProgram and the LightmapTexture if it has not yet been done @@ -243,7 +243,7 @@ public class LodRenderer } else { shaderProgram.bind(); } - GL33.glActiveTexture(GL33.GL_TEXTURE0); + GL32.glActiveTexture(GL32.GL_TEXTURE0); LightmapTexture lightmapTexture = new LightmapTexture(); /*---------Get required data--------*/ @@ -297,9 +297,9 @@ public class LodRenderer { bufferId = (storageBufferIds != null && usingBufferStorage) ? storageBufferIds[x][z][i] : vbos[x][z][i].id; if (bufferId==0) continue; - GL33.glBindBuffer(GL33.GL_ARRAY_BUFFER, bufferId); + GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, bufferId); shaderProgram.bindVertexBuffer(bufferId); - GL33.glDrawArrays(GL33.GL_TRIANGLES, 0, vbos[x][z][i].vertexCount); + GL32.glDrawArrays(GL32.GL_TRIANGLES, 0, vbos[x][z][i].vertexCount); } } } @@ -313,18 +313,18 @@ public class LodRenderer // if this cleanup isn't done MC will crash // when trying to render its own terrain - GL33.glBindBuffer(GL33.GL_ARRAY_BUFFER, 0); + GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0); shaderProgram.unbind(); lightmapTexture.free(); - GL33.glPolygonMode(GL33.GL_FRONT_AND_BACK, GL33.GL_FILL); - GL33.glDisable(GL33.GL_BLEND); // TODO: what should this be reset to? + GL32.glPolygonMode(GL32.GL_FRONT_AND_BACK, GL32.GL_FILL); + GL32.glDisable(GL32.GL_BLEND); // TODO: what should this be reset to? - GL33.glUseProgram(currentProgram); + GL32.glUseProgram(currentProgram); // clear the depth buffer so everything is drawn over the LODs - GL33.glClear(GL33.GL_DEPTH_BUFFER_BIT); + GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT); // end of internal LOD profiling profiler.pop(); diff --git a/src/main/java/com/seibel/lod/core/render/objects/LightmapTexture.java b/src/main/java/com/seibel/lod/core/render/objects/LightmapTexture.java index 16494c204..5e136cbd6 100644 --- a/src/main/java/com/seibel/lod/core/render/objects/LightmapTexture.java +++ b/src/main/java/com/seibel/lod/core/render/objects/LightmapTexture.java @@ -1,33 +1,32 @@ package com.seibel.lod.core.render.objects; -import org.lwjgl.opengl.GL20; -import org.lwjgl.opengl.GL30; +import org.lwjgl.opengl.GL32; public class LightmapTexture { public int id; public LightmapTexture() { - id = GL30.glGenTextures(); + id = GL32.glGenTextures(); bind(); } public void bind() { - GL20.glBindTexture(GL20.GL_TEXTURE_2D, id); + GL32.glBindTexture(GL32.GL_TEXTURE_2D, id); } public void unbind() { - GL20.glBindTexture(GL20.GL_TEXTURE_2D, 0); + GL32.glBindTexture(GL32.GL_TEXTURE_2D, 0); } public void free() { - GL20.glDeleteTextures(id); + GL32.glDeleteTextures(id); } // private int[] testArray; public void fillData(int lightMapWidth, int lightMapHeight, int[] pixels) { - GL20.glDeleteTextures(id); - id = GL30.glGenTextures(); - GL20.glBindTexture(GL20.GL_TEXTURE_2D, id); + GL32.glDeleteTextures(id); + id = GL32.glGenTextures(); + GL32.glBindTexture(GL32.GL_TEXTURE_2D, id); if (pixels.length != lightMapWidth*lightMapHeight) throw new RuntimeException("Lightmap Width*Height not equal to pixels provided!"); @@ -49,12 +48,12 @@ public class LightmapTexture { MC.sendChatMessage(same + " " + badIndex); */ // comment this line out to prevent uploading the new lightmap - GL20.glTexImage2D(GL20.GL_TEXTURE_2D, 0, GL20.GL_RGBA, lightMapWidth, - lightMapHeight, 0, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels); - GL20.glTexParameteri(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_WRAP_S, GL20.GL_CLAMP_TO_BORDER); - GL20.glTexParameteri(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_WRAP_T, GL20.GL_CLAMP_TO_BORDER); - GL20.glTexParameteri(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_MIN_FILTER, GL20.GL_NEAREST); - GL20.glTexParameteri(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_MAG_FILTER, GL20.GL_NEAREST); + GL32.glTexImage2D(GL32.GL_TEXTURE_2D, 0, GL32.GL_RGBA, lightMapWidth, + lightMapHeight, 0, GL32.GL_RGBA, GL32.GL_UNSIGNED_BYTE, pixels); + GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_WRAP_S, GL32.GL_CLAMP_TO_BORDER); + GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_WRAP_T, GL32.GL_CLAMP_TO_BORDER); + GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MIN_FILTER, GL32.GL_NEAREST); + GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MAG_FILTER, GL32.GL_NEAREST); } } diff --git a/src/main/java/com/seibel/lod/core/render/objects/Shader.java b/src/main/java/com/seibel/lod/core/render/objects/Shader.java index f071c107e..cf6c91729 100644 --- a/src/main/java/com/seibel/lod/core/render/objects/Shader.java +++ b/src/main/java/com/seibel/lod/core/render/objects/Shader.java @@ -26,7 +26,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL32; import com.seibel.lod.core.api.ClientApi; @@ -52,15 +52,15 @@ public class Shader { ClientApi.LOGGER.info("Loading shader at "+path); // Create an empty shader object - id = GL20.glCreateShader(type); + id = GL32.glCreateShader(type); StringBuilder source = loadFile(path, absoluteFilePath); - GL20.glShaderSource(id, source); + GL32.glShaderSource(id, source); - GL20.glCompileShader(id); + GL32.glCompileShader(id); // check if the shader compiled - int status = GL20.glGetShaderi(id, GL20.GL_COMPILE_STATUS); - if (status != GL20.GL_TRUE) { - String message = "Shader compiler error. Details: "+GL20.glGetShaderInfoLog(id); + int status = GL32.glGetShaderi(id, GL32.GL_COMPILE_STATUS); + if (status != GL32.GL_TRUE) { + String message = "Shader compiler error. Details: "+GL32.glGetShaderInfoLog(id); free(); // important! throw new RuntimeException(message); } @@ -69,7 +69,7 @@ public class Shader // REMEMBER to always free the resource! public void free() { - GL20.glDeleteShader(id); + GL32.glDeleteShader(id); } private StringBuilder loadFile(String path, boolean absoluteFilePath) { diff --git a/src/main/java/com/seibel/lod/core/render/objects/ShaderProgram.java b/src/main/java/com/seibel/lod/core/render/objects/ShaderProgram.java index b0490559f..31db6214c 100644 --- a/src/main/java/com/seibel/lod/core/render/objects/ShaderProgram.java +++ b/src/main/java/com/seibel/lod/core/render/objects/ShaderProgram.java @@ -22,7 +22,7 @@ package com.seibel.lod.core.render.objects; import java.awt.Color; import java.nio.FloatBuffer; -import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL32; import org.lwjgl.system.MemoryStack; import com.seibel.lod.core.objects.math.Mat4f; @@ -49,42 +49,42 @@ public class ShaderProgram * This will bind ShaderProgram */ public ShaderProgram(String vert, String frag, String fragDataOutputName) { - Shader vertShader = new Shader(GL20.GL_VERTEX_SHADER, vert, false); - Shader fragShader = new Shader(GL20.GL_FRAGMENT_SHADER, frag, false); + Shader vertShader = new Shader(GL32.GL_VERTEX_SHADER, vert, false); + Shader fragShader = new Shader(GL32.GL_FRAGMENT_SHADER, frag, false); - id = GL20.glCreateProgram(); + id = GL32.glCreateProgram(); - GL20.glAttachShader(this.id, vertShader.id); - GL20.glAttachShader(this.id, fragShader.id); - //GL30.glBindFragDataLocation(id, 0, fragDataOutputName); - GL20.glLinkProgram(this.id); + GL32.glAttachShader(this.id, vertShader.id); + GL32.glAttachShader(this.id, fragShader.id); + //GL32.glBindFragDataLocation(id, 0, fragDataOutputName); + GL32.glLinkProgram(this.id); vertShader.free(); // important! fragShader.free(); // important! - int status = GL20.glGetProgrami(this.id, GL20.GL_LINK_STATUS); - if (status != GL20.GL_TRUE) { - String message = "Shader Link Error. Details: "+GL20.glGetProgramInfoLog(this.id); + int status = GL32.glGetProgrami(this.id, GL32.GL_LINK_STATUS); + if (status != GL32.GL_TRUE) { + String message = "Shader Link Error. Details: "+GL32.glGetProgramInfoLog(this.id); free(); // important! throw new RuntimeException(message); } - GL20.glUseProgram(id); // This HAVE to be a direct call to prevent calling the overloaded version + GL32.glUseProgram(id); // This HAVE to be a direct call to prevent calling the overloaded version } /** This will bind ShaderProgram */ public void bind() { - GL20.glUseProgram(id); + GL32.glUseProgram(id); } /** This will unbind ShaderProgram */ public void unbind() { - GL20.glUseProgram(0); + GL32.glUseProgram(0); } // REMEMBER to always free the resource! public void free() { - GL20.glDeleteProgram(id); + GL32.glDeleteProgram(id); } /** WARNING: Slow native call! Cache it if possible! @@ -97,7 +97,7 @@ public class ShaderProgram */ public int getAttributeLocation(CharSequence name) { - int i = GL20.glGetAttribLocation(id, name); + int i = GL32.glGetAttribLocation(id, name); if (i==-1) throw new RuntimeException("Attribute name not found: "+name); return i; } @@ -112,7 +112,7 @@ public class ShaderProgram */ public int getUniformLocation(CharSequence name) { - int i = GL20.glGetUniformLocation(id, name); + int i = GL32.glGetUniformLocation(id, name); if (i==-1) throw new RuntimeException("Uniform name not found: "+name); return i; } @@ -121,31 +121,31 @@ public class ShaderProgram public void setUniform(int location, boolean value) { // This use -1 for false as that equals all one set - GL20.glUniform1i(location, value ? 1 : 0); + GL32.glUniform1i(location, value ? 1 : 0); } /** Requires ShaderProgram binded. */ public void setUniform(int location, int value) { - GL20.glUniform1i(location, value); + GL32.glUniform1i(location, value); } /** Requires ShaderProgram binded. */ public void setUniform(int location, float value) { - GL20.glUniform1f(location, value); + GL32.glUniform1f(location, value); } /** Requires ShaderProgram binded. */ public void setUniform(int location, Vec3f value) { - GL20.glUniform3f(location, value.x, value.y, value.z); + GL32.glUniform3f(location, value.x, value.y, value.z); } /** Requires ShaderProgram binded. */ public void setUniform(int location, Vec3d value) { - GL20.glUniform3f(location, (float) value.x, (float) value.y, (float) value.z); + GL32.glUniform3f(location, (float) value.x, (float) value.y, (float) value.z); } /** Requires ShaderProgram binded. */ @@ -155,7 +155,7 @@ public class ShaderProgram { FloatBuffer buffer = stack.mallocFloat(4 * 4); value.store(buffer); - GL20.glUniformMatrix4fv(location, false, buffer); + GL32.glUniformMatrix4fv(location, false, buffer); } } @@ -163,7 +163,7 @@ public class ShaderProgram * Requires ShaderProgram binded. */ public void setUniform(int location, Color value) { - GL20.glUniform4f(location, value.getRed() / 256.0f, value.getGreen() / 256.0f, value.getBlue() / 256.0f, value.getAlpha() / 256.0f); + GL32.glUniform4f(location, value.getRed() / 256.0f, value.getGreen() / 256.0f, value.getBlue() / 256.0f, value.getAlpha() / 256.0f); } } diff --git a/src/main/java/com/seibel/lod/core/render/objects/VertexAttribute.java b/src/main/java/com/seibel/lod/core/render/objects/VertexAttribute.java index 241b3465f..3c96150d6 100644 --- a/src/main/java/com/seibel/lod/core/render/objects/VertexAttribute.java +++ b/src/main/java/com/seibel/lod/core/render/objects/VertexAttribute.java @@ -19,9 +19,7 @@ package com.seibel.lod.core.render.objects; -import org.lwjgl.opengl.GL15; -import org.lwjgl.opengl.GL20; -import org.lwjgl.opengl.GL30; +import org.lwjgl.opengl.GL32; public abstract class VertexAttribute { @@ -37,34 +35,34 @@ public abstract class VertexAttribute { this.byteSize = byteSize; } public static VertexPointer addFloatPointer(boolean normalized) { - return new VertexPointer(1, GL15.GL_FLOAT, normalized, 4); + return new VertexPointer(1, GL32.GL_FLOAT, normalized, 4); } public static VertexPointer addVec2Pointer(boolean normalized) { - return new VertexPointer(2, GL15.GL_FLOAT, normalized, 8); + return new VertexPointer(2, GL32.GL_FLOAT, normalized, 8); } public static VertexPointer addVec3Pointer(boolean normalized) { - return new VertexPointer(3, GL15.GL_FLOAT, normalized, 12); + return new VertexPointer(3, GL32.GL_FLOAT, normalized, 12); } public static VertexPointer addVec4Pointer(boolean normalized) { - return new VertexPointer(1, GL15.GL_FLOAT, normalized, 16); + return new VertexPointer(1, GL32.GL_FLOAT, normalized, 16); } public static VertexPointer addUnsignedBytePointer(boolean normalized) { - return new VertexPointer(1, GL15.GL_UNSIGNED_BYTE, normalized, 1); + return new VertexPointer(1, GL32.GL_UNSIGNED_BYTE, normalized, 1); } public static VertexPointer addUnsignedBytesPointer(int elementCount, boolean normalized) { - return new VertexPointer(elementCount, GL15.GL_UNSIGNED_BYTE, normalized, elementCount); + return new VertexPointer(elementCount, GL32.GL_UNSIGNED_BYTE, normalized, elementCount); } public static VertexPointer addIntPointer(boolean normalized) { - return new VertexPointer(1, GL15.GL_INT, normalized, 4); + return new VertexPointer(1, GL32.GL_INT, normalized, 4); } public static VertexPointer addIvec2Pointer(boolean normalized) { - return new VertexPointer(2, GL15.GL_INT, normalized, 8); + return new VertexPointer(2, GL32.GL_INT, normalized, 8); } public static VertexPointer addIvec3Pointer(boolean normalized) { - return new VertexPointer(3, GL15.GL_INT, normalized, 12); + return new VertexPointer(3, GL32.GL_INT, normalized, 12); } public static VertexPointer addIvec4Pointer(boolean normalized) { - return new VertexPointer(4, GL15.GL_INT, normalized, 16); + return new VertexPointer(4, GL32.GL_INT, normalized, 16); } } @@ -74,23 +72,23 @@ public abstract class VertexAttribute { // This will bind VertexAttribute protected VertexAttribute() { - id = GL30.glGenVertexArrays(); - GL30.glBindVertexArray(id); + id = GL32.glGenVertexArrays(); + GL32.glBindVertexArray(id); } // This will bind VertexAttribute public void bind() { - GL30.glBindVertexArray(id); + GL32.glBindVertexArray(id); } // This will unbind VertexAttribute public void unbind() { - GL30.glBindVertexArray(0); + GL32.glBindVertexArray(0); } // REMEMBER to always free the resource! public void free() { - GL30.glDeleteVertexArrays(id); + GL32.glDeleteVertexArrays(id); } // Requires VertexAttribute binded, VertexBuffer binded diff --git a/src/main/java/com/seibel/lod/core/render/objects/VertexAttributePostGL43.java b/src/main/java/com/seibel/lod/core/render/objects/VertexAttributePostGL43.java index a8ec0da3a..f5948e5ee 100644 --- a/src/main/java/com/seibel/lod/core/render/objects/VertexAttributePostGL43.java +++ b/src/main/java/com/seibel/lod/core/render/objects/VertexAttributePostGL43.java @@ -1,8 +1,5 @@ package com.seibel.lod.core.render.objects; -import java.util.ArrayList; - -import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL43; import com.seibel.lod.core.api.ClientApi; diff --git a/src/main/java/com/seibel/lod/core/render/objects/VertexAttributePreGL43.java b/src/main/java/com/seibel/lod/core/render/objects/VertexAttributePreGL43.java index 1bd9ebf55..14e2d049b 100644 --- a/src/main/java/com/seibel/lod/core/render/objects/VertexAttributePreGL43.java +++ b/src/main/java/com/seibel/lod/core/render/objects/VertexAttributePreGL43.java @@ -5,7 +5,7 @@ import java.util.Iterator; import java.util.TreeMap; import java.util.TreeSet; -import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL32; import com.seibel.lod.core.api.ClientApi; @@ -34,12 +34,12 @@ public final class VertexAttributePreGL43 extends VertexAttribute { // Requires VertexAttribute binded, VertexBuffer binded public void bindBufferToAllBindingPoint(int buffer) { for (int i=0; i