1 #ifndef SUBTITLESTHREAD_H
2 #define SUBTITLESTHREAD_H
5 #include <yarp/os/BufferedPort.h>
10 #include <OpenGL/glu.h>
20 yarp::os::BufferedPort<yarp::os::Bottle> mTxtMsgPort;
21 yarp::os::BufferedPort<yarp::os::Bottle> mTxtDbgPort;
26 mTxtMsgPort.open((
GUI_NAME+objPortName).c_str());
27 mTxtDbgPort.open((
GUI_NAME+texPortName).c_str());
29 mTxtMsgPort.setStrict();
30 mTxtDbgPort.setStrict();
43 mTxtMsgPort.interrupt();
46 mTxtDbgPort.interrupt();
52 static double txtWatchDogStart = yarp::os::Time::now();
53 static double dbgWatchDogStart = yarp::os::Time::now();
54 static std::string txtMsg;
55 static std::string dbgMsg;
57 Bottle* msg = mTxtMsgPort.read(
false);
58 Bottle* dbg = mTxtDbgPort.read(
false);
62 txtMsg= msg->get(0).asString().c_str();
63 txtWatchDogStart = yarp::os::Time::now();
67 dbgMsg = dbg->get(0).asString().c_str();
68 dbgWatchDogStart = yarp::os::Time::now();
71 if (yarp::os::Time::now()-txtWatchDogStart < 3.0 && !txtMsg.empty())
73 drawText(
"iCub: ",txtMsg.c_str(),1.0f,1.0f,1.0f);
76 if (yarp::os::Time::now()-dbgWatchDogStart < 3.0 && !dbgMsg.empty())
78 drawText(
"Dbg: ",dbgMsg.c_str(),1.0f,1.0f,1.0f);
83 void drawText(
const char* speaker,
const char* text,
float r,
float g,
float b)
87 glTranslatef(-4.0f, -2.5f, -5.0f);
90 glDisable(GL_LIGHTING);
93 static char tmp[1024];
96 for (
int i=0;
tmp[i]!=
'\0'; ++i)
98 glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,
tmp[i]);
100 glEnable(GL_LIGHTING);
SubtitlesManager(const char *objPortName, const char *texPortName)
void drawText(const char *speaker, const char *text, float r, float g, float b)