//------------------------------------------------------------------------------------- void BaseApplication::go(void) { #ifdef _DEBUG mResourcesCfg = "resources_d.cfg"; mPluginsCfg = "plugins_d.cfg"; #else mResourcesCfg = "resources.cfg"; mPluginsCfg = "plugins.cfg"; #endif if (!setup()) return; mRoot->startRendering(); // clean up destroyScene(); }
//------------------------------------------------------------------------------------- void BaseApplication::go(void) { #ifdef _DEBUG mResourcesCfg = "resources_d.cfg"; mPluginsCfg = "plugins_d.cfg"; #else mResourcesCfg = "resources.cfg"; mPluginsCfg = "plugins.cfg"; #endif if (!setup()) return; gameLog->logMessage("Init complete!"); mRoot->startRendering(); gameLog->logMessage("Exiting!"); // clean up destroyScene(); }
void Game::go(){ #ifdef _DEBUG mOgreResourcesCfg = "resources_d.cfg"; mOgrePluginsCfg = "plugins_d.cfg"; #else mOgreResourcesCfg = "resources.cfg"; mOgrePluginsCfg = "plugins.cfg"; #endif if (!setup()) return; mOgreRoot->startRendering(); // clean up destroyScene(); }
//------------------------------------------------------------------------------------- void OgreApplication::go(void) { if (!setup()) return; while(!mShutDown) { mRoot->renderOneFrame(); // 通知系统分派消息 Ogre::WindowEventUtilities::messagePump(); if(!g_hasEvent) Sleep(1); } // clean up destroyScene(); }
void BaseManager::destroy() { destroyScene(); destroyPointerManager(); destroyInput(); destroyGui(); destroyRender(); if (hWnd) { DestroyWindow(hWnd); hWnd = 0; } UnregisterClass(WND_CLASS_NAME, hInstance); }
//------------------------------------------------------------------------------ void BaseApplication::go(void) { #ifdef _DEBUG resources_cfg = "resources_d.cfg"; plugins_cfg = "plugins_d.cfg"; #else resources_cfg = "resources.cfg"; plugins_cfg = "plugins.cfg"; #endif // Check for errors if (!setup()) return; // Launch root->startRendering(); // Clean up destroyScene(); }
SampleWindow::SampleWindow(Parameters& parameters) #if USE_SDL : SDLWindow(parameters) { #else : GLFWWindow(parameters) { #endif m_camera->setPosition(Vec3(0.0f, 0.0f, -10.0f)); createEffects(); createScene(); } SampleWindow::~SampleWindow() { destroyScene(); destroyEffects(); } void SampleWindow::createEffects() { m_visualEffects[0] = m_renderer->createVisualEffect("smooth.vert", "smooth.frag"); m_visualEffects[1] = m_renderer->createVisualEffect("gouraud.vert", "gouraud.frag"); m_visualEffects[2] = m_renderer->createVisualEffect("phong.vert", "phong.frag"); }
void ClientSideGame::go(void) { #ifdef _DEBUG mResourcesCfg = "resources_d.cfg"; mPluginsCfg = "plugins_d.cfg"; #else mResourcesCfg = "resources.cfg"; mPluginsCfg = "plugins.cfg"; #endif if (!setup()) return; while(keepRunning) { gameLoop(); } // clean up destroyScene(); }
void BaseManager::shutdown() { mPreLuaScript.clear(); mPreLuaLocation.clear(); mPreLoad.clear(); destroyScene(); destroyPointerManager(); destroyInput(); destroyGui(); mSceneManager->destroyQuery( mSceneQuery ); mSceneQuery = nullptr; destroySceneManager(); //清除内部帧监听器 //必须在destroyScene等后面被施放 delete mInputFilter; mInputFilter = nullptr; if (mRoot) { Ogre::RenderWindow* window = mRoot->getAutoCreatedWindow(); if (window) window->removeAllViewports(); OGRE_DELETE mRoot; mRoot = nullptr; } if( mCoutSource ){ //删除mCoutSource,不要过早删除它。 delete mCoutSource; mCoutSource = nullptr; } }
//------------------------------------------------------------------------------------- void BaseApplication::go(void) { #ifdef _DEBUG mResourcesCfg = "resources_d.cfg"; mPluginsCfg = "plugins_d.cfg"; #else mResourcesCfg = "resources.cfg"; mPluginsCfg = "plugins.cfg"; #endif if (!setup()) return; while(!mShutDown) { Update(); Render(); } // clean up destroyScene(); }
CIrrWindow::~CIrrWindow() { destroyScene(); m_device->drop(); }
OgreApp::~OgreApp(){ destroyScene(); if (mRoot) delete mRoot; }
void MainMenuScene::onExitScene(){ destroyScene(); }
/** * * \param pScene */ void World::destroyScene(Scene* pScene) { destroyScene(pScene->getName()); }
int main(int argc, char* argv[]) { glfwSetErrorCallback(error_callback); if (!glfwInit()) return 1; glfwWindowHint(GLFW_RED_BITS, 8); glfwWindowHint(GLFW_GREEN_BITS, 8); glfwWindowHint(GLFW_BLUE_BITS, 8); glfwWindowHint(GLFW_ALPHA_BITS, 8); glfwWindowHint(GLFW_DEPTH_BITS, 32); glfwWindowHint(GLFW_STENCIL_BITS, GLFW_DONT_CARE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); glfwWindowHint(GLFW_SAMPLES, 4); GLFWwindow *window = glfwCreateWindow(1024, 768, "Lightmapping Example", NULL, NULL); if (!window) return 1; glfwMakeContextCurrent(window); gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); glfwSwapInterval(1); scene_t scene = {0}; if (!initScene(&scene)) { fprintf(stderr, "Could not initialize scene.\n"); return 1; } printf("Ambient Occlusion Baking Example.\n"); printf("Use your mouse and the W, A, S, D, E, Q keys to navigate.\n"); printf("Press SPACE to start baking one light bounce!\n"); printf("This will take a few seconds and bake a lightmap illuminated by:\n"); printf("1. The mesh itself (initially black)\n"); printf("2. A white sky (1.0f, 1.0f, 1.0f)\n"); while (!glfwWindowShouldClose(window)) { glfwPollEvents(); if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) bake(&scene); int w, h; glfwGetFramebufferSize(window, &w, &h); glViewport(0, 0, w, h); // camera for glfw window float view[16], projection[16]; fpsCameraViewMatrix(window, view); perspectiveMatrix(projection, 45.0f, (float)w / (float)h, 0.01f, 100.0f); // draw to screen with a blueish sky glClearColor(0.6f, 0.8f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); drawScene(&scene, view, projection); glfwSwapBuffers(window); } destroyScene(&scene); glfwDestroyWindow(window); glfwTerminate(); return 0; }
void SplashScene::onExitScene(){ destroyScene(); }
//------------------------------------------------------------------------------------- bool App::update(float a_DeltaT) { //process networking m_NetworkManager.ProcessNetworkIO(a_DeltaT); //get window messages MSG msg; while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage(&msg); DispatchMessage(&msg); } //check to see if we've connected to a new server if(m_NetworkManager.IsConnectedToServer() && !m_SceneSetup) createScene(); //check to see if we've been disconnected from a server if(!m_NetworkManager.IsConnectedToServer() && m_SceneSetup) destroyScene(); //check to see if any new players have joined while(m_NetworkManager.HaveNewPlayersConnected()) { NodeInfo newConnectee = m_NetworkManager.GetNewConnectee(); m_Entities.push_back(new PlayerEntity(newConnectee.nodeName, newConnectee.node_uid, *mSceneMgr, NULL)); m_ConnectedNodes.push_back(newConnectee); } //update player if(m_pPlayerEntity) m_pPlayerEntity->Update(a_DeltaT); else std::cout << ""; //check to see if we have any updated info from other entities if(m_NetworkManager.HaveEntitiesUpdatedPos()) { std::map<int, Ogre::Vector3> newPositions = m_NetworkManager.GetNewEntityPos(); while(newPositions.size()) { for(unsigned short n=0;n<m_Entities.size();n++) { if(m_Entities[n]->GetNodeUID() == newPositions.begin()->first) { m_Entities[n]->SetPosition( newPositions.begin()->second ); break; } } newPositions.erase(newPositions.begin()); } } //update all other entities for(unsigned short n=0;n<m_Entities.size();n++) { if(m_Entities[n]) m_Entities[n]->Update(a_DeltaT); } //handle input injection and misc other Ogre::FrameEvent frameEvent; frameRenderingQueued(frameEvent); //render a single frame return mRoot->renderOneFrame(); }
bool DemoApplication::go(void) { #ifdef _DEBUG mResourcesCfg = "resources_d.cfg"; mPluginsCfg = "plugins_d.cfg"; #else mResourcesCfg = "resources.cfg"; mPluginsCfg = "plugins.cfg"; #endif // construct Ogre::Root mRoot = new Ogre::Root(mPluginsCfg); if(!mRoot->showConfigDialog()) { return false; } // setup resources // Load resource paths from config file Ogre::ConfigFile cf; cf.load(mResourcesCfg); // Go through all sections & settings in the file Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); Ogre::String secName, typeName, archName; while (seci.hasMoreElements()) { secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); } } // configure // Show the configuration dialog and initialise the system // You can skip this and use root.restoreConfig() to load configuration // settings if you were sure there are valid ones saved in ogre.cfg if(mRoot->restoreConfig() || mRoot->showConfigDialog()) { // If returned true, user clicked OK so initialise // Here we choose to let the system create a default rendering window by passing 'true' mWindow = mRoot->initialise(true, "Render Window"); } else { return false; } m_initializationSuccessful = true; // choose scene manager // Get the SceneManager, in this case a generic one mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); //------------------------------------------------------------------------------------- // Set default mip map level (NB some APIs ignore this) Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(MIP_UNLIMITED); // Create any resource listeners (for loading screens) //createResourceListener(); // load resources Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); // Init the input system InitCamera(); // Init the input system InitInputSystem(); // // create a a physics world m_physicsWorld = OnCreateWorld (this); // // create a debug Renderer for showing physics data visually m_debugRender = new OgreNewtonDebugger (mSceneMgr->getRootSceneNode()->createChildSceneNode("_OgreNewton_Debugger_Node_"), m_physicsWorld); // crate frame listeners createFrameListener(); // call for creation of the scene createScene(); while(!m_exitApplication) { // Pump window messages for nice behavior Ogre::WindowEventUtilities::messagePump(); if(mWindow->isClosed()) { break; } // do the physics update m_physicsWorld->Update(); // Render a frame if(!mRoot->renderOneFrame()) { break; } } // destroy the scene before quiting m_physicsWorld->WaitForUpdateToFinish(); destroyScene(); return true; }
void GamePlayScene::onExitScene(){ destroyScene(); }
Scene::~Scene(void) { destroyScene(); }
int main(int argc, char* argv[]) { glfwSetErrorCallback(error_callback); if (!glfwInit()) { fprintf(stderr, "Could not initialize GLFW.\n"); return EXIT_FAILURE; } glfwWindowHint(GLFW_RED_BITS, 8); glfwWindowHint(GLFW_GREEN_BITS, 8); glfwWindowHint(GLFW_BLUE_BITS, 8); glfwWindowHint(GLFW_ALPHA_BITS, 8); glfwWindowHint(GLFW_DEPTH_BITS, 32); glfwWindowHint(GLFW_STENCIL_BITS, GLFW_DONT_CARE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); glfwWindowHint(GLFW_SAMPLES, 4); GLFWwindow *window = glfwCreateWindow(1024, 768, "Lightmapping Example", NULL, NULL); if (!window) { fprintf(stderr, "Could not create window.\n"); glfwTerminate(); return EXIT_FAILURE; } glfwMakeContextCurrent(window); gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); glfwSwapInterval(1); scene_t scene = {0}; if (!initScene(&scene)) { fprintf(stderr, "Could not initialize scene.\n"); glfwDestroyWindow(window); glfwTerminate(); return EXIT_FAILURE; } printf("Ambient Occlusion Baking Example.\n"); printf("Use your mouse and the W, A, S, D, E, Q keys to navigate.\n"); printf("Press SPACE to start baking one light bounce!\n"); printf("This will take a few seconds and bake a lightmap illuminated by:\n"); printf("1. The mesh itself (initially black)\n"); printf("2. A white sky (1.0f, 1.0f, 1.0f)\n"); while (!glfwWindowShouldClose(window)) { mainLoop(window, &scene); } destroyScene(&scene); glfwDestroyWindow(window); glfwTerminate(); return EXIT_SUCCESS; }