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

The following examples show how to use com.mojang.blaze3d.systems.RenderSystem#enableTexture() . 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: ScreenDrawing.java    From LibGui with MIT License 6 votes vote down vote up
/**
 * Draws an untextured rectangle of the specified RGB color.
 */
public static void coloredRect(int left, int top, int width, int height, int color) {
	if (width <= 0) width = 1;
	if (height <= 0) height = 1;

	float a = (color >> 24 & 255) / 255.0F;
	float r = (color >> 16 & 255) / 255.0F;
	float g = (color >> 8 & 255) / 255.0F;
	float b = (color & 255) / 255.0F;
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder buffer = tessellator.getBuffer();
	RenderSystem.enableBlend();
	RenderSystem.disableTexture();
	RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
	buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR); //I thought GL_QUADS was deprecated but okay, sure.
	buffer.vertex(left,         top + height, 0.0D).color(r, g, b, a).next();
	buffer.vertex(left + width, top + height, 0.0D).color(r, g, b, a).next();
	buffer.vertex(left + width, top,          0.0D).color(r, g, b, a).next();
	buffer.vertex(left,         top,          0.0D).color(r, g, b, a).next();
	tessellator.draw();
	RenderSystem.enableTexture();
	RenderSystem.disableBlend();
}
 
Example 2
Source File: WTextField.java    From LibGui with MIT License 6 votes vote down vote up
@Environment(EnvType.CLIENT)
private void invertedRect(int x, int y, int width, int height) {
	Tessellator tessellator_1 = Tessellator.getInstance();
	BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
	RenderSystem.color4f(0.0F, 0.0F, 255.0F, 255.0F);
	RenderSystem.disableTexture();
	RenderSystem.enableColorLogicOp();
	RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
	bufferBuilder_1.begin(GL11.GL_QUADS, VertexFormats.POSITION);
	bufferBuilder_1.vertex(x,       y+height, 0.0D).next();
	bufferBuilder_1.vertex(x+width, y+height, 0.0D).next();
	bufferBuilder_1.vertex(x+width, y,        0.0D).next();
	bufferBuilder_1.vertex(x,       y,        0.0D).next();
	tessellator_1.draw();
	RenderSystem.disableColorLogicOp();
	RenderSystem.enableTexture();
}
 
Example 3
Source File: ToggleButton.java    From MiningGadgets with MIT License 6 votes vote down vote up
@Override
public void renderButton(int p_renderButton_1_, int p_renderButton_2_, float p_renderButton_3_) {
    Color activeColor = this.enabled ? Color.GREEN : Color.RED;

    RenderSystem.enableBlend();
    RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA.param, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA.param, GlStateManager.SourceFactor.ONE.param, GlStateManager.DestFactor.ZERO.param);
    RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA.param, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA.param);

    RenderSystem.disableTexture();
    RenderSystem.color4f(activeColor.getRed() / 255f, activeColor.getGreen() / 255f, activeColor.getBlue() / 255f, this.enabled ? .4f : .6f);
    blit(this.x, this.y, 0, 0, this.width, this.height);
    RenderSystem.enableTexture();

    RenderSystem.color4f(1f, 1f, 1f, 1f);
    Minecraft.getInstance().getTextureManager().bindTexture(texture);
    blit(this.x +2, this.y + 5, 0, 0, 16, 16, 16, 16);
}
 
Example 4
Source File: GuiAddBlock.java    From XRay-Mod with GNU General Public License v3.0 6 votes vote down vote up
static void renderPreview(int x, int y, float r, float g, float b) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder tessellate = tessellator.getBuffer();
    RenderSystem.enableBlend();
    RenderSystem.disableTexture();
    RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    RenderSystem.color4f(r/255, g/255, b/255, 1);
    tessellate.begin(7, DefaultVertexFormats.POSITION);
    tessellate.pos(x, y, 0.0D).endVertex();
    tessellate.pos(x, y + 45, 0.0D).endVertex();
    tessellate.pos(x + 202, y + 45, 0.0D).endVertex();
    tessellate.pos(x + 202, y, 0.0D).endVertex();
    tessellator.draw();
    RenderSystem.enableTexture();
    RenderSystem.disableBlend();
}
 
