1 package com.irtimaled.bbor.client.renderers;
3 import com.irtimaled.bbor.client.Camera;
4 import com.irtimaled.bbor.client.config.ConfigManager;
5 import com.mojang.blaze3d.platform.GlStateManager;
6 import com.mojang.blaze3d.systems.RenderSystem;
7 import net.minecraft.client.util.math.MatrixStack;
8 import net.minecraft.util.math.Quaternion;
9 import org.lwjgl.opengl.GL11;
11 public class RenderHelper {
13 public static void beforeRender() {
15 GlStateManager._blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
16 GL11.glEnable(GL11.GL_LINE_SMOOTH);
17 RenderSystem.disableCull();
19 RenderSystem.depthMask(true);
20 RenderSystem.depthFunc(GL11.GL_LEQUAL);
22 if (ConfigManager.alwaysVisible.get()) {
23 RenderSystem.disableDepthTest();
25 RenderBatch.beginBatch();
28 public static void afterRender() {
29 RenderBatch.endBatch();
31 RenderSystem.enableCull();
32 GL11.glDisable(GL11.GL_LINE_SMOOTH);
33 RenderSystem.setShaderColor(1, 1, 1, 1);
36 public static void beforeRenderFont(MatrixStack matrixStack, OffsetPoint offsetPoint) {
37 RenderSystem.assertThread(RenderSystem::isOnRenderThread);
40 matrixStack.translate(offsetPoint.getX(), offsetPoint.getY() + 0.002D, offsetPoint.getZ());
41 // GL11.glNormal3f(0.0F, 1.0F, 0.0F);
42 matrixStack.multiply(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F));
43 matrixStack.multiply(new Quaternion(0.0F, 90.0F, 1.0F, 0.0F));
44 matrixStack.scale(-0.0175F, -0.0175F, 0.0175F);
47 GlStateManager._blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
52 public static void afterRenderFont(MatrixStack matrixStack) {
55 RenderSystem.assertThread(RenderSystem::isOnRenderThread);
60 // public static void disableLighting() {
61 // RenderSystem.assertThread(RenderSystem::isOnRenderThread);
62 // GL11.glDisable(GL11.GL_LIGHTING);
65 public static void disableDepthTest() {
66 GlStateManager._disableDepthTest();
69 public static void enableDepthTest() {
70 GlStateManager._enableDepthTest();
73 // public static void disableFog() {
74 // RenderSystem.assertThread(RenderSystem::isOnRenderThread);
75 // GL11.glDisable(GL11.GL_FOG);
78 public static void disableBlend() {
79 GlStateManager._disableBlend();
82 public static void enableBlend() {
83 GlStateManager._enableBlend();
86 // public static void disableAlphaTest() {
87 // RenderSystem.assertThread(RenderSystem::isOnRenderThread);
88 // GL11.glDisable(GL32.GL_ALPHA_TEST);
91 // public static void enableAlphaTest() {
92 // RenderSystem.assertThread(RenderSystem::isOnRenderThread);
93 // GL11.glEnable(GL11.GL_ALPHA_TEST);
96 public static void disableTexture() {
97 GlStateManager._disableTexture();
100 public static void enableTexture() {
101 GlStateManager._enableTexture();
104 // public static void shadeModelSmooth() {
105 // RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
106 // GL11.glShadeModel(GL11.GL_SMOOTH);
109 // public static void shadeModelFlat() {
110 // RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
111 // GL11.glShadeModel(GL11.GL_FLAT);
114 // public static void enablePointSmooth() {
115 // GL11.glEnable(GL11.GL_POINT_SMOOTH);
118 public static void lineWidth2() {
119 RenderSystem.assertThread(RenderSystem::isOnRenderThread);
120 RenderSystem.lineWidth(2f);
123 public static void polygonModeLine() {
124 GlStateManager._polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
127 public static void polygonModeFill() {
128 GlStateManager._polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
131 public static void polygonOffsetMinusOne() {
132 GlStateManager._polygonOffset(-1.f, -1.f);
135 public static void enablePolygonOffsetLine() {
136 RenderSystem.assertThread(RenderSystem::isOnRenderThread);
137 GL11.glEnable(GL11.GL_POLYGON_OFFSET_LINE);
140 public static void depthMaskTrue() {
141 GlStateManager._depthMask(true);
144 public static void blendFuncGui() {
145 GlStateManager._blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
148 public static void depthFuncAlways() {
149 GlStateManager._depthFunc(GL11.GL_ALWAYS);
152 public static void depthFuncLessEqual() {
153 GlStateManager._depthFunc(GL11.GL_LEQUAL);
156 public static void applyRegionalRenderOffset(MatrixStack matrixStack)
159 int regionX = (((int) Camera.getX()) >> 9) << 9;
160 int regionZ = (((int) Camera.getZ()) >> 9) << 9;
162 matrixStack.translate(regionX - Camera.getX(), -Camera.getY(),
163 regionZ - Camera.getZ());