mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-25 14:34:33 +00:00
Use GlStateManager
This commit is contained in:
1 parent
31a305ffc2
commit
9c4b081f6d
24 files changed
+144
-152
No files matched your search
@@ -14,7 +14,6 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -159,9 +158,9 @@ public class CraftGUIUtil {
|
||||
if (rotating) {
|
||||
GlStateManager.pushMatrix();
|
||||
final float phase = Minecraft.getSystemTime() / 20;
|
||||
GL11.glTranslatef(8, 8, 0);
|
||||
GL11.glRotatef(phase, 0, -0.866f, 0.5f);
|
||||
GL11.glTranslatef(-8, -8, -67.1f);
|
||||
GlStateManager.translate(8, 8, 0);
|
||||
GlStateManager.rotate(phase, 0, -0.866f, 0.5f);
|
||||
GlStateManager.translate(-8, -8, -67.1f);
|
||||
}
|
||||
|
||||
minecraft.getRenderItem().renderItemAndEffectIntoGUI(null, itemStack, pos.x(), pos.y());
|
||||
|
||||
@@ -14,6 +14,7 @@ import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillMachine;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillRecipes;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -35,14 +36,14 @@ public class ControlLumbermillProgress extends ControlProgressBase {
|
||||
|
||||
@Override
|
||||
public void onRenderForeground(int guiWidth, int guiHeight) {
|
||||
GL11.glDisable(2896);
|
||||
GlStateManager.disableLighting();
|
||||
final int sawX = (int) (63 * this.progress);
|
||||
CraftGUI.render.texture(ControlLumbermillProgress.Saw, new IPoint(sawX, -8 + Math.round(6 * (float) Math.sin(this.animation))));
|
||||
final ItemStack item = Window.get(this).getInventory().getStackInSlot(LumbermillMachine.SLOT_LOG);
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
GL11.glDisable(2896);
|
||||
GlStateManager.disableLighting();
|
||||
Block block = null;
|
||||
if (item.getItem() instanceof ItemBlock) {
|
||||
block = ((ItemBlock) item.getItem()).getBlock();
|
||||
@@ -70,12 +71,12 @@ public class ControlLumbermillProgress extends ControlProgressBase {
|
||||
final IPoint size = this.getSize();
|
||||
final IPoint pos = this.getAbsolutePosition();
|
||||
CraftGUI.render.limitArea(new IArea(pos.add(IPoint.ZERO), new IPoint(Math.round(this.progress * 64) + 2, 18)), guiWidth, guiHeight);
|
||||
GL11.glEnable(3089);
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
//TODO RENDERING
|
||||
//CraftGUI.Render.iconBlock(new IPoint(1 + j * 16, 1), icon2);
|
||||
}
|
||||
GL11.glDisable(3089);
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
CraftGUI.render.texture(ControlLumbermillProgress.Saw2, new IPoint(sawX + 2, -8 + Math.round(6 * (float) Math.sin(this.animation))));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ControlFluidDisplay extends Control implements ITooltip {
|
||||
FluidStack itemStack;
|
||||
@@ -59,19 +59,19 @@ public class ControlFluidDisplay extends Control implements ITooltip {
|
||||
final int b = hex & 0xFF;
|
||||
final ResourceLocation iconRL = this.itemStack.getFluid().getStill();
|
||||
TextureAtlasSprite icon = FMLClientHandler.instance().getClient().getTextureMapBlocks().getAtlasSprite(iconRL.toString());
|
||||
GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GlStateManager.color(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 771);
|
||||
if (this.getSize().x() != 16) {
|
||||
GL11.glPushMatrix();
|
||||
GlStateManager.pushMatrix();
|
||||
final float scale = this.getSize().x() / 16.0f;
|
||||
GL11.glScalef(scale, scale, 1.0f);
|
||||
GlStateManager.scale(scale, scale, 1.0f);
|
||||
CraftGUI.render.sprite(IPoint.ZERO, icon);
|
||||
GL11.glPopMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
} else {
|
||||
CraftGUI.render.sprite(IPoint.ZERO, icon);
|
||||
}
|
||||
GL11.glDisable(3042);
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import binnie.craftgui.events.EventMouse;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -20,7 +21,6 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -71,17 +71,17 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float par3) {
|
||||
this.window.setMousePosition(mouseX - (int) this.window.getPosition().x(), mouseY - (int) this.window.getPosition().y());
|
||||
this.drawDefaultBackground();
|
||||
GL11.glDisable(32826);
|
||||
GlStateManager.disableRescaleNormal();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(2896);
|
||||
GL11.glDisable(2929);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableDepth();
|
||||
this.zLevel = 10.0f;
|
||||
//GuiScreen.itemRender.zLevel = this.zLevel;
|
||||
this.window.render(this.width, this.height);
|
||||
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(32826);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableRescaleNormal();
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
|
||||
final InventoryPlayer playerInventory = this.mc.thePlayer.inventory;
|
||||
this.draggedItem = playerInventory.getItemStack();
|
||||
@@ -89,10 +89,10 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
CraftGUIUtil.renderItem(new IPoint(mouseX - 8, mouseY - 8), this.draggedItem, false);
|
||||
}
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glDisable(32826);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glDisable(2896);
|
||||
GL11.glDisable(2929);
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableDepth();
|
||||
final MinecraftTooltip tooltip = new MinecraftTooltip();
|
||||
if (this.isHelpMode()) {
|
||||
tooltip.setType(Tooltip.Type.Help);
|
||||
@@ -105,18 +105,18 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
this.renderTooltip(new IPoint(mouseX, mouseY), tooltip);
|
||||
}
|
||||
this.zLevel = 0.0f;
|
||||
GL11.glEnable(2896);
|
||||
GL11.glEnable(2929);
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableDepth();
|
||||
}
|
||||
|
||||
public void renderTooltip(final IPoint mousePosition, final MinecraftTooltip tooltip) {
|
||||
final int mouseX = (int) mousePosition.x();
|
||||
final int mouseY = (int) mousePosition.y();
|
||||
final FontRenderer font = this.getFontRenderer();
|
||||
GL11.glDisable(32826);
|
||||
GlStateManager.disableRescaleNormal();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(2896);
|
||||
GL11.glDisable(2929);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableDepth();
|
||||
int k = 0;
|
||||
final List<String> strings = new ArrayList<>();
|
||||
for (final String string : tooltip.getList()) {
|
||||
@@ -175,11 +175,11 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
try {
|
||||
final NBTTagCompound nbt = JsonToNBT.getTagFromJson(split);
|
||||
final ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(i1, j1 - 1.5f, 0.0f);
|
||||
GL11.glScalef(0.6f, 0.6f, 1.0f);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(i1, j1 - 1.5f, 0.0f);
|
||||
GlStateManager.scale(0.6f, 0.6f, 1.0f);
|
||||
CraftGUIUtil.renderItem(IPoint.ZERO, stack, false);
|
||||
GL11.glPopMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
} catch (NBTException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -193,10 +193,10 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
}
|
||||
this.zLevel = 0.0f;
|
||||
//GuiScreen.itemRender.zLevel = 0.0f;
|
||||
GL11.glEnable(2896);
|
||||
GL11.glEnable(2929);
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableDepth();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glEnable(32826);
|
||||
GlStateManager.enableRescaleNormal();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ControlEnergyBar extends Control implements ITooltip {
|
||||
public static boolean isError;
|
||||
@@ -77,7 +76,8 @@ public class ControlEnergyBar extends Control implements ITooltip {
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
CraftGUI.render.texture(CraftGUITexture.EnergyBarBack, this.getArea());
|
||||
final float percentage = this.getPercentage() / 100.0f;
|
||||
CraftGUI.render.colour(this.getColourFromPercentage(percentage));
|
||||
int colourFromPercentage = this.getColourFromPercentage(percentage);
|
||||
CraftGUI.render.colour(colourFromPercentage);
|
||||
final IArea area = this.getArea();
|
||||
switch (this.direction) {
|
||||
case Top:
|
||||
@@ -119,14 +119,12 @@ public class ControlEnergyBar extends Control implements ITooltip {
|
||||
}
|
||||
|
||||
public int getColourFromPercentage(final float percentage) {
|
||||
int colour = 16777215;
|
||||
if (percentage > 0.5) {
|
||||
final int r = (int) ((1.0 - 2.0 * (percentage - 0.5)) * 255.0);
|
||||
colour = (r << 16) + 65280;
|
||||
return (r << 16) + 65280;
|
||||
} else {
|
||||
final int g = (int) (255.0f * (2.0f * percentage));
|
||||
colour = 16711680 + (g << 8);
|
||||
return 16711680 + (g << 8);
|
||||
}
|
||||
return colour;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
public class ControlSlide extends Control {
|
||||
private IArea expanded;
|
||||
@@ -49,16 +49,16 @@ public class ControlSlide extends Control {
|
||||
texture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline).crop(this.anchor.opposite(), 8);
|
||||
CraftGUI.render.texture(texture, tabArea.inset(2));
|
||||
final IArea labelArea = new IArea(-lw / 2, 0, lw, lh);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(shift.x() + this.anchor.x() * 2, shift.y() + this.anchor.y() * 2, 0);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(shift.x() + this.anchor.x() * 2, shift.y() + this.anchor.y() * 2, 0);
|
||||
if (this.anchor.x() != 0) {
|
||||
GL11.glRotatef(90.0f, 0.0f, 0.0f, this.anchor.x());
|
||||
GlStateManager.rotate(90.0f, 0.0f, 0.0f, this.anchor.x());
|
||||
}
|
||||
if (this.anchor.y() > 0) {
|
||||
GL11.glTranslatef(0.0f, -lh, 0.0f);
|
||||
GlStateManager.translate(0.0f, -lh, 0.0f);
|
||||
}
|
||||
CraftGUI.render.text(labelArea, TextJustification.MiddleCenter, this.label, 16777215);
|
||||
GL11.glPopMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
CraftGUI.render.texture(CraftGUITexture.Window, this.getArea());
|
||||
final Object slideTexture = (this.anchor == Position.Bottom) ? CraftGUITexture.SlideDown : ((this.anchor == Position.Top) ? CraftGUITexture.SlideUp : ((this.anchor == Position.Left) ? CraftGUITexture.SlideLeft : CraftGUITexture.SlideRight));
|
||||
|
||||
Reference in new issue
Block a user