mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 21:02:15 +00:00
* More Caching * Pull TextureTracker & TextureInfoCache out of Iris and into GLSM * Cache more TextureInfo state * GLSM: glTexParameter, glGetTexParameter(i|f), glGetTexLevelParameteri * Move IrisRenderSystem -> GLSM.RenderSystem * Ensure DSA works properly with GLSM * Further updates to DSA for texParameter/getTexParameter * A few more cached fields for TextureInfo * Properly handle deleteTextures * Ensure anyone crazy enough to use an Int/FloatBuffer for single value params get redirected * Add optional runtime disabling of GLSM * Switch checkGLError from an inject to a redirect, hopefully fewer allocations * Fewer allocations for clearBufferState * Microoptimization for (setup|clear)BufferState
39 lines
1.4 KiB
Java
39 lines
1.4 KiB
Java
package net.coderbot.iris.rendertarget;
|
|
|
|
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
|
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
|
import net.coderbot.iris.gl.GlResource;
|
|
import net.coderbot.iris.gl.texture.DepthBufferFormat;
|
|
import org.lwjgl.opengl.GL11;
|
|
import org.lwjgl.opengl.GL12;
|
|
|
|
public class DepthTexture extends GlResource {
|
|
public DepthTexture(int width, int height, DepthBufferFormat format) {
|
|
super(RenderSystem.createTexture(GL11.GL_TEXTURE_2D));
|
|
final int texture = getGlId();
|
|
|
|
resize(width, height, format);
|
|
|
|
RenderSystem.texParameteri(texture, GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
|
|
RenderSystem.texParameteri(texture, GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
|
RenderSystem.texParameteri(texture, GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
|
RenderSystem.texParameteri(texture, GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
|
|
|
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, 0);
|
|
}
|
|
|
|
void resize(int width, int height, DepthBufferFormat format) {
|
|
RenderSystem.texImage2D(getTextureId(), GL11.GL_TEXTURE_2D, 0, format.getGlInternalFormat(), width, height, 0,
|
|
format.getGlType(), format.getGlFormat(), null);
|
|
}
|
|
|
|
public int getTextureId() {
|
|
return getGlId();
|
|
}
|
|
|
|
@Override
|
|
protected void destroyInternal() {
|
|
GLStateManager.glDeleteTextures(getGlId());
|
|
}
|
|
}
|