Implement switching between images.
This commit is contained in:
37
src/main.cpp
37
src/main.cpp
@@ -21,9 +21,7 @@ struct
|
|||||||
{
|
{
|
||||||
optional<vector<string>> labels;
|
optional<vector<string>> labels;
|
||||||
vector<vector<LayerData>> data;
|
vector<vector<LayerData>> data;
|
||||||
float angle = 0;
|
vector<vector<LayerData>>::iterator currentData;
|
||||||
vector<LayerData>* currentData = nullptr;
|
|
||||||
map<tuple<string, int, int>, GLuint> textureMap;
|
|
||||||
vector<unique_ptr<LayerVisualisation>> layerVisualisations;
|
vector<unique_ptr<LayerVisualisation>> layerVisualisations;
|
||||||
} rendererData;
|
} rendererData;
|
||||||
|
|
||||||
@@ -86,11 +84,10 @@ static void renderLayerName(const LayerData &data)
|
|||||||
glTranslatef(0, 0, -10);
|
glTranslatef(0, 0, -10);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateVisualisers(unsigned int dataset)
|
static void updateVisualisers()
|
||||||
{
|
{
|
||||||
rendererData.layerVisualisations.clear();
|
rendererData.layerVisualisations.clear();
|
||||||
|
|
||||||
rendererData.currentData = &rendererData.data[dataset];
|
|
||||||
for (auto &layer : *rendererData.currentData) {
|
for (auto &layer : *rendererData.currentData) {
|
||||||
LayerVisualisation* visualisation = nullptr;
|
LayerVisualisation* visualisation = nullptr;
|
||||||
switch (layer.shape().size()) {
|
switch (layer.shape().size()) {
|
||||||
@@ -108,6 +105,32 @@ static void updateVisualisers(unsigned int dataset)
|
|||||||
|
|
||||||
rendererData.layerVisualisations.emplace_back(visualisation);
|
rendererData.layerVisualisations.emplace_back(visualisation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glutPostRedisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void specialKeyFunc(int key, int, int)
|
||||||
|
{
|
||||||
|
switch (key) {
|
||||||
|
case GLUT_KEY_LEFT:
|
||||||
|
if (rendererData.currentData == rendererData.data.begin()) {
|
||||||
|
rendererData.currentData = rendererData.data.end();
|
||||||
|
}
|
||||||
|
--rendererData.currentData;
|
||||||
|
updateVisualisers();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GLUT_KEY_RIGHT:
|
||||||
|
++rendererData.currentData;
|
||||||
|
if (rendererData.currentData == rendererData.data.end()) {
|
||||||
|
rendererData.currentData = rendererData.data.begin();
|
||||||
|
}
|
||||||
|
updateVisualisers();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
LOG(INFO) << "Received keystroke " << key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void idleFunc()
|
static void idleFunc()
|
||||||
@@ -133,6 +156,7 @@ int main(int argc, char *argv[])
|
|||||||
glutDisplayFunc(render);
|
glutDisplayFunc(render);
|
||||||
glutIdleFunc(idleFunc);
|
glutIdleFunc(idleFunc);
|
||||||
glutReshapeFunc(changeWindowSize);
|
glutReshapeFunc(changeWindowSize);
|
||||||
|
glutSpecialFunc(specialKeyFunc);
|
||||||
|
|
||||||
Camera::instance().registerControls();
|
Camera::instance().registerControls();
|
||||||
|
|
||||||
@@ -142,7 +166,8 @@ int main(int argc, char *argv[])
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVisualisers(0);
|
rendererData.currentData = rendererData.data.begin();
|
||||||
|
updateVisualisers();
|
||||||
|
|
||||||
// Enable depth test to fix objects behind you
|
// Enable depth test to fix objects behind you
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|||||||
Reference in New Issue
Block a user