Optimized SDL_RenderDrawCircle.

Change mouse warping strategy in hidden test cheat.
This commit is contained in:
Muzychenko Andrey committed 2022-05-27 13:54:36 +03:00
1 parent 4183e7f0bf
commit cfe2691892
3 files changed
+42 -18

No files matched your search

+24 -12
View File
@@ -21,6 +21,8 @@ gdrv_bitmap8* DebugOverlay::dbScreen = nullptr;
static int SDL_RenderDrawCircle(SDL_Renderer* renderer, int x, int y, int radius)
{
SDL_Point points[256];
int pointCount = 0;
int offsetx, offsety, d;
int status;
@@ -29,21 +31,28 @@ static int SDL_RenderDrawCircle(SDL_Renderer* renderer, int x, int y, int radius
d = radius - 1;
status = 0;
while (offsety >= offsetx) {
status += SDL_RenderDrawPoint(renderer, x + offsetx, y + offsety);
status += SDL_RenderDrawPoint(renderer, x + offsety, y + offsetx);
status += SDL_RenderDrawPoint(renderer, x - offsetx, y + offsety);
status += SDL_RenderDrawPoint(renderer, x - offsety, y + offsetx);
status += SDL_RenderDrawPoint(renderer, x + offsetx, y - offsety);
status += SDL_RenderDrawPoint(renderer, x + offsety, y - offsetx);
status += SDL_RenderDrawPoint(renderer, x - offsetx, y - offsety);
status += SDL_RenderDrawPoint(renderer, x - offsety, y - offsetx);
while (offsety >= offsetx)
{
if (pointCount + 8 > 256)
{
status = SDL_RenderDrawPoints(renderer, points, pointCount);
pointCount = 0;
if (status < 0) {
status = -1;
break;
if (status < 0) {
status = -1;
break;
}
}
points[pointCount++] = { x + offsetx, y + offsety };
points[pointCount++] = { x + offsety, y + offsetx };
points[pointCount++] = { x - offsetx, y + offsety };
points[pointCount++] = { x - offsety, y + offsetx };
points[pointCount++] = { x + offsetx, y - offsety };
points[pointCount++] = { x + offsety, y - offsetx };
points[pointCount++] = { x - offsetx, y - offsety };
points[pointCount++] = { x - offsety, y - offsetx };
if (d >= 2 * offsetx) {
d -= 2 * offsetx + 1;
offsetx += 1;
@@ -59,6 +68,9 @@ static int SDL_RenderDrawCircle(SDL_Renderer* renderer, int x, int y, int radius
}
}
if (pointCount > 0)
status = SDL_RenderDrawPoints(renderer, points, pointCount);
return status;
}