Java Code Examples for net.minecraft.client.renderer.GlStateManager#disablePolygonOffset()

The following examples show how to use net.minecraft.client.renderer.GlStateManager#disablePolygonOffset() . 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: LitematicaRenderer.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void renderSchematicOverlay()
{
    boolean invert = Hotkeys.INVERT_OVERLAY_RENDER_STATE.getKeybind().isKeybindHeld();

    if (Configs.Visuals.ENABLE_SCHEMATIC_OVERLAY.getBooleanValue() != invert)
    {
        boolean renderThrough = Configs.Visuals.SCHEMATIC_OVERLAY_RENDER_THROUGH.getBooleanValue() || Hotkeys.RENDER_OVERLAY_THROUGH_BLOCKS.getKeybind().isKeybindHeld();
        float lineWidth = (float) (renderThrough ? Configs.Visuals.SCHEMATIC_OVERLAY_OUTLINE_WIDTH_THROUGH.getDoubleValue() : Configs.Visuals.SCHEMATIC_OVERLAY_OUTLINE_WIDTH.getDoubleValue());

        GlStateManager.pushMatrix();
        GlStateManager.disableTexture2D();
        GlStateManager.disableCull();
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.001F);
        GlStateManager.enablePolygonOffset();
        GlStateManager.doPolygonOffset(-0.4f, -0.8f);
        fi.dy.masa.malilib.render.RenderUtils.setupBlend();
        GlStateManager.glLineWidth(lineWidth);
        fi.dy.masa.malilib.render.RenderUtils.color(1f, 1f, 1f, 1f);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);

        if (renderThrough)
        {
            GlStateManager.disableDepth();
        }

        this.getWorldRenderer().renderBlockOverlays();

        GlStateManager.enableDepth();
        GlStateManager.doPolygonOffset(0f, 0f);
        GlStateManager.disablePolygonOffset();
        GlStateManager.enableTexture2D();
        GlStateManager.popMatrix();
    }
}
 
Example 2
Source File: LitematicaRenderer.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void piecewiseRenderSolid(boolean renderColliding, float partialTicks)
{
    if (this.renderPiecewiseBlocks)
    {
        this.mc.profiler.startSection("litematica_blocks_solid");

        if (renderColliding)
        {
            GlStateManager.enablePolygonOffset();
            GlStateManager.doPolygonOffset(-0.3f, -0.6f);
        }

        this.startShaderIfEnabled();

        this.getWorldRenderer().renderBlockLayer(BlockRenderLayer.SOLID, partialTicks, this.entity);

        this.disableShader();

        if (renderColliding)
        {
            GlStateManager.doPolygonOffset(0f, 0f);
            GlStateManager.disablePolygonOffset();
        }

        this.mc.profiler.endSection();
    }
}
 
Example 3
Source File: LitematicaRenderer.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void piecewiseRenderCutoutMipped(boolean renderColliding, float partialTicks)
{
    if (this.renderPiecewiseBlocks)
    {
        this.mc.profiler.startSection("litematica_blocks_cutout_mipped");

        if (renderColliding)
        {
            GlStateManager.enablePolygonOffset();
            GlStateManager.doPolygonOffset(-0.3f, -0.6f);
        }

        this.startShaderIfEnabled();

        this.getWorldRenderer().renderBlockLayer(BlockRenderLayer.CUTOUT_MIPPED, partialTicks, this.entity);

        this.disableShader();

        if (renderColliding)
        {
            GlStateManager.doPolygonOffset(0f, 0f);
            GlStateManager.disablePolygonOffset();
        }

        this.mc.profiler.endSection();
    }
}
 
Example 4
Source File: LitematicaRenderer.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void piecewiseRenderCutout(boolean renderColliding, float partialTicks)
{
    if (this.renderPiecewiseBlocks)
    {
        this.mc.profiler.startSection("litematica_blocks_cutout");

        if (renderColliding)
        {
            GlStateManager.enablePolygonOffset();
            GlStateManager.doPolygonOffset(-0.3f, -0.6f);
        }

        this.startShaderIfEnabled();

        this.getWorldRenderer().renderBlockLayer(BlockRenderLayer.CUTOUT, partialTicks, this.entity);

        this.disableShader();

        if (renderColliding)
        {
            GlStateManager.doPolygonOffset(0f, 0f);
            GlStateManager.disablePolygonOffset();
        }

        this.mc.profiler.endSection();
    }
}
 
Example 5
Source File: PhasedBlockRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void finishRender(BufferBuilder buffer) {
	Tessellator.getInstance().draw();
	buffer.setTranslation(0, 0, 0);

	GlStateManager.glBlendEquation(GL14.GL_FUNC_ADD);
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
	GlStateManager.depthMask(true);

	GlStateManager.disablePolygonOffset();
	GlStateManager.enableDepth();
	GlStateManager.enableTexture2D();
}
 
