From ffea333609e60fce2005d878820fdebf925ba82f Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Tue, 3 Apr 2018 19:55:30 +0200 Subject: [PATCH] Implement increasing particle sizes. Refs #1. --- src/fmri/ActivityAnimation.cpp | 1 - src/fmri/FlatLayerVisualisation.hpp | 4 ++-- src/fmri/RenderingState.cpp | 37 +++++++++++++++++++++++++++++ src/fmri/RenderingState.hpp | 2 +- src/fmri/main.cpp | 13 ---------- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/fmri/ActivityAnimation.cpp b/src/fmri/ActivityAnimation.cpp index b4a841d..0b51506 100644 --- a/src/fmri/ActivityAnimation.cpp +++ b/src/fmri/ActivityAnimation.cpp @@ -63,7 +63,6 @@ ActivityAnimation::ActivityAnimation( void ActivityAnimation::draw(float timeScale) { const auto &vertexBuffer = animate(startingPos, delta, timeScale); - glPointSize(5); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); diff --git a/src/fmri/FlatLayerVisualisation.hpp b/src/fmri/FlatLayerVisualisation.hpp index de001a7..82cc3b0 100644 --- a/src/fmri/FlatLayerVisualisation.hpp +++ b/src/fmri/FlatLayerVisualisation.hpp @@ -33,8 +33,8 @@ namespace fmri 0, 2, 3, 1, 2, 3 }; - constexpr const auto VERTICES_PER_NODE = NODE_SHAPE.size() / 3; - constexpr const auto FACES_PER_NODE = NODE_FACES.size() / 3; + static constexpr auto VERTICES_PER_NODE = std::tuple_size::value / 3; + static constexpr auto FACES_PER_NODE = std::tuple_size::value / 3; void setVertexPositions(int vertexNo, float *destination); diff --git a/src/fmri/RenderingState.cpp b/src/fmri/RenderingState.cpp index 5570612..3ca5544 100644 --- a/src/fmri/RenderingState.cpp +++ b/src/fmri/RenderingState.cpp @@ -32,6 +32,15 @@ static float getFPS() return fps; } +static void updatePointSize(float dir) { + float size, granularity; + glGetFloatv(GL_POINT_SIZE, &size); + glGetFloatv(GL_POINT_SIZE_GRANULARITY, &granularity); + granularity = std::max(0.5f, granularity); + size += dir * granularity; + glPointSize(std::max(1.f, size)); +} + void RenderingState::move(unsigned char key, bool sprint) { float speed = 0.5f; @@ -102,6 +111,14 @@ void RenderingState::handleKey(unsigned char x) toggle(options.activatedOnly); break; + case '+': + updatePointSize(1); + break; + + case '-': + updatePointSize(-1); + break; + default: // Do nothing. break; @@ -259,6 +276,7 @@ void RenderingState::renderOverlayText() const "i: toggle interactions visible\n" "o: toggle activated nodes only\n" "p: toggle interaction paths visible\n" + "+/-: increase/decrease particle size\n" "q: quit\n"; } @@ -332,3 +350,22 @@ const Color &RenderingState::pathColor() const { return options.pathColor; } + +RenderingState::RenderingState() noexcept +{ + // Enable depth test to fix objects behind you + glEnable(GL_DEPTH_TEST); + + // Nicer rendering + glEnable(GL_POINT_SMOOTH); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_POLYGON_SMOOTH); + glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); + glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); + glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // Set initial point size + glPointSize(3); +} diff --git a/src/fmri/RenderingState.hpp b/src/fmri/RenderingState.hpp index 17368c6..27e9c87 100644 --- a/src/fmri/RenderingState.hpp +++ b/src/fmri/RenderingState.hpp @@ -73,7 +73,7 @@ namespace fmri std::vector> layerVisualisations; std::vector> interactionAnimations; - RenderingState() noexcept = default; + RenderingState() noexcept; void configureRenderingContext() const; diff --git a/src/fmri/main.cpp b/src/fmri/main.cpp index a7d8275..8d88273 100644 --- a/src/fmri/main.cpp +++ b/src/fmri/main.cpp @@ -67,19 +67,6 @@ int main(int argc, char *argv[]) RenderingState::instance().registerControls(); - // Enable depth test to fix objects behind you - glEnable(GL_DEPTH_TEST); - - // Nicer rendering - glEnable(GL_POINT_SMOOTH); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_POLYGON_SMOOTH); - glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); - glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // Start visualisation glutMainLoop();