Jump to content

[1.8.9] I need help drawing a box using WorldRenderer


61352151511

Recommended Posts

I've tried every DefaultVertexFormat and none of them seem to work, I'm just trying to accomplish the simple goal of drawing a half transparent square. Any help and explanation is appreciated so I know for the future.

 

@Override public void drawScreen(int mouseX, int mouseY, float partialTicks) {
	Tessellator tessellator = Tessellator.getInstance();
	WorldRenderer worldRenderer = tessellator.getWorldRenderer();
	GlStateManager.color(1F, 1F, 1F, 1F);
	worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
	worldRenderer.pos(200, 20, this.zLevel).color(0, 0, 0, 0.5F).endVertex();
	worldRenderer.pos(20, 20, this.zLevel).color(0, 0, 0, 0.5F).endVertex();
	worldRenderer.pos(200, 200, this.zLevel).color(0, 0, 0, 0.5F).endVertex();
	worldRenderer.pos(20, 200, this.zLevel).color(0, 0, 0, 0.5F).endVertex();
	tessellator.draw();
	super.drawScreen(mouseX, mouseY, partialTicks);
}

Link to comment
Share on other sites

Well, you want mode 7 because that's GL11.GL_QUADS which is squares.

 

Your problem is likely that you're trying to draw this square at a location in the world* and it's huge.  Also note that a quad is only visible from one side.  In this case, the north side.  If you're trying to draw to pixel locations on the screen,* then it would be pointed away from the camera.

 

*I'll admit that I'm not entirely sure what getWorldRenderer() does.

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.

Link to comment
Share on other sites

Yea Gui rendering changed a lot from 1.8 - > 1.8.8/1.8.9 Although the class is called "WorldRenderer" it is also used for things such as GUIs, I've looked at vanilla code and this is the method for drawBackground

 

    public void drawBackground(int tint)
    {
        GlStateManager.disableLighting();
        GlStateManager.disableFog();
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        this.mc.getTextureManager().bindTexture(optionsBackground);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        float f = 32.0F;
        worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldrenderer.pos(0.0D, (double)this.height, 0.0D).tex(0.0D, (double)((float)this.height / 32.0F + (float)tint)).color(64, 64, 64, 255).endVertex();
        worldrenderer.pos((double)this.width, (double)this.height, 0.0D).tex((double)((float)this.width / 32.0F), (double)((float)this.height / 32.0F + (float)tint)).color(64, 64, 64, 255).endVertex();
        worldrenderer.pos((double)this.width, 0.0D, 0.0D).tex((double)((float)this.width / 32.0F), (double)tint).color(64, 64, 64, 255).endVertex();
        worldrenderer.pos(0.0D, 0.0D, 0.0D).tex(0.0D, (double)tint).color(64, 64, 64, 255).endVertex();
        tessellator.draw();
    }

 

So I don't need .tex as my GUI element isn't textured. Like I don't see much difference in the two. If you can think of a case in vanilla where just a box is drawn on screen without a texture, I'll take a look at that (I also looked at tooltips yet that didn't seem to help either)

 

Edit: I probably should have searched more before giving up. I scrolled through the Gui class and there's a drawRect static method that takes 4 corners and a color.

Link to comment
Share on other sites

Yea Gui rendering changed a lot from 1.8 - > 1.8.8/1.8.9 Although the class is called "WorldRenderer" it is also used for things such as GUIs

 

Some of the names MCP has given things are just weird.

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.

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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