Java Code Examples for com.mojang.blaze3d.systems.RenderSystem#enableDepthTest()

The following examples show how to use com.mojang.blaze3d.systems.RenderSystem#enableDepthTest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WItem.java    From LibGui with MIT License 5 votes vote down vote up
@Environment(EnvType.CLIENT)
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
	RenderSystem.enableDepthTest();

	MinecraftClient mc = MinecraftClient.getInstance();
	ItemRenderer renderer = mc.getItemRenderer();
	renderer.zOffset = 100f;
	renderer.renderInGui(items.get(current), x + getWidth() / 2 - 9, y + getHeight() / 2 - 9);
	renderer.zOffset = 0f;
}
 
Example 2
Source File: Render.java    From XRay-Mod with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void clean()
{
    RenderSystem.polygonMode( GL_FRONT_AND_BACK, GL_FILL );
    RenderSystem.disableBlend();
    RenderSystem.enableDepthTest();
    RenderSystem.depthMask( true );
    RenderSystem.enableTexture();
}
 
Example 3
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 4 votes vote down vote up
public void render(Camera camera, float partialTick)
{
    IWorld iWorld = this.client.world;
    DimensionType dimensionType = iWorld.getDimension().getType();
    if (shapes.get(dimensionType) == null || shapes.get(dimensionType).isEmpty()) return;
    long currentTime = client.world.getTime();
    RenderSystem.disableTexture();
    RenderSystem.enableDepthTest();
    RenderSystem.depthFunc(515);
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    //RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
    //RenderSystem.shadeModel(7425);
    RenderSystem.shadeModel(GL11.GL_FLAT);
    RenderSystem.enableAlphaTest();
    RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003f);
    RenderSystem.disableCull();
    RenderSystem.disableLighting();
    RenderSystem.depthMask(false);
    //RenderSystem.polygonOffset(-3f, -3f);
    //RenderSystem.enablePolygonOffset();
    //Entity entity = this.client.gameRenderer.getCamera().getFocusedEntity();

    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();

    // render
    double cameraX = camera.getPos().x;
    double cameraY = camera.getPos().y;
    double cameraZ = camera.getPos().z;

    synchronized (shapes)
    {
        shapes.get(dimensionType).long2ObjectEntrySet().removeIf(
                entry -> entry.getValue().isExpired(currentTime)
        );
        shapes.get(dimensionType).values().forEach(
                s ->
                {
                    if ( s.shouldRender(dimensionType))
                        s.renderFaces(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
                }
        );
        //lines
        shapes.get(dimensionType).values().forEach(

                s -> {
                    if ( s.shouldRender(dimensionType))
                        s.renderLines(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
                }
        );
    }
    RenderSystem.enableCull();
    RenderSystem.depthMask(true);
    RenderSystem.lineWidth(1.0F);
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.enableTexture();
    RenderSystem.shadeModel(7424);
}
 
Example 4
Source File: RenderMiningLaser.java    From MiningGadgets with MIT License 4 votes vote down vote up
private static void drawLasers(RenderWorldLastEvent event, Vec3d from, RayTraceResult trace, double xOffset, double yOffset, double zOffset, float r, float g, float b, float thickness, PlayerEntity player, float ticks, float speedModifier) {
    Hand activeHand;
    if (player.getHeldItemMainhand().getItem() instanceof MiningGadget) {
        activeHand = Hand.MAIN_HAND;
    } else if (player.getHeldItemOffhand().getItem() instanceof MiningGadget) {
        activeHand = Hand.OFF_HAND;
    } else {
        return;
    }

    ItemStack stack = player.getHeldItem(activeHand);

    double distance = from.subtract(trace.getHitVec()).length();
    long gameTime = player.world.getGameTime();
    double v = gameTime * speedModifier;
    float additiveThickness = (thickness * 3.5f) * calculateLaserFlickerModifier(gameTime);
    BufferBuilder wr = Tessellator.getInstance().getBuffer();

    Vec3d view = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();

    MatrixStack matrix = event.getMatrixStack();
    matrix.translate(view.getX(), view.getY(), view.getZ());
    if( trace.getType() == RayTraceResult.Type.MISS )
        matrix.translate(-from.x, -from.y, -from.z);

    RenderSystem.pushMatrix();
    RenderSystem.multMatrix(matrix.getLast().getMatrix());

    RenderSystem.enableColorMaterial();
    // This makes it so we don't clip into the world, we're effectively drawing on it
    RenderSystem.disableDepthTest();
    RenderSystem.enableBlend();
    //This makes it so multiplayer doesn't matter which side the player is standing on to see someone elses laser
    RenderSystem.disableCull();
    RenderSystem.enableTexture();

    RenderSystem.rotatef(MathHelper.lerp(ticks, -player.rotationYaw, -player.prevRotationYaw), 0, 1, 0);
    RenderSystem.rotatef(MathHelper.lerp(ticks, player.rotationPitch, player.prevRotationPitch), 1, 0, 0);

    // additive laser beam
    RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    RenderSystem.color4f(r, g, b, 0.7f);
    Minecraft.getInstance().getTextureManager().bindTexture(laserBeamGlow);
    drawBeam(xOffset, yOffset, zOffset, additiveThickness, activeHand, distance, wr, 0.5, 1, ticks);

    // main laser, colored part
    RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    RenderSystem.color4f(r, g, b, 1.0f);
    Minecraft.getInstance().getTextureManager().bindTexture(laserBeam2);
    drawBeam(xOffset, yOffset, zOffset, thickness, activeHand, distance, wr, v, v + distance * 1.5, ticks);
    // white core
    RenderSystem.color4f(MiningProperties.getColor(stack, MiningProperties.COLOR_RED_INNER) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN_INNER) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE_INNER) / 255f, 1.0f);
    Minecraft.getInstance().getTextureManager().bindTexture(laserBeam);
    drawBeam(xOffset, yOffset, zOffset, thickness / 2, activeHand, distance, wr, v, v + distance * 1.5, ticks);

    RenderSystem.enableDepthTest();
    RenderSystem.enableCull();
    RenderSystem.popMatrix();
}
 
Example 5
Source File: ScreenDrawing.java    From LibGui with MIT License 3 votes vote down vote up
public static void maskedRect(Identifier mask, Identifier texture, int left, int top, int width, int height) {


		texturedRect(left, top, width, height, mask, 0, 0, 1, 1, 0xFFFFFFFF); //TODO: 7 Z

		RenderSystem.enableDepthTest();
		RenderSystem.depthFunc(GL11.GL_EQUAL);

		texturedRect(left, top, width, height, texture, 0, 0, 1, 1, 0xFFFFFFFF); //, 7);

		RenderSystem.depthFunc(GL11.GL_LESS);
		RenderSystem.disableDepthTest();
	}