diff --git a/.clangd b/.clangd index 4ae1f41..9dcba43 100644 --- a/.clangd +++ b/.clangd @@ -1,3 +1,6 @@ +If: + OS: Windows + CompileFlags: Add: --target=x86_64-w64-mingw32 \ No newline at end of file diff --git a/main.cpp b/main.cpp index 65bd161..510b208 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,7 @@ #include "lopenglprogram.h" #include "camera.h" #include +#include #include #include #include @@ -10,9 +11,7 @@ #include #include #include -#include -#include - +#include class GLWidget { @@ -55,6 +54,9 @@ public: if (heatmapVbo_) { glDeleteBuffers(1, &heatmapVbo_); } + if (heatmapIbo_) { + glDeleteBuffers(1, &heatmapIbo_); + } deinit_ = true; } @@ -224,7 +226,30 @@ private: } void initHeatmapGeometry_() { + if (heatmapIbo_) { + glDeleteBuffers(1, &heatmapIbo_); + heatmapIbo_ = 0; + } + if (heatmapVbo_) { + glDeleteBuffers(1, &heatmapVbo_); + heatmapVbo_ = 0; + } + if (heatmapVao_) { + glDeleteVertexArrays(1, &heatmapVao_); + heatmapVao_ = 0; + } + const float aspect = (panelWidth_ > 1e-6F) ? (panelHeight_ / panelWidth_) : 1.0F; + const int max_res = 512; + const int cols = std::max(2, std::min(dotcols_ * dotupscale_, max_res)); + int rows = std::max(2, int(cols * aspect + 0.5F)); + rows = std::max(2, std::min(rows, max_res)); + heatmapcols_ = cols; + heatmaprows_ = rows; + + const int vertex_count = cols * rows; + std::vector verts; + } bool initBgProgram() { @@ -483,6 +508,7 @@ private: std::string heatmapFragShaderPath_; unsigned int heatmapVao_ = 0; unsigned int heatmapVbo_ = 0; + unsigned int heatmapIbo_ = 0; ViewPort viewport_{800, 600}; Camera camera_{glm::vec3(0.0F, 0.0F, 2.0F)}; @@ -493,6 +519,12 @@ private: float lastFrame_ = 0.0f; bool lightMode_ = false; + int dotcols_ = 8; + int dotrows_ = 12; + int dotupscale_ = 100; + int heatmapcols_; + int heatmaprows_; + bool deinit_; };