aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-01-16 22:09:18 +0100
committerSamuel Fadel <samuelfadel@gmail.com>2016-01-16 22:09:18 +0100
commit0e8a1062471b25bcbcf61d306e6dd875dd779f37 (patch)
tree296643bc3be5a58071bcded33baf37a623317f5e
parent748049f5a3e364d92f2eb2ec188a6cd657ef1087 (diff)
VoronoiSplat: code reordering.
-rw-r--r--voronoisplat.cpp77
1 files changed, 39 insertions, 38 deletions
diff --git a/voronoisplat.cpp b/voronoisplat.cpp
index a804769..dcddc11 100644
--- a/voronoisplat.cpp
+++ b/voronoisplat.cpp
@@ -24,44 +24,6 @@ static int nextPow2(int n)
return n + 1;
}
-class VoronoiSplatRenderer
- : public QQuickFramebufferObject::Renderer
-{
-public:
- // 'size' must be square (and power of 2)
- VoronoiSplatRenderer();
- virtual ~VoronoiSplatRenderer();
-
-protected:
- QOpenGLFramebufferObject *createFramebufferObject(const QSize &size);
- void render();
- void synchronize(QQuickFramebufferObject *item);
-
-private:
- void setupShaders();
- void setupVAOs();
- void setupTextures();
- void resizeTextures();
-
- void updateSites();
- void updateValues();
- void updateColorScale();
- void computeDT();
-
- QSize m_size;
- const std::vector<float> *m_sites, *m_values, *m_cmap;
-
- QQuickWindow *m_window; // used to reset OpenGL state (as per docs)
- QOpenGLFunctions gl;
- QOpenGLShaderProgram *m_program1, *m_program2;
- GLuint m_FBO;
- GLuint m_VBOs[3];
- GLuint m_textures[2], m_colormapTex;
- QOpenGLVertexArrayObject m_sitesVAO, m_2ndPassVAO;
- bool m_sitesChanged, m_valuesChanged, m_colorScaleChanged;
-};
-
-
VoronoiSplat::VoronoiSplat(QQuickItem *parent)
: QQuickFramebufferObject(parent)
, m_cmap(3*Colormap::SAMPLES)
@@ -125,6 +87,45 @@ void VoronoiSplat::setColorScale(const ColorScale &scale)
update();
}
+// ----------------------------------------------------------------------------
+
+class VoronoiSplatRenderer
+ : public QQuickFramebufferObject::Renderer
+{
+public:
+ // 'size' must be square (and power of 2)
+ VoronoiSplatRenderer();
+ virtual ~VoronoiSplatRenderer();
+
+protected:
+ QOpenGLFramebufferObject *createFramebufferObject(const QSize &size);
+ void render();
+ void synchronize(QQuickFramebufferObject *item);
+
+private:
+ void setupShaders();
+ void setupVAOs();
+ void setupTextures();
+ void resizeTextures();
+
+ void updateSites();
+ void updateValues();
+ void updateColorScale();
+ void computeDT();
+
+ QSize m_size;
+ const std::vector<float> *m_sites, *m_values, *m_cmap;
+
+ QQuickWindow *m_window; // used to reset OpenGL state (as per docs)
+ QOpenGLFunctions gl;
+ QOpenGLShaderProgram *m_program1, *m_program2;
+ GLuint m_FBO;
+ GLuint m_VBOs[3];
+ GLuint m_textures[2], m_colormapTex;
+ QOpenGLVertexArrayObject m_sitesVAO, m_2ndPassVAO;
+ bool m_sitesChanged, m_valuesChanged, m_colorScaleChanged;
+};
+
QQuickFramebufferObject::Renderer *VoronoiSplat::createRenderer() const
{
return new VoronoiSplatRenderer;