Fix GLMC.glDeleteTextures() calls
This commit is contained in:
+17
-8
@@ -1,5 +1,7 @@
|
||||
package com.seibel.distanthorizons.core.render.glObject.texture;
|
||||
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
|
||||
import org.lwjgl.opengl.GL11C;
|
||||
import org.lwjgl.opengl.GL13C;
|
||||
import org.lwjgl.opengl.GL43C;
|
||||
@@ -8,12 +10,15 @@ import java.nio.ByteBuffer;
|
||||
|
||||
public class DHDepthTexture
|
||||
{
|
||||
private static final IMinecraftGLWrapper GLMC = SingletonInjector.INSTANCE.get(IMinecraftGLWrapper.class);
|
||||
|
||||
|
||||
private int id;
|
||||
public DHDepthTexture(int width, int height, EDhDepthBufferFormat format)
|
||||
{
|
||||
this.id = GL43C.glGenTextures();
|
||||
|
||||
resize(width, height, format);
|
||||
this.resize(width, height, format);
|
||||
|
||||
GL43C.glTexParameteri(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MIN_FILTER, GL11C.GL_NEAREST);
|
||||
GL43C.glTexParameteri(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, GL11C.GL_NEAREST);
|
||||
@@ -24,27 +29,31 @@ public class DHDepthTexture
|
||||
}
|
||||
|
||||
// For internal use by Iris for copying data. Do not use this in DH.
|
||||
public DHDepthTexture(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public DHDepthTexture(int id) { this.id = id; }
|
||||
|
||||
public void resize(int width, int height, EDhDepthBufferFormat format)
|
||||
{
|
||||
GL43C.glBindTexture(GL43C.GL_TEXTURE_2D, getTextureId());
|
||||
GL43C.glBindTexture(GL43C.GL_TEXTURE_2D, this.getTextureId());
|
||||
GL43C.glTexImage2D(GL11C.GL_TEXTURE_2D, 0, format.getGlInternalFormat(), width, height, 0,
|
||||
format.getGlType(), format.getGlFormat(), (ByteBuffer) null);
|
||||
}
|
||||
|
||||
public int getTextureId()
|
||||
{
|
||||
if (id == -1) throw new IllegalStateException("Depth texture does not exist!");
|
||||
return id;
|
||||
if (this.id == -1)
|
||||
{
|
||||
throw new IllegalStateException("Depth texture does not exist!");
|
||||
}
|
||||
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
GL43C.glDeleteTextures(getTextureId());
|
||||
GLMC.glDeleteTextures(this.getTextureId());
|
||||
this.id = -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+6
-1
@@ -1,5 +1,7 @@
|
||||
package com.seibel.distanthorizons.core.render.glObject.texture;
|
||||
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
|
||||
import org.joml.Vector2i;
|
||||
import org.lwjgl.opengl.GL11C;
|
||||
import org.lwjgl.opengl.GL13C;
|
||||
@@ -9,6 +11,9 @@ import java.nio.ByteBuffer;
|
||||
|
||||
public class DhColorTexture
|
||||
{
|
||||
private static final IMinecraftGLWrapper GLMC = SingletonInjector.INSTANCE.get(IMinecraftGLWrapper.class);
|
||||
|
||||
|
||||
private final EDhInternalTextureFormat internalFormat;
|
||||
private final EDhPixelFormat format;
|
||||
private final EDhPixelType type;
|
||||
@@ -100,7 +105,7 @@ public class DhColorTexture
|
||||
this.throwIfInvalid();
|
||||
this.isValid = false;
|
||||
|
||||
GL43C.glDeleteTextures(this.id);
|
||||
GLMC.glDeleteTextures(this.id);
|
||||
}
|
||||
|
||||
/** @throws IllegalStateException if the texture isn't valid */
|
||||
|
||||
Reference in New Issue
Block a user