Skip to content

Commit f81ecea

Browse files
committed
more efficient draw method for non gradient rectangle
1 parent 859adc8 commit f81ecea

File tree

1 file changed

+12
-1
lines changed
  • src/main/java/com/cleanroommc/modularui/drawable

1 file changed

+12
-1
lines changed

src/main/java/com/cleanroommc/modularui/drawable/GuiDraw.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,18 @@ public class GuiDraw {
4343
public static final double PI_2 = Math.PI / 2;
4444

4545
public static void drawRect(float x0, float y0, float w, float h, int color) {
46-
drawRect(x0, y0, w, h, color, color, color, color);
46+
Platform.setupDrawColor();
47+
float x1 = x0 + w, y1 = y0 + h;
48+
float r = Color.getRedF(color);
49+
float g = Color.getGreenF(color);
50+
float b = Color.getBlueF(color);
51+
float a = Color.getAlphaF(color);
52+
Platform.startDrawing(Platform.DrawMode.QUADS, Platform.VertexFormat.POS_COLOR, bufferBuilder -> {
53+
bufferBuilder.pos(x0, y0, 0.0f).color(r, g, b, a).endVertex();
54+
bufferBuilder.pos(x0, y1, 0.0f).color(r, g, b, a).endVertex();
55+
bufferBuilder.pos(x1, y1, 0.0f).color(r, g, b, a).endVertex();
56+
bufferBuilder.pos(x1, y0, 0.0f).color(r, g, b, a).endVertex();
57+
});
4758
}
4859

4960
public static void drawHorizontalGradientRect(float x0, float y0, float w, float h, int colorLeft, int colorRight) {

0 commit comments

Comments
 (0)