Skip to content

Commit

Permalink
Replace GL11 with GlStateManager, good bit of testing still needed
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Jul 8, 2019
1 parent be268b5 commit de1bd30
Show file tree
Hide file tree
Showing 111 changed files with 342 additions and 378 deletions.
6 changes: 3 additions & 3 deletions src/main/java/mekanism/client/entity/ParticleLaser.java
Expand Up @@ -40,8 +40,8 @@ public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialT
tessellator.draw();

GlStateManager.pushMatrix();
GL11.glPushAttrib(GL11.GL_POLYGON_BIT + GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_CULL_FACE);
GlStateManager.enablePolygonOffset();
GlStateManager.disableCull();
MekanismRenderer.glowOn();

float newX = (float) (prevPosX + (posX - prevPosX) * (double) partialTicks - interpPosX);
Expand Down Expand Up @@ -95,7 +95,7 @@ public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialT
tessellator.draw();

MekanismRenderer.glowOff();
GL11.glPopAttrib();
GlStateManager.disablePolygonOffset();
GlStateManager.popMatrix();

buffer.begin(7, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
Expand Down
Expand Up @@ -25,7 +25,6 @@
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)
public class GuiAdvancedElectricMachine<RECIPE extends AdvancedMachineRecipe<RECIPE>> extends GuiMekanismTile<TileEntityAdvancedElectricMachine<RECIPE>> {
Expand Down Expand Up @@ -76,7 +75,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand All @@ -103,9 +102,7 @@ public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas)
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
//TODO: Use GuiGasGauge?
int tint = gas.getGas().getTint();
if (tint != -1) {
MekanismRenderer.color(tint);
}
MekanismRenderer.color(tint);
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, gas.getGas().getSprite(), sizeX, sizeY);
MekanismRenderer.resetColor();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mekanism/client/gui/GuiAmbientAccumulator.java
Expand Up @@ -2,6 +2,7 @@

