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

Function drawPointerMode

Samples/NiViewer/Draw.cpp:1040–1189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1038}
1039
1040void drawPointerMode(IntPair* pPointer)
1041{
1042 char buf[512] = "";
1043 int nCharWidth = glutBitmapWidth(GLUT_BITMAP_HELVETICA_18, '0');
1044 int nPointerValue = 0;
1045
1046 XnDouble dTimestampDivider = 1E6;
1047
1048 const DepthMetaData* pDepthMD = getDepthMetaData();
1049
1050 if (pDepthMD != NULL)
1051 {
1052 // Print the scale black background
1053 glEnable(GL_BLEND);
1054 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1055
1056 glBegin(GL_QUADS);
1057 glColor4f(0, 0, 0, 0.7);
1058 glVertex2i(0, WIN_SIZE_Y); // lower left
1059 glVertex2i(WIN_SIZE_X, WIN_SIZE_Y);
1060 glVertex2i(WIN_SIZE_X, WIN_SIZE_Y - 135);
1061 glVertex2i(0, WIN_SIZE_Y - 135);
1062 glEnd();
1063
1064 glDisable(GL_BLEND);
1065
1066 // set a large point size (for the scale)
1067 glPointSize(15);
1068
1069 // Print the scale data
1070 glBegin(GL_POINTS);
1071 for (int i = 0; i < pDepthMD->ZRes(); i+=1)
1072 {
1073 float fNewColor = g_pDepthHist[i];
1074 if ((fNewColor > 0.004) && (fNewColor < 0.996))
1075 {
1076 glColor3f(fNewColor, fNewColor, 0);
1077 glVertex3f(((i/10)*2), WIN_SIZE_Y - 23, 1);
1078 }
1079 }
1080 glEnd();
1081
1082 // Print the pointer scale data
1083 if (pPointer != NULL)
1084 {
1085 // make sure pointer in on a depth pixel (take in mind cropping might be in place)
1086 IntPair pointerInDepth = *pPointer;
1087 pointerInDepth.X -= pDepthMD->XOffset();
1088 pointerInDepth.Y -= pDepthMD->YOffset();
1089
1090 if (pointerInDepth.X < (int)pDepthMD->XRes() && pointerInDepth.Y < (int)pDepthMD->YRes())
1091 {
1092 nPointerValue = (*pDepthMD)(pointerInDepth.X, pointerInDepth.Y);
1093
1094 glBegin(GL_POINTS);
1095 glColor3f(1,0,0);
1096 glVertex3f(10 + ((nPointerValue/10)*2), WIN_SIZE_Y - 70, 1);
1097 glEnd();

Callers 1

drawFrameFunction · 0.85

Calls 15

getDepthMetaDataFunction · 0.85
getDepthGeneratorFunction · 0.85
getImageMetaDataFunction · 0.85
getImageGeneratorFunction · 0.85
getIRMetaDataFunction · 0.85
getIRGeneratorFunction · 0.85
getAudioMetaDataFunction · 0.85
getAudioGeneratorFunction · 0.85
isStatisticsActiveFunction · 0.85
ZResMethod · 0.80
XOffsetMethod · 0.80
YOffsetMethod · 0.80

Tested by

no test coverage detected