From 9ffce1697f9f9317ac712dbd0520622bd04c82e6 Mon Sep 17 00:00:00 2001 From: Ruixiang Du Date: Sat, 2 Nov 2024 20:16:02 +0800 Subject: [PATCH] [wip] shaders --- src/imview/CMakeLists.txt | 5 ++- .../include/imview/widget/details/shader.hpp | 44 +++++++++++++++++++ src/imview/src/widget/details/shader.cpp | 11 +++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 src/imview/include/imview/widget/details/shader.hpp create mode 100644 src/imview/src/widget/details/shader.cpp diff --git a/src/imview/CMakeLists.txt b/src/imview/CMakeLists.txt index 7f7a671..fa93889 100644 --- a/src/imview/CMakeLists.txt +++ b/src/imview/CMakeLists.txt @@ -22,10 +22,9 @@ add_library(imview src/fonts.cpp src/scene_object.cpp src/panel.cpp - ${AUTO_LAYOUT_SRC} src/layer.cpp + ${AUTO_LAYOUT_SRC} # src/popup.cpp - src/buffer/scrolling_plot_buffer.cpp # utils src/utils/image_utils.cpp # widgets @@ -37,8 +36,10 @@ add_library(imview src/widget/rt_line_plot_widget.cpp src/widget/gl_scene_widget.cpp src/widget/details/gl_frame_buffer.cpp + src/widget/details/shader.cpp # data buffer src/buffer/buffer_registry.cpp + src/buffer/scrolling_plot_buffer.cpp # event handling src/event/event_dispatcher.cpp src/event/async_event_dispatcher.cpp diff --git a/src/imview/include/imview/widget/details/shader.hpp b/src/imview/include/imview/widget/details/shader.hpp new file mode 100644 index 0000000..1b3f8eb --- /dev/null +++ b/src/imview/include/imview/widget/details/shader.hpp @@ -0,0 +1,44 @@ +/* + * @file shader.hpp + * @date 11/2/24 + * @brief + * + * @copyright Copyright (c) 2024 Ruixiang Du (rdu) + */ + +#ifndef XMOTION_SHADER_HPP +#define XMOTION_SHADER_HPP + +#include +#include + +#include + +#include "glad/glad.h" + +namespace quickviz { +class Shader { + public: + enum class Type { + kUnknown = 0, + kVertex, + kFragment, + }; + + public: + Shader(const std::string& source, Type type); + ~Shader(); + + // public methods + void Compile(); + GLuint GetShaderID() const { return shader_id_; } + + private: + std::string LoadSourceFile(const std::string& file_path); + + GLuint shader_id_; + Type type_; +}; +} // namespace quickviz + +#endif // XMOTION_SHADER_HPP \ No newline at end of file diff --git a/src/imview/src/widget/details/shader.cpp b/src/imview/src/widget/details/shader.cpp new file mode 100644 index 0000000..cedcbd0 --- /dev/null +++ b/src/imview/src/widget/details/shader.cpp @@ -0,0 +1,11 @@ +/* + * @file shader.cpp + * @date 11/2/24 + * @brief + * + * @copyright Copyright (c) 2024 Ruixiang Du (rdu) + */ + +#include "imview/widget/details/shader.hpp" + +namespace quickviz {} // namespace quickviz \ No newline at end of file