Jump to content

Recommended Posts

Posted

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.

Posted

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?

Posted

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

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