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

The following examples show how to use com.mojang.blaze3d.systems.RenderSystem#popMatrix() . 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: Render.java    From XRay-Mod with GNU General Public License v3.0 7 votes vote down vote up
static void renderBlocks(RenderWorldLastEvent event) {
       Vector3d view = XRay.mc.gameRenderer.getActiveRenderInfo().getProjectedView();

       MatrixStack stack = event.getMatrixStack();
       stack.translate(-view.x, -view.y, -view.z); // translate

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

       Tessellator tessellator = Tessellator.getInstance();
       BufferBuilder buffer = tessellator.getBuffer();
       Profile.BLOCKS.apply(); // Sets GL state for block drawing

       syncRenderList.forEach(blockProps -> {
           buffer.begin( GL_LINES, DefaultVertexFormats.POSITION_COLOR );
           renderBlockBounding(buffer, blockProps);
           tessellator.draw();
       } );

       Profile.BLOCKS.clean();
       RenderSystem.popMatrix();
}
 
Example 2
Source File: HallowedLoadingScreen.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
public void render(int mouseX, int mouseY, float delta) {
	renderDirtBackground(0);
	this.drawCenteredString(font, I18n.translate(message), width / 2, height / 2 - 50, 0xFFFFFF);
	
	float scale = 100f;
	RenderSystem.pushMatrix();
	RenderSystem.translatef(width / 2f, height / 2f + 65 + MathHelper.sin(floatingTick / 6.5f) * 25, 500f);
	RenderSystem.scalef(scale, scale, scale);
	RenderSystem.rotatef(180, 1, 0, 0);
	RenderSystem.rotatef(rotation, 0, 1, 0);
	
	minecraft.getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
	minecraft.getItemRenderer().renderGuiItem(pumpkinStack, 0, 0);
	
	RenderSystem.popMatrix();
}
 
Example 3
Source File: GuiBase.java    From XRay-Mod with GNU General Public License v3.0 6 votes vote down vote up
public static void drawTexturedQuadFit(double x, double y, double width, double height, int[] color, float alpha)
{
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder tessellate = tessellator.getBuffer();

    RenderSystem.pushMatrix();
    tessellate.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);

    if ( color != null )
        RenderSystem.color4f((float) color[0] / 255, (float) color[1] / 255, (float) color[2] / 255, alpha / 255);

    tessellate.pos(x + 0, y + height, (double) 0).tex( 0,1).endVertex();
    tessellate.pos(x + width, y + height, (double) 0).tex( 1, 1).endVertex();
    tessellate.pos(x + width, y + 0, (double) 0).tex( 1,0).endVertex();
    tessellate.pos(x + 0, y + 0, (double) 0).tex( 0, 0).endVertex();
    tessellator.draw();

    RenderSystem.popMatrix();
}
 
Example 4
Source File: RenderCustomEndPortal.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
@SuppressWarnings ("deprecation")
public void setupRenderState() {
    state.renderStates.forEach(RenderState::setupRenderState);
    RenderSystem.disableLighting();
    RenderSystem.pushMatrix();//Apply stack here.
    mat.glApply();
    RenderSystem.pushMatrix();
    GlStateManager.translated(projectedView.x, f11, projectedView.z);
    GlStateManager.texGenMode(GlStateManager.TexGen.S, GL11.GL_OBJECT_LINEAR);
    GlStateManager.texGenMode(GlStateManager.TexGen.T, GL11.GL_OBJECT_LINEAR);
    GlStateManager.texGenMode(GlStateManager.TexGen.R, GL11.GL_OBJECT_LINEAR);
    GlStateManager.texGenMode(GlStateManager.TexGen.Q, GL11.GL_EYE_LINEAR);
    GlStateManager.texGenParam(GlStateManager.TexGen.S, GL11.GL_OBJECT_PLANE, bufferTexData(1.0F, 0.0F, 0.0F, 0.0F));
    GlStateManager.texGenParam(GlStateManager.TexGen.T, GL11.GL_OBJECT_PLANE, bufferTexData(0.0F, 0.0F, 1.0F, 0.0F));
    GlStateManager.texGenParam(GlStateManager.TexGen.R, GL11.GL_OBJECT_PLANE, bufferTexData(0.0F, 0.0F, 0.0F, 1.0F));
    GlStateManager.texGenParam(GlStateManager.TexGen.Q, GL11.GL_EYE_PLANE, bufferTexData(0.0F, 1.0F, 0.0F, 0.0F));
    GlStateManager.enableTexGen(GlStateManager.TexGen.S);
    GlStateManager.enableTexGen(GlStateManager.TexGen.T);
    GlStateManager.enableTexGen(GlStateManager.TexGen.R);
    GlStateManager.enableTexGen(GlStateManager.TexGen.Q);
    RenderSystem.popMatrix();
    RenderSystem.matrixMode(GL11.GL_TEXTURE);
    RenderSystem.pushMatrix();
    RenderSystem.loadIdentity();
    RenderSystem.translatef(0.0F, System.currentTimeMillis() % 700000L / 700000F, 0.0F);
    RenderSystem.scalef(f6, f6, f6);
    RenderSystem.translatef(0.5F, 0.5F, 0.0F);
    RenderSystem.rotatef((idx * idx * 4321 + idx * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
    RenderSystem.translatef(-0.5F, -0.5F, 0.0F);
    RenderSystem.translated(-projectedView.x, -projectedView.z, -projectedView.y);
    float f92 = f8 + (float) projectedView.y;
    RenderSystem.translated((projectedView.x * f5) / f92, (projectedView.z * f5) / f92, -projectedView.y + 20);
}
 
Example 5
Source File: RenderCustomEndPortal.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
@SuppressWarnings ("deprecation")
public void clearRenderState() {
    RenderSystem.popMatrix();
    RenderSystem.matrixMode(GL11.GL_MODELVIEW);
    RenderSystem.popMatrix();//Pop stack here.
    GlStateManager.disableTexGen(GlStateManager.TexGen.S);
    GlStateManager.disableTexGen(GlStateManager.TexGen.T);
    GlStateManager.disableTexGen(GlStateManager.TexGen.R);
    GlStateManager.disableTexGen(GlStateManager.TexGen.Q);
    state.renderStates.forEach(RenderState::clearRenderState);
}
 
Example 6
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 7
Source File: VBORenderType.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void clearRenderState() {
    RenderSystem.popMatrix();
    states.forEach(RenderState::clearRenderState);
    super.clearRenderState();
}