Create a configurable overlay.
This commit is contained in:
@@ -92,7 +92,7 @@ void RenderingState::handleKey(unsigned char x)
|
|||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RenderingState::infoLine()const
|
std::string RenderingState::debugInfo()const
|
||||||
{
|
{
|
||||||
std::stringstream buffer;
|
std::stringstream buffer;
|
||||||
buffer << "Pos(x,y,z) = (" << pos[0] << ", " << pos[1] << ", " << pos[2] << ")\n";
|
buffer << "Pos(x,y,z) = (" << pos[0] << ", " << pos[1] << ", " << pos[2] << ")\n";
|
||||||
@@ -217,17 +217,30 @@ void RenderingState::render(float time) const
|
|||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
renderDebugInfo();
|
renderOverlayText();
|
||||||
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingState::renderDebugInfo() const
|
void RenderingState::renderOverlayText() const
|
||||||
{
|
{
|
||||||
|
std::stringstream overlayText;
|
||||||
|
if (options.showDebug) {
|
||||||
|
overlayText << debugInfo() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.showHelp) {
|
||||||
|
overlayText << "Controls:\n"
|
||||||
|
"WASD: move\n"
|
||||||
|
"shift: move faster\n"
|
||||||
|
"F1: toggle this help message\n"
|
||||||
|
"F2: toggle debug info\n";
|
||||||
|
}
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
setOrthographicProjection();
|
setOrthographicProjection();
|
||||||
glColor3f(1, 1, 0);
|
glColor3f(1, 1, 0);
|
||||||
renderText(infoLine(), 2, 10);
|
renderText(overlayText.str(), 2, 10);
|
||||||
restorePerspectiveProjection();
|
restorePerspectiveProjection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,6 +274,15 @@ void RenderingState::handleSpecialKey(int key)
|
|||||||
updateVisualisers();
|
updateVisualisers();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GLUT_KEY_F1:
|
||||||
|
options.showHelp = !options.showHelp;
|
||||||
|
glutPostRedisplay();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GLUT_KEY_F2:
|
||||||
|
options.showDebug = !options.showDebug;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOG(INFO) << "Received keystroke " << key;
|
LOG(INFO) << "Received keystroke " << key;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ namespace fmri
|
|||||||
static RenderingState& instance();
|
static RenderingState& instance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct {
|
||||||
|
bool showDebug = false;
|
||||||
|
bool showHelp = true;
|
||||||
|
} options;
|
||||||
std::array<float, 3> pos;
|
std::array<float, 3> pos;
|
||||||
std::array<float, 2> angle;
|
std::array<float, 2> angle;
|
||||||
std::map<std::string, LayerInfo> layerInfo;
|
std::map<std::string, LayerInfo> layerInfo;
|
||||||
@@ -58,8 +62,8 @@ namespace fmri
|
|||||||
void move(unsigned char key);
|
void move(unsigned char key);
|
||||||
void updateVisualisers();
|
void updateVisualisers();
|
||||||
|
|
||||||
std::string infoLine()const;
|
std::string debugInfo() const;
|
||||||
void renderDebugInfo() const;
|
void renderOverlayText() const;
|
||||||
void renderLayerName(const std::string& name) const;
|
void renderLayerName(const std::string& name) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user