MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / DrawLabels

Method DrawLabels

Samples/NiUserSelection/SceneDrawer.cpp:167–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165#define MAX_USER_LABEL_LEN 50
166#define MAX_ID_LABEL_LEN 120
167void SceneDrawer::DrawLabels(XnUserID nUserId)
168{
169#ifndef USE_GLES
170 char strUserLabel[MAX_USER_LABEL_LEN] = "";
171 char strOutputLabel[MAX_ID_LABEL_LEN] = "";
172 XnFloat color[3];
173
174 XnPoint3D com;
175 xnOSMemSet(strOutputLabel, 0, sizeof(strOutputLabel));
176 XnStatus res=m_pUserTrackerObj->GetUserColor(nUserId,color);
177 XnFloat userExitPose=m_pUserTrackerObj->GetExitPoseState(nUserId)*100.0f;
178 if(res!=XN_STATUS_OK)
179 return; // bad user!
180 xnOSMemSet(strUserLabel, 0, sizeof(strUserLabel));
181 res=m_pUserTrackerObj->GetUserStringPos(nUserId,com,strUserLabel,MAX_USER_LABEL_LEN-1);
182 if(res!=XN_STATUS_OK)
183 return; // bad user!
184
185 if (!g_bPrintState)
186 {
187 if(userExitPose>0)
188 {
189 sprintf(strOutputLabel, "%d - Exit wait %3.0f%% done.", nUserId,userExitPose);
190 }
191 else
192 {
193 sprintf(strOutputLabel, "%d", nUserId);
194 }
195
196 }
197 else
198 {
199 if(userExitPose>0)
200 {
201 sprintf(strOutputLabel, "%d - %s - Exit wait %3.0f%% done.", nUserId,strUserLabel,userExitPose);
202 }
203 else
204 {
205 sprintf(strOutputLabel, "%d - %s", nUserId,strUserLabel);
206 }
207
208 }
209
210 glColor4f(1-color[0], 1-color[1], 1-color[2], 1);
211
212 glRasterPos2i(com.X, com.Y);
213 int len = (int)strlen(strOutputLabel);
214
215 for(int c=0; c<len; c++)
216 {
217 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,strOutputLabel[c]);
218 }
219#endif
220}
221
222
223#define drawOneLine(x1,y1,x2,y2) \

Callers 1

glutDisplayMethod · 0.80

Calls 4

GetUserColorMethod · 0.80
GetExitPoseStateMethod · 0.80
GetUserStringPosMethod · 0.80
xnOSMemSetFunction · 0.50

Tested by

no test coverage detected