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,13 +9,9 @@ public:
|
|||
array = {};
|
||||
}
|
||||
|
||||
T& get(const int32_t x, const int32_t y) {
|
||||
return array[y * Width + x];
|
||||
decltype(auto) operator[](this auto& self, const int32_t x, const int32_t y) {
|
||||
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;
|
||||
}
|
||||
|
||||
colors.get(x, y) = glm::vec4(chosen_display, 1.0f);
|
||||
colors[x, y] = glm::vec4(chosen_display, 1.0f);
|
||||
|
||||
image_dirty = true;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ void dump_to_file() {
|
|||
int i = 0;
|
||||
for (int32_t y = height - 1; y >= 0; y--) {
|
||||
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.g;
|
||||
pixels[i++] = c.b;
|
||||
|
|
Loading…
Add table
Reference in a new issue