diff --git a/src/glutils.cpp b/src/glutils.cpp index 1ee54bd..2dde313 100644 --- a/src/glutils.cpp +++ b/src/glutils.cpp @@ -102,3 +102,9 @@ GLuint fmri::compileShader(GLenum type, char const *source) abort(); } } + +void ::fmri::setColorFromIntensity(float i) +{ + // TODO: something more expressive. + glColor3f(i, i, i); +} diff --git a/src/glutils.hpp b/src/glutils.hpp index 2b947b1..3fedb87 100644 --- a/src/glutils.hpp +++ b/src/glutils.hpp @@ -33,4 +33,11 @@ namespace fmri { * @param h new Height. */ void changeWindowSize(int w, int h); + + /** + * Set the current drawing color based on some intensity value. + * + * @param i The intensity. + */ + void setColorFromIntensity(float i); } diff --git a/src/main.cpp b/src/main.cpp index 954d44d..fa825b8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,7 +57,9 @@ static void render() glPushMatrix(); for (auto& layer : *rendererData.currentData) { + glPushMatrix(); renderLayer(layer); + glPopMatrix(); glTranslatef(-5, 0, 0); } glPopMatrix(); @@ -90,10 +92,10 @@ static void renderFlatLayer(const LayerData& data) // Color depends on current value. vector intensities(data.data(), data.data() + data.numEntries()); rescale(intensities.begin(), intensities.end(), 0, 1); - glColor3f(1, 1, 1); glPushMatrix(); for (auto i : intensities) { + setColorFromIntensity(i); drawOneParticle(); glTranslatef(0, 0, -2); } @@ -118,6 +120,8 @@ static void renderLayer(const LayerData& data) // Draw the name of the layer for reference. glColor3f(0.5, 0.5, 0.5); renderText(data.name()); + + glTranslatef(0, 0, -2); switch (shape.size()) { case 4: // TODO: implement this.