Fixed whatever was wrong with my shader

This commit is contained in:
2022-12-05 19:27:32 -08:00
parent 8059158bae
commit 5b6f9124b5
21 changed files with 284 additions and 61 deletions

View File

@ -105,31 +105,25 @@ int main(int argc, char *argv[]) {
}
// Calculate division sizes (pixels)
float divX = (
(float)w - ((float)borderX * 2.0f) -
((float)gapX * ((float)cols - 1))
) / cols;
float divY = (
(float)h - ((float)borderY * 2.0f) -
((float)gapY * ((float)rows - 1))
) / rows;
int divX = (w - (borderX * 2) - (gapX * (cols - 1))) / cols;
int divY = (h - (borderY * 2) - (gapY * (rows - 1))) / rows;
// Calculate the division sizes (units)
float tdivX = divX / (float)w;
float tdivY = divY / (float)h;
float tdivX = (float)divX / (float)w;
float tdivY = (float)divY / (float)h;
// Output buffer prep
char *buffer = malloc(sizeof(char) * (cols * rows * 48 + 48 + 48));
buffer[0] = '\0';
sprintf(buffer, "%i|%i|", cols, rows);
sprintf(buffer, "%i|%i|%i|%i|", cols, rows, divX, divY);
// Now prep tileset.
for(int y = 0; y < rows; y++) {
for(int x = 0; x < cols; x++) {
float ux0 = (borderX + (divX * x) + (gapX * x)) / w;
float ux0 = (borderX + ((float)divX * x) + ((float)gapX * x)) / w;
float ux1 = ux0 + tdivX;
float uy0 = (borderY + (divY * y) + (gapY * y)) / h;
float uy0 = (borderY + ((float)divY * y) + ((float)gapY * y)) / h;
float uy1 = uy0 + tdivY;
sprintf(buffer, "%s%f,%f,%f,%f|", buffer, ux0, ux1, uy0, uy1);
}