void CHapticViewerView::initHL()
{
    HDErrorInfo error;
    m_hHD = hdInitDevice(HD_DEFAULT_DEVICE);
    if (HD_DEVICE_ERROR(error = hdGetError()))
    {
        char errorMsg[500];
        sprintf(errorMsg,
                "HD error %s\nHHD: %X\nError Code: %X\nInternalErrorCode: %d\n%s\n",
                hdGetErrorString(error.errorCode),
                error.hHD,
                error.errorCode,
                error.internalErrorCode,
                "Failed to initialize haptic device");
        MessageBox(errorMsg);
        getchar();
        exit(1);
    }   
    
    // Create a haptic context for the device. The haptic context maintains 
    // the state that persists between frame intervals and is used for
    // haptic rendering.
    m_hHLRC = hlCreateContext(m_hHD);
    hlMakeCurrent(m_hHLRC); 

    hlTouchableFace(HL_FRONT);
}
Пример #2
0
/******************************************************************************
 Pretty prints a message containing the error code name, the error code and
 the internal error code.
******************************************************************************/
void hduPrintError(FILE *stream, const HDErrorInfo *error,
                   const char *message)
{
    fprintf(stream, "HD Error: %s\n", getErrorCodeName(error->errorCode));
    fprintf(stream, "%s\n", hdGetErrorString(error->errorCode));
    fprintf(stream, "HHD: %X\n", error->hHD);
    fprintf(stream, "Error Code: %X\n", error->errorCode);
    fprintf(stream, "Internal Error Code: %d\n", error->internalErrorCode);
    fprintf(stream, "Message: %s\n", message);
}
Пример #3
0
 string getHLErrorString( HLerror error ) {
   if( error.errorCode == HL_DEVICE_ERROR ) {
     stringstream s;
     s << "HL_DEVICE_ERROR( " 
       << hdGetErrorString( error.errorInfo.errorCode )
       << " )";
     return s.str();
   } else {
     return error.errorCode;
   }
 }
Пример #4
0
/******************************************************************************
 Pretty prints a message containing the error code name, the error code and
 the internal error code.
******************************************************************************/
std::ostream &operator<<(std::ostream &os, const HDErrorInfo &error)
{    
    os << "HD Error : " << getErrorCodeName(error.errorCode) << std::endl;
    os << hdGetErrorString(error.errorCode) << std::endl;
	os.setf(std::ios::hex);
    os << "HHD: " << error.hHD << std::endl;
    os << "Error Code: " << error.errorCode << std::endl;
	os.setf(std::ios::dec);
    os << "Internal Error Code: " << error.internalErrorCode << std::endl;

    return os;    
}