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 just need to draw a filled circle, that's it, but I can't find anything helpful online. Everything I tried doesn't work. :(

I'm inside the drawScreen method of a GuiScreen class.

  • Author

Yes, I know, but I need to draw it in slices of different colors and I have a dynamic number of slices.

I really can't find anything on the new renderer class.

I really can't find anything on the new renderer class.

 

I mean, why do you care? WorldRenderer is just a wrapper for FEW GL methods.

If you want anything fancy you need to use GL directly (google is really your friend).

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Ok, looks like the problem was another one.

I came up with this:

private static final double twicePI = Math.PI*2;
private static void drawCircle(double x, double y, int radius, int slices)
{
	GL11.glBegin(GL11.GL_TRIANGLE_FAN);
	GL11.glVertex2d(x, y);
	for(int i = 0; i <= slices;i++) 
	{
		GL11.glVertex2d(x + (radius * Math.cos(i *  twicePI / slices)), y + (radius * Math.sin(i * twicePI / slices)));
	}
	GL11.glEnd();
}

This should render a filled circle, centered at (x,y), but i doesn't render anything.

 

If i replace "GL_TRIANGLE_FAN" with "GL_TRIANGLE_STRIPES" and I add "GlStateManager.disableTexture2D();" before I get something, but it's not what i want.

 

Am I forgetting anything?

  • Author

Ok, I fixed the code, now it finally works.

I'll post it, just in case anybody needs it.

public static final double TWICE_PI = Math.PI*2;	
private static Tessellator tessellator = Tessellator.getInstance();
private static WorldRenderer worldRenderer = tessellator.getWorldRenderer();
public static void drawRegularPolygon(double x, double y, int radius, int sides)
{
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    worldRenderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION);
    worldRenderer.pos(x, y, 0).endVertex();
    
for(int i = 0; i <= sides ;i++) 
{
	double angle = (TWICE_PI * i / sides) + Math.toRadians(180);
	worldRenderer.pos(x + Math.sin(angle) * radius, y + Math.cos(angle) * radius, 0).endVertex();
}
    tessellator.draw();
    
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}

This will draw a regular polygon with <sides>sides. If you set it high enough, obviosly, you will get a circle.

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.