Search in sources :

Example 1 with MinecraftClientAccessor

use of com.glisco.isometricrenders.mixin.MinecraftClientAccessor in project isometric-renders by gliscowo.

the class IsometricRenderHelper method renderIntoImage.

public static NativeImage renderIntoImage(int size, RenderCallback renderCallback) {
    Framebuffer framebuffer = new Framebuffer(size, size, true, MinecraftClient.IS_SYSTEM_MAC);
    RenderSystem.pushMatrix();
    RenderSystem.enableBlend();
    RenderSystem.clear(16640, MinecraftClient.IS_SYSTEM_MAC);
    framebuffer.setClearColor(0, 0, 0, 0);
    framebuffer.clear(MinecraftClient.IS_SYSTEM_MAC);
    framebuffer.beginWrite(true);
    RenderSystem.matrixMode(GL11.GL_PROJECTION);
    RenderSystem.pushMatrix();
    RenderSystem.loadIdentity();
    RenderSystem.ortho(-1, 1, 1, -1, -100.0, 100.0);
    RenderSystem.matrixMode(GL11.GL_MODELVIEW);
    RenderSystem.pushMatrix();
    RenderSystem.loadIdentity();
    setupLighting();
    VertexConsumerProvider.Immediate vertexConsumers = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
    MatrixStack matrixStack = new MatrixStack();
    renderCallback.render(matrixStack, vertexConsumers, ((MinecraftClientAccessor) MinecraftClient.getInstance()).getRenderTickCounter().tickDelta);
    vertexConsumers.draw();
    RenderSystem.popMatrix();
    RenderSystem.matrixMode(GL11.GL_PROJECTION);
    RenderSystem.popMatrix();
    RenderSystem.matrixMode(GL11.GL_MODELVIEW);
    RenderSystem.popMatrix();
    framebuffer.endWrite();
    return takeKeyedSnapshot(framebuffer, RuntimeConfig.backgroundColor, false, false);
}
Also used : MinecraftClientAccessor(com.glisco.isometricrenders.mixin.MinecraftClientAccessor) Framebuffer(net.minecraft.client.gl.Framebuffer) MatrixStack(net.minecraft.client.util.math.MatrixStack) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Aggregations

MinecraftClientAccessor (com.glisco.isometricrenders.mixin.MinecraftClientAccessor)1 Framebuffer (net.minecraft.client.gl.Framebuffer)1 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1