Posted March 18, 201411 yr Hey Guys! I wanted to create a renderer for a tile entity to show a title for the Block. The Problem is that the plain face is just rendered black and the water can be seen through it. Why? (PS: The normal block isn't opaque, but I don't think that's the error) @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float var8) { String title = ((TileEntityReadableBookshelf)te).bookTitle; Main.logPlainText(" " + title); FontRenderer fontrenderer = this.func_147498_b(); GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 0.75F, (float)z + 0.5F); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(Minecraft.getMinecraft().thePlayer.rotationYawHead, 0, 1, 0); GL11.glTranslatef(0.0F, 0.0F, -0.75F); GL11.glNormal3f(0.0F, 0.0F, 1.0F); GL11.glScalef(0.03F, 0.03F, 0.03F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int i = fontrenderer.getStringWidth(title) / 2; tessellator.setColorOpaque(255, 0, 0); //Seems to have no effect! tessellator.addVertex(-i - 1, -1.0D, 0.0D); tessellator.addVertex(-i - 1, 8.0D, 0.0D); tessellator.addVertex(i + 1, 8.0D, 0.0D); tessellator.addVertex(i + 1, -1.0D, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); //Also no effect! fontrenderer.drawString(title, -fontrenderer.getStringWidth(title) / 2, 0, 16777215); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
March 18, 201411 yr Hi If you want the face to be opaque, you should turn off BLEND before rendering. i.e. GL11.glDisable(GL11.GL_BLEND); You probably also don't want to disable the depth mask before rendering the face, otherwise entities that are behind the face might render over the top of it if they're drawn afterwards. GL11.glDepthMask(true); -TGG
March 19, 201411 yr Author OK, I changed this, but the Face is still rendered black, although I set GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
March 19, 201411 yr Author I just copied the code from the rendering of Entity names. @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float var8) { String title = ((TileEntityReadableBookshelf)te).bookTitle; FontRenderer fontrenderer = this.func_147498_b(); GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 0.75F, (float)z + 0.5F); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(Minecraft.getMinecraft().thePlayer.rotationYawHead, 0, 1, 0); GL11.glTranslatef(0.0F, 0.0F, -0.75F); GL11.glNormal3f(0.0F, 0.0F, 1.0F); GL11.glScalef(0.03F, 0.03F, 0.03F); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); Tessellator tessellator = Tessellator.instance; byte b0 = 0; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int j = fontrenderer.getStringWidth(title) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex(-j - 1, -1 + b0, 0.0D); tessellator.addVertex(-j - 1, 8 + b0, 0.0D); tessellator.addVertex(j + 1, 8 + b0, 0.0D); tessellator.addVertex(j + 1, -1 + b0, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); fontrenderer.drawString(title, -fontrenderer.getStringWidth(title) / 2, b0, 553648127); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); fontrenderer.drawString(title, -fontrenderer.getStringWidth(title) / 2, b0, -1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } This is the effect: http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
March 19, 201411 yr Before the line GL11.glEnable(GL11.GL_ALPHA_TEST); put this piece of code inside: int bright = 0xF0; int brightX = bright % 65536; int brightY = bright / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX, brightY); It should brighten your render stuff up. The bright integer can range from 0x00 (complete darkness) to 0xF0 (complete brightness). If it doesn't work, put it before tessellator.startDrawingQuads(); Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
March 19, 201411 yr Author Before the line GL11.glEnable(GL11.GL_ALPHA_TEST); put this piece of code inside: int bright = 0xF0; int brightX = bright % 65536; int brightY = bright / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX, brightY); It should brighten your render stuff up. The bright integer can range from 0x00 (complete darkness) to 0xF0 (complete brightness). If it doesn't work, put it before tessellator.startDrawingQuads(); Works fine ! Thanks! http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
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.