Back to sanity for bufi

This commit is contained in:
Carlos Sanchez 2024-07-22 21:01:14 -04:00
parent 32c37b8a7d
commit 59de3e28ea

8
main.c
View File

@ -58,25 +58,19 @@ void drawTexInto(struct texture tex, struct texture buffer, struct rect texbound
i32 stepy = 256 * (float)texheight / outheight;
i32 texx = 256 * texbounds.x1;
i32 texy = 256 * texbounds.y1;
i32 bufy = 3 * (bufbounds.x1 + bufbounds.y1 * buffer.width);
i32 bufyinc = 3 * buffer.width;
i32 bufi = bufy;
//log("%f,%f step %f,%f", texx, texy, stepx, stepy);
// Buffer is R G B for each pixel, then across then down. If you want X, Y,
// it's: 3 * (x + y * width)
for(int y = bufbounds.y1; y < bufbounds.y2; y++) {
texx = texbounds.x1;
bufi = bufy;
for(int x = bufbounds.x1; x < bufbounds.x2; x++) {
i32 texi = 3 * ((texx >> 8) + tex.width * (texy >> 8));
i32 bufi = 3 * (x + y * buffer.width);
memcpy(buffer.data + bufi, tex.data + texi, 3);
texx += stepx;
bufi += 3;
}
texy += stepy;
bufy += bufyinc;
}
}