Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.10.2] Rendering fading out item in HUD


P3pp3rF1y
 Share

Recommended Posts

I am looking for an example of code that renders item into hud and uses alpha channel to how much transparent it is. Ultimately want to add a bit of code that fades the item out of HUD after a bit of time.

 

When I just need to render item into GUI I use RenderItem.renderItemIntoGUI, but that internally renders it with alpha set to 1f so I will need to get part of its code to render my item semi transparently. However in trying this out I wasn't able to figure out what exactly.

I made sure that enableBlend is called, passed value of less than 1f to alpha parameter of color method and messed around with blendFunc parameters, but wasn't able to figure this out.

I used RenderItem.renderItem to render the item in GUI, which in my tries would either get me the 1f alpha channel item in HUD or a glow in the shape of the item (definitely not the transparent one).

 

I guess this is likely very easy for someone with more opengl knowledge than I have.

 

Would you be able to point me to an example of code that does this? Or point out the OpenGL commands that need to be run to achieve semi transparent item in HUD?

 

Link to comment
Share on other sites

Vazkii does fairly simple stuff.

 

		GlStateManager.pushMatrix();
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GlStateManager.color(1F, 1F, 1F, alpha);
	mc.renderEngine.bindTexture(autojumpEnabled ? AUTOJUMP_ON : AUTOJUMP_OFF);
	Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, 32, 32, 32, 32);
	GlStateManager.popMatrix();

 

I have tried this combination with the exception of replacing Gui.drawModalRectWithCustomSizedTexture with RenderItem.renderItem as I can't simply draw a texture because the item has tint indexes that colors get applied to. Based on this I guess something in the renderItem is messing the transparency rendering.

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.

Guest
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.