Posted December 20, 201410 yr I have a working GUI that draws to the screen just fine, but it renders in front of the chat instead of behind. What should I do? Image: Code: GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1, 1, 1, 1); ResourceLocation r = new ResourceLocation(Reference.PREFIX + "textures/gui/armorBar.png"); res = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); int x = (res.getScaledWidth() / 2) - 11; int y = res.getScaledHeight() - 49; GL11.glPushMatrix(); Minecraft.getMinecraft().getTextureManager().bindTexture(r); Util.drawTexturedModalRect(x, y, 0, 0, 9, 9); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_BLEND); I can show other code if you wish. Lead DivineRPG Developer
December 20, 201410 yr Drawing is step-by-step procedure, it's literally like placing layer over layer - 1st one executed will be on bottom, second on top of it. Where and how are you calling this renderer? 1.7.10 is no longer supported by forge, you are on your own.
December 20, 201410 yr Author I figured that was the case. I just don't know what to change to fix that. The function is being called with the RenderGameOverlayEvent which is being called in the ClientProxy in the preInit. Lead DivineRPG Developer
December 20, 201410 yr Author I actually tried to do that earlier but I don't know how to set an ElementType. Lead DivineRPG Developer
January 12, 201510 yr Author Okay so, kinda forgot about this, but what ever I tried, it didn't fix the problem. public void renderOverlay(RenderGameOverlayEvent event){ if(event.isCanceled() || event.type != ElementType.EXPERIENCE) return; if((EventArmorTick.size != 0) && !Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) { //gui.drawArmor(); } } Tried ElementType.Armor and some others. Nothing worked. Tried RenderGameOverlayEvent.Pre with and without event.isCanceled() Am I doing something wrong? Using recommended (1230) forge by the way. Lead DivineRPG Developer
January 12, 201510 yr Author Using Pre was just a suggestion by someone helping me. I've also tried using Post. Lead DivineRPG Developer
January 12, 201510 yr Author Well it's the exact same as shown but with the changed event. Do I need to change something? public void renderOverlay(RenderGameOverlayEvent.Post event){ if(event.isCanceled() || event.type != ElementType.EXPERIENCE) return; if((EventArmorTick.size != 0) && !Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) { gui.drawArmor(); } } Lead DivineRPG Developer
January 12, 201510 yr Author Oh, if I replace gui.drawArmor() with a drawString method like you did, it draws behind the chat. So it's not the event that's the problem it's drawArmor(). (drawArmor() can be seen in the OP) Lead DivineRPG Developer
January 13, 201510 yr Author Oh that's slightly outdated code. GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glColor4f(1, 1, 1, 1); ResourceLocation r = new ResourceLocation(Reference.PREFIX + "textures/gui/armorBar.png"); res = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); int x = (res.getScaledWidth() / 2) - 11; int y = res.getScaledHeight() - 49; switch(EventArmorTick.size) { case 1: Minecraft.getMinecraft().getTextureManager().bindTexture(r); Util.drawTexturedModalRect(x, y, 0, 0, 9, 9); break; } GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); Here's drawTexturedModalRect. Pretty sure this is the same as the normal drawTexturedModalRect, I don't remember why I added it. public static void drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6) { float f = 0.00390625F; float f1 = 0.00390625F; Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + par6), 1D, (double)((float)(par3 + 0) * f), (double)((float)(par4 + par6) * f1)); tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + par6), 1D, (double)((float)(par3 + par5) * f), (double)((float)(par4 + par6) * f1)); tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + 0), 1D, (double)((float)(par3 + par5) * f), (double)((float)(par4 + 0) * f1)); tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), 1D, (double)((float)(par3 + 0) * f), (double)((float)(par4 + 0) * f1)); tessellator.draw(); } Lead DivineRPG Developer
January 13, 201510 yr Author I need the glColor because if I don't have it, the new GUI changes colors depending on other renders I added to the screen. I believe that I need to other gl stuff for the glColor to work. Lead DivineRPG Developer
January 13, 201510 yr Author That is very true . In my defence though, I wrote the function without the gl stuff but the color problem presented itself, and I asked someome helping me if they knew how to fix it. They did. Lead DivineRPG Developer
January 13, 201510 yr If you know what glPushMatrix() and glPopMatrix() do, glPushAttrib(ALL_ATTRIB_BITS ) and glPopAttrib() are similar, but they work with most blending options, lighting changes, etc. Edit: After taking another look at your code, I'm guessing you don't exactly know what glPushMatrix() and glPopMatrix() do, since you don't have any transformations in between those two lines. glPopMatrix() resets any OpenGL transforms ( glScale , glTranslate , glRotate ) that you do after the corresponding glPushMatrix() call. Since you don't have any transforms, you don't actually need to push/pop the matrix. Also, it's better practice to make your ResourceLocation s static and final (and away from any other OpenGL code), since it's unlikely that they will be changing during your rendering. You don't want to make a new ResourceLocation every frame when you only need to make one at the beginning. Here are two documented examples of modifying the overlay that might help you (the GUI overlay doesn't really change between 1.8 and 1.7): https://github.com/Nephroid1/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/overlay_simple https://github.com/Nephroid1/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/overlay_advanced GitHub|Recipe API Proposal
January 14, 201510 yr Author @diesieben07 Removed all the gl stuff, didn't work. @Nephroid Will take a look. (For the record, I did do the static final, but I didn't copy it to this forum) Edit: Thanks for the examples. I understand a lot better now. I don't think it helps me with my problem though. Lead DivineRPG Developer
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.