aboutsummaryrefslogtreecommitdiff
path: root/voronoisplat.h
diff options
context:
space:
mode:
authorSamuel Fadel <samuel@nihil.ws>2023-06-04 13:02:14 +0200
committerSamuel Fadel <samuel@nihil.ws>2023-06-04 13:02:14 +0200
commitfb23c8d47f6dcef429423256d8dddcc0f7184fc4 (patch)
tree34e0032f28df5807e4abd90d6b1b4baad24d2991 /voronoisplat.h
parent0f34fd437efb936ef29ac91186321aa7251fbfb1 (diff)
Further advances in nuklear port.
Rendering now looks similar to Qt version, needs a few tweaks: * Proper multisampling * Background Missing features: * Barcharts * Interactivity (e.g. brushing/linking in all objects) * History view of interactions
Diffstat (limited to 'voronoisplat.h')
-rw-r--r--voronoisplat.h45
1 files changed, 38 insertions, 7 deletions
diff --git a/voronoisplat.h b/voronoisplat.h
index 894b6ca..bab3fc0 100644
--- a/voronoisplat.h
+++ b/voronoisplat.h
@@ -4,20 +4,25 @@
#include <memory>
#include <armadillo>
+#include <glad/gl.h>
#include <nod.hpp>
#include "colorscale.h"
+#include "geometry.h"
#include "scale.h"
+#include "shader.h"
class VoronoiSplat
{
public:
VoronoiSplat();
+ ~VoronoiSplat();
// Renderer *createRenderer() const;
void update();
+ void draw();
- const std::vector<float> &sites() const { return m_sites; }
+ const std::vector<vec2> &sites() const { return m_sites; }
const std::vector<float> &values() const { return m_values; }
const std::vector<float> &colorScale() const { return m_cmap; }
LinearScale<float> scaleX() const { return m_sx; }
@@ -25,6 +30,11 @@ public:
float alpha() const { return m_alpha; }
float beta() const { return m_beta; }
+ size_t width() const { return m_width; }
+ size_t height() const { return m_height; }
+
+ GLuint texture() { return m_outTex; }
+
void setSitesChanged(bool sitesChanged) {
m_sitesChanged = sitesChanged;
}
@@ -37,18 +47,20 @@ public:
nod::signal<void(const arma::mat &)> sitesChanged;
nod::signal<void(const arma::vec &)> valuesChanged;
- nod::signal<void(std::shared_ptr<const ColorScale>)> colorScaleChanged;
+ nod::signal<void(GLuint)> colormapChanged;
nod::signal<void(const LinearScale<float> &, const LinearScale<float> &)> scaleChanged;
nod::signal<void(float)> alphaChanged, betaChanged;
+ void setSize(size_t width, size_t height);
+
// 'points' should be a 2D points matrix (each point in a row)
void setSites(const arma::mat &points);
// Set the value to be colorScaleped in each site
void setValues(const arma::vec &values);
- // Set colorScale data based on the given color scale
- void setColorScale(std::shared_ptr<const ColorScale> scale);
+ // Set colormap texture used for color lookup in rendering
+ void setColormap(GLuint texture);
void setScale(const LinearScale<float> &sx,
const LinearScale<float> &sy);
@@ -59,11 +71,30 @@ public:
// Maximum blur radius
void setBeta(float beta);
+ void setupShaders();
+ void setupVAOs();
+ void setupTextures();
+ void resizeTextures();
+
+ void updateSites();
+ void updateValues();
+ void updateColormap();
+ void updateTransform();
+
private:
- std::vector<float> m_sites, m_values, m_cmap;
- LinearScale<float> m_sx, m_sy;
+ std::unique_ptr<Shader> m_program1, m_program2, m_programVoronoi;
+ GLuint m_dtVAO, m_sitesVAO, m_2ndPassVAO, m_voronoiVAO;
+ GLfloat m_transform[4][4];
+ GLuint m_FBO, m_voronoiFBO, m_preFBO;
+ GLuint m_VBOs[3], m_dtVBO;
+ GLuint m_textures[2], m_colormapTex, m_voronoiDepthTex, m_outTex;
+
float m_alpha, m_beta;
- bool m_sitesChanged, m_valuesChanged, m_colorScaleChanged;
+ size_t m_width, m_height;
+ std::vector<vec2> m_sites;
+ std::vector<float> m_values, m_cmap;
+ LinearScale<float> m_sx, m_sy;
+ bool m_sitesChanged, m_valuesChanged, m_colorScaleChanged, m_redraw;
};
#endif // VORONOISPLAT_H