Example 5
Source File: SpaceRaceScreen.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
private static void fillSolid(Matrix4f matrix, int x1, int y1, int x2, int y2, int color) {
    int j;
    if (x1 < x2) {
        j = x1;
        x1 = x2;
        x2 = j;
    }

    if (y1 < y2) {
        j = y1;
        y1 = y2;
        y2 = j;
    }

    float f = (float) (color >> 24 & 255) / 255.0F;
    float g = (float) (color >> 16 & 255) / 255.0F;
    float h = (float) (color >> 8 & 255) / 255.0F;
    float k = (float) (color & 255) / 255.0F;
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    RenderSystem.disableBlend();
    RenderSystem.disableTexture();
    RenderSystem.defaultBlendFunc();
    bufferBuilder.begin(7, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(matrix, (float) x1, (float) y2, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(g, h, k, f).next();
    bufferBuilder.end();
    BufferRenderer.draw(bufferBuilder);
    RenderSystem.enableTexture();
}
 
Example 6
Source File: MiningSettingScreen.java    From MiningGadgets with MIT License 5 votes vote down vote up
@Override
public void renderButton(int p_renderButton_1_, int p_renderButton_2_, float p_renderButton_3_) {
    RenderSystem.disableTexture();
    RenderSystem.color4f(.4f, .4f, .4f, 1f);
    this.blit(this.x, this.y, 0, 0, this.width, this.height);

    if( this.isWhitelist )
        RenderSystem.color4f(1f, 1f, 1f, 1f);
    else
        RenderSystem.color4f(0f, 0f, 0f, 1f);

    this.blit(this.x + 2, this.y + 2, 0, 0, this.width-4, this.height-4);
    RenderSystem.enableTexture();
}
 
Example 7
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 8
Source File: ListWidget.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
protected void renderList(MatrixStack matrixStack, int i, int j, int k,
	int l, float f)
{
	int m = getItemCount();
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder bufferBuilder = tessellator.getBuffer();
	
	for(int n = 0; n < m; ++n)
	{
		int o = j + n * itemHeight + headerHeight;
		int p = itemHeight - 4;
		if(o > bottom || o + p < top)
			updateItemPosition(n, i, o, f);
		
		if(renderSelection && isSelectedItem(n))
		{
			int q = left + width / 2 - getRowWidth() / 2;
			int r = left + width / 2 + getRowWidth() / 2;
			RenderSystem.disableTexture();
			float g = isFocused() ? 1.0F : 0.5F;
			RenderSystem.color4f(g, g, g, 1.0F);
			bufferBuilder.begin(7, VertexFormats.POSITION);
			bufferBuilder.vertex(q, o + p + 2, 0.0D).next();
			bufferBuilder.vertex(r, o + p + 2, 0.0D).next();
			bufferBuilder.vertex(r, o - 2, 0.0D).next();
			bufferBuilder.vertex(q, o - 2, 0.0D).next();
			tessellator.draw();
			RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F);
			bufferBuilder.begin(7, VertexFormats.POSITION);
			bufferBuilder.vertex(q + 1, o + p + 1, 0.0D).next();
			bufferBuilder.vertex(r - 1, o + p + 1, 0.0D).next();
			bufferBuilder.vertex(r - 1, o - 1, 0.0D).next();
			bufferBuilder.vertex(q + 1, o - 1, 0.0D).next();
			tessellator.draw();
			RenderSystem.enableTexture();
		}
		
		renderItem(matrixStack, n, i, o, p, k, l, f);
	}
	
}
 
Example 9
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 10
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();
}