aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.mingw9
-rw-r--r--base/main.cpp41
2 files changed, 48 insertions, 2 deletions
diff --git a/Makefile.mingw b/Makefile.mingw
index 0788ac5916..4a75442532 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -17,15 +17,20 @@ RM_REC = $(RM) -r
ZIP = zip -q
CP = cp
+### Uncomment these 2 lines,if you want to build ScummVM
+### as a consoleless Win32 application
+#DEFINES = -DNO_CONSOLE
+#LIBS=-mwindows
+
#######################################################################
# Default compilation parameters. Normally don't edit these #
#######################################################################
CXXFLAGS:= -g -O -Wall -Wuninitialized -Wno-long-long -Wno-multichar -Wno-unknown-pragmas
-DEFINES :=
+DEFINES +=
LDFLAGS :=
INCLUDES:= -I. -Icommon -Iscumm $(SDL_CFLAGS)
-LIBS := $(SDL_LIBS) -lmingw32 -lwinmm -lopengl32
+LIBS += $(SDL_LIBS) -lmingw32 -lwinmm -lopengl32
OBJS := scummvmico.o backends/sdl/sdl-common.o backends/sdl/sdl_gl.o
EXEEXT :=.exe
diff --git a/base/main.cpp b/base/main.cpp
index 888203d3cb..ac49cd3ab2 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -85,6 +85,12 @@ const char *gScummVMFullVersion = "ScummVM 0.5.3cvs (" __DATE__ " " __TIME__ ")"
Config *g_config = 0;
NewGui *g_gui = 0;
+#if defined(WIN32) && defined(NO_CONSOLE)
+#include <cstdio>
+#define STDOUT_FILE TEXT("stdout.txt")
+#define STDERR_FILE TEXT("stderr.txt")
+#endif
+
#if defined(QTOPIA)
// FIXME - why exactly is this needed?
extern "C" int main(int argc, char *argv[]);
@@ -222,6 +228,41 @@ int main(int argc, char *argv[]) {
#endif
#endif
+// Code copied from SDL_main
+#if defined(WIN32) && defined(NO_CONSOLE)
+
+ /* Flush the output in case anything is queued */
+ fclose(stdout);
+ fclose(stderr);
+
+ /* Redirect standard input and standard output */
+ FILE *newfp = freopen(STDOUT_FILE, "w", stdout);
+ if ( newfp == NULL ) { /* This happens on NT */
+#if !defined(stdout)
+ stdout = fopen(STDOUT_FILE, "w");
+#else
+ newfp = fopen(STDOUT_FILE, "w");
+ if ( newfp ) {
+ *stdout = *newfp;
+ }
+#endif
+ }
+ newfp = freopen(STDERR_FILE, "w", stderr);
+ if ( newfp == NULL ) { /* This happens on NT */
+#if !defined(stderr)
+ stderr = fopen(STDERR_FILE, "w");
+#else
+ newfp = fopen(STDERR_FILE, "w");
+ if ( newfp ) {
+ *stderr = *newfp;
+ }
+#endif
+ }
+ setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */
+ setbuf(stderr, NULL); /* No buffering */
+
+#endif //defined(WIN32) && defined(USE_CONSOLE)
+
// Read the config file
g_config = new Config(scummhome, "scummvm");
g_config->set("versioninfo", gScummVMVersion);