import mekanism.client.gui.element.GuiGasGauge;
import mekanism.client.gui.element.GuiGauge.Type;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.inventory.container.ContainerNull;
import mekanism.common.tile.TileEntityAmbientAccumulator;
import mekanism.common.util.LangUtils;
Expand All @@ -11,7 +12,6 @@
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)
public class GuiAmbientAccumulator extends GuiMekanismTile<TileEntityAmbientAccumulator> {
Expand All @@ -31,7 +31,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mekanism/client/gui/GuiBoilerStats.java
Expand Up @@ -5,6 +5,7 @@
import mekanism.client.gui.element.GuiBoilerTab.BoilerTab;
import mekanism.client.gui.element.GuiGraph;
import mekanism.client.gui.element.GuiHeatInfo;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.config.MekanismConfig;
import mekanism.common.content.boiler.SynchronizedBoilerData;
import mekanism.common.inventory.container.ContainerNull;
Expand All @@ -18,7 +19,6 @@
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)
public class GuiBoilerStats extends GuiMekanismTile<TileEntityBoilerCasing> {
Expand Down Expand Up @@ -67,7 +67,7 @@ public void updateScreen() {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mekanism/client/gui/GuiChanceMachine.java
Expand Up @@ -14,6 +14,7 @@
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.gui.element.GuiTransporterConfigTab;
import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.inventory.container.ContainerChanceMachine;
import mekanism.common.recipe.machines.ChanceMachineRecipe;
import mekanism.common.tile.TileEntityChanceMachine;
Expand All @@ -23,7 +24,6 @@
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)
public class GuiChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends GuiMekanismTile<TileEntityChanceMachine<RECIPE>> {
Expand Down Expand Up @@ -67,7 +67,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/mekanism/client/gui/GuiDictionary.java
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import mekanism.client.gui.element.GuiScrollList;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.sound.SoundHandler;
import mekanism.common.OreDictCache;
import mekanism.common.inventory.container.ContainerDictionary;
Expand All @@ -18,7 +19,6 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public class GuiDictionary extends GuiMekanism {
Expand Down Expand Up @@ -49,23 +49,23 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int xAxis = mouseX - guiWidth;
int yAxis = mouseY - guiHeight;
if (xAxis >= 6 && xAxis <= 22 && yAxis >= 6 && yAxis <= 22) {
GlStateManager.pushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GlStateManager.disableLighting();
GlStateManager.disableDepth();

int x = guiWidth + 6;
int y = guiHeight + 6;
drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433);

GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
GlStateManager.popMatrix();
}
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/mekanism/client/gui/GuiDigitalMiner.java
Expand Up @@ -35,8 +35,6 @@
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

@SideOnly(Side.CLIENT)
public class GuiDigitalMiner extends GuiMekanismTile<TileEntityDigitalMiner> {
Expand Down Expand Up @@ -138,9 +136,9 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {

if (!tileEntity.missingStack.isEmpty()) {
GlStateManager.pushMatrix();
GL11.glColor4f(1, 1, 1, 1);
MekanismRenderer.resetColor();
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GlStateManager.enableRescaleNormal();
mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture());
drawTexturedRectFromIcon(144, 27, MekanismRenderer.getColorIcon(EnumColor.DARK_RED), 16, 16);
itemRender.renderItemAndEffectIntoGUI(tileEntity.missingStack, 144, 27);
Expand Down Expand Up @@ -181,7 +179,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java
Expand Up @@ -40,7 +40,6 @@
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public class GuiDigitalMinerConfig extends GuiMekanismTile<TileEntityDigitalMiner> {
Expand Down Expand Up @@ -422,7 +421,7 @@ protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, in
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);

mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
Expand Up @@ -14,6 +14,7 @@
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.gui.element.GuiTransporterConfigTab;
import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.inventory.container.ContainerDoubleElectricMachine;
import mekanism.common.recipe.machines.DoubleMachineRecipe;
import mekanism.common.tile.prefab.TileEntityDoubleElectricMachine;
Expand All @@ -23,7 +24,6 @@
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)
public class GuiDoubleElectricMachine<RECIPE extends DoubleMachineRecipe<RECIPE>> extends GuiMekanismTile<TileEntityDoubleElectricMachine<RECIPE>> {
Expand Down Expand Up @@ -68,7 +68,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mekanism/client/gui/GuiDynamicTank.java
@@ -1,6 +1,7 @@
package mekanism.client.gui;

import mekanism.client.gui.element.GuiContainerEditMode;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.content.tank.TankUpdateProtocol;
import mekanism.common.inventory.container.ContainerDynamicTank;
import mekanism.common.tile.TileEntityDynamicTank;
Expand All @@ -11,7 +12,6 @@
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)
public class GuiDynamicTank extends GuiEmbeddedGaugeTile<TileEntityDynamicTank> {
Expand Down Expand Up @@ -45,7 +45,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mekanism/client/gui/GuiElectricMachine.java
Expand Up @@ -14,6 +14,7 @@
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.gui.element.GuiTransporterConfigTab;
import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.inventory.container.ContainerElectricMachine;
import mekanism.common.recipe.machines.BasicMachineRecipe;
import mekanism.common.tile.prefab.TileEntityElectricMachine;
Expand All @@ -23,7 +24,6 @@
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)
public class GuiElectricMachine<RECIPE extends BasicMachineRecipe<RECIPE>> extends GuiMekanismTile<TileEntityElectricMachine<RECIPE>> {
Expand Down Expand Up @@ -67,7 +67,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mekanism/client/gui/GuiElectricPump.java
Expand Up @@ -11,6 +11,7 @@
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.inventory.container.ContainerElectricPump;
import mekanism.common.tile.TileEntityElectricPump;
import mekanism.common.util.LangUtils;
Expand All @@ -20,7 +21,6 @@
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)
public class GuiElectricPump extends GuiMekanismTile<TileEntityElectricPump> {
Expand Down Expand Up @@ -59,7 +59,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
Expand Up @@ -17,6 +17,7 @@
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism;
import mekanism.common.inventory.container.ContainerElectrolyticSeparator;
Expand All @@ -31,7 +32,6 @@
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)
public class GuiElectrolyticSeparator extends GuiMekanismTile<TileEntityElectrolyticSeparator> {
Expand Down Expand Up @@ -97,7 +97,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mekanism/client/gui/GuiEnergyCube.java
Expand Up @@ -10,6 +10,7 @@
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.gui.element.GuiTransporterConfigTab;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.inventory.container.ContainerEnergyCube;
import mekanism.common.tile.TileEntityEnergyCube;
import mekanism.common.util.LangUtils;
Expand All @@ -19,7 +20,6 @@
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)
public class GuiEnergyCube extends GuiMekanismTile<TileEntityEnergyCube> {
Expand Down Expand Up @@ -48,7 +48,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/mekanism/client/gui/GuiFactory.java
Expand Up @@ -33,7 +33,6 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public class GuiFactory extends GuiMekanismTile<TileEntityFactory> {
Expand Down Expand Up @@ -80,7 +79,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(getGuiLocation());
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
MekanismRenderer.resetColor();
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
Expand All @@ -101,9 +100,7 @@ protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, in
if (gas != null) {
//TODO: Use GuiGasGauge?
int tint = gas.getGas().getTint();
if (tint != -1) {
MekanismRenderer.color(tint);
}
MekanismRenderer.color(tint);
displayGauge(8, 78, tileEntity.getScaledGasLevel(160), 5, gas.getGas().getSprite());
MekanismRenderer.resetColor();
}
Expand Down

0 comments on commit de1bd30

Please sign in to comment.