| 50 | } |
| 51 | |
| 52 | int32 App::Run() |
| 53 | { |
| 54 | try |
| 55 | { |
| 56 | if(createConsole) |
| 57 | { |
| 58 | Win32Call(AllocConsole()); |
| 59 | Win32Call(SetConsoleTitle(applicationName.c_str())); |
| 60 | FILE* consoleFile = nullptr; |
| 61 | freopen_s(&consoleFile, "CONOUT$", "wb", stdout); |
| 62 | } |
| 63 | |
| 64 | window.SetClientArea(deviceManager.BackBufferWidth(), deviceManager.BackBufferHeight()); |
| 65 | deviceManager.Initialize(window); |
| 66 | |
| 67 | if(showWindow) |
| 68 | window.ShowWindow(); |
| 69 | |
| 70 | blendStates.Initialize(deviceManager.Device()); |
| 71 | rasterizerStates.Initialize(deviceManager.Device()); |
| 72 | depthStencilStates.Initialize(deviceManager.Device()); |
| 73 | samplerStates.Initialize(deviceManager.Device()); |
| 74 | |
| 75 | // Create a font + SpriteRenderer |
| 76 | font.Initialize(L"Arial", 18, SpriteFont::Regular, true, deviceManager.Device()); |
| 77 | spriteRenderer.Initialize(deviceManager.Device()); |
| 78 | |
| 79 | Profiler::GlobalProfiler.Initialize(deviceManager.Device(), deviceManager.ImmediateContext()); |
| 80 | |
| 81 | window.RegisterMessageCallback(WM_SIZE, OnWindowResized, this); |
| 82 | |
| 83 | // Initialize AntTweakBar |
| 84 | TwCall(TwInit(TW_DIRECT3D11, deviceManager.Device())); |
| 85 | |
| 86 | // Create a tweak bar |
| 87 | tweakBar = TwNewBar("Settings"); |
| 88 | std::string helpTextDefinition = MakeAnsiString(" GLOBAL help='%s' ", globalHelpText.c_str()); |
| 89 | TwCall(TwDefine(helpTextDefinition.c_str())); |
| 90 | TwCall(TwDefine(" GLOBAL fontsize=3 ")); |
| 91 | |
| 92 | Settings.Initialize(tweakBar); |
| 93 | |
| 94 | TwHelper::SetValuesWidth(Settings.TweakBar(), 120, false); |
| 95 | |
| 96 | AppSettings::Initialize(deviceManager.Device()); |
| 97 | |
| 98 | Initialize(); |
| 99 | |
| 100 | AfterReset(); |
| 101 | |
| 102 | while(window.IsAlive()) |
| 103 | { |
| 104 | if(!window.IsMinimized()) |
| 105 | { |
| 106 | timer.Update(); |
| 107 | Settings.Update(); |
| 108 | |
| 109 | CalculateFPS(); |
no test coverage detected