日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Delta3d框架学习--程序启动过程详解

發布時間:2024/8/23 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Delta3d框架学习--程序启动过程详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一個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和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 needif(mFirstFrame){#ifndef MULTITHREAD_FIX_HACK_BREAKS_CEGUIdtCore::ObserverPtr<osgViewer::GraphicsWindow> gw;if (GetWindow() != NULL){gw = GetWindow()->GetOsgViewerGraphicsWindow();}if (!singleThreaded && gw.valid() && gw->isRealized()){gw->releaseContext();} #endifif (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();} }




總結

以上是生活随笔為你收集整理的Delta3d框架学习--程序启动过程详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。