package cc.extra.api.system.draw;
import com.mojang.blaze3d.systems.RenderSystem;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.GameRenderer;
import org.joml.Matrix4f;
import cc.extra.common.QuickImports;
import static net.minecraft.client.render.VertexFormat.DrawMode.QUADS;
import static net.minecraft.client.render.VertexFormats.*;
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
public class DrawEngineImpl implements DrawEngine, QuickImports {
@ Override
public void quad(Matrix4f matrix4f, float x, float y, float width, float height) {
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
{
bufferBuilder.vertex(matrix4f, x, y + height, 0).texture(0, 0);
bufferBuilder.vertex(matrix4f, x + width, y + height, 0).texture(0, 1);
bufferBuilder.vertex(matrix4f, x + width, y, 0).texture(1, 1);
bufferBuilder.vertex(matrix4f, x, y, 0).texture(1, 0);
}
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
}
@ Override
public void quad(Matrix4f matrix4f, float x, float y, float width, float height, int color) {
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
{
bufferBuilder.vertex(matrix4f, x, y + height, 0).texture(0, 0).color(color);
bufferBuilder.vertex(matrix4f, x + width, y + height, 0).texture(0, 1).color(color);
bufferBuilder.vertex(matrix4f, x + width, y, 0).texture(1, 1).color(color);
bufferBuilder.vertex(matrix4f, x, y, 0).texture(1, 0).color(color);
}
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
}
}