Example 6
Source File: TESRBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void renderText(String text, double x, double y, double z, EnumFacing side, EnumFacing barrelFront)
{
    FontRenderer fontRenderer = this.mc.fontRenderer;
    int strLenHalved = fontRenderer.getStringWidth(text) / 2;

    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);

    if (side == EnumFacing.UP || side == EnumFacing.DOWN)
    {
        GlStateManager.rotate(LABEL_ROT_SIDE_Y[barrelFront.getIndex()], 0, 1, 0);
        GlStateManager.rotate(90f * side.getYOffset(), 1, 0, 0);
    }
    else
    {
        GlStateManager.rotate(LABEL_ROT_SIDE_Y[side.getIndex()], 0, 1, 0);
    }

    GlStateManager.translate(0, 0.48, 0);
    GlStateManager.scale(-0.01F, -0.01F, 0.01F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    GlStateManager.disableLighting();
    GlStateManager.enablePolygonOffset();
    GlStateManager.depthMask(false);
    GlStateManager.enableBlend();
    GlStateManager.doPolygonOffset(-1, -20);

    this.getFontRenderer().drawString(text, -strLenHalved, 0, 0xFFFFFFFF);

    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
    GlStateManager.disablePolygonOffset();
    GlStateManager.enableLighting();

    GlStateManager.popMatrix();
}
 
Example 7
Source File: WrapperGlStateManager.java    From ClientBase with MIT License 4 votes vote down vote up
public static void disablePolygonOffset() {
    GlStateManager.disablePolygonOffset();
}
 
Example 8
Source File: LitematicaRenderer.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void piecewiseRenderTranslucent(boolean renderColliding, float partialTicks)
{
    if (this.renderPiecewisePrepared)
    {
        if (this.renderPiecewiseBlocks)
        {
            this.mc.profiler.startSection("litematica_translucent");

            if (renderColliding)
            {
                GlStateManager.enablePolygonOffset();
                GlStateManager.doPolygonOffset(-0.3f, -0.6f);
            }

            this.startShaderIfEnabled();

            this.getWorldRenderer().renderBlockLayer(BlockRenderLayer.TRANSLUCENT, partialTicks, this.entity);

            this.disableShader();

            if (renderColliding)
            {
                GlStateManager.doPolygonOffset(0f, 0f);
                GlStateManager.disablePolygonOffset();
            }

            this.mc.profiler.endSection();
        }

        if (this.renderPiecewiseSchematic)
        {
            this.mc.profiler.startSection("litematica_overlay");

            this.renderSchematicOverlay();

            this.mc.profiler.endSection();
        }

        this.cleanup();
    }
}
 
Example 9
Source File: ChamsMod.java    From ForgeHax with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onPostRenderLiving(RenderLivingEvent.Post event) {
  GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
  GlStateManager.doPolygonOffset(1.0F, 1000000);
  GlStateManager.disablePolygonOffset();
}
 
Example 10
Source File: StructureManager.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Will not draw the structure if it is not already baked. Resource reloading will re-bake if required.
 *
 * @param alpha    The transparency of the rendered structure.
 * @param location The ResourceLocation of the structure to look up.
 */
@SideOnly(Side.CLIENT)
public void draw(ResourceLocation location, float alpha) {
	HashMap<Integer, int[]> cache = vboCache.get(location);

	if (cache == null || cache.isEmpty()) {
		bake(location);
		return;
	}

	GlStateManager.pushMatrix();
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GlStateManager.enablePolygonOffset();
	GlStateManager.doPolygonOffset(1f, -0.05f);
	//	GlStateManager.disableDepth();

	int alphaFunc = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC);
	float alphaRef = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF);
	GlStateManager.alphaFunc(GL11.GL_ALWAYS, 1);

	Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

	Tessellator tes = Tessellator.getInstance();
	BufferBuilder buffer = tes.getBuffer();

	for (int layerID : cache.keySet()) {

		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
		buffer.addVertexData(cache.get(layerID));

		for (int i = 0; i < buffer.getVertexCount(); i++) {
			buffer.putColorRGBA(buffer.getColorIndex(i), 255, 255, 255, (int) (alpha * 255));
		}

		tes.draw();
	}

	GlStateManager.alphaFunc(alphaFunc, alphaRef);
	//	GlStateManager.enableDepth();
	GlStateManager.disablePolygonOffset();
	GlStateManager.color(1F, 1F, 1F, 1F);
	GlStateManager.popMatrix();
}
 
