]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/renderers/RenderHelper.java
fix world save load screen render issues
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / renderers / RenderHelper.java
1 package com.irtimaled.bbor.client.renderers;
2
3 import com.irtimaled.bbor.client.config.ConfigManager;
4 import com.mojang.blaze3d.systems.RenderSystem;
5 import net.minecraft.client.MinecraftClient;
6 import net.minecraft.client.render.GameRenderer;
7 import net.minecraft.util.Identifier;
8 import org.lwjgl.opengl.GL11;
9
10 public class RenderHelper {
11     public static final int QUADS = GL11.GL_QUADS;
12     public static final int LINES = GL11.GL_LINES;
13     public static final int LINE_LOOP = GL11.GL_LINE_LOOP;
14     public static final int POINTS = GL11.GL_POINTS;
15
16     //public static final VertexFormat.DrawMode CUSTOM = ReflectionHelper.getPrivateInstanceBuilder(VertexFormat.DrawMode.class,)
17     public static void beforeRender() {
18         enableBlend();
19         RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
20         lineWidth2();
21         disableTexture();
22         RenderSystem.disableCull();
23         enableDepthTest();
24
25         if (ConfigManager.alwaysVisible.get()) {
26             RenderSystem.clear(GL11.GL_DEPTH_BUFFER_BIT, MinecraftClient.IS_SYSTEM_MAC);
27         }
28     }
29
30     public static void setTexture(Identifier texture) {
31         RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
32         RenderSystem.setShaderTexture(0, texture);
33     }
34
35     public static void resetShader() {
36         RenderSystem.setShader(GameRenderer::getPositionColorShader);
37     }
38
39     public static void afterRender() {
40         polygonModeFill();
41         RenderSystem.enableCull();
42         enableTexture();
43     }
44
45     public static void beforeRenderFont(OffsetPoint offsetPoint) {
46        // RenderSystem.pushMatrix();
47         polygonModeFill();
48         //RenderSystem.translated(offsetPoint.getX(), offsetPoint.getY() + 0.002D, offsetPoint.getZ());
49         //RenderSystem.normal3f(0.0F, 1.0F, 0.0F);
50         //RenderSystem.rotatef(0.0F, 0.0F, 1.0F, 0.0F);
51         //RenderSystem.rotatef(90.0F, 1.0F, 0.0F, 0.0F);
52         //RenderSystem.scalef(-0.0175F, -0.0175F, 0.0175F);
53         enableTexture();
54         enableBlend();
55         RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
56
57         depthMaskTrue();
58     }
59
60     public static void afterRenderFont() {
61         disableTexture();
62         disableBlend();
63         //RenderSystem.popMatrix();
64         enableDepthTest();
65     }
66
67     public static void disableLighting() {
68         //RenderSystem.disableLighting();
69     }
70
71     public static void disableDepthTest() {
72         RenderSystem.disableDepthTest();
73     }
74
75     public static void enableDepthTest() {
76         RenderSystem.enableDepthTest();
77     }
78
79     public static void disableBlend() {
80         RenderSystem.disableBlend();
81     }
82
83     public static void enableBlend() {
84         RenderSystem.enableBlend();
85     }
86
87     public static void disableAlphaTest() {
88         //RenderSystem.disableAlphaTest();
89     }
90
91     public static void enableAlphaTest() {
92         //RenderSystem.enableAlphaTest();
93     }
94
95     public static void disableTexture() {
96         RenderSystem.disableTexture();
97     }
98
99     public static void enableTexture() {
100         RenderSystem.enableTexture();
101     }
102
103     public static void shadeModelSmooth() {
104         //RenderSystem.shadeModel(GL11.GL_SMOOTH);
105     }
106
107     public static void shadeModelFlat() {
108         //RenderSystem.shadeModel(GL11.GL_FLAT);
109     }
110
111     public static void enablePointSmooth() {
112         GL11.glEnable(GL11.GL_POINT_SMOOTH);
113     }
114
115     public static void lineWidth2() {
116         RenderSystem.lineWidth(2f);
117     }
118
119     public static void polygonModeLine() {
120         RenderSystem.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
121     }
122
123     public static void polygonModeFill() {
124         RenderSystem.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
125     }
126
127     public static void polygonOffsetMinusOne() {
128         RenderSystem.polygonOffset(-1.f, -1.f);
129     }
130
131     public static void enablePolygonOffsetLine() {
132         //RenderSystem.enableLineOffset();
133     }
134
135     public static void depthMaskTrue() {
136         RenderSystem.depthMask(true);
137     }
138
139     public static void pointSize5() {
140         GL11.glPointSize(5);
141     }
142
143     public static void blendFuncGui() {
144         RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
145     }
146
147     public static void depthFuncAlways() {
148         RenderSystem.depthFunc(GL11.GL_ALWAYS);
149     }
150
151     public static void depthFuncLessEqual() {
152         RenderSystem.depthFunc(GL11.GL_LEQUAL);
153     }
154 }