diff --git a/src/FlatLayerVisualisation.cpp b/src/FlatLayerVisualisation.cpp index 3aabda9..03f59ee 100644 --- a/src/FlatLayerVisualisation.cpp +++ b/src/FlatLayerVisualisation.cpp @@ -88,6 +88,6 @@ void FlatLayerVisualisation::render() glColorPointer(3, GL_FLOAT, 0, colorBuffer.get()); glDrawElements(GL_TRIANGLES, faceCount * 3, GL_UNSIGNED_INT, indexBuffer.get()); - glDisable(GL_VERTEX_ARRAY); - glDisable(GL_COLOR_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); } diff --git a/src/MultiImageVisualisation.cpp b/src/MultiImageVisualisation.cpp index b6dd6d9..93ff6bc 100644 --- a/src/MultiImageVisualisation.cpp +++ b/src/MultiImageVisualisation.cpp @@ -15,6 +15,10 @@ MultiImageVisualisation::MultiImageVisualisation(const fmri::LayerData &layer) width = dimensions[2], height = dimensions[3]; + CHECK_EQ(1, images) << "Only single input image is supported" << endl; + + vertexBuffer = std::make_unique(channels * 12); + auto dataPtr = layer.data(); for (auto i = 0; i < images; ++i) { for (auto j = 0; j < channels; ++j) { @@ -22,6 +26,36 @@ MultiImageVisualisation::MultiImageVisualisation(const fmri::LayerData &layer) dataPtr += width * height; } } + + int columns = sqrt(channels); + while (channels % columns) columns++; + int rows = channels / columns; + + // Create the quads for the images. + int r = 0, c = 0; + int v = 0; + for (int i = 0; i < channels; ++i) { + vertexBuffer[v++] = 0; + vertexBuffer[v++] = 0 + 3 * r; + vertexBuffer[v++] = 0 - 3 * c; + + vertexBuffer[v++] = 0; + vertexBuffer[v++] = 2 + 3 * r; + vertexBuffer[v++] = 0 - 3 * c; + + vertexBuffer[v++] = 0; + vertexBuffer[v++] = 2 + 3 * r; + vertexBuffer[v++] = 2 - 3 * c; + + vertexBuffer[v++] = 0; + vertexBuffer[v++] = 0 + 3 * r; + vertexBuffer[v++] = 2 - 3 * c; + + if (++c >= columns) { + c = 0; + ++r; + } + } } MultiImageVisualisation::~MultiImageVisualisation() @@ -33,5 +67,9 @@ MultiImageVisualisation::~MultiImageVisualisation() void MultiImageVisualisation::render() { - // TODO: do something. + glEnableClientState(GL_VERTEX_ARRAY); + glColor3f(1, 1, 1); + glVertexPointer(3, GL_FLOAT, 0, vertexBuffer.get()); + glDrawArrays(GL_QUADS, 0, 4 * textureReferences.size()); + glDisableClientState(GL_VERTEX_ARRAY); } diff --git a/src/MultiImageVisualisation.hpp b/src/MultiImageVisualisation.hpp index b1a46c3..2d713fe 100644 --- a/src/MultiImageVisualisation.hpp +++ b/src/MultiImageVisualisation.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "LayerVisualisation.hpp" #include "LayerData.hpp" @@ -17,5 +18,6 @@ namespace fmri private: std::map, GLuint> textureReferences; + std::unique_ptr vertexBuffer; }; }