Implement increasing particle sizes. Refs #1.

This commit is contained in:
2018-04-03 19:55:30 +02:00
parent d4d4d6d431
commit ffea333609
5 changed files with 40 additions and 17 deletions

View File

@@ -63,7 +63,6 @@ ActivityAnimation::ActivityAnimation(
void ActivityAnimation::draw(float timeScale) void ActivityAnimation::draw(float timeScale)
{ {
const auto &vertexBuffer = animate(startingPos, delta, timeScale); const auto &vertexBuffer = animate(startingPos, delta, timeScale);
glPointSize(5);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);

View File

@@ -33,8 +33,8 @@ namespace fmri
0, 2, 3, 0, 2, 3,
1, 2, 3 1, 2, 3
}; };
constexpr const auto VERTICES_PER_NODE = NODE_SHAPE.size() / 3; static constexpr auto VERTICES_PER_NODE = std::tuple_size<typeof(NODE_SHAPE)>::value / 3;
constexpr const auto FACES_PER_NODE = NODE_FACES.size() / 3; static constexpr auto FACES_PER_NODE = std::tuple_size<typeof(NODE_FACES)>::value / 3;
void setVertexPositions(int vertexNo, float *destination); void setVertexPositions(int vertexNo, float *destination);

View File

@@ -32,6 +32,15 @@ static float getFPS()
return fps; 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) void RenderingState::move(unsigned char key, bool sprint)
{ {
float speed = 0.5f; float speed = 0.5f;
@@ -102,6 +111,14 @@ void RenderingState::handleKey(unsigned char x)
toggle(options.activatedOnly); toggle(options.activatedOnly);
break; break;
case '+':
updatePointSize(1);
break;
case '-':
updatePointSize(-1);
break;
default: default:
// Do nothing. // Do nothing.
break; break;
@@ -259,6 +276,7 @@ void RenderingState::renderOverlayText() const
"i: toggle interactions visible\n" "i: toggle interactions visible\n"
"o: toggle activated nodes only\n" "o: toggle activated nodes only\n"
"p: toggle interaction paths visible\n" "p: toggle interaction paths visible\n"
"+/-: increase/decrease particle size\n"
"q: quit\n"; "q: quit\n";
} }
@@ -332,3 +350,22 @@ const Color &RenderingState::pathColor() const
{ {
return options.pathColor; 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);
}

View File

@@ -73,7 +73,7 @@ namespace fmri
std::vector<std::unique_ptr<LayerVisualisation>> layerVisualisations; std::vector<std::unique_ptr<LayerVisualisation>> layerVisualisations;
std::vector<std::unique_ptr<Animation>> interactionAnimations; std::vector<std::unique_ptr<Animation>> interactionAnimations;
RenderingState() noexcept = default; RenderingState() noexcept;
void configureRenderingContext() const; void configureRenderingContext() const;

View File

@@ -67,19 +67,6 @@ int main(int argc, char *argv[])
RenderingState::instance().registerControls(); 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 // Start visualisation
glutMainLoop(); glutMainLoop();