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:
Add:
--target=x86_64-w64-mingw32

View File

@@ -1,6 +1,7 @@
#include "lopenglprogram.h"
#include "camera.h"
#include <GLFW/glfw3.h>
#include <algorithm>
#include <functional>
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/matrix_transform.hpp>
@@ -10,9 +11,7 @@
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <print>
#include <vector>
class GLWidget {
@@ -55,6 +54,9 @@ public:
if (heatmapVbo_) {
glDeleteBuffers(1, &heatmapVbo_);
}
if (heatmapIbo_) {
glDeleteBuffers(1, &heatmapIbo_);
}
deinit_ = true;
}
@@ -224,6 +226,29 @@ 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<float> verts;
}
@@ -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_;
};