]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/renderers/RenderHelper.java
Get 1.17.1 building
[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 afterRender() {
36         polygonModeFill();
37         RenderSystem.enableCull();
38         enableTexture();
39     }
40
41     public static void beforeRenderFont(OffsetPoint offsetPoint) {
42        // RenderSystem.pushMatrix();
43         polygonModeFill();
44         //RenderSystem.translated(offsetPoint.getX(), offsetPoint.getY() + 0.002D, offsetPoint.getZ());
45         //RenderSystem.normal3f(0.0F, 1.0F, 0.0F);
46         //RenderSystem.rotatef(0.0F, 0.0F, 1.0F, 0.0F);
47         //RenderSystem.rotatef(90.0F, 1.0F, 0.0F, 0.0F);
48         //RenderSystem.scalef(-0.0175F, -0.0175F, 0.0175F);
49         enableTexture();
50         enableBlend();
51         RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
52
53         depthMaskTrue();
54     }
55
56     public static void afterRenderFont() {
57         disableTexture();
58         disableBlend();
59         //RenderSystem.popMatrix();
60         enableDepthTest();
61     }
62
63     public static void disableLighting() {
64         //RenderSystem.disableLighting();
65     }
66
67     public static void disableDepthTest() {
68         RenderSystem.disableDepthTest();
69     }
70
71     public static void enableDepthTest() {
72         RenderSystem.enableDepthTest();
73     }
74
75     public static void disableBlend() {
76         RenderSystem.disableBlend();
77     }
78
79     public static void enableBlend() {
80         RenderSystem.enableBlend();
81     }
82
83     public static void disableAlphaTest() {
84         //RenderSystem.disableAlphaTest();
85     }
86
87     public static void enableAlphaTest() {
88         //RenderSystem.enableAlphaTest();
89     }
90
91     public static void disableTexture() {
92         RenderSystem.disableTexture();
93     }
94
95     public static void enableTexture() {
96         RenderSystem.enableTexture();
97     }
98
99     public static void shadeModelSmooth() {
100         //RenderSystem.shadeModel(GL11.GL_SMOOTH);
101     }
102
103     public static void shadeModelFlat() {
104         //RenderSystem.shadeModel(GL11.GL_FLAT);
105     }
106
107     public static void enablePointSmooth() {
108         GL11.glEnable(GL11.GL_POINT_SMOOTH);
109     }
110
111     public static void lineWidth2() {
112         RenderSystem.lineWidth(2f);
113     }
114
115     public static void polygonModeLine() {
116         RenderSystem.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
117     }
118
119     public static void polygonModeFill() {
120         RenderSystem.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
121     }
122
123     public static void polygonOffsetMinusOne() {
124         RenderSystem.polygonOffset(-1.f, -1.f);
125     }
126
127     public static void enablePolygonOffsetLine() {
128         //RenderSystem.enableLineOffset();
129     }
130
131     public static void depthMaskTrue() {
132         RenderSystem.depthMask(true);
133     }
134
135     public static void pointSize5() {
136         GL11.glPointSize(5);
137     }
138
139     public static void blendFuncGui() {
140         RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
141     }
142
143     public static void depthFuncAlways() {
144         RenderSystem.depthFunc(GL11.GL_ALWAYS);
145     }
146
147     public static void depthFuncLessEqual() {
148         RenderSystem.depthFunc(GL11.GL_LEQUAL);
149     }
150 }