C API: playdate->graphics->fillPolygon updates unexpected portions of the display

My setup is a follows:

  • C API
  • macOS 12.5
  • Playdate SDK Version 1.12.3 (140884)

Problem: I'm trying to limit the amount of unnecessary display updating. When rendering a polygon using playdate->graphics->fillPolygon, unexpected portions of the display are updated; specifically, everything to the "left" and "above" of the rendered polygon.

Some basic code that renders a poly:

int xOffset = 200;
int yOffset = 100;
int numPoints = 6;
int points[12] = {
    xOffset + 0, yOffset + 0,
    xOffset + 50, yOffset + 20,
    xOffset + 75, yOffset + 50,
    xOffset + 75, yOffset + 80,
    xOffset + 50, yOffset + 90,
    xOffset + 0, yOffset + 0
};
pd_gfx->fillPolygon(numPoints, points, kColorBlack, kPolygonFillNonZero);

For this example, it doesn't particularly matter what LCDPolygonFillRule is used, or what kind of shape is rendered -- the result is the same.

A screenshot with "Highlight Screen Updates" enabled:

  • Expected results: just the filled portion, or the bounding box of the polygon is updated

  • Actual results: the entirety of the screen to the left/above the polygon is updated


This may be an expected implementation detail for poly fills -- I'm not sure!

Is this a bug, or expected?

It's a bug. When I'm computing the update bounds there I'm starting with the "empty" rect (0,0,0,0) but then the following code thinks that means it include the point (0,0). :man_facepalming: Thanks for catching this!

2 Likes