Delta3d框架学习--程序启动过程详解
来源:互联网 发布:添加网络打印机搜不到 编辑:程序博客网 时间:2024/05/30 05:04
一个Delta3d程序启动过程详解
一、初始化一个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和GameManagermApplication = 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(); }}
0 0
- Delta3d框架学习--程序启动过程详解
- 程序的启动和退出过程详解
- Delta3D 引擎 框架 结构分析
- HelloWord 第一个delta3D程序
- S60 Symbian程序框架及启动过程简介
- Delta3D学习之App类
- Delta3D学习之dtCore::System
- Delta3D学习之dtCore::System
- Android 启动过程框架
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- OGRE启动过程详解(OGRE HelloWorld程序原理解析)
- Spring框架学习【Web环境中Spring的启动过程】
- win32程序启动过程
- Cocoa程序启动过程
- MFC程序启动过程
- placeholder 修改颜色
- elasticsearch failed to parse date field
- NLTK数据下载
- THINKPHP之调试数据库错误信息
- 目前比较全的CSS重设(reset)方法总结
- Delta3d框架学习--程序启动过程详解
- 数据库三大范式
- 5. Longest Palindromic Substring
- Sqlite使用
- c++UTM地理坐标系与WGS84地理坐标系之间的转换
- 调用startActivityForResult,onActivityResult无响应?
- 关于NIO笔记(一):IO与NIO的区别
- Bluetooth SDP
- Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)