diff --git a/src/main/scala/li/cil/oc/client/Textures.scala b/src/main/scala/li/cil/oc/client/Textures.scala index 46ae96e3e..99a49d12d 100644 --- a/src/main/scala/li/cil/oc/client/Textures.scala +++ b/src/main/scala/li/cil/oc/client/Textures.scala @@ -20,7 +20,7 @@ object Textures { override protected def basePath = "textures/font/%s.png" - override protected def loader(map: TextureMap, loc: ResourceLocation) = textureManager.bindTexture(loc) + override protected def loader(map: TextureMap, loc: ResourceLocation) = Textures.bind(loc) } object GUI extends TextureBundle { @@ -51,7 +51,7 @@ object Textures { override protected def basePath = "textures/gui/%s.png" - override protected def loader(map: TextureMap, loc: ResourceLocation) = textureManager.bindTexture(loc) + override protected def loader(map: TextureMap, loc: ResourceLocation) = Textures.bind(loc) } object Icons extends TextureBundle { @@ -64,7 +64,7 @@ object Textures { override protected def basePath = "textures/icons/%s.png" - override protected def loader(map: TextureMap, loc: ResourceLocation) = textureManager.bindTexture(loc) + override protected def loader(map: TextureMap, loc: ResourceLocation) = Textures.bind(loc) } object Model extends TextureBundle { @@ -77,7 +77,7 @@ object Textures { override protected def basePath = "textures/model/%s.png" - override protected def loader(map: TextureMap, loc: ResourceLocation) = textureManager.bindTexture(loc) + override protected def loader(map: TextureMap, loc: ResourceLocation) = Textures.bind(loc) } // These are kept in the block texture atlas to support animations. @@ -483,17 +483,7 @@ object Textures { Screen.makeSureThisIsInitialized() - def bind(): Unit = { - // IMPORTANT: manager.bindTexture uses GlStateManager.bindTexture, and - // that has borked caching, so binding textures will sometimes fail, - // because it'll think the texture is already bound although it isn't. - // So we do it manually. - val manager = Minecraft.getMinecraft.renderEngine - val texture = manager.getTexture(TextureMap.locationBlocksTexture) - if (texture != null) { - GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getGlTextureId) - } - } + def bind(): Unit = Textures.bind(TextureMap.locationBlocksTexture) def getSprite(location: ResourceLocation) = Minecraft.getMinecraft.getTextureMapBlocks.getAtlasSprite(location.toString) @@ -502,6 +492,19 @@ object Textures { override protected def loader(map: TextureMap, loc: ResourceLocation) = map.registerSprite(loc) } + def bind(location: ResourceLocation): Unit = { + val manager = Minecraft.getMinecraft.renderEngine + manager.bindTexture(location) + // IMPORTANT: manager.bindTexture uses GlStateManager.bindTexture, and + // that has borked caching, so binding textures will sometimes fail, + // because it'll think the texture is already bound although it isn't. + // So we do it manually. + val texture = manager.getTexture(location) + if (texture != null) { + GL11.glBindTexture (GL11.GL_TEXTURE_2D, texture.getGlTextureId) + } + } + @SubscribeEvent def onTextureStitchPre(e: TextureStitchEvent.Pre): Unit = { Font.init(e.map) diff --git a/src/main/scala/li/cil/oc/client/gui/Assembler.scala b/src/main/scala/li/cil/oc/client/gui/Assembler.scala index 98c775eb6..24de3c4eb 100644 --- a/src/main/scala/li/cil/oc/client/gui/Assembler.scala +++ b/src/main/scala/li/cil/oc/client/gui/Assembler.scala @@ -11,10 +11,10 @@ import li.cil.oc.common.container.ComponentSlot import li.cil.oc.common.template.AssemblerTemplates import li.cil.oc.common.tileentity import net.minecraft.client.gui.GuiButton +import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.player.InventoryPlayer import net.minecraft.inventory.Slot import net.minecraft.util.IChatComponent -import org.lwjgl.opengl.GL11 import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsScala._ @@ -61,7 +61,7 @@ class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Asse } override def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) = { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Me lazy... prevents NEI render glitch. + GlStateManager.pushAttrib() if (!assemblerContainer.isAssembling) { val message = if (!assemblerContainer.getSlot(0).getHasStack) { @@ -90,7 +90,7 @@ class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Asse tooltip.add(Localization.Assembler.Progress(assemblerContainer.assemblyProgress, timeRemaining)) copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj) } - GL11.glPopAttrib() + GlStateManager.popAttrib() } private def formatTime(seconds: Int) = { @@ -100,8 +100,8 @@ class Assembler(playerInventory: InventoryPlayer, val assembler: tileentity.Asse } override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { - GL11.glColor3f(1, 1, 1) // Required under Linux. - mc.renderEngine.bindTexture(Textures.GUI.RobotAssembler) + GlStateManager.color(1, 1, 1) // Required under Linux. + Textures.bind(Textures.GUI.RobotAssembler) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) if (assemblerContainer.isAssembling) progress.level = assemblerContainer.assemblyProgress / 100.0 else progress.level = 0 diff --git a/src/main/scala/li/cil/oc/client/gui/Case.scala b/src/main/scala/li/cil/oc/client/gui/Case.scala index 2c767b804..dded12bab 100644 --- a/src/main/scala/li/cil/oc/client/gui/Case.scala +++ b/src/main/scala/li/cil/oc/client/gui/Case.scala @@ -8,6 +8,7 @@ import li.cil.oc.client.{PacketSender => ClientPacketSender} import li.cil.oc.common.container import li.cil.oc.common.tileentity import net.minecraft.client.gui.GuiButton +import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.player.InventoryPlayer import org.lwjgl.opengl.GL11 @@ -46,8 +47,8 @@ class Case(playerInventory: InventoryPlayer, val computer: tileentity.Case) exte } override def drawSecondaryBackgroundLayer() { - GL11.glColor3f(1, 1, 1) // Required under Linux. - mc.renderEngine.bindTexture(Textures.GUI.Computer) + GlStateManager.color(1, 1, 1) + Textures.bind(Textures.GUI.Computer) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) } diff --git a/src/main/scala/li/cil/oc/client/gui/CustomGuiContainer.scala b/src/main/scala/li/cil/oc/client/gui/CustomGuiContainer.scala index 8e41f365f..ac6bf7a7b 100644 --- a/src/main/scala/li/cil/oc/client/gui/CustomGuiContainer.scala +++ b/src/main/scala/li/cil/oc/client/gui/CustomGuiContainer.scala @@ -3,13 +3,12 @@ package li.cil.oc.client.gui import java.util import li.cil.oc.client.gui.widget.WidgetContainer +import li.cil.oc.util.RenderState import net.minecraft.client.gui.FontRenderer import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.RenderHelper import net.minecraft.inventory.Container -import org.lwjgl.opengl.GL11 -import org.lwjgl.opengl.GL12 import scala.collection.convert.WrapAsScala._ @@ -25,17 +24,16 @@ abstract class CustomGuiContainer(container: Container) extends GuiContainer(con override def windowZ = zLevel // Pretty much Scalaified copy-pasta from base-class. - override def drawHoveringText(text: util.List[_], x: Int, y: Int, font: FontRenderer) { + override def drawHoveringText(text: util.List[_], x: Int, y: Int, font: FontRenderer): Unit = { copiedDrawHoveringText(text, x, y, font) } - protected def copiedDrawHoveringText(text: util.List[_], x: Int, y: Int, font: FontRenderer) { + protected def copiedDrawHoveringText(text: util.List[_], x: Int, y: Int, font: FontRenderer): Unit = { if (!text.isEmpty) { - GlStateManager.pushAttrib() - GL11.glDisable(GL12.GL_RESCALE_NORMAL) + GlStateManager.disableRescaleNormal() RenderHelper.disableStandardItemLighting() - GL11.glDisable(GL11.GL_LIGHTING) - GL11.glDisable(GL11.GL_DEPTH_TEST) + GlStateManager.disableLighting() + GlStateManager.disableDepth() val textWidth = text.map(line => font.getStringWidth(line.asInstanceOf[String])).max @@ -75,7 +73,15 @@ abstract class CustomGuiContainer(container: Container) extends GuiContainer(con } zLevel = 0f - GlStateManager.popAttrib() + GlStateManager.enableLighting() + GlStateManager.enableDepth() + RenderHelper.enableStandardItemLighting() + GlStateManager.enableRescaleNormal() } } + + override def drawGradientRect(left: Int, top: Int, right: Int, bottom: Int, startColor: Int, endColor: Int): Unit = { + super.drawGradientRect(left, top, right, bottom, startColor, endColor) + RenderState.makeItBlend() + } } diff --git a/src/main/scala/li/cil/oc/client/gui/Database.scala b/src/main/scala/li/cil/oc/client/gui/Database.scala index 31cf5bd1d..a5ee962f9 100644 --- a/src/main/scala/li/cil/oc/client/gui/Database.scala +++ b/src/main/scala/li/cil/oc/client/gui/Database.scala @@ -4,9 +4,9 @@ import li.cil.oc.client.Textures import li.cil.oc.common.Tier import li.cil.oc.common.container import li.cil.oc.common.inventory.DatabaseInventory +import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.player.InventoryPlayer import net.minecraft.inventory.Slot -import org.lwjgl.opengl.GL11 class Database(playerInventory: InventoryPlayer, val databaseInventory: DatabaseInventory) extends DynamicGuiContainer(new container.Database(playerInventory, databaseInventory)) { ySize = 256 @@ -14,17 +14,17 @@ class Database(playerInventory: InventoryPlayer, val databaseInventory: Database override def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) {} override protected def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { - GL11.glColor4f(1, 1, 1, 1) - mc.renderEngine.bindTexture(Textures.GUI.Database) + GlStateManager.color(1, 1, 1, 1) + Textures.bind(Textures.GUI.Database) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) if (databaseInventory.tier > Tier.One) { - mc.renderEngine.bindTexture(Textures.GUI.Database1) + Textures.bind(Textures.GUI.Database1) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) } if (databaseInventory.tier > Tier.Two) { - mc.renderEngine.bindTexture(Textures.GUI.Database2) + Textures.bind(Textures.GUI.Database2) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) } } diff --git a/src/main/scala/li/cil/oc/client/gui/Disassembler.scala b/src/main/scala/li/cil/oc/client/gui/Disassembler.scala index d01cb6b4f..f5047b2a9 100644 --- a/src/main/scala/li/cil/oc/client/gui/Disassembler.scala +++ b/src/main/scala/li/cil/oc/client/gui/Disassembler.scala @@ -5,8 +5,8 @@ import li.cil.oc.client.Textures import li.cil.oc.client.gui.widget.ProgressBar import li.cil.oc.common.container import li.cil.oc.common.tileentity +import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.player.InventoryPlayer -import org.lwjgl.opengl.GL11 class Disassembler(playerInventory: InventoryPlayer, val disassembler: tileentity.Disassembler) extends DynamicGuiContainer(new container.Disassembler(playerInventory, disassembler)) { private def disassemblerContainer = inventorySlots.asInstanceOf[container.Disassembler] @@ -20,8 +20,8 @@ class Disassembler(playerInventory: InventoryPlayer, val disassembler: tileentit } override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { - GL11.glColor3f(1, 1, 1) // Required under Linux. - mc.renderEngine.bindTexture(Textures.GUI.Disassembler) + GlStateManager.color(1, 1, 1) + Textures.bind(Textures.GUI.Disassembler) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) progress.level = disassemblerContainer.disassemblyProgress / 100.0 drawWidgets() diff --git a/src/main/scala/li/cil/oc/client/gui/Drone.scala b/src/main/scala/li/cil/oc/client/gui/Drone.scala index f8420d440..47106f83f 100644 --- a/src/main/scala/li/cil/oc/client/gui/Drone.scala +++ b/src/main/scala/li/cil/oc/client/gui/Drone.scala @@ -13,8 +13,8 @@ import li.cil.oc.common.entity import li.cil.oc.util.PackedColor import li.cil.oc.util.RenderState import li.cil.oc.util.TextBuffer -import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiButton +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.entity.player.InventoryPlayer import org.lwjgl.opengl.GL11 @@ -79,16 +79,16 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D GL11.glScaled(scale, scale, 1) GL11.glPushAttrib(GL11.GL_DEPTH_BUFFER_BIT) GL11.glDepthMask(false) - GL11.glColor3f(0.5f, 0.5f, 1f) + GlStateManager.color(0.5f, 0.5f, 1f) TextBufferRenderCache.render(bufferRenderer) - GL11.glPopAttrib() + GlStateManager.popAttrib() } override protected def changeSize(w: Double, h: Double, recompile: Boolean) = 2.0 override protected def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) { drawBufferLayer() - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Me lazy... prevents NEI render glitch. + GlStateManager.pushAttrib() if (isPointInRegion(power.x, power.y, power.width, power.height, mouseX, mouseY)) { val tooltip = new java.util.ArrayList[String] val format = Localization.Computer.Power + ": %d%% (%d/%d)" @@ -103,12 +103,12 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D tooltip.add(if (drone.isRunning) Localization.Computer.TurnOff else Localization.Computer.TurnOn) copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj) } - GL11.glPopAttrib() + GlStateManager.popAttrib() } override protected def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { - GL11.glColor3f(1, 1, 1) // Required under Linux. - mc.renderEngine.bindTexture(Textures.GUI.Drone) + GlStateManager.color(1, 1, 1) + Textures.bind(Textures.GUI.Drone) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) power.level = drone.globalBuffer.toDouble / math.max(drone.globalBufferSize.toDouble, 1.0) drawWidgets() @@ -119,11 +119,6 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D drawInventorySlots() } - protected override def drawGradientRect(par1: Int, par2: Int, par3: Int, par4: Int, par5: Int, par6: Int) { - super.drawGradientRect(par1, par2, par3, par4, par5, par6) - RenderState.makeItBlend() - } - // No custom slots, we just extend DynamicGuiContainer for the highlighting. override protected def drawSlotBackground(x: Int, y: Int) {} @@ -131,7 +126,7 @@ class Drone(playerInventory: InventoryPlayer, val drone: entity.Drone) extends D val slot = drone.selectedSlot if (slot >= 0 && slot < 16) { RenderState.makeItBlend() - Minecraft.getMinecraft.renderEngine.bindTexture(Textures.GUI.RobotSelection) + Textures.bind(Textures.GUI.RobotSelection) val now = System.currentTimeMillis() / 1000.0 val offsetV = ((now - now.toInt) * selectionsStates).toInt * selectionStepV val x = guiLeft + inventoryX - 1 + (slot % 4) * (selectionSize - 2) diff --git a/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala b/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala index e8f956bb8..10e68cffc 100644 --- a/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala +++ b/src/main/scala/li/cil/oc/client/gui/DynamicGuiContainer.scala @@ -11,6 +11,7 @@ import li.cil.oc.integration.Mods import li.cil.oc.integration.util.NEI import li.cil.oc.util.RenderState import net.minecraft.client.gui.Gui +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.inventory.Container import net.minecraft.inventory.Slot @@ -32,7 +33,7 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai } override protected def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() drawSecondaryForegroundLayer(mouseX, mouseY) @@ -40,14 +41,14 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai drawSlotHighlight(inventorySlots.inventorySlots.get(slot).asInstanceOf[Slot]) } - GL11.glPopAttrib() + GlStateManager.popAttrib() } protected def drawSecondaryBackgroundLayer() {} override protected def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { - GL11.glColor4f(1, 1, 1, 1) - mc.renderEngine.bindTexture(Textures.GUI.Background) + GlStateManager.color(1, 1, 1, 1) + Textures.bind(Textures.GUI.Background) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) drawSecondaryBackgroundLayer() @@ -58,14 +59,15 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai } protected def drawInventorySlots(): Unit = { - GL11.glPushMatrix() + GlStateManager.pushMatrix() GL11.glTranslatef(guiLeft, guiTop, 0) GL11.glDisable(GL11.GL_DEPTH_TEST) for (slot <- 0 until inventorySlots.inventorySlots.size()) { drawSlotInventory(inventorySlots.inventorySlots.get(slot).asInstanceOf[Slot]) } GL11.glEnable(GL11.GL_DEPTH_TEST) - GL11.glPopMatrix() + GlStateManager.popMatrix() + RenderState.makeItBlend() RenderState.makeItBlend() } @@ -78,9 +80,9 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai super.drawScreen(mouseX, mouseY, dt) if (Mods.NotEnoughItems.isAvailable) { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() drawNEIHighlights() - GL11.glPopAttrib() + GlStateManager.popAttrib() } } @@ -99,11 +101,11 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai slot match { case component: ComponentSlot => if (component.tierIcon != null) { - mc.getTextureManager.bindTexture(component.tierIcon) + Textures.bind(component.tierIcon) Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16) } if (component.hasBackground) { - mc.getTextureManager.bindTexture(slot.getBackgroundLocation) + Textures.bind(slot.getBackgroundLocation) Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16) } case _ => @@ -146,14 +148,14 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai } protected def drawDisabledSlot(slot: ComponentSlot) { - GL11.glColor4f(1, 1, 1, 1) - mc.getTextureManager.bindTexture(slot.tierIcon) + GlStateManager.color(1, 1, 1, 1) + Textures.bind(slot.tierIcon) Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16) } protected def drawSlotBackground(x: Int, y: Int) { - GL11.glColor4f(1, 1, 1, 1) - mc.getTextureManager.bindTexture(Textures.GUI.Slot) + GlStateManager.color(1, 1, 1, 1) + Textures.bind(Textures.GUI.Slot) val t = Tessellator.getInstance val r = t.getWorldRenderer r.startDrawingQuads() diff --git a/src/main/scala/li/cil/oc/client/gui/ImageButton.scala b/src/main/scala/li/cil/oc/client/gui/ImageButton.scala index 2a867fe61..aa2651273 100644 --- a/src/main/scala/li/cil/oc/client/gui/ImageButton.scala +++ b/src/main/scala/li/cil/oc/client/gui/ImageButton.scala @@ -1,12 +1,13 @@ package li.cil.oc.client.gui +import li.cil.oc.client.Textures import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiButton +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.util.ResourceLocation import net.minecraftforge.fml.relauncher.Side import net.minecraftforge.fml.relauncher.SideOnly -import org.lwjgl.opengl.GL11 @SideOnly(Side.CLIENT) class ImageButton(id: Int, x: Int, y: Int, w: Int, h: Int, @@ -23,8 +24,8 @@ class ImageButton(id: Int, x: Int, y: Int, w: Int, h: Int, override def drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) { if (visible) { - mc.renderEngine.bindTexture(image) - GL11.glColor4f(1, 1, 1, 1) + Textures.bind(image) + GlStateManager.color(1, 1, 1, 1) hovered = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height val x0 = xPosition @@ -38,7 +39,7 @@ class ImageButton(id: Int, x: Int, y: Int, w: Int, h: Int, val v1 = v0 + 0.5 val t = Tessellator.getInstance - var r = t.getWorldRenderer + val r = t.getWorldRenderer r.startDrawingQuads() r.addVertexWithUV(x0, y1, zLevel, u0, v1) r.addVertexWithUV(x1, y1, zLevel, u1, v1) diff --git a/src/main/scala/li/cil/oc/client/gui/Raid.scala b/src/main/scala/li/cil/oc/client/gui/Raid.scala index 584d84cdd..24a56d622 100644 --- a/src/main/scala/li/cil/oc/client/gui/Raid.scala +++ b/src/main/scala/li/cil/oc/client/gui/Raid.scala @@ -4,8 +4,8 @@ import li.cil.oc.Localization import li.cil.oc.client.Textures import li.cil.oc.common.container import li.cil.oc.common.tileentity +import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.player.InventoryPlayer -import org.lwjgl.opengl.GL11 class Raid(playerInventory: InventoryPlayer, val raid: tileentity.Raid) extends DynamicGuiContainer(new container.Raid(playerInventory, raid)) { override def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) = { @@ -20,8 +20,8 @@ class Raid(playerInventory: InventoryPlayer, val raid: tileentity.Raid) extends } override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { - GL11.glColor3f(1, 1, 1) // Required under Linux. - mc.renderEngine.bindTexture(Textures.GUI.Raid) + GlStateManager.color(1, 1, 1) // Required under Linux. + Textures.bind(Textures.GUI.Raid) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) } } diff --git a/src/main/scala/li/cil/oc/client/gui/Robot.scala b/src/main/scala/li/cil/oc/client/gui/Robot.scala index 68560439a..8ea741fd3 100644 --- a/src/main/scala/li/cil/oc/client/gui/Robot.scala +++ b/src/main/scala/li/cil/oc/client/gui/Robot.scala @@ -14,8 +14,8 @@ import li.cil.oc.common.container import li.cil.oc.common.tileentity import li.cil.oc.integration.opencomputers import li.cil.oc.util.RenderState -import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiButton +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.entity.player.InventoryPlayer import org.lwjgl.input.Keyboard @@ -106,11 +106,11 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten if (buffer != null) { GL11.glTranslatef(bufferX, bufferY, 0) RenderState.disableLighting() - GL11.glPushMatrix() + GlStateManager.pushMatrix() GL11.glTranslatef(-3, -3, 0) - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.color(1, 1, 1, 1) BufferRenderer.drawBackground() - GL11.glPopMatrix() + GlStateManager.popMatrix() RenderState.makeItBlend() val scaleX = bufferRenderWidth / buffer.renderWidth val scaleY = bufferRenderHeight / buffer.renderHeight @@ -129,7 +129,7 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten override protected def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) { drawBufferLayer() - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Me lazy... prevents NEI render glitch. + GlStateManager.pushAttrib() if (isPointInRegion(power.x, power.y, power.width, power.height, mouseX, mouseY)) { val tooltip = new java.util.ArrayList[String] val format = Localization.Computer.Power + ": %d%% (%d/%d)" @@ -144,13 +144,13 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten tooltip.add(if (robot.isRunning) Localization.Computer.TurnOff else Localization.Computer.TurnOn) copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj) } - GL11.glPopAttrib() + GlStateManager.popAttrib() } override protected def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) { - GL11.glColor3f(1, 1, 1) // Required under Linux. - if (buffer != null) mc.renderEngine.bindTexture(Textures.GUI.Robot) - else mc.renderEngine.bindTexture(Textures.GUI.RobotNoScreen) + GlStateManager.color(1, 1, 1) + if (buffer != null) Textures.bind(Textures.GUI.Robot) + else Textures.bind(Textures.GUI.RobotNoScreen) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) power.level = robot.globalBuffer / robot.globalBufferSize drawWidgets() @@ -161,11 +161,6 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten drawInventorySlots() } - protected override def drawGradientRect(par1: Int, par2: Int, par3: Int, par4: Int, par5: Int, par6: Int) { - super.drawGradientRect(par1, par2, par3, par4, par5, par6) - RenderState.makeItBlend() - } - // No custom slots, we just extend DynamicGuiContainer for the highlighting. override protected def drawSlotBackground(x: Int, y: Int) {} @@ -264,7 +259,7 @@ class Robot(playerInventory: InventoryPlayer, val robot: tileentity.Robot) exten val slot = robot.selectedSlot - inventoryOffset * 4 if (slot >= 0 && slot < 16) { RenderState.makeItBlend() - Minecraft.getMinecraft.renderEngine.bindTexture(Textures.GUI.RobotSelection) + Textures.bind(Textures.GUI.RobotSelection) val now = System.currentTimeMillis() / 1000.0 val offsetV = ((now - now.toInt) * selectionsStates).toInt * selectionStepV val x = guiLeft + inventoryX - 1 + (slot % 4) * (selectionSize - 2) diff --git a/src/main/scala/li/cil/oc/client/gui/Server.scala b/src/main/scala/li/cil/oc/client/gui/Server.scala index a8f4fee93..b922d0f4b 100644 --- a/src/main/scala/li/cil/oc/client/gui/Server.scala +++ b/src/main/scala/li/cil/oc/client/gui/Server.scala @@ -4,9 +4,9 @@ import li.cil.oc.Localization import li.cil.oc.client.Textures import li.cil.oc.common.container import li.cil.oc.common.inventory.ServerInventory +import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.player.InventoryPlayer import net.minecraft.inventory.Slot -import org.lwjgl.opengl.GL11 class Server(playerInventory: InventoryPlayer, serverInventory: ServerInventory) extends DynamicGuiContainer(new container.Server(playerInventory, serverInventory)) { override def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) { @@ -17,8 +17,8 @@ class Server(playerInventory: InventoryPlayer, serverInventory: ServerInventory) } override def drawSecondaryBackgroundLayer() { - GL11.glColor3f(1, 1, 1) // Required under Linux. - mc.renderEngine.bindTexture(Textures.GUI.Server) + GlStateManager.color(1, 1, 1) + Textures.bind(Textures.GUI.Server) drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize) } diff --git a/src/main/scala/li/cil/oc/client/gui/ServerRack.scala b/src/main/scala/li/cil/oc/client/gui/ServerRack.scala index 190e9cccd..6fb1dac26 100644 --- a/src/main/scala/li/cil/oc/client/gui/ServerRack.scala +++ b/src/main/scala/li/cil/oc/client/gui/ServerRack.scala @@ -10,10 +10,10 @@ import li.cil.oc.common.container import li.cil.oc.common.tileentity import net.minecraft.client.gui.GuiButton import net.minecraft.client.gui.GuiScreen +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.entity.player.InventoryPlayer import net.minecraft.util.EnumFacing -import org.lwjgl.opengl.GL11 class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRack) extends DynamicGuiContainer(new container.ServerRack(playerInventory, rack)) { protected var switchButton: ImageButton = _ @@ -96,7 +96,7 @@ class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRa override def drawSecondaryForegroundLayer(mouseX: Int, mouseY: Int) = { super.drawSecondaryForegroundLayer(mouseX, mouseY) - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) // Prevents NEI render glitch. + GlStateManager.pushAttrib() fontRendererObj.drawString( Localization.localizeImmediately(rack.getName), @@ -113,16 +113,16 @@ class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRa val h = 18 val t = Tessellator.getInstance val r = t.getWorldRenderer - mc.getTextureManager.bindTexture(Textures.GUI.Range) - GL11.glColor3f(1, 1, 1) - GL11.glDepthMask(false) + Textures.bind(Textures.GUI.Range) + GlStateManager.color(1, 1, 1) + GlStateManager.depthMask(false) r.startDrawingQuads() r.addVertexWithUV(tx, ty + h, zLevel, 0, 1) r.addVertexWithUV(tx + w, ty + h, zLevel, 1, 1) r.addVertexWithUV(tx + w, ty, zLevel, 1, 0) r.addVertexWithUV(tx, ty, zLevel, 0, 0) t.draw() - GL11.glDepthMask(true) + GlStateManager.depthMask(true) } drawCenteredString(fontRendererObj, @@ -135,6 +135,6 @@ class ServerRack(playerInventory: InventoryPlayer, val rack: tileentity.ServerRa copiedDrawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop, fontRendererObj) } - GL11.glPopAttrib() + GlStateManager.popAttrib() } } diff --git a/src/main/scala/li/cil/oc/client/gui/traits/DisplayBuffer.scala b/src/main/scala/li/cil/oc/client/gui/traits/DisplayBuffer.scala index f8a0ea1a6..31805b4a7 100644 --- a/src/main/scala/li/cil/oc/client/gui/traits/DisplayBuffer.scala +++ b/src/main/scala/li/cil/oc/client/gui/traits/DisplayBuffer.scala @@ -4,7 +4,7 @@ import li.cil.oc.client.renderer.gui.BufferRenderer import li.cil.oc.util.RenderState import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen -import org.lwjgl.opengl.GL11 +import net.minecraft.client.renderer.GlStateManager trait DisplayBuffer extends GuiScreen { protected def bufferX: Int @@ -36,15 +36,15 @@ trait DisplayBuffer extends GuiScreen { RenderState.checkError(getClass.getName + ".drawBufferLayer: entering (aka: wasntme)") - GL11.glPushMatrix() + GlStateManager.pushMatrix() RenderState.disableLighting() drawBuffer() - GL11.glPopMatrix() + GlStateManager.popMatrix() RenderState.checkError(getClass.getName + ".drawBufferLayer: buffer layer") } - protected def drawBuffer() + protected def drawBuffer(): Unit protected def changeSize(w: Double, h: Double, recompile: Boolean): Double } diff --git a/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala b/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala index 83ff2884c..f86a37cd7 100644 --- a/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala +++ b/src/main/scala/li/cil/oc/client/gui/traits/InputBuffer.scala @@ -5,7 +5,6 @@ import li.cil.oc.client.KeyBindings import li.cil.oc.client.Textures import li.cil.oc.integration.util.NEI import li.cil.oc.util.RenderState -import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen import net.minecraft.client.renderer.Tessellator import org.lwjgl.input.Keyboard @@ -37,7 +36,7 @@ trait InputBuffer extends DisplayBuffer { super.drawBufferLayer() if (System.currentTimeMillis() - showKeyboardMissing < 1000) { - Minecraft.getMinecraft.getTextureManager.bindTexture(Textures.GUI.KeyboardMissing) + Textures.bind(Textures.GUI.KeyboardMissing) GL11.glDisable(GL11.GL_DEPTH_TEST) val x = bufferX + buffer.renderWidth - 16 diff --git a/src/main/scala/li/cil/oc/client/gui/widget/ProgressBar.scala b/src/main/scala/li/cil/oc/client/gui/widget/ProgressBar.scala index ade4f23c2..a8980fdcc 100644 --- a/src/main/scala/li/cil/oc/client/gui/widget/ProgressBar.scala +++ b/src/main/scala/li/cil/oc/client/gui/widget/ProgressBar.scala @@ -1,7 +1,6 @@ package li.cil.oc.client.gui.widget import li.cil.oc.client.Textures -import net.minecraft.client.Minecraft import net.minecraft.client.renderer.Tessellator class ProgressBar(val x: Int, val y: Int) extends Widget { @@ -21,7 +20,7 @@ class ProgressBar(val x: Int, val y: Int) extends Widget { val ty = owner.windowY + y val w = width * level - Minecraft.getMinecraft.renderEngine.bindTexture(Textures.GUI.Bar) + Textures.bind(Textures.GUI.Bar) val t = Tessellator.getInstance val r = t.getWorldRenderer r.startDrawingQuads() diff --git a/src/main/scala/li/cil/oc/client/renderer/HighlightRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/HighlightRenderer.scala index 9b5432bc2..6c3b5b736 100644 --- a/src/main/scala/li/cil/oc/client/renderer/HighlightRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/HighlightRenderer.scala @@ -7,7 +7,7 @@ import li.cil.oc.util.BlockPosition import li.cil.oc.util.ExtendedBlock._ import li.cil.oc.util.ExtendedWorld._ import li.cil.oc.util.RenderState -import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.OpenGlHelper import net.minecraft.client.renderer.Tessellator import net.minecraft.util.EnumFacing @@ -38,13 +38,13 @@ object HighlightRenderer { val playerPos = e.player.getPositionEyes(e.partialTicks) val renderPos = blockPos.offset(-playerPos.xCoord, -playerPos.yCoord, -playerPos.zCoord) - GL11.glPushMatrix() - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushMatrix() + GlStateManager.pushAttrib() RenderState.makeItBlend() - Minecraft.getMinecraft.renderEngine.bindTexture(Textures.Model.HologramEffect) + Textures.bind(Textures.Model.HologramEffect) - OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, 1, 0) - GL11.glColor4f(0.0F, 1.0F, 0.0F, 0.4F) + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) + GlStateManager.color(0.0F, 1.0F, 0.0F, 0.4F) GL11.glTranslated(renderPos.xCoord, renderPos.yCoord, renderPos.zCoord) GL11.glScaled(1.002, 1.002, 1.002) @@ -92,8 +92,8 @@ object HighlightRenderer { } t.draw() - GL11.glPopAttrib() - GL11.glPopMatrix() + GlStateManager.popAttrib() + GlStateManager.popMatrix() } } } diff --git a/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala index f6755c754..27cb9f4a3 100644 --- a/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala @@ -8,6 +8,7 @@ import li.cil.oc.api.event.RobotRenderEvent import li.cil.oc.client.renderer.tileentity.RobotRenderer import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiContainer +import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.Entity import net.minecraftforge.client.event.RenderPlayerEvent import net.minecraftforge.fml.common.eventhandler.EventPriority @@ -50,8 +51,8 @@ object PetRenderer { override def call() = new PetLocation(e.entityPlayer) }) - GL11.glPushMatrix() - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushMatrix() + GlStateManager.pushAttrib() if (e.entityPlayer != Minecraft.getMinecraft.thePlayer) { val localPos = Minecraft.getMinecraft.thePlayer.getPositionEyes(e.partialRenderTick) val playerPos = e.entityPlayer.getPositionEyes(e.partialRenderTick) @@ -65,7 +66,7 @@ object PetRenderer { GL11.glEnable(GL11.GL_LIGHTING) GL11.glDisable(GL11.GL_BLEND) GL11.glEnable(GL12.GL_RESCALE_NORMAL) - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.color(1, 1, 1, 1) location.applyInterpolatedTransformations(e.partialRenderTick) @@ -74,8 +75,8 @@ object PetRenderer { RobotRenderer.renderChassis(null, offset, isRunningOverride = true) - GL11.glPopAttrib() - GL11.glPopMatrix() + GlStateManager.popAttrib() + GlStateManager.popMatrix() rendering = None } @@ -83,7 +84,7 @@ object PetRenderer { @SubscribeEvent(priority = EventPriority.LOWEST) def onRobotRender(e: RobotRenderEvent) { rendering match { - case Some((r, g, b)) => GL11.glColor3d(r, g, b) + case Some((r, g, b)) => GlStateManager.color(r.toFloat, g.toFloat, b.toFloat) case _ => } } diff --git a/src/main/scala/li/cil/oc/client/renderer/WirelessNetworkDebugRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/WirelessNetworkDebugRenderer.scala index 936954629..47d51a578 100644 --- a/src/main/scala/li/cil/oc/client/renderer/WirelessNetworkDebugRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/WirelessNetworkDebugRenderer.scala @@ -4,6 +4,7 @@ import li.cil.oc.Settings import li.cil.oc.server.network.WirelessNetwork import li.cil.oc.util.RenderState import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager import net.minecraft.world.World import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.ObfuscationReflectionHelper @@ -27,7 +28,7 @@ object WirelessNetworkDebugRenderer { val py = player.lastTickPosY + (player.posY - player.lastTickPosY) * e.partialTicks val pz = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * e.partialTicks - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() GL11.glPushMatrix() GL11.glTranslated(-px, -py, -pz) RenderState.makeItBlend() @@ -90,8 +91,8 @@ object WirelessNetworkDebugRenderer { } GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL) + GlStateManager.popAttrib() GL11.glPopMatrix() - GL11.glPopAttrib() case _ => } diff --git a/src/main/scala/li/cil/oc/client/renderer/entity/DroneRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/entity/DroneRenderer.scala index d993d97b2..fbc997ddf 100644 --- a/src/main/scala/li/cil/oc/client/renderer/entity/DroneRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/entity/DroneRenderer.scala @@ -2,6 +2,7 @@ package li.cil.oc.client.renderer.entity import li.cil.oc.client.Textures import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.entity.Render import net.minecraft.entity.Entity import org.lwjgl.opengl.GL11 @@ -11,15 +12,15 @@ object DroneRenderer extends Render(Minecraft.getMinecraft.getRenderManager) { override def doRender(entity: Entity, x: Double, y: Double, z: Double, yaw: Float, dt: Float) { bindEntityTexture(entity) - GL11.glPushMatrix() - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushMatrix() + GlStateManager.pushAttrib() GL11.glTranslated(x, y + 2 / 16f, z) model.render(entity, 0, 0, 0, 0, 0, dt) - GL11.glPopAttrib() - GL11.glPopMatrix() + GlStateManager.popAttrib() + GlStateManager.popMatrix() } override def getEntityTexture(entity: Entity) = Textures.Model.Drone diff --git a/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala b/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala index 49c5d3d88..5aa367c20 100644 --- a/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala +++ b/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala @@ -4,6 +4,7 @@ import li.cil.oc.common.entity.Drone import li.cil.oc.util.RenderState import net.minecraft.client.model.ModelBase import net.minecraft.client.model.ModelRenderer +import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.Entity import net.minecraft.util.Vec3 import org.lwjgl.opengl.GL11 @@ -106,7 +107,7 @@ final class ModelQuadcopter extends ModelBase { light3.rotateAngleZ = drone.flapAngles(3)(1) // Additive blending for the lights. - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) // Light color. val lightColor = drone.lightColor val r = ((lightColor >>> 16) & 0xFF).toByte @@ -141,7 +142,7 @@ final class ModelQuadcopter extends ModelBase { wing3.render(scale) RenderState.disableLighting() - GL11.glDepthFunc(GL11.GL_LEQUAL) + GlStateManager.depthFunc(GL11.GL_LEQUAL) light0.rotateAngleX = tilt light0.rotateAngleZ = tilt @@ -152,7 +153,7 @@ final class ModelQuadcopter extends ModelBase { light3.rotateAngleX = tilt light3.rotateAngleZ = -tilt - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) GL11.glColor3ub(0x66.toByte, 0xDD.toByte, 0x55.toByte) light0.render(scale) diff --git a/src/main/scala/li/cil/oc/client/renderer/font/DynamicFontRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/font/DynamicFontRenderer.scala index 7f9d65583..4516890fa 100644 --- a/src/main/scala/li/cil/oc/client/renderer/font/DynamicFontRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/font/DynamicFontRenderer.scala @@ -5,6 +5,7 @@ import li.cil.oc.client.renderer.font.DynamicFontRenderer.CharTexture import li.cil.oc.util.FontUtil import li.cil.oc.util.RenderState import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.resources.IReloadableResourceManager import net.minecraft.client.resources.IResourceManager import net.minecraft.client.resources.IResourceManagerReloadListener @@ -93,8 +94,8 @@ object DynamicFontRenderer { private val size = 256 class CharTexture(val owner: DynamicFontRenderer) { - private val id = GL11.glGenTextures() - GL11.glBindTexture(GL11.GL_TEXTURE_2D, id) + private val id = GlStateManager.generateTexture() + GlStateManager.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_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)) @@ -114,11 +115,11 @@ object DynamicFontRenderer { private var chars = 0 def delete() { - GL11.glDeleteTextures(id) + GlStateManager.deleteTexture(id) } def bind() { - GL11.glBindTexture(GL11.GL_TEXTURE_2D, id) + GlStateManager.bindTexture(id) } def isFull(char: Char) = chars + FontUtil.wcwidth(char) > capacity @@ -134,7 +135,7 @@ object DynamicFontRenderer { val x = chars % cols val y = chars / cols - GL11.glBindTexture(GL11.GL_TEXTURE_2D, id) + GlStateManager.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)) chars += glyphWidth diff --git a/src/main/scala/li/cil/oc/client/renderer/font/StaticFontRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/font/StaticFontRenderer.scala index f6449ba93..ff3a55f63 100644 --- a/src/main/scala/li/cil/oc/client/renderer/font/StaticFontRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/font/StaticFontRenderer.scala @@ -43,10 +43,10 @@ class StaticFontRenderer extends TextureFontRenderer { override protected def bindTexture(index: Int) { if (Settings.get.textAntiAlias) { - Minecraft.getMinecraft.getTextureManager.bindTexture(Textures.Font.AntiAliased) + Textures.bind(Textures.Font.AntiAliased) } else { - Minecraft.getMinecraft.getTextureManager.bindTexture(Textures.Font.Aliased) + Textures.bind(Textures.Font.Aliased) } } diff --git a/src/main/scala/li/cil/oc/client/renderer/font/TextureFontRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/font/TextureFontRenderer.scala index b1aef75f7..2d657ada8 100644 --- a/src/main/scala/li/cil/oc/client/renderer/font/TextureFontRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/font/TextureFontRenderer.scala @@ -4,6 +4,7 @@ import li.cil.oc.Settings import li.cil.oc.util.PackedColor import li.cil.oc.util.RenderState import li.cil.oc.util.TextBuffer +import net.minecraft.client.renderer.GlStateManager import org.lwjgl.opengl.GL11 /** @@ -34,11 +35,11 @@ abstract class TextureFontRenderer { val format = buffer.format GL11.glPushMatrix() - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() GL11.glScalef(0.5f, 0.5f, 1) - GL11.glDepthMask(false) + GlStateManager.depthMask(false) GL11.glDisable(GL11.GL_TEXTURE_2D) RenderState.checkError(getClass.getName + ".drawBuffer: configure state") @@ -106,7 +107,8 @@ abstract class TextureFontRenderer { RenderState.checkError(getClass.getName + ".drawBuffer: foreground") - GL11.glPopAttrib() + GlStateManager.depthMask(true) + GlStateManager.popAttrib() GL11.glPopMatrix() RenderState.checkError(getClass.getName + ".drawBuffer: leaving") diff --git a/src/main/scala/li/cil/oc/client/renderer/gui/BufferRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/gui/BufferRenderer.scala index 0ef30077e..a4869ac4d 100644 --- a/src/main/scala/li/cil/oc/client/renderer/gui/BufferRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/gui/BufferRenderer.scala @@ -4,6 +4,7 @@ import li.cil.oc.api.component.TextBuffer import li.cil.oc.client.Textures import li.cil.oc.util.RenderState import net.minecraft.client.renderer.GLAllocation +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.texture.TextureManager import org.lwjgl.opengl.GL11 @@ -34,7 +35,7 @@ object BufferRenderer { GL11.glNewList(displayLists, GL11.GL_COMPILE) - textureManager.get.bindTexture(Textures.GUI.Borders) + Textures.bind(Textures.GUI.Borders) GL11.glBegin(GL11.GL_QUADS) @@ -88,10 +89,11 @@ object BufferRenderer { def drawText(screen: TextBuffer) = if (textureManager.isDefined) { - GL11.glPushAttrib(GL11.GL_DEPTH_BUFFER_BIT) - GL11.glDepthMask(false) + GlStateManager.pushAttrib() + GlStateManager.depthMask(false) val changed = screen.renderText() - GL11.glPopAttrib() + GlStateManager.depthMask(true) + GlStateManager.popAttrib() changed } else false diff --git a/src/main/scala/li/cil/oc/client/renderer/item/ItemRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/item/ItemRenderer.scala index 9b30f68de..d3eedc346 100644 --- a/src/main/scala/li/cil/oc/client/renderer/item/ItemRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/item/ItemRenderer.scala @@ -9,6 +9,7 @@ import li.cil.oc.integration.opencomputers.Item import li.cil.oc.util.RenderState import net.minecraft.client.Minecraft import net.minecraft.client.gui.ScaledResolution +import net.minecraft.client.renderer.GlStateManager import net.minecraft.item.ItemStack import net.minecraft.util.AxisAlignedBB import net.minecraft.util.EnumChatFormatting @@ -68,21 +69,21 @@ object ItemRenderer extends IItemRenderer { GL11.glTranslatef(0.5f, 0.5f, 0.5f) if (descriptor == api.Items.get("craftingUpgrade")) { - tm.bindTexture(Textures.Model.UpgradeCrafting) + Textures.bind(Textures.Model.UpgradeCrafting) drawSimpleBlock() RenderState.checkError(getClass.getName + ".renderItem: crafting upgrade") } else if (descriptor == api.Items.get("generatorUpgrade")) { - tm.bindTexture(Textures.Model.UpgradeGenerator) + Textures.bind(Textures.Model.UpgradeGenerator) drawSimpleBlock(if (Item.dataTag(stack).getInteger("remainingTicks") > 0) 0.5f else 0) RenderState.checkError(getClass.getName + ".renderItem: generator upgrade") } else if (descriptor == api.Items.get("inventoryUpgrade")) { - tm.bindTexture(Textures.Model.UpgradeInventory) + Textures.bind(Textures.Model.UpgradeInventory) drawSimpleBlock() RenderState.checkError(getClass.getName + ".renderItem: inventory upgrade") @@ -90,7 +91,7 @@ object ItemRenderer extends IItemRenderer { } else if (isFloppy(descriptor)) { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() itemRenderer.renderItemIntoGUI(stack, 0, 0) val res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight) val fontRenderer = Minecraft.getMinecraft.fontRendererObj @@ -111,15 +112,15 @@ object ItemRenderer extends IItemRenderer { } GL11.glPopMatrix() } - GL11.glPopAttrib() + GlStateManager.popAttrib() RenderState.checkError("ItemRenderer.renderItem: floppy") } else if (descriptor == drone) { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() GL11.glPushMatrix() - Minecraft.getMinecraft.renderEngine.bindTexture(Textures.Model.Drone) + Textures.bind(Textures.Model.Drone) RenderState.makeItBlend() GL11.glDisable(GL11.GL_CULL_FACE) @@ -139,7 +140,7 @@ object ItemRenderer extends IItemRenderer { DroneRenderer.model.render() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() RenderState.checkError("ItemRenderer.renderItem: drone") } diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/AssemblerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/AssemblerRenderer.scala index ee5593e73..dbc55d579 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/AssemblerRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/AssemblerRenderer.scala @@ -3,6 +3,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.common.tileentity.Assembler import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -15,7 +16,7 @@ object AssemblerRenderer extends TileEntitySpecialRenderer { val assembler = tileEntity.asInstanceOf[Assembler] - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() @@ -70,7 +71,7 @@ object AssemblerRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") } diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/CaseRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/CaseRenderer.scala index 1f5391833..deaa23e19 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/CaseRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/CaseRenderer.scala @@ -3,6 +3,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.common.tileentity.Case import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -14,7 +15,7 @@ object CaseRenderer extends TileEntitySpecialRenderer { RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)") val computer = tileEntity.asInstanceOf[Case] - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() @@ -64,7 +65,7 @@ object CaseRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") } diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/ChargerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/ChargerRenderer.scala index 3c4c7a0bf..1872ff287 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/ChargerRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/ChargerRenderer.scala @@ -3,6 +3,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.common.tileentity.Charger import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -15,12 +16,12 @@ object ChargerRenderer extends TileEntitySpecialRenderer { val charger = tileEntity.asInstanceOf[Charger] if (charger.chargeSpeed > 0) { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() RenderState.setBlendAlpha(1) - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.color(1, 1, 1, 1) GL11.glPushMatrix() @@ -75,7 +76,7 @@ object ChargerRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() } RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/DisassemblerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/DisassemblerRenderer.scala index 19f7ffaee..189ee9aa3 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/DisassemblerRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/DisassemblerRenderer.scala @@ -3,6 +3,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.common.tileentity import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -14,11 +15,11 @@ object DisassemblerRenderer extends TileEntitySpecialRenderer { val disassembler = tileEntity.asInstanceOf[tileentity.Disassembler] if (disassembler.isActive) { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.color(1, 1, 1, 1) GL11.glPushMatrix() @@ -67,7 +68,7 @@ object DisassemblerRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() } RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/DiskDriveRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/DiskDriveRenderer.scala index d821c0a18..638abff07 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/DiskDriveRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/DiskDriveRenderer.scala @@ -4,6 +4,7 @@ import li.cil.oc.client.Textures import li.cil.oc.common.tileentity.DiskDrive import li.cil.oc.util.RenderState import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.OpenGlHelper import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer @@ -17,8 +18,8 @@ object DiskDriveRenderer extends TileEntitySpecialRenderer { RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)") val drive = tileEntity.asInstanceOf[DiskDrive] - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.pushAttrib() + GlStateManager.color(1, 1, 1, 1) GL11.glPushMatrix() @@ -75,7 +76,7 @@ object DiskDriveRenderer extends TileEntitySpecialRenderer { } GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") } diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/GeolyzerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/GeolyzerRenderer.scala index 1a083d777..951b2cde1 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/GeolyzerRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/GeolyzerRenderer.scala @@ -2,6 +2,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -11,13 +12,12 @@ object GeolyzerRenderer extends TileEntitySpecialRenderer { override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) { RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)") - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) - GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() RenderState.setBlendAlpha(1) - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.color(1, 1, 1, 1) GL11.glPushMatrix() @@ -42,8 +42,7 @@ object GeolyzerRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() - GL11.glPopClientAttrib() + GlStateManager.popAttrib() RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") } diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRenderer.scala index 2d18ef8e2..a7b5c319b 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/HologramRenderer.scala @@ -11,6 +11,7 @@ import li.cil.oc.Settings import li.cil.oc.client.Textures import li.cil.oc.common.tileentity.Hologram import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity import net.minecraft.util.EnumFacing @@ -64,9 +65,9 @@ object HologramRenderer extends TileEntitySpecialRenderer with Callable[Int] wit if (!hologram.hasPower) return GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS) - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.makeItBlend() - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) GL11.glColor4f(1, 1, 1, 1) val playerDistSq = x * x + y * y + z * z @@ -74,7 +75,7 @@ object HologramRenderer extends TileEntitySpecialRenderer with Callable[Int] wit val fadeDistSq = hologram.getFadeStartDistanceSquared RenderState.setBlendAlpha(0.75f * (if (playerDistSq > fadeDistSq) math.max(0, 1 - ((playerDistSq - fadeDistSq) / (maxDistSq - fadeDistSq)).toFloat) else 1)) - GL11.glPushMatrix() + GlStateManager.pushMatrix() GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5) hologram.yaw match { @@ -128,15 +129,16 @@ object HologramRenderer extends TileEntitySpecialRenderer with Callable[Int] wit // angles (because some faces will shine through sometimes and sometimes // they won't), so a more... consistent look is desirable. val glBuffer = cache.get(hologram, this) - GL11.glColorMask(false, false, false, false) - GL11.glDepthMask(true) + GlStateManager.colorMask(false, false, false, false) + GlStateManager.depthMask(true) draw(glBuffer) - GL11.glColorMask(true, true, true, true) - GL11.glDepthFunc(GL11.GL_EQUAL) + GlStateManager.colorMask(true, true, true, true) + GlStateManager.depthFunc(GL11.GL_EQUAL) draw(glBuffer) - GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.depthFunc(GL11.GL_LEQUAL) + GlStateManager.popMatrix() + GlStateManager.popAttrib() GL11.glPopClientAttrib() RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/MicrocontrollerRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/MicrocontrollerRenderer.scala index 612df7e1e..9b23af4c3 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/MicrocontrollerRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/MicrocontrollerRenderer.scala @@ -3,6 +3,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.common.tileentity.Microcontroller import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -14,12 +15,12 @@ object MicrocontrollerRenderer extends TileEntitySpecialRenderer { RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)") val mcu = tileEntity.asInstanceOf[Microcontroller] - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() RenderState.setBlendAlpha(1) - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.color(1, 1, 1, 1) GL11.glPushMatrix() @@ -62,7 +63,7 @@ object MicrocontrollerRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") } diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/PowerDistributorRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/PowerDistributorRenderer.scala index c968f8d6f..f775f5feb 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/PowerDistributorRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/PowerDistributorRenderer.scala @@ -3,6 +3,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.common.tileentity import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -14,7 +15,7 @@ object PowerDistributorRenderer extends TileEntitySpecialRenderer { val distributor = tileEntity.asInstanceOf[tileentity.PowerDistributor] if (distributor.globalBuffer > 0) { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() @@ -70,7 +71,7 @@ object PowerDistributorRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() } RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/RaidRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/RaidRenderer.scala index c453fb770..a3e7385c8 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/RaidRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/RaidRenderer.scala @@ -3,6 +3,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.common.tileentity.Raid import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.WorldRenderer import net.minecraft.client.renderer.texture.TextureAtlasSprite @@ -16,11 +17,11 @@ object RaidRenderer extends TileEntitySpecialRenderer { RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)") val raid = tileEntity.asInstanceOf[Raid] - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.color(1, 1, 1, 1) GL11.glPushMatrix() @@ -65,7 +66,7 @@ object RaidRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") } diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/RobotRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/RobotRenderer.scala index c026f22af..c58da4c43 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/RobotRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/RobotRenderer.scala @@ -219,7 +219,7 @@ object RobotRenderer extends TileEntitySpecialRenderer { { // Additive blending for the light. - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) // Light color. val lightColor = if (robot != null && robot.info != null) robot.info.lightColor else 0xF23030 val r = ((lightColor >>> 16) & 0xFF).toByte @@ -290,7 +290,7 @@ object RobotRenderer extends TileEntitySpecialRenderer { GL11.glPushMatrix() - GL11.glDepthMask(true) + GlStateManager.depthMask(true) GL11.glEnable(GL11.GL_LIGHTING) GL11.glDisable(GL11.GL_BLEND) GL11.glColor4f(1, 1, 1, 1) @@ -424,7 +424,7 @@ object RobotRenderer extends TileEntitySpecialRenderer { GL11.glScalef(-scale, -scale, scale) RenderState.makeItBlend() - GL11.glDepthMask(false) + GlStateManager.depthMask(false) GL11.glDisable(GL11.GL_LIGHTING) GL11.glDisable(GL11.GL_TEXTURE_2D) @@ -439,7 +439,7 @@ object RobotRenderer extends TileEntitySpecialRenderer { GL11.glEnable(GL11.GL_TEXTURE_2D) // For the font. f.drawString(name, -halfWidth, 0, 0xFFFFFFFF) - GL11.glDepthMask(true) + GlStateManager.depthMask(true) GL11.glEnable(GL11.GL_LIGHTING) GL11.glDisable(GL11.GL_BLEND) diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala index 8f4286df4..529dbb03e 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/ScreenRenderer.scala @@ -7,6 +7,7 @@ import li.cil.oc.common.tileentity.Screen import li.cil.oc.integration.util.Wrench import li.cil.oc.util.RenderState import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -54,11 +55,11 @@ object ScreenRenderer extends TileEntitySpecialRenderer { RenderState.checkError(getClass.getName + ".renderTileEntityAt: checks") - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.color(1, 1, 1, 1) GL11.glPushMatrix() @@ -74,7 +75,7 @@ object ScreenRenderer extends TileEntitySpecialRenderer { val alpha = math.max(0, 1 - ((distance - fadeDistanceSq) * fadeRatio).toFloat) if (canUseBlendColor) { GL14.glBlendColor(0, 0, 0, alpha) - GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE) + GlStateManager.blendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE) } } @@ -87,7 +88,7 @@ object ScreenRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") } @@ -120,7 +121,7 @@ object ScreenRenderer extends TileEntitySpecialRenderer { if (Wrench.holdsApplicableWrench(Minecraft.getMinecraft.thePlayer, screen.getPos) || screens.contains(api.Items.get(stack))) { GL11.glPushMatrix() transform() - GL11.glDepthMask(false) + GlStateManager.depthMask(false) GL11.glTranslatef(screen.width / 2f - 0.5f, screen.height / 2f - 0.5f, 0.05f) val t = Tessellator.getInstance @@ -137,7 +138,7 @@ object ScreenRenderer extends TileEntitySpecialRenderer { t.draw() - GL11.glDepthMask(true) + GlStateManager.depthMask(true) GL11.glPopMatrix() } } diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/ServerRackRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/ServerRackRenderer.scala index bb65c899a..f0b63bf68 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/ServerRackRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/ServerRackRenderer.scala @@ -3,6 +3,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.common.tileentity.ServerRack import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -14,11 +15,11 @@ object ServerRackRenderer extends TileEntitySpecialRenderer { RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)") val rack = tileEntity.asInstanceOf[ServerRack] - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() - GL11.glColor4f(1, 1, 1, 1) + GlStateManager.color(1, 1, 1, 1) GL11.glPushMatrix() @@ -76,7 +77,7 @@ object ServerRackRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") } diff --git a/src/main/scala/li/cil/oc/client/renderer/tileentity/SwitchRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/tileentity/SwitchRenderer.scala index aeb4ef5ca..c9b7625da 100644 --- a/src/main/scala/li/cil/oc/client/renderer/tileentity/SwitchRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/tileentity/SwitchRenderer.scala @@ -3,6 +3,7 @@ package li.cil.oc.client.renderer.tileentity import li.cil.oc.client.Textures import li.cil.oc.common.tileentity import li.cil.oc.util.RenderState +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.tileentity.TileEntity @@ -15,7 +16,7 @@ object SwitchRenderer extends TileEntitySpecialRenderer { val switch = tileEntity.asInstanceOf[tileentity.Switch] val activity = math.max(0, 1 - (System.currentTimeMillis() - switch.lastMessage) / 1000.0) if (activity > 0) { - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS) + GlStateManager.pushAttrib() RenderState.disableLighting() RenderState.makeItBlend() @@ -60,7 +61,7 @@ object SwitchRenderer extends TileEntitySpecialRenderer { RenderState.enableLighting() GL11.glPopMatrix() - GL11.glPopAttrib() + GlStateManager.popAttrib() } RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving") diff --git a/src/main/scala/li/cil/oc/util/RenderState.scala b/src/main/scala/li/cil/oc/util/RenderState.scala index 0017ded22..c5ce7e4ba 100644 --- a/src/main/scala/li/cil/oc/util/RenderState.scala +++ b/src/main/scala/li/cil/oc/util/RenderState.scala @@ -3,6 +3,7 @@ package li.cil.oc.util import li.cil.oc.OpenComputers import li.cil.oc.Settings import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.RenderHelper import org.lwjgl.opengl._ import org.lwjgl.util.glu.GLU @@ -36,12 +37,12 @@ object RenderState { } def makeItBlend() { - GL11.glEnable(GL11.GL_BLEND) - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) + GlStateManager.enableBlend() + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) } def setBlendAlpha(alpha: Float) = { - GL11.glColor4f(1, 1, 1, alpha) - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) + GlStateManager.color(1, 1, 1, alpha) + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) } }