// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// bool Pool3dGame::VInitOpenGL() { bool result = true; GF_LOG_DEB("Initializing the GLEW library"); #if TARGET_OS_MAC glewExperimental = GL_TRUE; #endif GLenum res = glewInit(); if (GLEW_OK != res) { // Problem: glewInit failed, something is seriously wrong. GF_LOG_ERR(string("Failed to initialize the GLEW library: ") + string(reinterpret_cast<const char *>(glewGetErrorString(res)))); result = false; } if(result) { GF_LOG_DEB(string("Using GLEW version: ") + string(reinterpret_cast<const char *>(glewGetString(GLEW_VERSION)))); } // Check for required OpenGL extensions here and set application wide flags if certain features are available. // TODO: check for other extensions. #ifdef GLEW_EXT_texture_filter_anisotropic m_isAnisotropicExtPresent = true; #endif // Perform any global OpenGL initialization here. if(result) { // Set the color buffer clear value. glClearColor(GameHalloran::g_gcLightGray.GetX(), GameHalloran::g_gcLightGray.GetY(), GameHalloran::g_gcLightGray.GetZ(), GameHalloran::g_gcLightGray.GetW()); // Enable depth testing. glEnable(GL_DEPTH_TEST); // Set the alpha blending function. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Turn on anitaliasing for lines glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Cull all back facing triangles. glCullFace(GL_BACK); // Set the triangle winding. glFrontFace(GL_CCW); // Initialize the TextureManager last once all other OpenGL initialization is done. m_texManagerPtr.reset(GCC_NEW TextureManager(10, 1024*1024*20)); m_texManagerPtr->SetTextureFilterMode(TextureManager::eAnisotropic); m_texManagerPtr->SetAnisotropicLinearLevel(1.0f); GameMain::SetupTextureAtlasManager(std::string("atlases") + ZipFile::ZIP_PATH_SEPERATOR + std::string("atlasDictionary.xml")); } return (result); }
// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// bool Pool3dGameEventListener::VHandleEvent(IEventData const &eventObj) { bool result = true; // NB. Note to self, the event will not be propagated anymore if you return TRUE from this method. // Take care you return FALSE for events that might have script listeners... // Log receipt of the event and its type. GF_LOG_TRACE_TRC(VGetName(), string("Recevied event type = ") + string(eventObj.VGetEventType().getStr())); // Check what event has occurred and handle it appropriately. if(eventObj.VGetEventType() == EvtData_Graphics_Config_Change::sk_EventType) { const EvtData_Graphics_Config_Change &castEvent = static_cast<const EvtData_Graphics_Config_Change &>(eventObj); result = OnGraphicsConfigChange(castEvent); } else if(eventObj.VGetEventType() == EvtData_Sound_Config_Change::sk_EventType) { const EvtData_Sound_Config_Change &castEvent = static_cast<const EvtData_Sound_Config_Change &>(eventObj); result = OnSoundConfigChange(castEvent); } // TODO: Handle other UI view events here... else { GF_LOG_DEB(string("View: Unknown game event received: ") + eventObj.VGetEventType().getStr()); result = false; } return (result); }
bool TestApp::VInitOpenGL() { bool result = true; GF_LOG_DEB("Initializing the GLEW library"); #if defined(TARGET_OS_MAC) glewExperimental = GL_TRUE; #endif GLenum res = glewInit(); if(GLEW_OK != res) { GF_LOG_ERR(string("Failed to initialize the GLEW library: ") + string(reinterpret_cast<const char *>(glewGetErrorString(res)))); result = false; } if(result) { GF_LOG_DEB(string("Using GLEW version: ") + string(reinterpret_cast<const char *>(glewGetString(GLEW_VERSION)))); } #ifdef GLEW_EXT_texture_filter_anisotropic m_isAnisotropicExtPresent = true; #endif if(result) { glClearColor(GameHalloran::g_gcBlue.GetX() , GameHalloran::g_gcBlue.GetY() , GameHalloran::g_gcBlue.GetZ() , GameHalloran::g_gcBlue.GetW()); glEnable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glCullFace(GL_BACK); glFrontFace(GL_CCW); m_texManagerPtr.reset(GCC_NEW TextureManager(10, 1024 * 1024 * 20)); m_texManagerPtr->SetTextureFilterMode(TextureManager::eAnisotropic); m_texManagerPtr->SetAnisotropicLinearLevel(1.0f); GameMain::SetupTextureAtlasManager(std::string("atlases") + ZipFile::ZIP_PATH_SEPERATOR + std::string("atlasDictionary.xml")); } return (result); }