// // Program starts here // int main( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) { HRESULT hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, &g_pD2DFactory ); hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof( IDWriteFactory ), reinterpret_cast<IUnknown**>( &g_pDWriteFactory ) ); hr = CoInitialize( NULL ); hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, reinterpret_cast<void**>( &g_pWICFactory ) ); g_pHWND = CreateGameWindow(); createDeviceResources(); // // Create a GWEN Direct2D renderer // g_pRenderer = new gwen::Renderer::Direct2D( g_pRT, g_pDWriteFactory, g_pWICFactory ); runSample(); delete g_pRenderer; g_pRenderer = NULL; if ( g_pRT != NULL ) { g_pRT->Release(); g_pRT = NULL; } }
bool CGame::Init( void *pvInstance ) { m_hEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); if ( !m_hEvent ) { return false; } OSVERSIONINFO vinfo; vinfo.dwOSVersionInfoSize = sizeof(vinfo); if ( !GetVersionEx( &vinfo ) ) { return false; } if ( vinfo.dwPlatformId == VER_PLATFORM_WIN32s ) { return false; } // FIXME: Any additional OS version enforcement. Also could check DX for DX 8.1 at least thread->Init(); videomode->Init(); // Create engine window, etc. if ( !CreateGameWindow( (HINSTANCE)pvInstance )) return(false); m_pcdinput = new CDInput(m_hWindow); return(m_pcdinput->FInitOK()); }
//Calls the 4 methods to make the GUI void StandardGame::MakeGUIAndDisplay(int y, int x) { CreateGameWindow(); CreateButtons(); ConnectSignalsToButtons(); CreateTableAndAddEverythingToIt(y,x); //Show window and everything in it gtk_widget_show_all(Window); //sleeps, waiting for events gtk_main (); }
HDC GameWindow::Init(HINSTANCE hinstance) { m_hinstance = hinstance; CreateGameWindow("IN3026 Template"); // If we never got a valid window handle, quit the program if(m_hwnd == NULL) { return NULL; } else { // INIT OpenGL InitOpenGL(); return m_hdc; } }
int main() { // // Create a new window // g_pHWND = CreateGameWindow(); // // Create a GWEN GDI+ Renderer // Note: we're using the buffered version. // This version draws to a texture and then draws that texture to the window // This prevents all the crazy flickering (test with Gwen::Renderer::GDIPlus to see) // Gwen::Renderer::GDIPlusBuffered* pRenderer = new Gwen::Renderer::GDIPlusBuffered( g_pHWND ); // // Create a GWEN skin // //Gwen::Skin::Simple skin; Gwen::Skin::TexturedBase* skin = new Gwen::Skin::TexturedBase( pRenderer ); skin->Init( "DefaultSkin.png" ); // // Create a Canvas (it's root, on which all other GWEN panels are created) // Gwen::Controls::Canvas* pCanvas = new Gwen::Controls::Canvas( skin ); pCanvas->SetSize( 998, 650 - 24 ); pCanvas->SetDrawBackground( true ); pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) ); // // Create our unittest control (which is a Window with controls in it) // UnitTest* pUnit = new UnitTest( pCanvas ); pUnit->SetPos( 10, 10 ); // // Create a Windows Control helper // (Processes Windows MSG's and fires input at GWEN) // Gwen::Input::Windows GwenInput; GwenInput.Initialize( pCanvas ); // // Begin the main game loop // MSG msg; while( true ) { // Skip out if the window is closed if ( !IsWindowVisible( g_pHWND ) ) break; // If we have a message from windows.. if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { // .. give it to the input handler to process GwenInput.ProcessMessage( msg ); // if it's QUIT then quit.. if ( msg.message == WM_QUIT ) break; if ( msg.message == WM_PAINT ) { // This doesn't actually draw it, it just marks it // so it will redraw when next checked (NeedsRedraw) pCanvas->Redraw(); } // Handle the regular window stuff.. TranslateMessage(&msg); DispatchMessage(&msg); } // If GWEN's Canvas needs a redraw then redraw it // // In your game you would probably just draw it // every frame. But we have the option of only // drawing it when it needs it too. // if ( pCanvas->NeedsRedraw() ) { pCanvas->RenderCanvas(); } } delete pCanvas; delete skin; delete pRenderer; }
// // Program starts here // int main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { // // Create a window and attach directx to it // g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ); g_pHWND = CreateGameWindow(); CreateD3DDevice(); // // Create a GWEN DirectX renderer // Gwen::Renderer::DirectX9* pRenderer = new Gwen::Renderer::DirectX9( g_pD3DDevice ); // // Create a GWEN skin // Gwen::Skin::TexturedBase skin; skin.SetRender( pRenderer ); skin.Init( "DefaultSkin.png" ); // // Create a Canvas (it's root, on which all other GWEN panels are created) // Gwen::Controls::Canvas* pCanvas = new Gwen::Controls::Canvas( &skin ); pCanvas->SetSize( 1000, 622 ); pCanvas->SetDrawBackground( true ); pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) ); // // Create our unittest control (which is a Window with controls in it) // UnitTest* pUnit = new UnitTest( pCanvas ); pUnit->SetPos( 10, 10 ); // // Create a Windows Control helper // (Processes Windows MSG's and fires input at GWEN) // Gwen::Input::Windows GwenInput; GwenInput.Initialize( pCanvas ); // // Begin the main game loop // MSG msg; while( true ) { // Skip out if the window is closed if ( !IsWindowVisible( g_pHWND ) ) break; // If we have a message from windows.. if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { // .. give it to the input handler to process GwenInput.ProcessMessage( msg ); // if it's QUIT then quit.. if ( msg.message == WM_QUIT ) break; // Handle the regular window stuff.. TranslateMessage(&msg); DispatchMessage(&msg); } else { // Normal DirectX rendering loop g_pD3DDevice->BeginScene(); g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 0 ), 1, 0 ); // This is how easy it is to render GWEN! pCanvas->RenderCanvas(); g_pD3DDevice->EndScene(); g_pD3DDevice->Present( NULL, NULL, NULL, NULL ); } } if ( g_pD3DDevice ) { g_pD3DDevice->Release(); g_pD3DDevice = NULL; } if ( g_pD3D ) { g_pD3D->Release(); g_pD3D = NULL; } }
int main() { // // Create a new window // g_pHWND = CreateGameWindow(); // // Create OpenGL Device // HGLRC OpenGLContext = CreateOpenGLDeviceContext(); // // Create a GWEN OpenGL Renderer // #ifdef USE_DEBUG_FONT gwen::Renderer::OpenGL* pRenderer = new gwen::Renderer::OpenGL_DebugFont(); #else gwen::Renderer::OpenGL* pRenderer = new gwen::Renderer::OpenGL(); #endif pRenderer->Init(); // // Create a GWEN skin // gwen::Skin::TexturedBase* pSkin = new gwen::Skin::TexturedBase( pRenderer ); pSkin->Init( "DefaultSkin.png" ); // // Create a Canvas (it's root, on which all other GWEN panels are created) // gwen::Controls::Canvas* pCanvas = new gwen::Controls::Canvas( pSkin ); pCanvas->SetSize( 998, 650 - 24 ); pCanvas->SetDrawBackground( true ); pCanvas->SetBackgroundColor( gwen::Color( 150, 170, 170, 255 ) ); // // Create our unittest control (which is a Window with controls in it) // UnitTest* pUnit = new UnitTest( pCanvas ); pUnit->SetPos( 10, 10 ); // // Create a Windows Control helper // (Processes Windows MSG's and fires input at GWEN) // gwen::Input::Windows gwenInput; gwenInput.Initialize( pCanvas ); // // Begin the main game loop // MSG msg; while ( true ) { // Skip out if the window is closed if ( !IsWindowVisible( g_pHWND ) ) { break; } // If we have a message from windows.. if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { // .. give it to the input handler to process gwenInput.ProcessMessage( msg ); // if it's QUIT then quit.. if ( msg.message == WM_QUIT ) { break; } // Handle the regular window stuff.. TranslateMessage( &msg ); DispatchMessage( &msg ); } // Main OpenGL Render Loop { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); pCanvas->RenderCanvas(); SwapBuffers( GetDC( g_pHWND ) ); } } // Clean up OpenGL wglMakeCurrent( NULL, NULL ); wglDeleteContext( OpenGLContext ); delete pCanvas; delete pSkin; delete pRenderer; }
// // CreateMainWindow // // Window initialization // HWND CreateMainWindow() { return CreateGameWindow("Dark Reign II"); }
// // Program starts here // int main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { // // Create a window and attach directx to it // g_pHWND = CreateGameWindow(); CreateD3DDevice(); RECT FrameBounds; GetClientRect(g_pHWND, &FrameBounds); // // Create a GWEN DirectX renderer // Gwen::Renderer::DirectX10* pRenderer = new Gwen::Renderer::DirectX10(g_pd3dDevice); // // Create a GWEN skin // Gwen::Skin::TexturedBase* pSkin = new Gwen::Skin::TexturedBase(pRenderer); pSkin->Init("DefaultSkin.png"); // // Create a Canvas (it's root, on which all other GWEN panels are created) // Gwen::Controls::Canvas* pCanvas = new Gwen::Controls::Canvas(pSkin); pCanvas->SetSize(FrameBounds.right, FrameBounds.bottom); pCanvas->SetDrawBackground(true); pCanvas->SetBackgroundColor(Gwen::Color(150, 170, 170, 255)); // // Create our unittest control (which is a Window with controls in it) // UnitTest* pUnit = new UnitTest(pCanvas); pUnit->SetPos(10, 10); // // Create a Windows Control helper // (Processes Windows MSG's and fires input at GWEN) // Gwen::Input::Windows GwenInput; GwenInput.Initialize(pCanvas); // // Begin the main game loop // MSG msg; while (true) { // Skip out if the window is closed if (!IsWindowVisible(g_pHWND)) { break; } // If we have a message from windows.. if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // .. give it to the input handler to process GwenInput.ProcessMessage(msg); // if it's QUIT then quit.. if (msg.message == WM_QUIT) { break; } // Handle the regular window stuff.. TranslateMessage(&msg); DispatchMessage(&msg); } else { float ClearColor[4] = { 0.128f, 0.128f, 0.3f, 1.0f }; // Normal DirectX rendering loop g_pd3dDevice->ClearRenderTargetView(g_pRenderTargetView, ClearColor); // This is how easy it is to render GWEN! pCanvas->RenderCanvas(); g_pSwapChain->Present(0, 0); } } delete pCanvas; delete pSkin; delete pRenderer; if (g_pRenderTargetView) { g_pRenderTargetView->Release(); g_pRenderTargetView = NULL; } if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; } if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } }
void UGameEngine::Init(IEngineLoop* InEngineLoop) { DECLARE_SCOPE_CYCLE_COUNTER(TEXT("UGameEngine Init"), STAT_GameEngineStartup, STATGROUP_LoadTime); // Call base. UEngine::Init(InEngineLoop); #if USE_NETWORK_PROFILER FString NetworkProfilerTag; if( FParse::Value(FCommandLine::Get(), TEXT("NETWORKPROFILER="), NetworkProfilerTag ) ) { GNetworkProfiler.EnableTracking(true); } #endif // Load all of the engine modules that we need at startup that are not editor-related UGameEngine::LoadRuntimeEngineStartupModules(); // Load and apply user game settings GetGameUserSettings()->LoadSettings(); GetGameUserSettings()->ApplyNonResolutionSettings(); // Create game instance. For GameEngine, this should be the only GameInstance that ever gets created. { FStringClassReference GameInstanceClassName = GetDefault<UGameMapsSettings>()->GameInstanceClass; UClass* GameInstanceClass = (GameInstanceClassName.IsValid() ? LoadObject<UClass>(NULL, *GameInstanceClassName.ToString()) : UGameInstance::StaticClass()); GameInstance = NewObject<UGameInstance>(this, GameInstanceClass); GameInstance->InitializeStandalone(); } // // Creates the initial world context. For GameEngine, this should be the only WorldContext that ever gets created. // FWorldContext& InitialWorldContext = CreateNewWorldContext(EWorldType::Game); // Initialize the viewport client. UGameViewportClient* ViewportClient = NULL; if(GIsClient) { ViewportClient = NewObject<UGameViewportClient>(this, GameViewportClientClass); ViewportClient->Init(*GameInstance->GetWorldContext(), GameInstance); GameViewport = ViewportClient; GameInstance->GetWorldContext()->GameViewport = ViewportClient; } bCheckForMovieCapture = true; // Attach the viewport client to a new viewport. if(ViewportClient) { // This must be created before any gameplay code adds widgets bool bWindowAlreadyExists = GameViewportWindow.IsValid(); if (!bWindowAlreadyExists) { GameViewportWindow = CreateGameWindow(); } CreateGameViewport( ViewportClient ); if( !bWindowAlreadyExists ) { SwitchGameWindowToUseGameViewport(); } FString Error; if(ViewportClient->SetupInitialLocalPlayer(Error) == NULL) { UE_LOG(LogEngine, Fatal,TEXT("%s"),*Error); } UGameViewportClient::OnViewportCreated().Broadcast(); } GameInstance->StartGameInstance(); UE_LOG(LogInit, Display, TEXT("Game Engine Initialized.") ); // for IsInitialized() bIsInitialized = true; }
// // Program starts here // int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) { g_pHWND = CreateGameWindow(); CreateD3DDevice(); MY_UI::DirectX11* renderer = new MY_UI::DirectX11( g_Device, g_DeviceContext ); MY_UI::cRootWidget* root = new MY_UI::cRootWidget(); MY_UI::cWidgetSkin* skin = new MY_UI::cWidgetSkin(); //the MY_UI::Utilities::cInput input class declared above will clean up MY UI on its destruction so you dont need to free any memory. You can explicitly call MY_UI::DeInit() if you want when the program is shutting down though MY_UI::Init(renderer, skin, root); MY_UI::Utilities::SetCursor(MY_UI::Utilities::Standard); RECT temp; GetClientRect( g_pHWND, &temp ); root->SetSize(temp.right, temp.bottom); InitDemo(); InitScene(); // // Begin the main game loop // MY_UI::Controls::Text* fpscounter = new MY_UI::Controls::Text(root); fpscounter->SetFontSize(20); unsigned int framecount = 0; unsigned int lasttick = MY_UI::Utilities::GetTime(); std::string fpsStr, FrameStats; MSG msg; while( true ) { // Skip out if the window is closed if ( !IsWindowVisible( g_pHWND ) ) break; // If we have a message from windows.. if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { // if it's QUIT then quit.. if ( msg.message == WM_QUIT ) break; // Handle the regular window stuff.. TranslateMessage(&msg); DispatchMessage(&msg); } else { // Normal DirectX rendering loop framecount++; if(MY_UI::Utilities::GetTime() -lasttick >= 1000){// update float fps(static_cast<float>(framecount)); float msec(1000.0f/fps); std::ostringstream outs1; outs1.precision(4); outs1<<" FPS: "<<fps<<" MPF: "<<msec; fpsStr=outs1.str(); lasttick=MY_UI::Utilities::GetTime(); framecount=0;// reset std::ostringstream o; o<<"Draw Calls: "<<renderer->GetDrawCalls(); fpscounter->SetText(fpsStr +o.str()); } float ClearColor[4] = { .2f, .1f, 1.0f, 0.0f }; g_DeviceContext->ClearRenderTargetView( BackBufferRTV, ClearColor ); // This is how easy it is to render Render3D(); root->Draw(); SwapChain->Present(0, 0); } } MY_UI::Safe_Delete(Dummy);// destroy the dummy. This is not absolutely needed because the MY_UI library will clean up all widgets, but I delete it here because the 3d example needs to be shut down before everything else SAFE_DELETE(input);// make sure to delete this here. It will call the cleanup code in its destructor Cleanup();// clean up the 3d stuff HR(SwapChain->SetFullscreenState(false, 0));// this is needed in case full screen is on RELEASECOM(BackBufferRTV); RELEASECOM(SwapChain); RELEASECOM(g_DeviceContext); RELEASECOM(g_Device); }
void WindowsOpenGlWindow::SetScreenSize(const Graphics::PresentationParameters& pp) { assert(m_device != nullptr); m_window = CreateGameWindow(pp.BackBufferWidth, pp.BackBufferHeight, pp.IsFullScreen); PreferredBackBufferWidth(pp.BackBufferWidth); PreferredBackBufferHeight(pp.BackBufferHeight); // now create the OpenGL context static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 32, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 8, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 24, // 16Bit Z-Buffer (Depth Buffer) 8, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; m_hdc = GetDC((HWND)m_window); int pixelFormat = ChoosePixelFormat((HDC)m_hdc, &pfd); SetPixelFormat((HDC)m_hdc, pixelFormat, &pfd); HGLRC context = wglCreateContext((HDC)m_hdc); wglMakeCurrent((HDC)m_hdc, context); PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 #define WGL_CONTEXT_FLAGS_ARB 0x2094 int attribList[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 2, WGL_CONTEXT_MINOR_VERSION_ARB, 0, // WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, // WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0 }; HGLRC newContext = wglCreateContextAttribsARB((HDC)m_hdc, 0, attribList); if (wglMakeCurrent((HDC)m_hdc, newContext) == FALSE) throw Exception("zomg"); wglDeleteContext((HGLRC)context); ::ShowWindow((HWND)m_window, SW_SHOW); SetForegroundWindow((HWND)m_window); SetFocus((HWND)m_window); static_cast<Nxna::Graphics::OpenGl::OpenGlDevice*>(m_device)->OnContextCreated(); static_cast<Nxna::Graphics::OpenGl::OpenGlDevice*>(m_device)->UpdatePresentationParameters(pp); m_device->SetViewport(Nxna::Graphics::Viewport(0, 0, PreferredBackBufferWidth(), PreferredBackBufferHeight())); // tell the touch panel the display size Input::Touch::TouchPanel::SetDisplayWidth(pp.BackBufferWidth); Input::Touch::TouchPanel::SetDisplayHeight(pp.BackBufferHeight); }
void UGameEngine::Init(IEngineLoop* InEngineLoop) { DECLARE_SCOPE_CYCLE_COUNTER(TEXT("UGameEngine Init"), STAT_GameEngineStartup, STATGROUP_LoadTime); // Call base. UEngine::Init(InEngineLoop); #if USE_NETWORK_PROFILER FString NetworkProfilerTag; if( FParse::Value(FCommandLine::Get(), TEXT("NETWORKPROFILER="), NetworkProfilerTag ) ) { GNetworkProfiler.EnableTracking(true); } #endif // Load and apply user game settings GetGameUserSettings()->LoadSettings(); GetGameUserSettings()->ApplySettings(); // Creates the initial world context. For GameEngine, this should be the only WorldContext that ever gets created. FWorldContext &InitialWorldContext = CreateNewWorldContext(EWorldType::Game); // Initialize the viewport client. UGameViewportClient* ViewportClient = NULL; if(GIsClient) { ViewportClient = ConstructObject<UGameViewportClient>(GameViewportClientClass,this); ViewportClient->SetReferenceToWorldContext(InitialWorldContext); GameViewport = ViewportClient; InitialWorldContext.GameViewport = ViewportClient; } bCheckForMovieCapture = true; // Attach the viewport client to a new viewport. if(ViewportClient) { // This must be created before any gameplay code adds widgets bool bWindowAlreadyExists = GameViewportWindow.IsValid(); if (!bWindowAlreadyExists) { GameViewportWindow = CreateGameWindow(); } CreateGameViewport( ViewportClient ); if( !bWindowAlreadyExists ) { SwitchGameWindowToUseGameViewport(); } FString Error; if(!ViewportClient->Init(Error)) { UE_LOG(LogEngine, Fatal,TEXT("%s"),*Error); } } // Create default URL. // @note: if we change how we determine the valid start up map update LaunchEngineLoop's GetStartupMap() FURL DefaultURL; DefaultURL.LoadURLConfig( TEXT("DefaultPlayer"), GGameIni ); // Enter initial world. EBrowseReturnVal::Type BrowseRet = EBrowseReturnVal::Failure; FString Error; TCHAR Parm[4096]=TEXT(""); const TCHAR* Tmp = FCommandLine::Get(); #if UE_BUILD_SHIPPING // In shipping don't allow an override Tmp = TEXT(""); #endif // UE_BUILD_SHIPPING const UGameMapsSettings* GameMapsSettings = GetDefault<UGameMapsSettings>(); const FString& DefaultMap = GameMapsSettings->GetGameDefaultMap(); if (!FParse::Token(Tmp, Parm, ARRAY_COUNT(Parm), 0) || Parm[0] == '-') { FCString::Strcpy(Parm, *(DefaultMap + GameMapsSettings->LocalMapOptions)); } FURL URL( &DefaultURL, Parm, TRAVEL_Partial ); if( URL.Valid ) { BrowseRet = Browse(InitialWorldContext, URL, Error ); } // If waiting for a network connection, go into the starting level. if (BrowseRet != EBrowseReturnVal::Success && FCString::Stricmp(Parm, *DefaultMap) != 0) { const FText Message = FText::Format( NSLOCTEXT("Engine", "MapNotFound", "The map specified on the commandline '{0}' could not be found. Would you like to load the default map instead?"), FText::FromString( URL.Map ) ); // the map specified on the command-line couldn't be loaded. ask the user if we should load the default map instead if ( FCString::Stricmp(*URL.Map, *DefaultMap) != 0 && FMessageDialog::Open( EAppMsgType::OkCancel, Message ) != EAppReturnType::Ok) { // user canceled (maybe a typo while attempting to run a commandlet) FPlatformMisc::RequestExit( false ); return; } else { BrowseRet = Browse(InitialWorldContext, FURL(&DefaultURL, *(DefaultMap + GameMapsSettings->LocalMapOptions), TRAVEL_Partial), Error); } } // Handle failure. if( BrowseRet != EBrowseReturnVal::Success ) { UE_LOG(LogLoad, Fatal, TEXT("%s"), *FString::Printf( TEXT("Failed to enter %s: %s. Please check the log for errors."), Parm, *Error) ); } UE_LOG(LogInit, Display, TEXT("Game Engine Initialized.") ); // for IsInitialized() bIsInitialized = true; }
//---------------------------------------------------------------------------- // Creates a window, initializes the driver and sets up Direct3D state. //---------------------------------------------------------------------------- D3D_PUBLIC void D3DWnd_Init( void ) { ri.Printf( PRINT_ALL, "Initializing D3D11 subsystem\n" ); if ( !RegisterWindowClass() ) { //ri.Error( ERR_FATAL, "Failed to register D3D11 window class.\n" ); //return; } // @pjb: todo: fullscreen stuff bool fullscreen = r_fullscreen->integer != 0; cvar_t* vid_xpos = ri.Cvar_Get ("vid_xpos", "", 0); cvar_t* vid_ypos = ri.Cvar_Get ("vid_ypos", "", 0); g_hWnd = CreateGameWindow( vid_xpos->integer, vid_ypos->integer, vdConfig.vidWidth, vdConfig.vidHeight, fullscreen); if ( !g_hWnd ) { ri.Error( ERR_FATAL, "Failed to create Direct3D 11 window.\n" ); return; } QD3D11Device* device = InitDevice(); // @pjb: todo: do these based on cvars (or if not set, pick the best one) DXGI_SWAP_CHAIN_DESC1 scDesc; ZeroMemory( &scDesc, sizeof(scDesc) ); scDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; GetSwapChainDescFromConfig( &scDesc ); // @pjb: todo: set fullscreen based off config DXGI_SWAP_CHAIN_FULLSCREEN_DESC fsd; ZeroMemory( &fsd, sizeof(fsd) ); fsd.Windowed = TRUE; IDXGISwapChain1* swapChain = nullptr; HRESULT hr = QD3D::CreateSwapChain(device, g_hWnd, &scDesc, &fsd, &swapChain); if (FAILED(hr)) { // @pjb: todo: if swapchain desc is too fancy, fall back ri.Error( ERR_FATAL, "Failed to create Direct3D 11 swapchain: 0x%08x.\n", hr ); return; } InitSwapChain( swapChain ); SAFE_RELEASE( swapChain ); SAFE_RELEASE( device ); ::ShowWindow( g_hWnd, SW_SHOW ); ::UpdateWindow( g_hWnd ); ::SetForegroundWindow( g_hWnd ); ::SetFocus( g_hWnd ); }