Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);
}

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.

  • Author

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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.