diff --git a/Rakefile.rb b/Rakefile.rb index 3d0c84d..a0d05ce 100644 --- a/Rakefile.rb +++ b/Rakefile.rb @@ -26,7 +26,7 @@ task :default do "modules/gl3n/gl3n", "modules/glamour/glamour", ].each do |dir| - sources += Dir["#{dir}/**/*.d"] + sources += Dir["#{dir}/**/*.{d,c}"] end sources << "build/obj2d/logoobj.d" env["D_IMPORT_PATH"] += [ @@ -38,8 +38,9 @@ task :default do "modules/glamour", "build/obj2d", ] + env["CFLAGS"] += ["-Wall", "-std=gnu99"] env["DFLAGS"] += ["-fversion=Derelict3", "-fversion=gl3n", "-fversion=SDLImage"] - env["LDFLAGS"] += ["-static-libgcc"] + env["LDFLAGS"] += ["-static-libgcc", "-mwindows"] env.build_root = "build" env.Obj2D("build/obj2d/logoobj.d", "model/gentex-logo.obj") env.Program("gss", sources) diff --git a/src/displayinfo.c b/src/displayinfo.c new file mode 100644 index 0000000..0ef53d5 --- /dev/null +++ b/src/displayinfo.c @@ -0,0 +1,51 @@ +/* + * Author: Josh Holtrop + * This Windows-specific module will get the screen size + * and return the number of monitors present. + */ + +#include +#include +#include +#include + +void GetDisplaySize(int * width, int * height, int * num_monitors) +{ + int w = 0; + int h = 0; + int n = 0; + + /* loop through the display devices to get their dimensions */ + for (int i = 0; i < 10; i++) + { + DISPLAY_DEVICE dev; + dev.cb = sizeof(DISPLAY_DEVICE); + if (!EnumDisplayDevices(NULL, i, &dev, 0)) + break; + /* we only want real display devices to matter */ + if ((strcmp(dev.DeviceID, "") != 0) && (dev.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) + { + HDC hdc = CreateDC(TEXT("DISPLAY"), dev.DeviceString, NULL, NULL); + if (hdc != NULL) + { + n++; + w += GetDeviceCaps(hdc, HORZRES); + int thisHeight = GetDeviceCaps(hdc, VERTRES); + /* assume monitors are all horizontally aligned */ + if (thisHeight > h) + h = thisHeight; + } + } + } + + /* only update width and height if we have valid data */ + if (w != 0 && h != 0) + { + if (width != NULL) + *width = w; + if (height != NULL) + *height = h; + if (num_monitors != NULL) + *num_monitors = n; + } +}