void EditorEngine::InitRenderer( void* hwnd ) #endif { #if HELIUM_DIRECT3D HELIUM_VERIFY( D3D9Renderer::CreateStaticInstance() ); #endif Renderer* pRenderer = Renderer::GetStaticInstance(); if ( pRenderer ) { pRenderer->Initialize(); Renderer::ContextInitParameters mainCtxInitParams; mainCtxInitParams.pWindow = hwnd; mainCtxInitParams.bFullscreen = false; mainCtxInitParams.bVsync = true; mainCtxInitParams.displayWidth = 64; mainCtxInitParams.displayHeight = 64; HELIUM_VERIFY( pRenderer->CreateMainContext( mainCtxInitParams ) ); RenderResourceManager& rRenderResourceManager = RenderResourceManager::GetStaticInstance(); rRenderResourceManager.Initialize(); rRenderResourceManager.UpdateMaxViewportSize( wxSystemSettings::GetMetric(wxSYS_SCREEN_X), wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) ); HELIUM_VERIFY( DynamicDrawer::GetStaticInstance().Initialize() ); } }
/// Initialize this system. /// /// @param[in] rCommandLineInitialization Interface for initializing command-line parameters. /// @param[in] rObjectTypeRegistration Interface for registering GameObject-based types. Note that this must /// remain valid until Shutdown() is called on this system, as a reference /// to it will be held by this system. /// @param[in] rMemoryHeapPreInitialization Interface for performing any necessary pre-initialization of dynamic /// memory heaps. /// @param[in] rObjectLoaderInitialization Interface for creating and initializing the main GameObjectLoader instance. /// Note that this must remain valid until Shutdown() is called on this /// system, as a reference to it will be held by this system. /// @param[in] rConfigInitialization Interface for initializing application configuration settings. /// @param[in] rWindowManagerInitialization Interface for creating and initializing the global window manager /// instance. /// @param[in] rRendererInitialization Interface for creating and initializing the global renderer instance. /// @param[in] pWorldType Type of World to create for the main world. If this is null, the /// actual World type will be used. bool GameSystem::Initialize( CommandLineInitialization& rCommandLineInitialization, ObjectTypeRegistration& rObjectTypeRegistration, MemoryHeapPreInitialization& rMemoryHeapPreInitialization, ObjectLoaderInitialization& rObjectLoaderInitialization, ConfigInitialization& rConfigInitialization, WindowManagerInitialization& rWindowManagerInitialization, RendererInitialization& rRendererInitialization, const GameObjectType* pWorldType ) { // Initialize the timer first of all, in case someone wants to use it. Timer::StaticInitialize(); // Initialize command-line parameters. bool bCommandLineInitSuccess = rCommandLineInitialization.Initialize( m_moduleName, m_arguments ); HELIUM_ASSERT( bCommandLineInitSuccess ); if( !bCommandLineInitSuccess ) { HELIUM_TRACE( TRACE_ERROR, TXT( "GameSystem::Initialize(): Command-line initialization failed.\n" ) ); return false; } #if HELIUM_ENABLE_TRACE HELIUM_TRACE( TRACE_INFO, TXT( "Module name: %s\n" ), *m_moduleName ); HELIUM_TRACE( TRACE_INFO, TXT( "Command-line arguments:\n" ) ); size_t argumentCount = m_arguments.GetSize(); for( size_t argumentIndex = 0; argumentIndex < argumentCount; ++argumentIndex ) { HELIUM_TRACE( TRACE_INFO, TXT( "* %s\n" ), *m_arguments[ argumentIndex ] ); } #endif // Initialize the async loading thread. bool bAsyncLoaderInitSuccess = AsyncLoader::GetStaticInstance().Initialize(); HELIUM_ASSERT( bAsyncLoaderInitSuccess ); if( !bAsyncLoaderInitSuccess ) { HELIUM_TRACE( TRACE_ERROR, TXT( "GameSystem::Initialize(): Async loader initialization failed.\n" ) ); return false; } //pmd - Initialize the cache manager Path baseDirectory; if ( !File::GetBaseDirectory( baseDirectory ) ) { HELIUM_TRACE( TRACE_ERROR, TXT( "Could not get base directory." ) ); return false; } HELIUM_VERIFY( CacheManager::InitializeStaticInstance( baseDirectory ) ); // Initialize the reflection type registry and register GameObject-based types. Reflect::Initialize(); rObjectTypeRegistration.Register(); m_pObjectTypeRegistration = &rObjectTypeRegistration; // Perform dynamic memory heap pre-initialization. rMemoryHeapPreInitialization.PreInitialize(); // Create and initialize the main GameObjectLoader instance. GameObjectLoader* pObjectLoader = rObjectLoaderInitialization.Initialize(); HELIUM_ASSERT( pObjectLoader ); if( !pObjectLoader ) { HELIUM_TRACE( TRACE_ERROR, TXT( "GameSystem::Initialize(): GameObject loader initialization failed.\n" ) ); return false; } m_pObjectLoaderInitialization = &rObjectLoaderInitialization; // Initialize system configuration. bool bConfigInitSuccess = rConfigInitialization.Initialize(); HELIUM_ASSERT( bConfigInitSuccess ); if( !bConfigInitSuccess ) { HELIUM_TRACE( TRACE_ERROR, TXT( "GameSystem::Initialize(): Failed to initialize configuration settings.\n" ) ); return false; } // Initialize the job manager. bool bJobManagerInitSuccess = JobManager::GetStaticInstance().Initialize(); HELIUM_ASSERT( bJobManagerInitSuccess ); if( !bJobManagerInitSuccess ) { HELIUM_TRACE( TRACE_ERROR, TXT( "GameSystem::Initialize(): Job manager initialization failed.\n" ) ); return false; } // Create and initialize the window manager (note that we need a window manager for message loop processing, so // the instance cannot be left null). bool bWindowManagerInitSuccess = rWindowManagerInitialization.Initialize(); HELIUM_ASSERT( bWindowManagerInitSuccess ); if( !bWindowManagerInitSuccess ) { HELIUM_TRACE( TRACE_ERROR, TXT( "GameSystem::Initialize(): Window manager initialization failed.\n" ) ); return false; } WindowManager* pWindowManager = WindowManager::GetStaticInstance(); if( !pWindowManager ) { HELIUM_TRACE( TRACE_INFO, ( TXT( "GameSystem::Initialize(): No window manager created. A window manager is necessary for " ) TXT( "GameSystem execution.\n" ) ) ); return false; } // Create and initialize the renderer. bool bRendererInitSuccess = rRendererInitialization.Initialize(); HELIUM_ASSERT( bRendererInitSuccess ); if( !bRendererInitSuccess ) { HELIUM_TRACE( TRACE_ERROR, TXT( "GameSystem::Initialize(): Renderer initialization failed.\n" ) ); return false; } Renderer* pRenderer = Renderer::GetStaticInstance(); if( !pRenderer ) { HELIUM_TRACE( TRACE_INFO, TXT( "GameSystem::Initialize(): Using null renderer.\n" ) ); } else { // Create the main application window. Config& rConfig = Config::GetStaticInstance(); StrongPtr< GraphicsConfig > spGraphicsConfig( rConfig.GetConfigObject< GraphicsConfig >( Name( TXT( "GraphicsConfig" ) ) ) ); HELIUM_ASSERT( spGraphicsConfig ); uint32_t displayWidth = spGraphicsConfig->GetWidth(); uint32_t displayHeight = spGraphicsConfig->GetHeight(); bool bFullscreen = spGraphicsConfig->GetFullscreen(); bool bVsync = spGraphicsConfig->GetVsync(); Window::Parameters windowParameters; windowParameters.pTitle = TXT( "Lunar" ); windowParameters.width = displayWidth; windowParameters.height = displayHeight; windowParameters.bFullscreen = bFullscreen; m_pMainWindow = pWindowManager->Create( windowParameters ); HELIUM_ASSERT( m_pMainWindow ); if( !m_pMainWindow ) { HELIUM_TRACE( TRACE_ERROR, TXT( "Failed to create main application window.\n" ) ); return false; } m_pMainWindow->SetOnDestroyed( boost::bind( &GameSystem::OnMainWindowDestroyed, this, _1 ) ); Renderer::ContextInitParameters contextInitParams; contextInitParams.pWindow = m_pMainWindow->GetHandle(); contextInitParams.displayWidth = displayWidth; contextInitParams.displayHeight = displayHeight; contextInitParams.bFullscreen = bFullscreen; contextInitParams.bVsync = bVsync; bool bContextCreateResult = pRenderer->CreateMainContext( contextInitParams ); HELIUM_ASSERT( bContextCreateResult ); if( !bContextCreateResult ) { HELIUM_TRACE( TRACE_ERROR, TXT( "Failed to create main renderer context.\n" ) ); return false; } // Create and initialize the render resource manager. RenderResourceManager& rRenderResourceManager = RenderResourceManager::GetStaticInstance(); rRenderResourceManager.Initialize(); // Create and initialize the dynamic drawing interface. DynamicDrawer& rDynamicDrawer = DynamicDrawer::GetStaticInstance(); if( !rDynamicDrawer.Initialize() ) { HELIUM_TRACE( TRACE_ERROR, TXT( "Failed to initialize dynamic drawing support.\n" ) ); return false; } } // Initialize the world manager and main game world. WorldManager& rWorldManager = WorldManager::GetStaticInstance(); bool bWorldManagerInitSuccess = rWorldManager.Initialize(); HELIUM_ASSERT( bWorldManagerInitSuccess ); if( !bWorldManagerInitSuccess ) { HELIUM_TRACE( TRACE_ERROR, TXT( "World manager initialization failed.\n" ) ); return false; } if( !pWorldType ) { pWorldType = World::GetStaticType(); HELIUM_ASSERT( pWorldType ); } WorldPtr spDefaultWorld( rWorldManager.CreateDefaultWorld( pWorldType ) ); HELIUM_ASSERT( spDefaultWorld ); if( !spDefaultWorld ) { HELIUM_TRACE( TRACE_ERROR, TXT( "Failed to create the default world.\n" ) ); return false; } HELIUM_TRACE( TRACE_INFO, TXT( "Created default world \"%s\".\n" ), *spDefaultWorld->GetPath().ToString() ); bool bWorldInitSuccess = spDefaultWorld->Initialize(); HELIUM_ASSERT( bWorldInitSuccess ); if( !bWorldInitSuccess ) { HELIUM_TRACE( TRACE_ERROR, TXT( "Failed to initialize default world.\n" ) ); return false; } PackagePtr spLayerPackage; HELIUM_VERIFY( GameObject::Create< Package >( spLayerPackage, Name( TXT( "DefaultLayerPackage" ) ), NULL ) ); HELIUM_ASSERT( spLayerPackage ); LayerPtr spLayer; HELIUM_VERIFY( GameObject::Create< Layer >( spLayer, Name( TXT( "Layer" ) ), spLayerPackage ) ); HELIUM_ASSERT( spLayer ); spLayer->BindPackage( spLayerPackage ); HELIUM_VERIFY( spDefaultWorld->AddLayer( spLayer ) ); // Initialization complete. return true; }
int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpCmdLine*/, int nCmdShow ) { ForceLoadComponentsDll(); #if HELIUM_TOOLS ForceLoadEditorSupportDll(); #endif HELIUM_TRACE_SET_LEVEL( TraceLevels::Debug ); Timer::StaticInitialize(); #if !HELIUM_RELEASE && !HELIUM_PROFILE Helium::InitializeSymbols(); #endif AsyncLoader::GetStaticInstance().Initialize(); FilePath baseDirectory; if ( !FileLocations::GetBaseDirectory( baseDirectory ) ) { HELIUM_TRACE( TraceLevels::Error, TXT( "Could not get base directory." ) ); return -1; } HELIUM_VERIFY( CacheManager::InitializeStaticInstance( baseDirectory ) ); Helium::Bullet::Initialize(); int resultCode = -1; { Reflect::Initialize(); Helium::Components::Initialize(); Helium::TaskScheduler::CalculateSchedule(); #if HELIUM_TOOLS #endif InitEngineJobsDefaultHeap(); InitGraphicsJobsDefaultHeap(); InitTestJobsDefaultHeap(); #if HELIUM_TOOLS //HELIUM_VERIFY( LooseAssetLoader::InitializeStaticInstance() ); HELIUM_VERIFY( LooseAssetLoader::InitializeStaticInstance() ); AssetPreprocessor* pAssetPreprocessor = AssetPreprocessor::CreateStaticInstance(); HELIUM_ASSERT( pAssetPreprocessor ); PlatformPreprocessor* pPlatformPreprocessor = new PcPreprocessor; HELIUM_ASSERT( pPlatformPreprocessor ); pAssetPreprocessor->SetPlatformPreprocessor( Cache::PLATFORM_PC, pPlatformPreprocessor ); #else HELIUM_VERIFY( CacheAssetLoader::InitializeStaticInstance() ); #endif #if !GTEST AssetLoader* gAssetLoader = NULL; #endif gAssetLoader = AssetLoader::GetStaticInstance(); HELIUM_ASSERT( gAssetLoader ); Config& rConfig = Config::GetStaticInstance(); rConfig.BeginLoad(); while( !rConfig.TryFinishLoad() ) { gAssetLoader->Tick(); } #if HELIUM_TOOLS ConfigPc::SaveUserConfig(); #endif uint32_t displayWidth; uint32_t displayHeight; //bool bFullscreen; bool bVsync; { StrongPtr< GraphicsConfig > spGraphicsConfig( rConfig.GetConfigObject< GraphicsConfig >( Name( TXT( "GraphicsConfig" ) ) ) ); HELIUM_ASSERT( spGraphicsConfig ); displayWidth = spGraphicsConfig->GetWidth(); displayHeight = spGraphicsConfig->GetHeight(); //bFullscreen = spGraphicsConfig->GetFullscreen(); bVsync = spGraphicsConfig->GetVsync(); } WNDCLASSEXW windowClass; windowClass.cbSize = sizeof( windowClass ); windowClass.style = 0; windowClass.lpfnWndProc = WindowProc; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; windowClass.hInstance = hInstance; windowClass.hIcon = NULL; windowClass.hCursor = NULL; windowClass.hbrBackground = NULL; windowClass.lpszMenuName = NULL; windowClass.lpszClassName = L"HeliumTestAppClass"; windowClass.hIconSm = NULL; HELIUM_VERIFY( RegisterClassEx( &windowClass ) ); WindowData windowData; windowData.hMainWnd = NULL; windowData.hSubWnd = NULL; windowData.bProcessMessages = true; windowData.bShutdownRendering = false; windowData.resultCode = 0; DWORD dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU; RECT windowRect; windowRect.left = 0; windowRect.top = 0; windowRect.right = static_cast< LONG >( displayWidth ); windowRect.bottom = static_cast< LONG >( displayHeight ); HELIUM_VERIFY( AdjustWindowRect( &windowRect, dwStyle, FALSE ) ); HWND hMainWnd = ::CreateWindowW( L"HeliumTestAppClass", L"Helium TestApp", dwStyle, CW_USEDEFAULT, CW_USEDEFAULT, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, NULL, NULL, hInstance, NULL ); HELIUM_ASSERT( hMainWnd ); windowRect.left = 0; windowRect.top = 0; windowRect.right = static_cast< LONG >( displayWidth ); windowRect.bottom = static_cast< LONG >( displayHeight ); HELIUM_VERIFY( AdjustWindowRect( &windowRect, dwStyle, FALSE ) ); #if MULTI_WINDOW HWND hSubWnd = ::CreateWindowW( L"HeliumTestAppClass", L"Helium TestApp (second view)", dwStyle, CW_USEDEFAULT, CW_USEDEFAULT, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, NULL, NULL, hInstance, NULL ); HELIUM_ASSERT( hSubWnd ); #endif windowData.hMainWnd = hMainWnd; SetWindowLongPtr( hMainWnd, GWLP_USERDATA, reinterpret_cast< LONG_PTR >( &windowData ) ); ShowWindow( hMainWnd, nCmdShow ); UpdateWindow( hMainWnd ); #if MULTI_WINDOW windowData.hSubWnd = hSubWnd; SetWindowLongPtr( hSubWnd, GWLP_USERDATA, reinterpret_cast< LONG_PTR >( &windowData ) ); ShowWindow( hSubWnd, nCmdShow ); UpdateWindow( hSubWnd ); #endif HELIUM_VERIFY( D3D9Renderer::CreateStaticInstance() ); Renderer* pRenderer = Renderer::GetStaticInstance(); HELIUM_ASSERT( pRenderer ); pRenderer->Initialize(); Renderer::ContextInitParameters contextInitParams; contextInitParams.pWindow = hMainWnd; contextInitParams.displayWidth = displayWidth; contextInitParams.displayHeight = displayHeight; contextInitParams.bVsync = bVsync; HELIUM_VERIFY( pRenderer->CreateMainContext( contextInitParams ) ); #if MULTI_WINDOW contextInitParams.pWindow = hSubWnd; RRenderContextPtr spSubRenderContext = pRenderer->CreateSubContext( contextInitParams ); HELIUM_ASSERT( spSubRenderContext ); #endif Input::Initialize(&hMainWnd, false); { AssetPath prePassShaderPath; HELIUM_VERIFY( prePassShaderPath.Set( HELIUM_PACKAGE_PATH_CHAR_STRING TXT( "Shaders" ) HELIUM_OBJECT_PATH_CHAR_STRING TXT( "PrePass.hlsl" ) ) ); AssetPtr spPrePassShader; HELIUM_VERIFY( AssetLoader::GetStaticInstance()->LoadObject( prePassShaderPath, spPrePassShader ) ); HELIUM_ASSERT( spPrePassShader.Get() ); } RenderResourceManager& rRenderResourceManager = RenderResourceManager::GetStaticInstance(); rRenderResourceManager.Initialize(); rRenderResourceManager.UpdateMaxViewportSize( displayWidth, displayHeight ); //// Create a scene definition SceneDefinitionPtr spSceneDefinition; gAssetLoader->LoadObject( AssetPath( TXT( "/ExampleGames/Empty/Scenes/TestScene:SceneDefinition" ) ), spSceneDefinition ); EntityDefinitionPtr spEntityDefinition; gAssetLoader->LoadObject( AssetPath( TXT( "/ExampleGames/Empty/Scenes/TestScene:TestBull_Entity" ) ), spEntityDefinition ); DynamicDrawer& rDynamicDrawer = DynamicDrawer::GetStaticInstance(); HELIUM_VERIFY( rDynamicDrawer.Initialize() ); RRenderContextPtr spMainRenderContext = pRenderer->GetMainContext(); HELIUM_ASSERT( spMainRenderContext ); WorldManager& rWorldManager = WorldManager::GetStaticInstance(); HELIUM_VERIFY( rWorldManager.Initialize() ); // Create a world WorldPtr spWorld( rWorldManager.CreateWorld( spSceneDefinition ) ); HELIUM_ASSERT( spWorld ); HELIUM_TRACE( TraceLevels::Info, TXT( "Created world \"%s\".\n" ), *spSceneDefinition->GetPath().ToString() ); //Slice *pRootSlice = spWorld->GetRootSlice(); //Entity *pEntity = pRootSlice->CreateEntity(spEntityDefinition); GraphicsScene* pGraphicsScene = spWorld->GetComponents().GetFirst<GraphicsManagerComponent>()->GetGraphicsScene(); HELIUM_ASSERT( pGraphicsScene ); GraphicsSceneView* pMainSceneView = NULL; if( pGraphicsScene ) { uint32_t mainSceneViewId = pGraphicsScene->AllocateSceneView(); if( IsValid( mainSceneViewId ) ) { float32_t aspectRatio = static_cast< float32_t >( displayWidth ) / static_cast< float32_t >( displayHeight ); RSurface* pDepthStencilSurface = rRenderResourceManager.GetDepthStencilSurface(); HELIUM_ASSERT( pDepthStencilSurface ); pMainSceneView = pGraphicsScene->GetSceneView( mainSceneViewId ); HELIUM_ASSERT( pMainSceneView ); pMainSceneView->SetRenderContext( spMainRenderContext ); pMainSceneView->SetDepthStencilSurface( pDepthStencilSurface ); pMainSceneView->SetAspectRatio( aspectRatio ); pMainSceneView->SetViewport( 0, 0, displayWidth, displayHeight ); pMainSceneView->SetClearColor( Color( 0x00202020 ) ); //spMainCamera->SetSceneViewId( mainSceneViewId ); #if MULTI_WINDOW uint32_t subSceneViewId = pGraphicsScene->AllocateSceneView(); if( IsValid( subSceneViewId ) ) { GraphicsSceneView* pSubSceneView = pGraphicsScene->GetSceneView( subSceneViewId ); HELIUM_ASSERT( pSubSceneView ); pSubSceneView->SetRenderContext( spSubRenderContext ); pSubSceneView->SetDepthStencilSurface( pDepthStencilSurface ); pSubSceneView->SetAspectRatio( aspectRatio ); pSubSceneView->SetViewport( 0, 0, displayWidth, displayHeight ); pSubSceneView->SetClearColor( Color( 0x00202020 ) ); //spSubCamera->SetSceneViewId( subSceneViewId ); } #endif } #if !HELIUM_RELEASE && !HELIUM_PROFILE BufferedDrawer& rSceneDrawer = pGraphicsScene->GetSceneBufferedDrawer(); rSceneDrawer.DrawScreenText( 20, 20, String( TXT( "CACHING" ) ), Color( 0xff00ff00 ), RenderResourceManager::DEBUG_FONT_SIZE_LARGE ); rSceneDrawer.DrawScreenText( 21, 20, String( TXT( "CACHING" ) ), Color( 0xff00ff00 ), RenderResourceManager::DEBUG_FONT_SIZE_LARGE ); //rSceneDrawer.Draw //Helium::DynamicDrawer &drawer = DynamicDrawer::GetStaticInstance(); //drawer. #endif } rWorldManager.Update(); float time = 0.0f; #if MULTI_WINDOW spSubRenderContext.Release(); #endif spMainRenderContext.Release(); Helium::StrongPtr<Helium::Texture2d> texture; gAssetLoader->LoadObject( AssetPath( TXT( "/Textures:Triangle.png" ) ), texture); Helium::RTexture2d *rTexture2d = texture->GetRenderResource2d(); while( windowData.bProcessMessages ) { #if GRAPHICS_SCENE_BUFFERED_DRAWER BufferedDrawer& rSceneDrawer = pGraphicsScene->GetSceneBufferedDrawer(); rSceneDrawer.DrawScreenText( 20, 20, String( TXT( "RUNNING" ) ), Color( 0xffffffff ), RenderResourceManager::DEBUG_FONT_SIZE_LARGE ); rSceneDrawer.DrawScreenText( 21, 20, String( TXT( "RUNNING" ) ), Color( 0xffffffff ), RenderResourceManager::DEBUG_FONT_SIZE_LARGE ); time += 0.01f; DynamicArray<SimpleVertex> verticesU; verticesU.New( -100.0f, -100.0f, 750.0f ); verticesU.New( 100.0f, -100.0f, 750.0f ); verticesU.New( 100.0f, 100.0f, 750.0f ); verticesU.New( -100.0f, 100.0f, 750.0f ); rSceneDrawer.DrawLineList( verticesU.GetData(), static_cast<uint32_t>( verticesU.GetSize() ) ); DynamicArray<SimpleTexturedVertex> verticesT; verticesT.New( Simd::Vector3( -100.0f, 100.0f, 750.0f ), Simd::Vector2( 0.0f, 0.0f ) ); verticesT.New( Simd::Vector3( 100.0f, 100.0f, 750.0f ), Simd::Vector2( 1.0f, 0.0f ) ); verticesT.New( Simd::Vector3( -100.0f, -100.0f, 750.0f ), Simd::Vector2( 0.0f, 1.0f ) ); verticesT.New( Simd::Vector3( 100.0f, -100.0f, 750.0f ), Simd::Vector2( 1.0f, 1.0f ) ); //rSceneDrawer.DrawTextured( // RENDERER_PRIMITIVE_TYPE_TRIANGLE_STRIP, // verticesT.GetData(), // verticesT.GetSize(), // NULL, // 2, // rTexture2d, Helium::Color(1.0f, 1.0f, 1.0f, 1.0f), Helium::RenderResourceManager::RASTERIZER_STATE_DEFAULT, Helium::RenderResourceManager::DEPTH_STENCIL_STATE_NONE); //rSceneDrawer.DrawTexturedQuad(rTexture2d); Helium::Simd::Matrix44 transform = Helium::Simd::Matrix44::IDENTITY; Simd::Vector3 location(0.0f, 400.0f, 0.0f); Simd::Quat rotation(Helium::Simd::Vector3::BasisZ, time); Simd::Vector3 scale(1000.0f, 1000.0f, 1000.0f); transform.SetRotationTranslationScaling(rotation, location, scale); rSceneDrawer.DrawTexturedQuad(rTexture2d, transform, Simd::Vector2(0.0f, 0.0f), Simd::Vector2(0.5f, 0.5f)); #endif //Helium::Simd::Vector3 up = Simd::Vector3::BasisY; ////Helium::Simd::Vector3 eye(5000.0f * sin(time), 0.0f, 5000.0f * cos(time)); //Helium::Simd::Vector3 eye(0.0f, 0.0f, -1000.0f); //Helium::Simd::Vector3 forward = Simd::Vector3::Zero - eye; //forward.Normalize(); ////pMainSceneView->SetClearColor( Color( 0xffffffff ) ); //pMainSceneView->SetView(eye, forward, up); if (Input::IsKeyDown(Input::KeyCodes::KC_A)) { HELIUM_TRACE( TraceLevels::Info, TXT( "A is down" ) ); } if (Input::IsKeyDown(Input::KeyCodes::KC_ESCAPE)) { HELIUM_TRACE( TraceLevels::Info, TXT( "Exiting" ) ); break; } MSG message; if( PeekMessage( &message, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &message ); DispatchMessage( &message ); if( windowData.bShutdownRendering ) { if( spWorld ) { spWorld->Shutdown(); } spWorld.Release(); WorldManager::DestroyStaticInstance(); spSceneDefinition.Release(); spEntityDefinition.Release(); DynamicDrawer::DestroyStaticInstance(); RenderResourceManager::DestroyStaticInstance(); Renderer::DestroyStaticInstance(); break; } if( message.message == WM_QUIT ) { windowData.bProcessMessages = false; windowData.resultCode = static_cast< int >( message.wParam ); resultCode = static_cast< int >( message.wParam ); break; } } rWorldManager.Update(); #if GRAPHICS_SCENE_BUFFERED_DRAWER if( pGraphicsScene ) { BufferedDrawer& rSceneDrawer = pGraphicsScene->GetSceneBufferedDrawer(); rSceneDrawer.DrawScreenText( 20, 20, String( TXT( "Debug text test!" ) ), Color( 0xffffffff ) ); } #endif } if( spWorld ) { spWorld->Shutdown(); } spWorld.Release(); } WorldManager::DestroyStaticInstance(); DynamicDrawer::DestroyStaticInstance(); RenderResourceManager::DestroyStaticInstance(); Helium::Input::Cleanup(); Renderer::DestroyStaticInstance(); JobManager::DestroyStaticInstance(); Config::DestroyStaticInstance(); #if HELIUM_TOOLS AssetPreprocessor::DestroyStaticInstance(); #endif AssetLoader::DestroyStaticInstance(); CacheManager::DestroyStaticInstance(); Helium::Components::Cleanup(); Reflect::Cleanup(); AssetType::Shutdown(); Asset::Shutdown(); Reflect::ObjectRefCountSupport::Shutdown(); Helium::Bullet::Cleanup(); AssetPath::Shutdown(); Name::Shutdown(); FileLocations::Shutdown(); ThreadLocalStackAllocator::ReleaseMemoryHeap(); #if HELIUM_ENABLE_MEMORY_TRACKING DynamicMemoryHeap::LogMemoryStats(); ThreadLocalStackAllocator::ReleaseMemoryHeap(); #endif return resultCode; }
/// @copydoc RendererInitialization::Initialize() bool RendererInitializationWin::Initialize() { WindowManager* pWindowManager = WindowManager::GetStaticInstance(); if( !pWindowManager ) { HELIUM_TRACE( TraceLevels::Info, ( TXT( "RendererInitializationWin::Initialize(): No window manager created. A window manager is necessary for " ) TXT( "RendererInitializationWin execution.\n" ) ) ); return false; } if( !D3D9Renderer::CreateStaticInstance() ) { return false; } Renderer* pRenderer = D3D9Renderer::GetStaticInstance(); HELIUM_ASSERT( pRenderer ); if( !pRenderer->Initialize() ) { Renderer::DestroyStaticInstance(); return false; } // Create the main application window. Config& rConfig = Config::GetStaticInstance(); StrongPtr< GraphicsConfig > spGraphicsConfig( rConfig.GetConfigObject< GraphicsConfig >( Name( TXT( "GraphicsConfig" ) ) ) ); HELIUM_ASSERT( spGraphicsConfig ); uint32_t displayWidth = spGraphicsConfig->GetWidth(); uint32_t displayHeight = spGraphicsConfig->GetHeight(); bool bFullscreen = spGraphicsConfig->GetFullscreen(); bool bVsync = spGraphicsConfig->GetVsync(); Window::Parameters windowParameters; windowParameters.pTitle = TXT( "Helium" ); windowParameters.width = displayWidth; windowParameters.height = displayHeight; windowParameters.bFullscreen = bFullscreen; m_pMainWindow = pWindowManager->Create( windowParameters ); HELIUM_ASSERT( m_pMainWindow ); if( !m_pMainWindow ) { HELIUM_TRACE( TraceLevels::Error, TXT( "Failed to create main application window.\n" ) ); return false; } m_pMainWindow->SetOnDestroyed( Delegate<Window*>( this, &RendererInitializationWin::OnMainWindowDestroyed ) ); Renderer::ContextInitParameters contextInitParams; contextInitParams.pWindow = m_pMainWindow->GetHandle(); contextInitParams.displayWidth = displayWidth; contextInitParams.displayHeight = displayHeight; contextInitParams.bFullscreen = bFullscreen; contextInitParams.bVsync = bVsync; bool bContextCreateResult = pRenderer->CreateMainContext( contextInitParams ); HELIUM_ASSERT( bContextCreateResult ); if( !bContextCreateResult ) { HELIUM_TRACE( TraceLevels::Error, TXT( "Failed to create main renderer context.\n" ) ); return false; } // Create and initialize the render resource manager. RenderResourceManager& rRenderResourceManager = RenderResourceManager::GetStaticInstance(); rRenderResourceManager.Initialize(); // Create and initialize the dynamic drawing interface. DynamicDrawer& rDynamicDrawer = DynamicDrawer::GetStaticInstance(); if( !rDynamicDrawer.Initialize() ) { HELIUM_TRACE( TraceLevels::Error, TXT( "Failed to initialize dynamic drawing support.\n" ) ); return false; } return true; }