int InitGL() // All Setup For OpenGL goes here { glShadeModel(GL_SMOOTH); // Enables Smooth Shading glClearColor(0.0, 0.0, 0.0, 1.0); glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Test To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculation glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // Uses default lighting parameters glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glEnable(GL_NORMALIZE); glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); glEnable(GL_LIGHT1); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); // and now some init I need to do for other stuff ilInit(); /* Initialization of DevIL */ // mouse stuff pointer = toGLTexture("./dati/models/textures/mirino.png"); lastx = middleX; lasty = middleY; relativeX = 0.0; relativeY = 0.0; glutWarpPointer(middleX, middleY); // put the cursor in the middle of the screen //for the menu InitMenu(); // for the text t3dInit(); // for the skybox initSkybox(); // for the blend initAssets(); // for the sounds if (!sound_hit.loadFromFile("./dati/audio/hit.wav")) return -1; if (!sound_miss.loadFromFile("./dati/audio/miss.wav")) return -1; if (!sound_youreempty.loadFromFile("./dati/audio/youreempty.wav")) return -1; if (!sound_ohno.loadFromFile("./dati/audio/ohno.wav")) return -1; music.setLoop(true); if (!music.openFromFile("./dati/audio/Rango_Theme.ogg")) return -1; music.play(); return TRUE; // Initialization Went OK }
///Function that starts the entire process. void ScreenSaver::execute(int& argc , char** argv) { ///Generating objects generateTable(); generateBall(); glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(WIDTH , HEIGHT); glutInitWindowPosition(50,50); windowID = glutCreateWindow(" Bouncy ball "); init(); threadInit(); initSkybox(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMouseFunc(handleMouse); glutKeyboardFunc(handleKeyboard); glutSpecialFunc(handleSpecial); //GLUI *glUserInterface = GLUI_Master.create_glui_subwindow( windowID,GLUI_SUBWINDOW_RIGHT ); menu.createMenu(); glutTimerFunc(DELTA_T , timer , 0); glutMainLoop(); for(int i=0; i<NUM_BALLS;i++) pthread_exit(&vecBallThread[i]); }
bool Game::init() { m_pPipe = new Pipeline(); m_pPipe->setCamera(m_windowWidth, m_windowHeight); m_pPipe->init(); m_pGameCamera = m_pPipe->getCamera(); m_pShadowMap = new ShadowMap(); if(!m_pShadowMap->initShadow(m_windowWidth, m_windowHeight)) return false; m_pLightingEffect = new LightingTechnique(); if(!m_pLightingEffect->init()) return false; m_pLightingEffect->enable(); m_pLightingEffect->setSpotLights(1, m_pSpotLight); m_pLightingEffect->setTextureUnit(0); m_pLightingEffect->setShadowMapTextureUnit(1); m_pShadowMapEffect = new ShadowMapTechnique(); if(!m_pShadowMapEffect->init()) return false; if(!initModels()) std::cout << "LOG: Models error" << std::endl; if(!initSkybox()) std::cout << "LOG: Skybox initialization error!" << std::endl; /* if(!initHeightmap()) std::cout << "LOG: Heightmap initialization error!" << std::endl; */ cam = m_pGameCamera; glfwSetMouseButtonCallback(m_pWindow, Game::mouseButtonWrapper); glfwSetCharCallback(m_pWindow, Game::keyboardCharactersWrapper); glfwSetCursorPosCallback(m_pWindow, Game::mousePosWrapper); glfwSetKeyCallback(m_pWindow, Game::keyboardWrapper); return true; }