aboutsummaryrefslogtreecommitdiff
path: root/src/shaders/simple_shaders.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shaders/simple_shaders.cpp')
-rw-r--r--src/shaders/simple_shaders.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/shaders/simple_shaders.cpp b/src/shaders/simple_shaders.cpp
index ebbec31..af7bb79 100644
--- a/src/shaders/simple_shaders.cpp
+++ b/src/shaders/simple_shaders.cpp
@@ -1,10 +1,22 @@
#include "shaders/simple_shaders.hpp"
+#include <vector>
+#include <cstddef>
+#include <utility>
+#include "math/vector.hpp"
#include "math/mat4.hpp"
using namespace engine::shaders;
-using engine::math::Matrix4;
+using
+ engine::math::Vector4,
+ engine::math::Matrix4;
-SimpleShaders::SimpleShaders(int w, int h, unsigned char* pixels) : w { w }, h { h }, pixels { pixels } {
+SimpleShaders::SimpleShaders(int w, int h, unsigned char* pixels) : w { w }, h { h }, pixels {} {
+ this->pixels.reserve(w * h);
+ for (size_t i = 0; i < static_cast<std::size_t>(w * h); i++) {
+ [&]<std::size_t... j>(std::index_sequence<j...>) {
+ this->pixels.emplace_back(static_cast<float>(pixels[i * 4 + j]) / 255.f ...);
+ }(std::make_index_sequence<4> {});
+ }
}
void SimpleShaders::set_view(const Matrix4& view_mat, const Matrix4& proj_mat) {