use of net.minecraft.client.render.BufferBuilder in project RPG-Hud by KurodaAkira.
the class HudElement method drawRect.
/**
* Draws a rectangle on the screen
*
* @param posX
* the x positon on the screen
* @param posY
* the y positon on the screen
* @param width
* the width of the rectangle
* @param height
* the height of the rectangle
* @param color
* the color of the rectangle
*/
public static void drawRect(MatrixStack ms, int posX, int posY, int width, int height, int color) {
if (color == -1)
return;
float f3;
if (color <= 0xFFFFFF && color >= 0)
f3 = 1.0F;
else
f3 = (color >> 24 & 255) / 255.0F;
float f = (color >> 16 & 255) / 255.0F;
float f1 = (color >> 8 & 255) / 255.0F;
float f2 = (color & 255) / 255.0F;
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.disableDepthTest();
BufferBuilder vertexbuffer = Tessellator.getInstance().getBuffer();
vertexbuffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
vertexbuffer.vertex(ms.peek().getPositionMatrix(), posX, posY + height, 0).color(f, f1, f2, f3).next();
vertexbuffer.vertex(ms.peek().getPositionMatrix(), posX + width, posY + height, 0).color(f, f1, f2, f3).next();
vertexbuffer.vertex(ms.peek().getPositionMatrix(), posX + width, posY, 0).color(f, f1, f2, f3).next();
vertexbuffer.vertex(ms.peek().getPositionMatrix(), posX, posY, 0).color(f, f1, f2, f3).next();
vertexbuffer.end();
BufferRenderer.draw(vertexbuffer);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
RenderSystem.enableDepthTest();
}
use of net.minecraft.client.render.BufferBuilder in project ImmersivePortalsMod by qouteall.
the class MyRenderHelper method renderScreenTriangle.
static void renderScreenTriangle() {
GlStateManager.matrixMode(GL_MODELVIEW);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.matrixMode(GL_PROJECTION);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.disableAlphaTest();
GlStateManager.disableTexture();
GlStateManager.shadeModel(GL_SMOOTH);
GL20.glUseProgram(0);
GL11.glDisable(GL_CLIP_PLANE0);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBufferBuilder();
bufferbuilder.begin(GL_TRIANGLES, VertexFormats.POSITION_COLOR);
bufferbuilder.vertex(1, -1, 0).color(255, 255, 255, 255).next();
bufferbuilder.vertex(1, 1, 0).color(255, 255, 255, 255).next();
bufferbuilder.vertex(-1, 1, 0).color(255, 255, 255, 255).next();
bufferbuilder.vertex(-1, 1, 0).color(255, 255, 255, 255).next();
bufferbuilder.vertex(-1, -1, 0).color(255, 255, 255, 255).next();
bufferbuilder.vertex(1, -1, 0).color(255, 255, 255, 255).next();
tessellator.draw();
GlStateManager.matrixMode(GL_MODELVIEW);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL_PROJECTION);
GlStateManager.popMatrix();
GlStateManager.enableAlphaTest();
GlStateManager.enableTexture();
}
use of net.minecraft.client.render.BufferBuilder in project ImmersivePortalsMod by qouteall.
the class ViewAreaRenderer method buildPortalViewAreaTrianglesBuffer.
private static void buildPortalViewAreaTrianglesBuffer(Vec3d fogColor, Portal portal, BufferBuilder bufferbuilder, Vec3d cameraPos, float partialTicks, float layerWidth) {
// if layerWidth is small, the teleportation will not be seamless
// counter-clockwise triangles are front-faced in default
bufferbuilder.begin(GL_TRIANGLES, VertexFormats.POSITION_COLOR);
Vec3d posInPlayerCoordinate = portal.getPos().subtract(cameraPos);
if (portal instanceof Mirror) {
posInPlayerCoordinate = posInPlayerCoordinate.add(portal.getNormal().multiply(-0.001));
}
Consumer<Vec3d> vertexOutput = p -> putIntoVertex(bufferbuilder, p, fogColor);
if (portal.specialShape == null) {
generateTriangleRectangular(vertexOutput, portal, layerWidth, posInPlayerCoordinate);
} else {
generateTriangleSpecial(vertexOutput, portal, layerWidth, posInPlayerCoordinate);
}
if (shouldRenderAdditionalBox(portal, cameraPos)) {
renderAdditionalBox(portal, cameraPos, vertexOutput);
}
}
use of net.minecraft.client.render.BufferBuilder in project ImmersivePortalsMod by qouteall.
the class ViewAreaRenderer method drawPortalViewTriangle.
public static void drawPortalViewTriangle(Portal portal) {
MinecraftClient.getInstance().getProfiler().push("render_view_triangle");
DimensionRenderHelper helper = CGlobal.clientWorldLoader.getDimensionRenderHelper(portal.dimensionTo);
Vec3d fogColor = helper.getFogColor();
// important
GlStateManager.enableCull();
// In OpenGL, if you forget to set one rendering state and the result will be abnormal
// this design is bug-prone (DirectX is better in this aspect)
GuiLighting.disable();
GlStateManager.color4f(1, 1, 1, 1);
GlStateManager.disableFog();
GlStateManager.disableAlphaTest();
GlStateManager.disableTexture();
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.disableBlend();
GlStateManager.disableLighting();
GL11.glDisable(GL_CLIP_PLANE0);
if (OFInterface.isShaders.getAsBoolean()) {
fogColor = Vec3d.ZERO;
}
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBufferBuilder();
buildPortalViewAreaTrianglesBuffer(fogColor, portal, bufferbuilder, PortalRenderer.mc.gameRenderer.getCamera().getPos(), MyRenderHelper.partialTicks, portal instanceof Mirror ? 0 : 0.45F);
tessellator.draw();
GlStateManager.enableCull();
GlStateManager.enableAlphaTest();
GlStateManager.enableTexture();
GlStateManager.enableLighting();
MinecraftClient.getInstance().getProfiler().pop();
}
use of net.minecraft.client.render.BufferBuilder in project BedrockIfy by juancarloscp52.
the class AbstractPackScreenMixin method renderHeaderAndBottom.
/**
* Render top and bottom "dirt" bars when custom rotating background is enabled.
*/
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/pack/PackScreen;drawCenteredText(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", ordinal = 0))
private void renderHeaderAndBottom(CallbackInfo info) {
if (!Bedrockify.getInstance().settings.isCubemapBackgroundEnabled())
return;
headerWidth = Objects.requireNonNull(client).getWindow().getScaledWidth();
headerHeight = client.getWindow().getScaledHeight();
headerBottom = headerHeight - 51;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.client.getTextureManager().bindTexture(DrawableHelper.BACKGROUND_TEXTURE);
RenderSystem.enableDepthTest();
RenderSystem.depthFunc(519);
float tilingSize = 32.0F;
// Top and bottom bars.
bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
bufferBuilder.vertex(this.headerLeft, this.headerTop, -100.0D).texture(0.0F, (float) this.headerTop / tilingSize).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.headerLeft + this.headerWidth, this.headerTop, -100.0D).texture((float) this.headerWidth / tilingSize, (float) this.headerTop / tilingSize).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.headerLeft + this.headerWidth, 0.0D, -100.0D).texture((float) this.headerWidth / tilingSize, 0.0F).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.headerLeft, 0.0D, -100.0D).texture(0.0F, 0.0F).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.headerLeft, this.headerHeight, -100.0D).texture(0.0F, (float) this.headerHeight / tilingSize).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.headerLeft + this.headerWidth, this.headerHeight, -100.0D).texture((float) this.headerWidth / tilingSize, (float) this.headerHeight / tilingSize).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.headerLeft + this.headerWidth, this.headerBottom, -100.0D).texture((float) this.headerWidth / tilingSize, (float) this.headerBottom / tilingSize).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.headerLeft, this.headerBottom, -100.0D).texture(0.0F, (float) this.headerBottom / tilingSize).color(64, 64, 64, 255).next();
tessellator.draw();
RenderSystem.depthFunc(515);
RenderSystem.disableDepthTest();
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ZERO, GlStateManager.DstFactor.ONE);
RenderSystem.disableAlphaTest();
RenderSystem.shadeModel(7425);
RenderSystem.disableTexture();
// Top and bottom bar shadows.
bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
bufferBuilder.vertex(this.headerLeft, this.headerTop + 4, 0.0D).texture(0.0F, 1.0F).color(0, 0, 0, 0).next();
bufferBuilder.vertex(this.headerWidth, this.headerTop + 4, 0.0D).texture(1.0F, 1.0F).color(0, 0, 0, 0).next();
bufferBuilder.vertex(this.headerWidth, this.headerTop, 0.0D).texture(1.0F, 0.0F).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.headerLeft, this.headerTop, 0.0D).texture(0.0F, 0.0F).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.headerLeft, this.headerBottom, 0.0D).texture(0.0F, 1.0F).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.headerWidth, this.headerBottom, 0.0D).texture(1.0F, 1.0F).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.headerWidth, this.headerBottom - 4, 0.0D).texture(1.0F, 0.0F).color(0, 0, 0, 0).next();
bufferBuilder.vertex(this.headerLeft, this.headerBottom - 4, 0.0D).texture(0.0F, 0.0F).color(0, 0, 0, 0).next();
tessellator.draw();
RenderSystem.enableTexture();
RenderSystem.shadeModel(7424);
RenderSystem.enableAlphaTest();
RenderSystem.disableBlend();
}
Aggregations