Jump to content

Recommended Posts

Posted

Hello,

 

I'm rendering a label above a block and all is working fine except that the label is kinda grayish and i would like to have it white.

 

Here is my code:

 

 

GL11.glPushMatrix();
            
				GL11.glTranslatef((float)x + 0.5F, (float)y + 1.2F, (float)z + 0.5F);
				GL11.glNormal3f(0, 1, 0);
				GL11.glRotatef(-RenderManager.instance.playerViewY, 0, 1, 0);
				GL11.glRotatef(RenderManager.instance.playerViewX, 1, 0, 0);
				GL11.glScalef(-0.016666668F, -0.016666668F, 0.016666668F);
				GL11.glDisable(GL11.GL_LIGHTING);
				GL11.glDepthMask(false);
				GL11.glDisable(GL11.GL_DEPTH_TEST);
				GL11.glEnable(GL11.GL_BLEND);
				GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
				GL11.glDisable(GL11.GL_TEXTURE_2D);				
				Tessellator.instance.startDrawingQuads();
				Tessellator.instance.setColorRGBA_F(0, 0, 0, 0.25F);
				Tessellator.instance.addVertex(-RenderManager.instance.getFontRenderer().getStringWidth(text) / 2 - 1, -1, 0);
				Tessellator.instance.addVertex(-RenderManager.instance.getFontRenderer().getStringWidth(text) / 2 - 1, 2 + 8 * lines, 0);
				Tessellator.instance.addVertex(RenderManager.instance.getFontRenderer().getStringWidth(text) / 2 + 1, 2 + 8 * lines, 0);
				Tessellator.instance.addVertex(RenderManager.instance.getFontRenderer().getStringWidth(text) / 2 + 1, -1, 0);
				Tessellator.instance.draw();
				GL11.glEnable(GL11.GL_TEXTURE_2D);
				RenderManager.instance.getFontRenderer().drawString(text, -RenderManager.instance.getFontRenderer().getStringWidth(text) / 2, 0 , 553648127);		
				GL11.glEnable(GL11.GL_DEPTH_TEST);
				GL11.glDepthMask(true);
				RenderManager.instance.getFontRenderer().drawString(text, -RenderManager.instance.getFontRenderer().getStringWidth(text) / 2, 0, -1);
				GL11.glEnable(GL11.GL_LIGHTING);
				GL11.glDisable(GL11.GL_BLEND);
				GL11.glColor4f(1, 1, 1, 1);
            
				GL11.glPopMatrix();

 

 

Here is a screenshot of what i mean:

 

width=800 height=640http://i.imagebanana.com/img/5dbg9j9j/20131114_15.15.10.png[/img]

 

I hope you can help and thanks in advance!

 

ss7

You sir are a god damn hero.

Posted

For shits and giggles, compare to the code I used:

 

Tessellator tessellator = Tessellator.instance;
         byte byte0 = 0;
         GL11.glDisable(3553);
         tessellator.disableColor();
         tessellator.startDrawingQuads();
         int j = fontrenderer.getStringWidth(s) / 2;
         tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.35F);
         tessellator.addVertex(-j - 1, -1 + byte0, 0.0D);
         tessellator.addVertex(-j - 1, 8 + byte0, 0.0D);
         tessellator.addVertex(j + 1, 8 + byte0, 0.0D);
         tessellator.addVertex(j + 1, -1 + byte0, 0.0D);
         tessellator.draw();
         //tessellator.func_78381_a();
         GL11.glEnable(3553);
         fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, byte0, 553648127);
         GL11.glEnable(2929);
         GL11.glDepthMask(true);
         fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, byte0, -1);
         GL11.glEnable(2896);
         GL11.glDisable(3042);
         GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
         GL11.glPopMatrix();

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Hello,

 

I tried it with the

tessellator.disableColor();

but that's making no difference. It's still gray. BTW: I tried my rendering code on the player name and there it's working fine and it's colored white, but not on a block.

 

ss7

You sir are a god damn hero.

Posted

Just a thought but try removing the,

GL11.glDisable(GL11.GL_LIGHTING); and GL11.glEnable(GL11.GL_LIGHTING);

 

It worked for some block render issues I had once so maybe it might work for you.

Posted

Hi

 

Maybe I misunderstand your code, but doesn't this line set your background colour to grey (opaque black?)

 

Tessellator.instance.setColorRGBA_F(0, 0, 0, 0.25F);

 

If you want a white background, you need

 

Tessellator.instance.setColorRGBA_F(1, 1, 1, 0.25F);  ?

 

-TGG

 

Posted

Hi

 

You render the text twice. Once for the shadow in darkgrey color. This is what you see because you enable the DEPTH_TEST before rendering the white overlay text. Try to move the DEPTH_TEST enabling after the second text rendering. Tip: you may translate the shadow with 1 pixel in each direction (glTranslatef(1F, 1F, 0F))

Sorry for my bad English!

FBalazs

Posted

@Machir

That's not working for me. ):

 

@TGG

Yes, you misunderstood me, i mean the text and not the rectangle behind it.

 

@FBalazs

I tried that, but it's also not working. Should i move only the DEPTH_TEST or also the DepthMask thingy?

The weird thing is, that the text is perfectly white if i replace the code of the name above the player with mine, it's just not working for blocks. BTW: I use a TESR for the rendering.

 

ss7

You sir are a god damn hero.

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.

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

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Please read the FAQ and post logs as described there.
    • Upon starting the server I get; [main/ERROR] [minecraft/Main]: Failed to start the minecraft server net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [     Framework (framework) has failed to load correctly §7java.lang.NoClassDefFoundError: net/minecraft/client/gui/components/toasts/Toast ] I suspect there is a (possibly a few) client-only mods installed on my server. Any help would be appreciated! (Yes I know there are a lot of mods...) Here is the crash log:   https://paste.ee/p/pRz5mhMl#s=0
    • That's basically what the failure does, my apologies for failing to specify.  It just tries again on the next tick until it detects the entities for that chunk are loaded, and then tries to load the entity.  From there it gets into different failure states depending on what goes wrong, but in short, if the entity fails to load once the entity list becomes available, the request is cleared and must be resubmitted by the end user.  There should be few cases where that actually happens. Yes, that is my understanding of forceloading.  That's why on a successful summon, it removes the forceload.  Otherwise it does just leave the chunks loaded long term. Thank you for your help, any knowledge is useful!  I don't often mess with forceloading and my prior experience is 1.16 so I'm also a bit out of my depth haha.
    • I will have to do more research about 1.18 chunk loading. You were unclear about how your code manages with the entity load failure. If you simply used a loop, I suggest submitting a tick task to the next tick which does the same thing, checking if the entities are loaded and if so teleporting the right one else submitting another tick task etc. Also I think forceloading permanently force loads the chunk, and it only starts to unload when you make a subsequent call to mark the chunk as not forceloaded. I may be completely wrong, I dont know much about 1.18, most of my experience is 1.20. Good luck I hope you figure it out after all this time 😅
    • i managed to fix it by reinstalling the modpack and re-add all the extra mods I've had previously.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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