This commit is contained in:
2026-02-28 17:06:52 +08:00
parent 8a4058e7d1
commit db0fd98e4f
2 changed files with 38 additions and 3 deletions

View File

@@ -1,3 +1,6 @@
If:
OS: Windows
CompileFlags: CompileFlags:
Add: Add:
--target=x86_64-w64-mingw32 --target=x86_64-w64-mingw32

View File

@@ -1,6 +1,7 @@
#include "lopenglprogram.h" #include "lopenglprogram.h"
#include "camera.h" #include "camera.h"
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <algorithm>
#include <functional> #include <functional>
#include <glm/ext/matrix_clip_space.hpp> #include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/matrix_transform.hpp> #include <glm/ext/matrix_transform.hpp>
@@ -10,9 +11,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <tuple> #include <tuple>
#include <utility> #include <vector>
#include <print>
class GLWidget { class GLWidget {
@@ -55,6 +54,9 @@ public:
if (heatmapVbo_) { if (heatmapVbo_) {
glDeleteBuffers(1, &heatmapVbo_); glDeleteBuffers(1, &heatmapVbo_);
} }
if (heatmapIbo_) {
glDeleteBuffers(1, &heatmapIbo_);
}
deinit_ = true; deinit_ = true;
} }
@@ -224,7 +226,30 @@ private:
} }
void initHeatmapGeometry_() { 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<float> verts;
} }
bool initBgProgram() { bool initBgProgram() {
@@ -483,6 +508,7 @@ private:
std::string heatmapFragShaderPath_; std::string heatmapFragShaderPath_;
unsigned int heatmapVao_ = 0; unsigned int heatmapVao_ = 0;
unsigned int heatmapVbo_ = 0; unsigned int heatmapVbo_ = 0;
unsigned int heatmapIbo_ = 0;
ViewPort viewport_{800, 600}; ViewPort viewport_{800, 600};
Camera camera_{glm::vec3(0.0F, 0.0F, 2.0F)}; Camera camera_{glm::vec3(0.0F, 0.0F, 2.0F)};
@@ -493,6 +519,12 @@ private:
float lastFrame_ = 0.0f; float lastFrame_ = 0.0f;
bool lightMode_ = false; bool lightMode_ = false;
int dotcols_ = 8;
int dotrows_ = 12;
int dotupscale_ = 100;
int heatmapcols_;
int heatmaprows_;
bool deinit_; bool deinit_;
}; };