mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Improved block rendering a bit, should play much nicer with shaders now (thanks a ton to Ivorius for pointers).
This commit is contained in:
parent
806dda8827
commit
58056a837c
@ -118,11 +118,11 @@ abstract class TextureFontRenderer {
|
||||
|
||||
protected def textureCount: Int
|
||||
|
||||
protected def bindTexture(index: Int)
|
||||
protected def bindTexture(index: Int): Unit
|
||||
|
||||
protected def generateChar(char: Char)
|
||||
protected def generateChar(char: Char): Unit
|
||||
|
||||
protected def drawChar(tx: Float, ty: Float, char: Char)
|
||||
protected def drawChar(tx: Float, ty: Float, char: Char): Unit
|
||||
|
||||
private def drawQuad(color: Int, x: Int, y: Int, width: Int) = if (color != 0 && width > 0) {
|
||||
val x0 = x * charWidth
|
||||
|
@ -63,6 +63,8 @@ object AssemblerRenderer extends TileEntitySpecialRenderer {
|
||||
GL11.glRotatef(90, 0, 1, 0)
|
||||
}
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
|
||||
|
@ -56,6 +56,8 @@ object CaseRenderer extends TileEntitySpecialRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
|
||||
|
@ -68,6 +68,8 @@ object ChargerRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
t.draw()
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ object DisassemblerRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
t.draw()
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
}
|
||||
|
@ -66,6 +66,8 @@ object DiskDriveRenderer extends TileEntitySpecialRenderer {
|
||||
t.addVertexWithUV(1, 0, 0, 1, 0)
|
||||
t.addVertexWithUV(0, 0, 0, 0, 0)
|
||||
t.draw()
|
||||
|
||||
RenderState.enableLighting()
|
||||
}
|
||||
|
||||
GL11.glPopMatrix()
|
||||
|
@ -36,6 +36,8 @@ object GeolyzerRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
t.draw()
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
|
||||
|
@ -54,6 +54,8 @@ object MicrocontrollerRenderer extends TileEntitySpecialRenderer {
|
||||
t.draw()
|
||||
}
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
|
||||
|
@ -60,6 +60,8 @@ object PowerDistributorRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
t.draw()
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ object RaidRenderer extends TileEntitySpecialRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
|
||||
|
@ -12,6 +12,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import org.lwjgl.opengl.GL11
|
||||
import org.lwjgl.opengl.GL14
|
||||
|
||||
object ScreenRenderer extends TileEntitySpecialRenderer {
|
||||
private val maxRenderDistanceSq = Settings.get.maxScreenTextRenderDistance * Settings.get.maxScreenTextRenderDistance
|
||||
@ -66,7 +67,9 @@ object ScreenRenderer extends TileEntitySpecialRenderer {
|
||||
RenderState.checkError(getClass.getName + ".renderTileEntityAt: overlay")
|
||||
|
||||
if (distance > fadeDistanceSq) {
|
||||
RenderState.setBlendAlpha(math.max(0, 1 - ((distance - fadeDistanceSq) * fadeRatio).toFloat))
|
||||
val alpha = math.max(0, 1 - ((distance - fadeDistanceSq) * fadeRatio).toFloat)
|
||||
GL14.glBlendColor(0, 0, 0, alpha)
|
||||
GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE)
|
||||
}
|
||||
|
||||
RenderState.checkError(getClass.getName + ".renderTileEntityAt: fade")
|
||||
@ -75,6 +78,8 @@ object ScreenRenderer extends TileEntitySpecialRenderer {
|
||||
draw()
|
||||
}
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
|
||||
|
@ -62,6 +62,8 @@ object ServerRackRenderer extends TileEntitySpecialRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
|
||||
|
@ -55,6 +55,8 @@ object SwitchRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
t.draw()
|
||||
|
||||
RenderState.enableLighting()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
}
|
||||
|
@ -2,7 +2,8 @@ package li.cil.oc.util
|
||||
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.Settings
|
||||
import net.minecraft.client.renderer.OpenGlHelper
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.RenderHelper
|
||||
import org.lwjgl.opengl._
|
||||
import org.lwjgl.util.glu.GLU
|
||||
|
||||
@ -27,41 +28,22 @@ object RenderState {
|
||||
}
|
||||
|
||||
def disableLighting() {
|
||||
GL11.glDisable(GL11.GL_LIGHTING)
|
||||
if (arb) {
|
||||
ARBMultitexture.glActiveTextureARB(OpenGlHelper.lightmapTexUnit)
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D)
|
||||
ARBMultitexture.glActiveTextureARB(OpenGlHelper.defaultTexUnit)
|
||||
}
|
||||
else {
|
||||
GL13.glActiveTexture(OpenGlHelper.lightmapTexUnit)
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D)
|
||||
GL13.glActiveTexture(OpenGlHelper.defaultTexUnit)
|
||||
}
|
||||
Minecraft.getMinecraft.entityRenderer.disableLightmap(0)
|
||||
RenderHelper.disableStandardItemLighting()
|
||||
}
|
||||
|
||||
def enableLighting() {
|
||||
GL11.glEnable(GL11.GL_LIGHTING)
|
||||
if (arb) {
|
||||
ARBMultitexture.glActiveTextureARB(OpenGlHelper.lightmapTexUnit)
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D)
|
||||
ARBMultitexture.glActiveTextureARB(OpenGlHelper.defaultTexUnit)
|
||||
}
|
||||
else {
|
||||
GL13.glActiveTexture(OpenGlHelper.lightmapTexUnit)
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D)
|
||||
GL13.glActiveTexture(OpenGlHelper.defaultTexUnit)
|
||||
}
|
||||
Minecraft.getMinecraft.entityRenderer.enableLightmap(0)
|
||||
RenderHelper.enableStandardItemLighting()
|
||||
}
|
||||
|
||||
def makeItBlend() {
|
||||
GL11.glEnable(GL11.GL_BLEND)
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA)
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL)
|
||||
}
|
||||
|
||||
def setBlendAlpha(alpha: Float) = if (canUseBlendColor) {
|
||||
GL14.glBlendColor(0, 0, 0, alpha)
|
||||
GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE)
|
||||
GL11.glColor4f(1, 1, 1, alpha)
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user