Posted October 21, 20195 yr Hi, I have problem to draw texture overlay over block side. I am not familiar with OpenGL so I tried to look into other projects/mc source code, but without success. Currently I have this code in TER: private ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/block/machine_top.png"); @Override public void render(BoilerTile tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) { GlStateManager.pushMatrix(); bindTexture(texture); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); bufferbuilder.pos(x, y + 1.1, z + 1.0D).tex(0, 1).endVertex(); bufferbuilder.pos(x + 1.0D, y + 1.1, z + 1.0D).tex(1, 1).endVertex(); bufferbuilder.pos(x + 1.0D, y + 1.1, z).tex(1, 0).endVertex(); bufferbuilder.pos(x, y + 1.1, z).tex(0, 0).endVertex(); tessellator.draw(); GlStateManager.popMatrix(); } Results in this (texture is too dark): Can you please guide me how to draw texture overlay correctly? Edited October 21, 20195 yr by Yanny7
October 21, 20195 yr Author I got it working private ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/block/fluid_pipe.png"); @Override public void render(BoilerTile tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) { GlStateManager.pushMatrix(); GlStateManager.translated(x, y, z); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bindTexture(texture); RenderHelper.disableStandardItemLighting(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enableBlend(); GlStateManager.disableCull(); bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); bufferbuilder.pos(0, 1.1, 1).tex(0, 1).endVertex(); bufferbuilder.pos(1, 1.1, 1).tex(1, 1).endVertex(); bufferbuilder.pos(1, 1.1, 0).tex(1, 0).endVertex(); bufferbuilder.pos(0, 1.1, 0).tex(0, 0).endVertex(); tessellator.draw(); GlStateManager.enableCull(); GlStateManager.disableBlend(); RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); } and in Block class extends this: @Override public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT_MIPPED; }
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.