Example 11
Source File: TESRBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void renderStack(ItemStack stack, double posX, double posY, double posZ, EnumFacing side, EnumFacing barrelFront)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate(posX, posY, posZ);

    if (side == EnumFacing.UP || side == EnumFacing.DOWN)
    {
        GlStateManager.rotate(MODEL_ROT_SIDE_Y[barrelFront.getIndex()], 0, 1, 0);
        GlStateManager.rotate(-90f * side.getYOffset(), 1, 0, 0);
    }
    else
    {
        GlStateManager.rotate(MODEL_ROT_SIDE_Y[side.getIndex()], 0, 1, 0);
    }

    //GlStateManager.translate(-0.25, 0.2, 0); // This offset is currently added to the renderItemIntoGUI arguments
    GlStateManager.scale(0.55f, 0.55f, 1);

    if (this.renderItem.shouldRenderItemIn3D(stack))
    {
        GlStateManager.scale(1 / 16f, -1 / 16f, 0.0001);
    }
    else
    {
        GlStateManager.scale(1 / 16f, -1 / 16f, 0.01);
        GlStateManager.translate(0, 0, -100);
    }

    // The following rendering stuff within this method has been taken from Storage Drawers by jaquadro, found here:
    // https://github.com/jaquadro/StorageDrawers/blob/e5719be6d64f757a1b58c25e8ca5bc64074c6b9e/src/com/jaquadro/minecraft/storagedrawers/client/renderer/TileEntityDrawersRenderer.java#L180

    // At the time GL_LIGHT* are configured, the coordinates are transformed by the modelview
    // matrix. The transformations used in `RenderHelper.enableGUIStandardItemLighting` are
    // suitable for the orthographic projection used by GUI windows, but they are just a little
    // bit off when rendering a block in 3D and squishing it flat. An additional term is added
    // to account for slightly different shading on the half-size "icons" in 1x2 and 2x2
    // drawers due to the extreme angles caused by flattening the block (as noted below).

    GlStateManager.pushMatrix();
    GlStateManager.scale(2.6f, 2.6f, 1);
    GlStateManager.rotate(171.6f, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(84.9f, 1.0F, 0.0F, 0.0F);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();

    // TileEntitySkullRenderer alters both of these options on, but does not restore them.
    GlStateManager.enableCull();
    // This extra enable toggle is to fix a render glitch with items in Item Frames on screen,
    // and then hovering over a stack in an inventory... Rendering... always lovely...
    GlStateManager.enableRescaleNormal();
    GlStateManager.disableRescaleNormal();

    // GL_POLYGON_OFFSET is used to offset flat icons toward the viewer (-Z) in screen space,
    // so they always appear on top of the drawer's front space.
    GlStateManager.enablePolygonOffset();
    GlStateManager.doPolygonOffset(-1, -1);

    // DIRTY HACK: Fool GlStateManager into thinking GL_RESCALE_NORMAL is enabled, but disable
    // it using popAttrib This prevents RenderItem from enabling it again.
    //
    // Normals are transformed by the inverse of the modelview and projection matrices that
    // excludes the translate terms. When put through the extreme Z scale used to flatten the
    // block, this makes them point away from the drawer face at a very sharp angle. These
    // normals are no longer unit scale (normalized), and normalizing them via
    // GL_RESCALE_NORMAL causes a loss of precision that results in the normals pointing
    // directly away from the face, which is visible as the block faces having identical
    // (dark) shading.

    GlStateManager.pushAttrib();
    GlStateManager.enableRescaleNormal();
    GlStateManager.popAttrib();

    this.renderItem.renderItemIntoGUI(stack, -8, -7);

    GlStateManager.disableBlend(); // Clean up after RenderItem
    GlStateManager.enableAlpha();  // Restore world render state after RenderItem
    GlStateManager.disablePolygonOffset();

    GlStateManager.popMatrix();
}
 
Example 12
Source File: RenderPrimedCharge.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
public void doRender(EntityPrimedCharge entity, double x, double y, double z, float p_76986_8_, float partialTicks) {

  BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
  GlStateManager.pushMatrix();
  GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
  float f2;

  if ((float) entity.fuse - partialTicks + 1.0F < 10.0F) {
    f2 = 1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 10.0F;
    f2 = MathHelper.clamp(f2, 0.0F, 1.0F);
    f2 *= f2;
    f2 *= f2;
    float f3 = 1.0F + f2 * 0.3F;
    GlStateManager.scale(f3, f3, f3);
  }

  f2 = (1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
  this.bindEntityTexture(entity);
  GlStateManager.translate(-0.5F, -0.5F, 0.5F);
  blockrendererdispatcher.renderBlockBrightness(entity.getBlock().getDefaultState(), entity.getBrightness());
  GlStateManager.translate(0.0F, 0.0F, 1.0F);

  if (entity.fuse / 5 % 2 == 0) {
    GlStateManager.disableTexture2D();
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 772);
    GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
    GlStateManager.doPolygonOffset(-3.0F, -3.0F);
    GlStateManager.enablePolygonOffset();
    blockrendererdispatcher.renderBlockBrightness(entity.getBlock().getDefaultState(), 1.0F);
    GlStateManager.doPolygonOffset(0.0F, 0.0F);
    GlStateManager.disablePolygonOffset();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableBlend();
    GlStateManager.enableLighting();
    GlStateManager.enableTexture2D();
  }

  GlStateManager.popMatrix();
  super.doRender(entity, x, y, z, p_76986_8_, partialTicks);
}