Delta3d框架学习--程序启动过程详解
2017-02-27 10:18
483 查看
一个Delta3d程序启动过程详解
一、初始化一个dtGame::GameApplication的实例,dtGame::GameApplication* app = new dtGame::GameApplication();
设置游戏库的名称,SetGameLibraryName("libname");
调用app->Config("config.xml");Config内容如下:
在GameEntryPoint中的OnStartUp函数中将相应的组件添加至游戏管理器GameManager中;
在dtCore::System中有一个定时的循环,在循环中发送相关的消息(System::MESSAGE_FRAME等),然后在dtABC::BaseABC中的OnMessage()中进行消息响应。
一、初始化一个dtGame::GameApplication的实例,dtGame::GameApplication* app = new dtGame::GameApplication();
设置游戏库的名称,SetGameLibraryName("libname");
调用app->Config("config.xml");Config内容如下:
//解析GameEntryPoint的dll,获取相关函数指针 dtUtil::LibrarySharingManager& lsm = dtUtil::LibrarySharingManager::GetInstance(); std::string libName = GetGameLibraryName(); mEntryPointLib = lsm.LoadSharedLibrary(libName); dtUtil::LibrarySharingManager::LibraryHandle::SYMBOL_ADDRESS createAddr; dtUtil::LibrarySharingManager::LibraryHandle::SYMBOL_ADDRESS destroyAddr; createAddr = mEntryPointLib->FindSymbol("CreateGameEntryPoint"); destroyAddr = mEntryPointLib->FindSymbol("DestroyGameEntryPoint"); mCreateFunction = reinterpret_cast<CreateEntryPointFn>(createAddr); mDestroyFunction = reinterpret_cast<DestroyEntryPointFn>(destroyAddr); //创建Aplication和GameManager mApplication = mEntryPoint->CreateApplication(configFileName); mGameManager = new dtGame::GameManager(*mApplication->GetScene()); //执行相关初始化 mEntryPoint->Initialize(*mApplication, mArgc, mArgv); mApplication->Config(); mEntryPoint->OnStartup(*mApplication, *mGameManager); //开始系统循环 dtCore::System::GetInstance().Start();
在GameEntryPoint中的OnStartUp函数中将相应的组件添加至游戏管理器GameManager中;
在dtCore::System中有一个定时的循环,在循环中发送相关的消息(System::MESSAGE_FRAME等),然后在dtABC::BaseABC中的OnMessage()中进行消息响应。
void BaseABC::OnMessage(MessageData* data) { if (data->message == dtCore::System::MESSAGE_EVENT_TRAVERSAL) { EventTraversal(*static_cast<const double*>(data->userData)); } else if (data->message == dtCore::System::MESSAGE_PRE_FRAME) { PreFrame(*static_cast<const double*>(data->userData)); } else if (data->message == dtCore::System::MESSAGE_FRAME) { Frame(*static_cast<const double*>(data->userData)); } else if (data->message == dtCore::System::MESSAGE_POST_FRAME) { PostFrame(*static_cast<const double*>(data->userData)); } else if (data->message == dtCore::System::MESSAGE_PAUSE) { Pause(*static_cast<const double*>(data->userData)); } }在Frame函数中进行模型的渲染
void Application::Frame(const double deltaSimTime) { if(!mCompositeViewer->done()) { bool singleThreaded = mCompositeViewer->getThreadingModel() == osgViewer::ViewerBase::SingleThreaded; //NOTE: The OSG frame() advances the clock and does three traversals, event, update, and render. //We are moving the event traversal to be its own message so we can reliably accept input during the //typical Delta3D update of PreFrame(). The only exception to this is that we need if(mFirstFrame) { #ifndef MULTITHREAD_FIX_HACK_BREAKS_CEGUI dtCore::ObserverPtr<osgViewer::GraphicsWindow> gw; if (GetWindow() != NULL) { gw = GetWindow()->GetOsgViewerGraphicsWindow(); } if (!singleThreaded && gw.valid() && gw->isRealized()) { gw->releaseContext(); } #endif if (singleThreaded) { GetCompositeViewer()->setReleaseContextAtEndOfFrameHint(false); } mCompositeViewer->setUpThreading(); mCompositeViewer->frame(dtCore::System::GetInstance().GetSimTimeSinceStartup()); mFirstFrame = false; } // NOTE: The new version OSG (2.2) relies on absolute frame time // to update drawables; especially particle systems. // The time delta will be ignored here and the absolute simulation // time passed to the OSG scene updater. mCompositeViewer->advance(dtCore::System::GetInstance().GetSimTimeSinceStartup()); mCompositeViewer->updateTraversal(); mCompositeViewer->renderingTraversals(); } }
相关文章推荐
- android框架学习一android启动过程
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- Android应用框架之应用启动过程详解
- 大数据技术学习笔记之Hadoop框架基础4-MapReduceshuffer过程详解及zookeeper框架学习
- Android开发学习笔记4--安卓程序安装与启动过程剖析
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- 跟着Code走,详解Symbian UI程序框架(3)——窗口管理及绘制过程
- Android的学习之路(三)项目的启动过程和安装过程详解
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- UI基础学习之(六):程序的启动过程
- Android启动过程详解(1)——总体启动框架
- iOS开发学习之iOS程序启动过程
- 程序的启动和退出过程详解
- SpringMvc如何学习框架技术? 就像如上的图示一样,先掌握新技术的体系流程图。在快速弄明白程序执行流程后,在使用过程中 了解细节。
- MFC学习笔记之:程序关闭过程的函数响应顺序详解
- android应用程序窗口框架学习(3)-应用程序的进程的启动过程
- S60 Symbian程序框架及启动过程简介
- DOS的启动过程详解分析