| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #include <iostream>
- #include <stdio.h>
- #include <fcntl.h>
- #include <io.h>
- #include "BsEditorApplication.h"
- #include "BsPlatform.h"
- #include "BsCrashHandler.h"
- #if BS_PLATFORM == BS_PLATFORM_WIN32
- #include <windows.h>
- using namespace BansheeEngine;
- #if BS_DEBUG_MODE
- void InitializeDebugConsole()
- {
- //Create a console for this application
- AllocConsole();
- // Redirect standard output to console
- freopen("CONIN$", "r", stdin);
- freopen("CONOUT$", "w", stdout);
- freopen("CONOUT$", "w", stderr);
- // Clear streams to ensure they aren't in an error state
- std::wcout.clear();
- std::cout.clear();
- std::wcerr.clear();
- std::cerr.clear();
- std::wcin.clear();
- std::cin.clear();
- }
- void ShutdownDebugConsole()
- {
- //Write "Press any key to exit"
- HANDLE ConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
- DWORD CharsWritten;
- WriteConsole(ConsoleOutput, "\nPress any key to exit", 22, &CharsWritten, 0);
- //Disable line-based input mode so we can get a single character
- HANDLE ConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
- SetConsoleMode(ConsoleInput, 0);
- //Read a single character
- TCHAR InputBuffer;
- DWORD CharsRead;
- ReadConsole(ConsoleInput, &InputBuffer, 1, &CharsRead, 0);
- }
- #endif // End BS_DEBUG_MODE
- int CALLBACK WinMain(
- _In_ HINSTANCE hInstance,
- _In_ HINSTANCE hPrevInstance,
- _In_ LPSTR lpCmdLine,
- _In_ int nCmdShow
- )
- {
- #if BS_DEBUG_MODE
- InitializeDebugConsole();
- #endif
- CrashHandler::startUp();
- __try
- {
- EditorApplication::startUp(EditorRenderAPI::DX11);
- EditorApplication::instance().runMainLoop();
- EditorApplication::shutDown();
- }
- __except (gCrashHandler().reportCrash(GetExceptionInformation()))
- {
- PlatformUtility::terminate(true);
- }
- #if BS_DEBUG_MODE
- ShutdownDebugConsole();
- #endif
- CrashHandler::shutDown();
- return 0;
- }
- #endif // End BS_PLATFORM
|