コード例 #1
0
void updateGraphics(void)
{
    int px;

    // update position of label
    labelHapticDeviceModel->setLocalPos(10, displayH - 30, 0.0);

    // update position of label and content
    double posX = 1000 * hapticDevicePosition.x();
    double posY = 1000 * hapticDevicePosition.y();
    double posZ = 1000 * hapticDevicePosition.z();

    labelHapticDevicePosition->setString("position [mm]: " + cStr(posX, 0) + " " +
                                         cStr(posY, 0) + " " +
                                         cStr(posZ, 0));

    labelHapticDevicePosition->setLocalPos(10, displayH - 50, 0.0);

    // update haptic rate label
    labelHapticRate->setString ("haptic rate: "+cStr(frequencyCounter.getFrequency(), 0) + " [Hz]");

    px = (int)(0.5 * (displayW - labelHapticRate->getWidth()));
    labelHapticRate->setLocalPos(px, 15);

    // render world
    camera->renderView(displayW, displayH);

    // swap buffers
    glutSwapBuffers();

    // check for any OpenGL errors
    GLenum err;
    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));
}