summary refs log tree commit diff
path: root/src/Util/ImageViewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Util/ImageViewer.cpp')
-rw-r--r--src/Util/ImageViewer.cpp68
1 files changed, 8 insertions, 60 deletions
diff --git a/src/Util/ImageViewer.cpp b/src/Util/ImageViewer.cpp
index 4c78750..05d316c 100644
--- a/src/Util/ImageViewer.cpp
+++ b/src/Util/ImageViewer.cpp
@@ -1,38 +1,15 @@
-#include <GL/glew.h>
 #include "ImageViewer.hpp"
-#include "../Math/MVP.hpp"
 
 namespace MC::Util {
 
-ImageViewer::ImageViewer(
-        const GFX::Image::RawImage& image,
-        Real window_aspect
-) : m_texture(image),
-    m_program(
-        {GFX::Shading::Shader::Type::Vertex, vertex},
-        {GFX::Shading::Shader::Type::Fragment, fragment}
-    ),
-    m_mesh(create_mesh(window_aspect, image.width(), image.height())) {
-    m_program.bind();
-    auto model_uniform = m_program.uniform("model_matrix");
-    auto view_uniform = m_program.uniform("view_matrix");
-    auto projection_uniform = m_program.uniform("projection_matrix");
-
-    model_uniform.set(Math::MVP::model<F32>({}, Vector<3>::one(), {}));
-    view_uniform.set(Math::MVP::view<F32>({}, {}));
-    projection_uniform.set(Math::MVP::orthographic_projection<F32>(view_size * window_aspect, view_size, 0.0f, 100.0f));
-
-    m_program.unbind();
-}
-
-void ImageViewer::render() {
-    m_program.bind();
-    m_texture.bind();
-    m_mesh.bind();
-    glDrawElements(GL_TRIANGLES, m_mesh.size(), GL_UNSIGNED_INT, nullptr);
-    m_mesh.unbind();
-    m_texture.unbind();
-    m_program.unbind();
+void ImageViewer::render(GFX::Actions& actions) {
+    // TODO: Re-add texture support
+    // TODO: Add orthographic camera support
+    actions.add({
+        .program = GFX::Resources::Program::ImageViewer,
+        .mesh = &m_mesh,
+        .transform = Transform(),
+    });
 }
 
 GFX::Mesh ImageViewer::create_mesh(Real window_aspect, U32 image_width, U32 image_height) {
@@ -60,33 +37,4 @@ GFX::Mesh ImageViewer::create_mesh(Real window_aspect, U32 image_width, U32 imag
     }, {0, 1, 2, 0, 2, 3}};
 }
 
-const Char* ImageViewer::vertex = R"v(
-#version 330 core
-
-uniform mat4 model_matrix;
-uniform mat4 view_matrix;
-uniform mat4 projection_matrix;
-
-layout (location = 0) in vec3 position;
-layout (location = 1) in vec2 tex_coord;
-
-out vec2 frag_tex_coord;
-
-void main() {
-    gl_Position = projection_matrix * view_matrix * model_matrix * vec4(position, 1.0);
-    frag_tex_coord = tex_coord;
-})v";
-
-const Char* ImageViewer::fragment = R"f(
-#version 330 core
-
-uniform sampler2D image;
-
-in vec2 frag_tex_coord;
-out vec4 color;
-
-void main() {
-    color = texture(image, frag_tex_coord);
-})f";
-
 }
\ No newline at end of file