Jump to content

[1.7.10] Drawing Text With Alpha [SOLVED]


Recommended Posts



I have a double (ranges from 0 to 1) that represents my alpha channel, and then I use the GL11#glColor4d method to change the alpha channel. Afterwards, my text is drawn.


The problem is the translucency of the text drawn never changes. The first time it gets drawn it should be barely visible, but instead it looks like it has no alpha channel.



	Minecraft mc = MCUtil.getMC();
	ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
	int y = (sr.getScaledHeight() / 4) - (CHAR_HEIGHT * (text.size() - 1)), x = sr.getScaledWidth() / 2;


	GL11.glAlphaFunc(GL11.GL_GREATER, 0.002F);
	GL11.glColor4d(1D, 1D, 1D, alpha);

	for(String s : text) {
		RenderUtil.drawString(s, x - (getTextWidth(s) / 2), y, 0xFFFFFF);




Edit: I switched to using bit operations to attach an alpha to the hex colors.

	int hexAlpha = (int) (255 * alpha) << 24, c1 = 0xFFFF00, c2 = 0x000000;
	c1 += hexAlpha;
	c2 += hexAlpha;


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.