Posted March 31, 20169 yr 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.
March 31, 20169 yr 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.
April 1, 20169 yr 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.
April 3, 20169 yr 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?
April 4, 20169 yr 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.