43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
|
|
#ifndef RENDERTARGET_H
|
|
#define RENDERTARGET_H
|
|
|
|
#include "fastmath.hpp"
|
|
class Rendertarget {
|
|
|
|
public:
|
|
const int width;
|
|
const int height;
|
|
|
|
Rendertarget(int width, int height) : width(width), height(height) {
|
|
pixels = new decimal[width * height * 3];
|
|
depth = new decimal[width * height];
|
|
}
|
|
|
|
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];
|
|
}
|
|
}
|
|
decimal getDepth(int x, int y) { return depth[width * y + x]; }
|
|
void setDepth(int x, int y, decimal val) { depth[width * y + x] = val; }
|
|
|
|
void clearDepth() {
|
|
for (int i = 0; i < width * height; i++) {
|
|
depth[i].i = std::numeric_limits<int32_t>::max();
|
|
}
|
|
}
|
|
|
|
decimal *pixels;
|
|
decimal *depth;
|
|
};
|
|
|
|
#endif
|