Java tutorial
package com.teambrmodding.luxetumbra.utils; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import java.awt.*; /** * This file was created for Lux-et-Umbra-Redux * <p> * Lux-et-Umbra-Redux is licensed under the * Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License: * http://creativecommons.org/licenses/by-nc-sa/4.0/ * * @author Paul Davis - pauljoda * @since 10/8/2016 */ public class RenderUtils { /** * Used to pushGl new matrix and attributes to gl stack */ public static void pushGl() { GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); } /** * Used to popGl gl stack */ public static void popGl() { GlStateManager.popAttrib(); GlStateManager.popMatrix(); } /** * Set the GL color. You should probably reset it after this * * @param color The color to set */ public static void setColor(Color color) { GL11.glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F); } /** * Used to reset the GL Color */ public static void restoreColor() { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); } /** * Used to prepare the rendering state. For basic stuff that you want things to behave on */ public static void prepareRenderState() { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL12.GL_RESCALE_NORMAL); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_ALPHA_TEST); } /** * Un-does the prepare state */ public static void restoreRenderState() { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); RenderHelper.enableStandardItemLighting(); GL11.glDisable(GL11.GL_ALPHA_TEST); } }