Yea, what @Super Vegeta said.
Here is some code from my old engine. I got a little speed boost because DrawRect was HW accelerated and sin/cos is a lookup table. It worked well enough back then. Maybe this can give your more ideas as well.
Code:
procedure TPGRenderDevice.DrawCircle(aX, aY, aRadius: Single; aColor: Cardinal; aRenderState: TPGRenderState; aFilled: Boolean);
var
a : integer;
src: TPGVector3s;
dst: TPGVector3s;
dir: TPGVector3s;
begin
if aFilled then
begin
for a := 0 to 90 do
begin
dir.x := PG.Math.AngleCos(A) * aRadius;
dir.y := PG.Math.AngleSin(A) * aRadius;
src.x := ax - dir.x;
src.y := ay - dir.y;
dst.x := ax + dir.x;
dst.y := ay + dir.y;
PG.RenderDevice.DrawRect(src.x, src.y, dst.x-src.x, dst.y-src.y, aColor, aRenderState);
end;
end
else
begin
for a := 0 to 180 do
begin
dir.x := PG.Math.AngleCos(A) * aRadius;
dir.y := PG.Math.AngleSin(A) * aRadius;
src.x := ax - dir.x;
src.y := ay - dir.y;
dst.x := ax + dir.x;
dst.y := ay + dir.y;
PG.RenderDevice.DrawRect(src.x, src.y, 1, 1, aColor, aRenderState);
PG.RenderDevice.DrawRect(dst.x, dst.y, 1, 1, aColor, aRenderState);
end;
end;
end;
Bookmarks