polygon function
Implementation
int polygon(Pointer<SdlRenderer> renderer, Pointer<Int16> vx, Pointer<Int16> vy,
int n) {
/*
* Draw
*/
int result = 0;
int i, nn;
/*
* Vertex array NULL check
*/
if (vx == nullptr) {
return (-1);
}
if (vy == nullptr) {
return (-1);
}
/*
* Sanity check
*/
if (n < 3) {
return (-1);
}
/*
* Create array of points
*/
nn = n + 1;
var points = calloc<SdlPoint>(nn);
// points = (SDL_Point*)malloc(sizeof(SDL_Point) * nn);
if (points == nullptr) {
return -1;
}
for (i = 0; i < n; i++) {
points[i].x = vx[i];
points[i].y = vy[i];
}
points[n].x = vx[0];
points[n].y = vy[0];
/*
* Draw
*/
result |= sdlRenderDrawLines(renderer, points, nn);
calloc.free(points);
return (result);
}