diff options
| author | Dustin Graves <dustin@lunarg.com> | 2016-02-15 15:54:52 -0700 |
|---|---|---|
| committer | Jon Ashburn <jon@lunarg.com> | 2016-02-18 15:42:04 -0700 |
| commit | bcb0a4fe3cd339b9de03ab267ea785c0c08f03a6 (patch) | |
| tree | 74b18a856af168ad4cb4ecba0d574f016768e350 | |
| parent | 891e6b4720886d8b8a78fecf1e37490cf6528e05 (diff) | |
| download | usermoji-bcb0a4fe3cd339b9de03ab267ea785c0c08f03a6.tar.xz | |
demos: Adjust vulkaninfo failure cases
For Windows, after vulkaninfo allocates a console, it tries to resize the
console and change the title text. Failure of either operation was
treated as console icreation failure, which led to vulkaninfo printing
to the console and then closing the console immediately. Now treating
AllocConsole() failure as console creation failure and ignoring resize and
title text change failures. With this change, resize failure will not
stop the app from pausing after printing info to the console.
| -rw-r--r-- | demos/vulkaninfo.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/demos/vulkaninfo.c b/demos/vulkaninfo.c index 8f768bf5..8549b3a5 100644 --- a/demos/vulkaninfo.c +++ b/demos/vulkaninfo.c @@ -1213,7 +1213,8 @@ bool SetStdOutToNewConsole() { return false; // allocate a console for this app - AllocConsole(); + if (!AllocConsole()) + return false; // redirect unbuffered STDOUT to the console HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); @@ -1224,23 +1225,22 @@ bool SetStdOutToNewConsole() { // make the console window bigger CONSOLE_SCREEN_BUFFER_INFO csbi; - SMALL_RECT r; COORD bufferSize; - if (!GetConsoleScreenBufferInfo(consoleHandle, &csbi)) - return false; - bufferSize.X = csbi.dwSize.X + 30; - bufferSize.Y = 20000; - if (!SetConsoleScreenBufferSize(consoleHandle, bufferSize)) - return false; + if (GetConsoleScreenBufferInfo(consoleHandle, &csbi)) + { + bufferSize.X = csbi.dwSize.X + 30; + bufferSize.Y = 20000; + SetConsoleScreenBufferSize(consoleHandle, bufferSize); + } + + SMALL_RECT r; r.Left = r.Top = 0; r.Right = csbi.dwSize.X - 1 + 30; r.Bottom = 50; - if (!SetConsoleWindowInfo(consoleHandle, true, &r)) - return false; + SetConsoleWindowInfo(consoleHandle, true, &r); // change the console window title - if (!SetConsoleTitle(TEXT(APP_SHORT_NAME))) - return false; + SetConsoleTitle(TEXT(APP_SHORT_NAME)); return true; } |
