void printHelpGroup(int nXLocation, int* pnYLocation, const char* csGroup) { int nYLocation = *pnYLocation; unsigned char aKeys[20]; const char* aDescs[20]; int nCount; getGroupItems(csGroup, aKeys, aDescs, &nCount); glColor3f(0, 1, 0); glRasterPos2i(nXLocation, nYLocation); glPrintString(GLUT_BITMAP_TIMES_ROMAN_24, csGroup); nYLocation += 30; for (int i = 0; i < nCount; ++i, nYLocation += 22) { char buf[256]; switch (aKeys[i]) { case 27: sprintf(buf, "Esc"); break; default: sprintf(buf, "%c", aKeys[i]); break; } glColor3f(1, 0, 0); glRasterPos2i(nXLocation, nYLocation); glPrintString(GLUT_BITMAP_HELVETICA_18, buf); glRasterPos2i(nXLocation + 40, nYLocation); glPrintString(GLUT_BITMAP_HELVETICA_18, aDescs[i]); } *pnYLocation = nYLocation + 20; }
void printHelpGroup(int nXLocation, int* pnYLocation, const char* csGroup) { int nYLocation = *pnYLocation; int aSpecialKeys[20]; unsigned char aKeys[20]; const char* aDescs[20]; int nSpecialCount,nCount; getGroupItems(csGroup, aSpecialKeys, aKeys, aDescs, &nSpecialCount, &nCount); glColor3f(0, 1, 0); glRasterPos2i(nXLocation, nYLocation); glPrintString(GLUT_BITMAP_TIMES_ROMAN_24, csGroup); nYLocation += 30; for (int i = 0; i < (nSpecialCount + nCount); ++i, nYLocation += 22) { char buf[256]; XnUInt32 nWritten; if(i < nSpecialCount) { switch (aSpecialKeys[i]) { case GLUT_KEY_LEFT: xnOSStrFormat(buf, sizeof(buf), &nWritten, "Left"); break; case GLUT_KEY_RIGHT: xnOSStrFormat(buf, sizeof(buf), &nWritten, "Right"); break; case GLUT_KEY_UP: xnOSStrFormat(buf, sizeof(buf), &nWritten, "Up"); break; case GLUT_KEY_DOWN: xnOSStrFormat(buf, sizeof(buf), &nWritten, "Down"); break; default: xnOSStrFormat(buf, sizeof(buf), &nWritten, "[0x%2x]", aSpecialKeys[i]); break; } } else { int j = i - nSpecialCount; switch (aKeys[j]) { case 27: xnOSStrFormat(buf, sizeof(buf), &nWritten, "Esc"); break; case ' ': xnOSStrFormat(buf, sizeof(buf), &nWritten, "Space"); break; default: xnOSStrFormat(buf, sizeof(buf), &nWritten, "%c", aKeys[j]); break; } } glColor3f(1, 0, 0); glRasterPos2i(nXLocation, nYLocation); glPrintString(GLUT_BITMAP_HELVETICA_18, buf); glRasterPos2i(nXLocation + 50, nYLocation); glPrintString(GLUT_BITMAP_HELVETICA_18, aDescs[i]); } *pnYLocation = nYLocation + 20; }