// Advances GFx animation and draws the scene. void FxPlayerTiny::AdvanceAndDisplay() { // Clear the back buffer to a black color. pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(200,200,200), 1.0f, 0); // *** GFx Rendering if (pMovie) { // GRendererD3D9 does not modify D3DRS_FILLMODE, so we can set it here. pDevice->SetRenderState(D3DRS_FILLMODE, Wireframe ? D3DFILL_WIREFRAME : D3DFILL_SOLID); UInt32 time = timeGetTime(); Float delta = ((Float)(time - MovieLastTime)) / 1000.0f; // Advance time and display the movie. if (!Paused) pMovie->Advance(delta); pMovie->Display(); MovieLastTime = time; } // Present the back buffer contents to the display. pDevice->Present(NULL, NULL, NULL, NULL); }
//------------------------------------------------------------------------ void SkeletonComponent::CopyFrom( const GPtr<Component>& pComponent ) { if( !pComponent.isvalid() ) return; if( !pComponent->GetRtti()->IsDerivedFrom( *(this->GetRtti()) ) ) return; // TODO: GPtr<SkeletonComponent> pSource = pComponent.downcast<SkeletonComponent>(); n_assert(pSource.isvalid()); SetSkeletonID(pSource->GetSkeletonID()); }
void FxPlayerTiny::OnMouse(GFxEvent::EventType eventType, UInt button, SInt x, SInt y) { if (pMovie) { GFxMouseEvent mevent(eventType, button, (Float)x, (Float)y); pMovie->HandleEvent(mevent); } if (pHUD) { GFxMouseEvent mevent(eventType, button, (Float)x, (Float)y); pHUD->HandleEvent(mevent); } }
void FxPlayerTiny::DisplayHUD() { if (pHUD) { pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); UInt32 time = timeGetTime(); Float delta = ((Float)(time - MovieLastTime)) / 1000.0f; pHUD->Advance(delta); pHUD->Display(); MovieLastTime = time; } }
// Helper function that converts Windows VK keyCode values // to GFxKeyEvents and routes them to GFxPlayer. void FxPlayerTiny::HandleKeyEvent(UInt keyCode, bool downFlag) { GFxKey::Code key(GFxKey::VoidSymbol); if (keyCode >= 'A' && keyCode <= 'Z') { key = (GFxKey::Code) ((keyCode - 'A') + GFxKey::A); } else if (keyCode >= VK_F1 && keyCode <= VK_F15) { key = (GFxKey::Code) ((keyCode - VK_F1) + GFxKey::F1); } else if (keyCode >= VK_NUMPAD0 && keyCode <= VK_NUMPAD9) { key = (GFxKey::Code) ((keyCode - VK_NUMPAD0) + GFxKey::KP_0); } else { // Use a look-up table for keys don't correlate in order,. struct { int vk; GFxKey::Code gs; } table[] = { { VK_RETURN, GFxKey::Return }, { VK_ESCAPE, GFxKey::Escape }, { VK_LEFT, GFxKey::Left }, { VK_UP, GFxKey::Up }, { VK_RIGHT, GFxKey::Right }, { VK_DOWN, GFxKey::Down }, { VK_SPACE, GFxKey::Space }, { VK_BACK, GFxKey::Backspace }, { VK_DELETE, GFxKey::Delete }, { VK_INSERT, GFxKey::Insert }, // TODO: fill this out some more { 0, GFxKey::VoidSymbol } }; for (int i = 0; table[i].vk != 0; i++) { if (keyCode == (UInt)table[i].vk) { key = table[i].gs; break; } } } if (key != GFxKey::VoidSymbol) { if (pMovie) { // Pass Key events to the movie so that can be handled in ActionScript. GFxKeyEvent event(downFlag ? GFxEvent::KeyDown : GFxKeyEvent::KeyUp, key); pMovie->HandleEvent(event); } } }
// OnKey handles system keys by first interpreting some Ctrl+Key combinations // in a special way and passing the rest of them to the movie. void FxPlayerTiny::OnKey(UInt keyCode, bool downFlag) { if (!pMovie) return; bool ctrl = ControlKeyDown; if (keyCode == VK_CONTROL) { ControlKeyDown = downFlag; return; } if (keyCode == VK_MENU && downFlag) ControlKeyDown = false; // to enable Ctrl-Alt-... combinations to work if (ctrl && downFlag) { switch(keyCode) { case 'W': Wireframe = !Wireframe; break; case 'A': AAEnabled = ! AAEnabled; { UInt32 rendererFlags = pRenderConfig->GetRenderFlags() & ~GFxRenderConfig::RF_EdgeAA; if (AAEnabled) rendererFlags |= GFxRenderConfig::RF_EdgeAA; pRenderConfig->SetRenderFlags(rendererFlags); } break; case 'P': Paused = !Paused; break; } } else if (!ctrl) { HandleKeyEvent(keyCode, downFlag); } }
void FxPlayerTiny::DisplayLoginScreen() { pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(200,200,200), 1.0f, 0); if (pMovie) { pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); UInt32 time = timeGetTime(); Float delta = ((Float)(time - MovieLastTime)) / 1000.0f; pMovie->Advance(delta); pMovie->Display(); MovieLastTime = time; } pDevice->Present(NULL, NULL, NULL, NULL); }
void SkeletonComponent::SetAnimSkelTree() { //Find animation data Actor* actorParent = mActor->GetParent(); if (!actorParent) { return; } GPtr<Component> animation = actorParent->FindComponent(AnimationComponent::RTTI); if(animation.isvalid()) { GPtr<AnimationComponent> pAnimationCom = animation.downcast<AnimationComponent>(); const GPtr<SkeletonRes>& skeletonRes = GetSkeleton(); if (skeletonRes.isvalid() && !skeletonRes->IsSkelTreeEmpty()) { pAnimationCom->SetSkelTree(skeletonRes->GetSkelTree()); pAnimationCom->SetSkelTree(skeletonRes->GetSkelTreeArray()); pAnimationCom->SetGetSkelTree(true); m_bSkeletonDirty = false; } } }
// Window Message handler. Interprets windows messages and dispatches // mouse/keyboard input to the OnMouse/OnKeyboard functions. LRESULT FxPlayerTiny::MemberWndProc(UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_SETCURSOR: if (LOWORD(lParam)==HTCLIENT) { ::SetCursor(::LoadCursor(0, IDC_ARROW)); return 0; } break; // *** The following logic is used to route input to GFxPlayer. case WM_MOUSEMOVE: OnMouse(GFxEvent::MouseMove, 0, LOWORD(lParam), HIWORD(lParam)); return 0; case WM_LBUTTONDOWN: ::SetCapture(hWnd); OnMouse(GFxEvent::MouseDown, 0, LOWORD(lParam), HIWORD(lParam)); return 0; case WM_LBUTTONUP: ::ReleaseCapture(); OnMouse(GFxEvent::MouseUp, 0, LOWORD(lParam), HIWORD(lParam)); return 0; case WM_KEYDOWN: OnKey((UInt)wParam, 1); return 0; case WM_KEYUP: OnKey((UInt)wParam, 0); return 0; case WM_CHAR: { UInt32 wcharCode = (UInt32)wParam; if (pMovie && wcharCode) { GFxCharEvent event(wcharCode); pMovie->HandleEvent(event); } } break; } return DefWindowProc(hWnd, msg, wParam, lParam); }
void AutopatcherClientGFx3Impl::Init(const char *_pathToThisExe, GPtr<FxDelegate> pDelegate, GPtr<GFxMovieView> pMovie) { pDelegate->RegisterHandler(this); delegate=pDelegate; movie=pMovie; strcpy(pathToThisExe,_pathToThisExe); autopatcherClient=RakNet::OP_NEW<AutopatcherClient>(_FILE_AND_LINE_); fileListTransfer=RakNet::OP_NEW<FileListTransfer>(_FILE_AND_LINE_); packetizedTCP=RakNet::OP_NEW<PacketizedTCP>(_FILE_AND_LINE_); autopatcherClient->SetFileListTransferPlugin(fileListTransfer); packetizedTCP->AttachPlugin(autopatcherClient); packetizedTCP->AttachPlugin(fileListTransfer); }
// Called from main()/WindMain() after settings are initialized to execute // most of the program logic. Responsible for setting up the window, // loading movies and containing the playback/message loop. int FxPlayerTiny::Run() { if (!SetupWindow(GString(FXPLAYER_APP_TITLE " ") + FileName)) return 1; // Show the window. ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow(hWnd); // Create and Configure GFxLoader. GFxLoader loader; // Developers set states on the loader to modify loading and playback behavior. // If you need to load files from a custom package, for example, you can // create a GFxFileOpener derived class that loads files in a custom way. // Here GFxFileOpener and GFxFSCommandHandler are set for sample purposes. GPtr<GFxFileOpener> pfileOpener = *new GFxFileOpener; loader.SetFileOpener(pfileOpener); GPtr<GFxFSCommandHandler> pcommandHandler = *new FxPlayerFSCommandHandler; loader.SetFSCommandHandler(pcommandHandler); // For D3D, it is good to override image creator to keep image data, // so that it can be restored in case of a lost device. GPtr<GFxImageCreator> pimageCreator = *new GFxImageCreator(1); loader.SetImageCreator(pimageCreator); // Load the movie file and create its instance. if (!(pMovieDef = *loader.CreateMovie(FileName))) { GString errorString = "Unable to load file: "; errorString += FileName; MessageBox(NULL, errorString.ToCStr(), "Error", MB_OK | MB_ICONEXCLAMATION); return 1; } if (!(pMovie = *pMovieDef->CreateInstance())) return 1; // Create renderer. if (!(pRenderer = *GRendererD3D9::CreateRenderer())) return 1; // Configure renderer in "Dependent mode", honoring externally // configured device settings. if (!pRenderer->SetDependentVideoMode(pDevice, &PresentParams, 0, hWnd)) return 1; // Set renderer on loader so that it is also applied to all children. pRenderConfig = *new GFxRenderConfig(pRenderer, GFxRenderConfig::RF_EdgeAA | GFxRenderConfig::RF_StrokeNormal); loader.SetRenderConfig(pRenderConfig); // Set playback view to span the entire window. pMovie->SetViewport(Width, Height, 0,0, Width, Height); // If you wanted to use the movie as a transparent HUD overlay, you would // set Background Alpha to 0. We don't need to do this for player sample. // pMovie->SetBackgroundAlpha(0.0f); // Store initial timing, so that we can determine // how much to advance Flash playback. MovieLastTime = timeGetTime(); // Application / Player message loop. MSG msg; ZeroMemory(&msg, sizeof(msg)); // KevinJ: 1/3 functions, Init() // Path to current exe is used to the patcher can restart itself if needed RakNet::Lobby2ClientGFx3Impl sampleImpl; GPtr<FxDelegate> pDelegate = *new FxDelegate; pMovie->SetExternalInterface(pDelegate); RakNet::Lobby2Client lobby2Client; RakNet::Lobby2MessageFactory messageFactory; RakNet::RakPeerInterface *rakPeer = RakNet::RakPeerInterface::GetInstance(); RakNet::SocketDescriptor sd; rakPeer->Startup(1,&sd, 1); rakPeer->AttachPlugin(&lobby2Client); rakPeer->AttachPlugin(&sampleImpl); lobby2Client.SetMessageFactory(&messageFactory); lobby2Client.SetCallbackInterface(&sampleImpl); sampleImpl.Init(&lobby2Client, &messageFactory, rakPeer, pDelegate, pMovie); while(msg.message != WM_QUIT) { if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { // Check for lost D3D Devices. if (pRenderer) { GRendererD3D9::DisplayStatus status = pRenderer->CheckDisplayStatus(); if (status == GRendererD3D9::DisplayStatus_Unavailable) { ::Sleep(10); continue; } if (status == GRendererD3D9::DisplayStatus_NeedsReset) { if (!SUCCEEDED(ResetD3D())) continue; } } // Advance movie animation and render it to screen. AdvanceAndDisplay(); } // KevinJ: 2/3 functions, periodic update RakNet::Packet *p; for (p=rakPeer->Receive(); p; rakPeer->DeallocatePacket(p), p=rakPeer->Receive()) { } } // KevinJ: 3/3 functions, Shutdown() sampleImpl.Shutdown(); RakNet::RakPeerInterface::DestroyInstance(rakPeer); return 0; }
void GenesisTexture::createManual(int _width, int _height, TextureUsage _usage, PixelFormat _format) { m_width = _width; m_height = _height; mOriginalUsage = _usage; setFormat(_format); RenderBase::PixelFormat::Code wj_format = FormatMyGuiToWj(_format); GPtr<RenderBase::Texture> tex = RenderBase::Texture::Create(); tex->Setup(); // set type RenderBase::Texture::Type texType = RenderBase::Texture::Texture2D; tex->SetType( texType ); tex->SetWidth( _width ); tex->SetHeight( _height ); tex->SetDepth( 1); tex->SetNumMipLevels( 1 ); tex->SetPixelFormat( wj_format ); tex->SetUsage(UsageMyGuiToWj(_usage)); //tex->SetUsage(RenderBase::RenderResource::UsageDynamic); tex->SetAccess(RenderBase::RenderResource::AccessWrite); // dummy tex->SetSkippedMips( 0 ); tex->SetUnitIndex( 0 ); //tex->SetTexturePath(); if (m_texStream) { m_texStream = NULL; } m_texStream = IO::MemoryStream::Create(); m_texStream->SetAccessMode( IO::Stream::WriteAccess ); if( m_texStream->Open() ) { m_texStream->SetSize(m_width * m_height * mNumElemBytes); tex->SetStream( m_texStream.upcast<IO::Stream>() ); m_texStream->Close(); //m_texStream->SetAccessMode( IO::Stream::ReadAccess ); m_texHandle = Graphic::GraphicSystem::Instance()->CreateTexture(tex); GenesisTextureMgr::Instance()->AddManualTexture(this); m_bManualCreate = true; } else { m_texHandle = NULL; m_width = 0; m_height = 0; mOriginalUsage = TextureUsage::Default; mOriginalFormat = PixelFormat::Unknow; } }
void GenesisTextureMgr::ReLoadManualTextures() const { SizeT nCount = m_ManualTextures.Size(); for (IndexT i = 0; i < nCount; ++i) { GenesisTexture* pTex = m_ManualTextures[i]; SizeT width = pTex->getWidth(); SizeT height = pTex->getHeight(); RenderBase::PixelFormat::Code wj_format = GenesisTexture::FormatMyGuiToWj(pTex->getFormat()); GPtr<RenderBase::Texture> tex = RenderBase::Texture::Create(); tex->Setup(); // set type RenderBase::Texture::Type texType = RenderBase::Texture::Texture2D; tex->SetType( texType ); tex->SetWidth( width ); tex->SetHeight( height ); tex->SetDepth( 1); tex->SetNumMipLevels( 1 ); tex->SetPixelFormat( wj_format ); tex->SetAccess(RenderBase::RenderResource::AccessWrite); // dummy tex->SetSkippedMips( 0 ); tex->SetUnitIndex( 0 ); tex->SetStream( pTex->GetBuffer().upcast<IO::Stream>() ); Graphic::GraphicSystem::Instance()->UpdateTexture(pTex->GetTextureHandle(), tex); } }
void GenesisTexture::loadFromFile(const std::string& _filename) { Util::String filename = _filename.c_str(); Util::String url = s_resourcePath + filename; /*Resources::ResourceServer* resServer = Resources::ResourceServer::Instance(); GPtr<Resource> pRes = resServer->CreateOrGetResource(url, &ImageRes::RTTI ); n_assert( pRes.isvalid() ); if ( pRes->GetState() != Resource::Loaded ) { bool bOK = resServer->LoadResource(pRes,false); if (!bOK) { m_texHandle = RenderBase::PrimitiveHandle(); return; } } GPtr<ImageRes> pImage = pRes.downcast<ImageRes>(); n_assert( pImage.isvalid() ); //pImage->SetManuLoad(true); // 避免被卸载 if ( !pRes.isvalid() || !pRes->GetResourceId().IsValid() ) { m_texHandle = RenderBase::PrimitiveHandle(); return; } m_width = pImage->GetWidth(); m_height = pImage->GetHeight(); mOriginalUsage = TextureUsage::Default; setFormat(FormatWjToMyGui(pImage->GetPixelFormat()));//mOriginalFormat = const GPtr<GraphicSystem>& gs = GraphicSystem::Instance(); n_assert(gs.isvalid()); GPtr<RenderBase::Texture> tex = _BuildTextureData(pImage, m_texStream); if ( tex.isvalid() ) { m_texHandle = gs->CreateTexture( tex ); } else { m_texHandle = RenderBase::TextureHandle(); } pRes->UnLoad(); m_texStream = NULL;*/ GPtr<TextureResInfo> tri = Resources::ResourceManager::Instance()->CreateTextureInfo(url, 0); m_texHandle = tri->GetHandle(); RenderBase::TEXTURE_DESC texDesc; GraphicSystem::Instance()->GetTextureDesc(m_texHandle, texDesc); m_width = texDesc.width; m_height = texDesc.height; mOriginalUsage = TextureUsage::Default; setFormat(FormatWjToMyGui(texDesc.pixelFormat));//mOriginalFormat = }
GPtr<RenderBase::Texture> _BuildTextureData(const GPtr<Resources::ImageRes>& image, GPtr<IO::MemoryStream>& memStream) { n_assert(image.isvalid()); if ( !image.isvalid() ) { return GPtr<RenderBase::Texture>(); } if ( !image->Validata() ) { return GPtr<RenderBase::Texture>(); } GPtr<RenderBase::Texture> tex = RenderBase::Texture::Create(); tex->Setup(); // set type RenderBase::Texture::Type texType = RenderBase::Texture::InvalidType; if ( image->GetNumFace() == 1 ) { if ( image->GetDepth() == 1) { texType = RenderBase::Texture::Texture2D; } else { n_assert( image->GetDepth() > 1); texType = RenderBase::Texture::Texture3D; } } else { n_assert( image->GetNumFace() > 1); texType = RenderBase::Texture::TextureCube; } n_assert( texType != RenderBase::Texture::InvalidType) tex->SetType( texType ); tex->SetWidth( image->GetWidth() ); tex->SetHeight( image->GetHeight() ); tex->SetDepth( image->GetDepth() ); tex->SetNumMipLevels( image->GetMipMapLevel() + 1 ); tex->SetPixelFormat( image->GetPixelFormat() ); // dummy tex->SetSkippedMips( 0 ); tex->SetUnitIndex( 0 ); n_assert( image->GetResourceId().IsValid() ); tex->SetTexturePath(image->GetResourceId()); const GPtr<ImageData>& imageData = image->GetImageData(); n_assert( imageData.isvalid() ); if (memStream) { memStream = NULL; } memStream = IO::MemoryStream::Create(); memStream->SetAccessMode( IO::Stream::ReadWriteAccess ); if( memStream->Open() ) { memStream->Write( imageData->Ptr(), imageData->Size() ); tex->SetStream( memStream.upcast<IO::Stream>() ); memStream->Close(); return tex; } return GPtr<RenderBase::Texture>(); }
int FxPlayerTiny::Run() { // Windows conf if (!SetupWindow(GString(FXPLAYER_APP_TITLE " "))) return 1; ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow(hWnd); // Gfx conf GFxLoader loader; GPtr<GFxFileOpener> pfileOpener = *new GFxFileOpener; loader.SetFileOpener(pfileOpener); // Register FsCommandHander GPtr<GFxFSCommandHandler> pcommandHandler = *new FxPlayerFSCommandHandler; loader.SetFSCommandHandler(pcommandHandler); // Register FsDelegate pGameDelegate = *new FxDelegate(); loader.SetExternalInterface(pGameDelegate); pGameDelegate->RegisterHandler(this); GPtr<GFxImageCreator> pimageCreator = *new GFxImageCreator(1); loader.SetImageCreator(pimageCreator); // Login flash if (!(pMovieDef = *loader.CreateMovie(FXPLAYER_FILENAME))) { GString errorString = "Unable to load file: "; MessageBox(NULL, errorString.ToCStr(), "Error", MB_OK | MB_ICONEXCLAMATION); return 1; } if (!(pMovie = *pMovieDef->CreateInstance())) return 1; pMovie->SetViewport(Width, Height, 0,0, Width, Height); // HUD flash if (!(pHUDDef = *loader.CreateMovie(CONFIG_FILENAME))) { GString errorString = "Unable to load file: "; MessageBox(NULL, errorString.ToCStr(), "Error", MB_OK | MB_ICONEXCLAMATION); return 1; } if (!(pHUD = *pHUDDef->CreateInstance())) return 1; pHUD->SetBackgroundAlpha(0.0f); pHUD->SetViewport(Width, Height, 0,0, Width, Height); // render config if (!(pRenderer = *GRendererD3D9::CreateRenderer())) return 1; if (!pRenderer->SetDependentVideoMode(pDevice, &PresentParams, 0, hWnd)) return 1; pRenderConfig = *new GFxRenderConfig(pRenderer, GFxRenderConfig::RF_EdgeAA | GFxRenderConfig::RF_StrokeNormal); loader.SetRenderConfig(pRenderConfig); // how much to advance Flash playback. MovieLastTime = timeGetTime(); // Application / Player message loop. MSG msg; ZeroMemory(&msg, sizeof(msg)); while(msg.message != WM_QUIT && g_gamestate != GAME_STATE::QUIT) { if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { // Check for lost D3D Devices. if (pRenderer) { GRendererD3D9::DisplayStatus status = pRenderer->CheckDisplayStatus(); if (status == GRendererD3D9::DisplayStatus_Unavailable) { ::Sleep(10); continue; } if (status == GRendererD3D9::DisplayStatus_NeedsReset) { if (!SUCCEEDED(ResetD3D())) continue; } } switch (g_gamestate) { case GAME_STATE::LOGIN_SCREEN: DisplayLoginScreen(); break; case GAME_STATE::LOGINED: DisplayGameScreen(); break; default: break; } } } return 0; }
//============================================================ // <T>释放游戏库。</T> //============================================================ TInt WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, TInt nCmdShow){ // 初始化处理 MoGameEngineInitialize(); #ifdef MO_RENDER_DX9 MoEngineDirectX9(); #endif // MO_RENDER_DX9 #ifdef MO_RENDER_DX10 MoEngineDirectX10(); #endif // MO_RENDER_DX10 #ifdef MO_RENDER_DX11 MoEngineDirectX11(); #endif // MO_RENDER_DX11 #ifdef MO_RENDER_GLES2 MoEngineOpenGLES2(); #endif // MO_RENDER_GLES2 RFeatureManager::Instance().Construct(); //............................................................ // 设置信息 RApplication::Instance().Parameters()->Setup(lpszCmdLine); FApplicationParameter* pApplicationParameter = MO_CREATE(FApplicationParameter); pApplicationParameter->SetName("-home"); pApplicationParameter->SetValue("E:/Microbject/MoCross/Demo/Android/MpTestDemo/assets"); RApplication::Instance().Parameters()->Parameters()->Push(pApplicationParameter); RApplication::Instance().SetHinstance(hInstance); RApplication::Instance().SetCommandShow(nCmdShow); RAssetManager::Instance().Setup(); //RTechniqueManager::Instance().Capability().optionInstance = ETrue; //RTechniqueManager::Instance().Capability().optionMerge = ETrue; //............................................................ // 设置日志 FNetLoggerWriter* pWriter = FNetLoggerWriter::InstanceCreate(); pWriter->SetHost("127.0.0.1"); pWriter->SetPort(9999); //pWriter->Open(); //RLoggerFeature::Instance().NetLoggerConsole()->Register(pWriter); // 注册环境信息 TCharC* pHomePath = RApplication::Instance().Parameters()->FindValue("-home"); TCharC* pConfigName = RApplication::Instance().Parameters()->FindValue("-config"); TFsPath configFileName; configFileName.AppendFormat("%s\\%s.xml", pHomePath, pConfigName); GPtr<FXmlParser> xmlParser = FXmlParser::InstanceCreate(); GPtr<FXmlNode> configNode = xmlParser->LoadNodeFile(configFileName); RConfigurationManager::Instance().LoadConfiguration(configFileName); REnvironmentManager::Instance().Register("home", pHomePath); //............................................................ // 创建窗口 SIntSize2 screenSize(1200, 800); #if defined(MO_RENDER_DX9) | defined(MO_RENDER_DX10) | defined(MO_RENDER_DX11) FRenderWindow* pWindow = MO_CREATE(FRenderDirectXWindow); #endif // MO_RENDER_DIRECTX #ifdef MO_RENDER_GLES2 FRenderWindow* pWindow = MO_CREATE(FRenderOpenGLWindow); #endif // MO_RENDER_GLES2 pWindow->Size().Assign(screenSize); pWindow->Setup(); // 初始化渲染设备 #if defined(MO_RENDER_DX9) | defined(MO_RENDER_DX10) | defined(MO_RENDER_DX11) FPdxRenderDevice* pRenderDevice = (FPdxRenderDevice*)RDeviceManager::Instance().Find<FRenderDevice>(); pRenderDevice->SetWindowHandle(pWindow->Handle()); #endif // MO_RENDER_DIRECTX #ifdef MO_RENDER_GLES2 FRenderDevice* pRenderDevice = RDeviceManager::Instance().Find<FRenderDevice>(); #endif // MO_RENDER_GLES2 pRenderDevice->Setup(); // 初始化舞台 MoGameEngineStartup(); RFeatureManager::Instance().Startup(); // 选择渲染方式 RPipelineManager::Instance().SelectPipeline("simple"); //RPipelineManager::Instance().SelectPipeline("shadow"); // 注册字体 FEoFont* pFont = FEoFont::InstanceCreate(); pFont->CharSize().Set(14, 14); pFont->SetAssetName("asset:/font/DroidSansFallback.ttf"); RFontManager::Instance().RegisterFont(pFont); //............................................................ // 打开资源管理器 RResource3dManager::Instance().ThemeConsole()->Open("asset:/theme/color.ser"); //RResource3dManager::Instance().ThemeConsole()->Open("asset:/theme/shadow.ser"); //RGmResourceManager::Instance().Open(); //RGmTemplateConsole::Instance().Open(); //............................................................ // 注册事件 FMouseDevice* pMouseDevice = RDeviceManager::Instance().Find<FMouseDevice>(); pMouseDevice->ListenersMouseDown().Register(&OnMouseDown); pMouseDevice->ListenersMouseMove().Register(&OnMouseMove); pMouseDevice->ListenersMouseUp().Register(&OnMouseUp); FKeyboardDevice* pKeyboardDevice = RDeviceManager::Instance().Find<FKeyboardDevice>(); pKeyboardDevice->ListenersKeyDown().Register(&OnKeyDown); //............................................................ // 激活舞台 //RInstance3dManager::Instance().TemplateConsole()->Alloc("pvw.sc.courtyard.item.02.022"); //FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.show.item.001"); FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.show.item.009"); //FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.sc.car.01.001"); //FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.sc.car.01.002"); //FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.sc.car.01.003"); //FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.sc.house.01.scene"); //FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.show.skeleton.01"); //FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.show.skeleton.02"); //FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.show.skeleton.05"); //FGameScene* pScene = RGameSceneManager::Instance().Load("pvw.sc.courtyard.scene"); pScene->ListenersFrameEnter().Register(&OnEnterFrame); RStageManager::Instance().SelectStage(pScene); //............................................................ // 处理窗口 pWindow->Startup(); pWindow->Process(); //............................................................ MoGameEngineShutdown(); RFeatureManager::Instance().Shutdown(); //............................................................ // 释放处理 RFeatureManager::Instance().Dispose(); MoGameEngineRelease(); return 0; }