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