hello guys, i need your help with this.. i've been trying to render an arc in OpenGL but all i'm getting at always is an oval..
here is the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| private void renderArc(float x, float y, float width, float height, float start, float end, int cap) { float theta; float angle_increment; float x1; float y1;
angle_increment = (float) (2 * MathHelper.pi()) / 90; GL11.glPushMatrix();
GL11.glTranslatef(x + (width / 2), y + (height / 2), 0);
this.setProperties();
GL11.glBegin(cap); for (theta = start; theta < end + angle_increment; theta += angle_increment) { x1 = (float) ((width / 2) * Math.cos(theta)); y1 = (float) ((height / 2) * Math.sin(theta));
GL11.glVertex2f(x1, y1); } GL11.glEnd();
GL11.glPopMatrix();
GL11.glColor3f(1.0f, 1.0f, 1.0f); } |