Use a multi-dimensional subscript operator
This commit is contained in:
parent
a844a5c2d7
commit
475fd8fe90
2 changed files with 5 additions and 9 deletions
|
@ -9,12 +9,8 @@ public:
|
||||||
array = {};
|
array = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
T& get(const int32_t x, const int32_t y) {
|
decltype(auto) operator[](this auto& self, const int32_t x, const int32_t y) {
|
||||||
return array[y * Width + x];
|
return self.array[y * Width + x];
|
||||||
}
|
|
||||||
|
|
||||||
T get(const int32_t x, const int32_t y) const {
|
|
||||||
return array[y * Width + x];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<T, Width * Height> array = {};
|
std::array<T, Width * Height> array = {};
|
||||||
|
|
|
@ -74,7 +74,7 @@ bool calculate_tile(const int32_t from_x, const int32_t to_width, const int32_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
colors.get(x, y) = glm::vec4(chosen_display, 1.0f);
|
colors[x, y] = glm::vec4(chosen_display, 1.0f);
|
||||||
|
|
||||||
image_dirty = true;
|
image_dirty = true;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ void dump_to_file() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (int32_t y = height - 1; y >= 0; y--) {
|
for (int32_t y = height - 1; y >= 0; y--) {
|
||||||
for (int32_t x = 0; x < width; x++) {
|
for (int32_t x = 0; x < width; x++) {
|
||||||
const glm::ivec4 c = colors.get(x, y);
|
const glm::ivec4 c = colors[x, y];
|
||||||
pixels[i++] = c.r;
|
pixels[i++] = c.r;
|
||||||
pixels[i++] = c.g;
|
pixels[i++] = c.g;
|
||||||
pixels[i++] = c.b;
|
pixels[i++] = c.b;
|
||||||
|
|
Loading…
Add table
Reference in a new issue