Posted November 14, 201311 yr 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: http://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.
November 14, 201311 yr 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.
November 16, 201311 yr Author 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.
November 16, 201311 yr 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.
November 16, 201311 yr 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
November 16, 201311 yr 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
November 16, 201311 yr Author @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.