BOOL CHapticViewerView::SetupPixelFormat() { static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; m_hDC = ::GetDC(m_hWnd); GLuint PixelFormat = ChoosePixelFormat(m_hDC, &pfd); if (!PixelFormat) { return false ; } if(!SetPixelFormat(m_hDC,PixelFormat,&pfd)) { return false; } m_hRC = wglCreateContext(m_hDC); if(!m_hRC) { return false; } if(!wglMakeCurrent(m_hDC, m_hRC)) { return false; } initGL(); initHL(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SwapBuffers(m_hDC); QueryPerformanceCounter(&g_drawPerfli); QueryPerformanceFrequency(&g_liFreq); return true; }
/******************************************************************************* Initializes the scene. Handles initializing both OpenGL and HL. *******************************************************************************/ void initScene() { //Get the path of models and textures and load them up.. char descr1[100]; char *descr = getenv("OH_SDK_BASE"); if (descr == NULL) { std::cout<<"Warning, OH_SDK_BASE not set"<<std::endl; descr1[0] = '\0'; } strcpy(descr1,descr) ; char descr2[100]; strcpy(descr2,descr); char descr3[100]; strcpy(descr3,descr); model1Path = strcat(descr1, model1Path); model2Path = strcat(descr2, model2Path); texture1Path = strcat(descr3, texture1Path); std::cout<<"Loading.."<<model1Path<<std::endl; std::cout<<"Loading.."<<model2Path<<std::endl; std::cout<<"Loading.."<<texture1Path<<std::endl; //Load the pixels from the image pixel loader... int loading = pixelLoadFromImage(texture1Path,0); if (!loading) { fprintf(stderr, "Texture file not found\n"); _getch(); exit(0); } else { printf("Texture Loading successful \n\n"); } initOBJModel(); initToolOBJModel(); initGL(); initHL(); }
/******************************************************************************* Initializes the scene. Handles initializing both OpenGL and HL. *******************************************************************************/ void initScene() { initGL(); initHL(); }
HapticApp::HapticApp(int width, int height) { initGlut(width, height); initHL(); _happ = this; _running = false; }