bool Engine::Initialize(const Engine::Setting *setting /*= NULL*/) { if (mInited) return false; if (NULL != setting) mSetting = *setting; bool isOk = true; if (isOk) isOk = InitializeScreen(); if (isOk) isOk = InitializeRenderSystem(); if (!isOk) { Finalize(); return false; } mInited = true; return true; }
bool rxRenderer::CreateViewport( const rxViewportConfig& config, rxViewport &OutViewport ) { Assert( gNumViewports.NumRefs() < RX_MAX_VIEWPORTS ); Assert(OutViewport.IsNull()); Assert( OutViewport.uniqueId == INDEX_NONE ); Assert( gCurrentViewport == nil ); if( gNumViewports.NumRefs() >= RX_MAX_VIEWPORTS ) { dxErrf("Failed to create a new viewport.\n"); return false; } UINT windowWidth = 0; UINT windowHeight = 0; Win_GetWindowSize( config.windowHandle, windowWidth, windowHeight ); ValidateViewportSize( windowWidth, windowHeight ); const UINT newViewportIndex = gNumViewports.NumRefs(); const bool bIsMainViewport = (newViewportIndex == RX_MAIN_VIEWPORT_ID); DBGNEWLINE(); if( bIsMainViewport ) { DBGOUT( "Creating the main viewport: %ux%u.\n", windowWidth, windowHeight ); } else { DBGOUT( "Creating viewport [%u]: %ux%u.\n", newViewportIndex, windowWidth, windowHeight ); } // check if we need to initialize for the first time if( gNumViewports.IncRef() ) { InitializeRenderSystem( windowWidth, windowHeight ); } DXGI_SWAP_CHAIN_DESC spawnChainDesc; D3D_DefaultSwapChainDesc( config.windowHandle, spawnChainDesc ); VRET_FALSE_IF_NOT(D3D_InitializeViewport( spawnChainDesc, config.bDepthStencil, OutViewport )); Assert(!OutViewport.IsNull()); OutViewport.uniqueId = newViewportIndex; return true; }
void tRenderer::InitializeScene() { InitializeRenderSystem(); InitializeSceneResources(); // Allow derived classes to initialize elements of their scene now that the rendering system is ready. }