Skip to content

Commit

Permalink
add windows console window
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelscholle committed Mar 2, 2025
1 parent cddb2bf commit 8b78b0d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@
#include "platform/appleplatform.h"
#endif

#if defined(__windows__)
#include <windows.h>
#include <stdio.h>
#include <fcntl.h>

void attachConsole() {
if (AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole()) {
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
setvbuf(stdout, nullptr, _IONBF, 0);
setvbuf(stderr, nullptr, _IONBF, 0);
printf("Console attached!\n");
} else {
MessageBoxA(NULL, "Failed to attach console!", "Error", MB_OK | MB_ICONERROR);
}
}
#endif

#include "logging/logmessagesmodel.h"
#include "logging/hudlogmessagesmodel.h"
#include "util/qopenhd.h"
Expand Down Expand Up @@ -237,6 +255,7 @@ int main(int argc, char *argv[]) {

#if defined(__windows__)
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
attachConsole();
#endif

QCoreApplication::setOrganizationName("OpenHD");
Expand Down

0 comments on commit 8b78b0d

Please sign in to comment.