fix: reduced ram usage

This commit is contained in:
2025-12-20 21:08:01 +01:00
parent beacb9a985
commit 09bc4d9326
2 changed files with 8 additions and 10 deletions

View File

@@ -98,7 +98,7 @@ int main(int argc, char *argv[]) {
std::function<void(int, uint32_t *)> addTo = [&target](int start,
uint32_t *arr) {
for (int c = 0; c < 3; c++) {
arr[c] += target.pixels[start + c].i >> SHIFT_AMOUNT;
arr[c] += target.pixels[start + c];
}
};

View File

@@ -10,22 +10,20 @@ class Rendertarget {
const int height;
Rendertarget(int width, int height) : width(width), height(height) {
pixels = new decimal[width * height * 3];
pixels = new uint8_t[width * height * 3];
depth = new decimal[width * height];
for (int i = 0; i < width * height * 3; i++) {
pixels[i] = 0;
}
}
void set(int x, int y, vec3 val) {
int start = (width * y + x) * 3;
for (int i = 0; i < 3; i++) {
pixels[start + i] = val[i];
}
}
void get(int x, int y, vec3 *val) {
int start = (width * y + x) * 3;
for (int i = 0; i < 3; i++) {
(*val)[i] = pixels[start + i];
pixels[start + i] = (uint8_t)(val[i].i >> SHIFT_AMOUNT);
}
}
decimal getDepth(int x, int y) { return depth[width * y + x]; }
void setDepth(int x, int y, decimal val) { depth[width * y + x] = val; }
@@ -35,7 +33,7 @@ class Rendertarget {
}
}
decimal *pixels;
uint8_t *pixels;
decimal *depth;
};