mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 02:12:42 -04:00
More rendering glitch fixing...
This commit is contained in:
parent
a3274bc7de
commit
b09cb024a0
@ -3,6 +3,7 @@ package li.cil.oc.client
|
|||||||
import li.cil.oc.Settings
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.common.Slot
|
import li.cil.oc.common.Slot
|
||||||
import li.cil.oc.common.Tier
|
import li.cil.oc.common.Tier
|
||||||
|
import li.cil.oc.util.RenderState
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.client.renderer.texture.TextureMap
|
import net.minecraft.client.renderer.texture.TextureMap
|
||||||
import net.minecraft.util.ResourceLocation
|
import net.minecraft.util.ResourceLocation
|
||||||
@ -502,7 +503,7 @@ object Textures {
|
|||||||
// So we do it manually.
|
// So we do it manually.
|
||||||
val texture = manager.getTexture(location)
|
val texture = manager.getTexture(location)
|
||||||
if (texture != null) {
|
if (texture != null) {
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getGlTextureId)
|
RenderState.bindTexture(texture.getGlTextureId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,11 +95,11 @@ object DynamicFontRenderer {
|
|||||||
|
|
||||||
class CharTexture(val owner: DynamicFontRenderer) {
|
class CharTexture(val owner: DynamicFontRenderer) {
|
||||||
private val id = GlStateManager.generateTexture()
|
private val id = GlStateManager.generateTexture()
|
||||||
GlStateManager.bindTexture(id)
|
RenderState.bindTexture(id)
|
||||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST)
|
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST)
|
||||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST)
|
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST)
|
||||||
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, BufferUtils.createByteBuffer(size * size * 4))
|
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, BufferUtils.createByteBuffer(size * size * 4))
|
||||||
GlStateManager.bindTexture(0)
|
RenderState.bindTexture(0)
|
||||||
|
|
||||||
RenderState.checkError(getClass.getName + ".<init>: create texture")
|
RenderState.checkError(getClass.getName + ".<init>: create texture")
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ object DynamicFontRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def bind() {
|
def bind() {
|
||||||
GlStateManager.bindTexture(id)
|
RenderState.bindTexture(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
def isFull(char: Char) = chars + FontUtil.wcwidth(char) > capacity
|
def isFull(char: Char) = chars + FontUtil.wcwidth(char) > capacity
|
||||||
@ -136,7 +136,7 @@ object DynamicFontRenderer {
|
|||||||
val x = chars % cols
|
val x = chars % cols
|
||||||
val y = chars / cols
|
val y = chars / cols
|
||||||
|
|
||||||
GlStateManager.bindTexture(id)
|
RenderState.bindTexture(id)
|
||||||
GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 1 + x * cellWidth, 1 + y * cellHeight, w, h, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, owner.glyphProvider.getGlyph(char))
|
GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 1 + x * cellWidth, 1 + y * cellHeight, w, h, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, owner.glyphProvider.getGlyph(char))
|
||||||
|
|
||||||
chars += glyphWidth
|
chars += glyphWidth
|
||||||
|
@ -8,6 +8,14 @@ import net.minecraft.client.renderer.RenderHelper
|
|||||||
import org.lwjgl.opengl._
|
import org.lwjgl.opengl._
|
||||||
import org.lwjgl.util.glu.GLU
|
import org.lwjgl.util.glu.GLU
|
||||||
|
|
||||||
|
// This class has evolved into a wrapper for GlStateManager that basically does
|
||||||
|
// nothing but call the corresponding GlStateManager methods and then also
|
||||||
|
// forcefully applies whatever that call *should* do. This way the state
|
||||||
|
// manager's internal state is kept up-to-date but we also avoid issues with
|
||||||
|
// that state being incorrect causing wrong behavior (I've had too many render
|
||||||
|
// bugs where textures were not bound correctly or state was not updated
|
||||||
|
// because the state manager thought it already was in the state to change to,
|
||||||
|
// so I frankly don't care if this is less performant anymore).
|
||||||
object RenderState {
|
object RenderState {
|
||||||
val arb = GLContext.getCapabilities.GL_ARB_multitexture && !GLContext.getCapabilities.OpenGL13
|
val arb = GLContext.getCapabilities.GL_ARB_multitexture && !GLContext.getCapabilities.OpenGL13
|
||||||
|
|
||||||
@ -147,4 +155,9 @@ object RenderState {
|
|||||||
GlStateManager.color(1, 1, 1, alpha)
|
GlStateManager.color(1, 1, 1, alpha)
|
||||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE)
|
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def bindTexture(id: Int): Unit = {
|
||||||
|
GlStateManager.bindTexture(id)
|
||||||
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user