+ // Output to Window
+ pixelFormat = qaglChoosePixelFormat(NULL, 0, attributes);
+ error = qaglGetError();
+ if (error != AGL_NO_ERROR)
+ {
+ Con_Printf("qaglChoosePixelFormat FAILED: %s\n",
+ (char *)qaglErrorString(error));
+ ReleaseWindow(window);
+ return false;
+ }
+ }
+ else // Output is fullScreen
+ {
+ CGDirectDisplayID mainDisplay;
+ CFDictionaryRef refDisplayMode;
+ GDHandle gdhDisplay;
+
+ // Get the mainDisplay and set resolution to current
+ mainDisplay = CGMainDisplayID();
+ CGDisplayCapture(mainDisplay);
+
+ // TOCHECK: not sure whether or not it's necessary to change the resolution
+ // "by hand", or if aglSetFullscreen does the job anyway
+ refDisplayMode = CGDisplayBestModeForParametersAndRefreshRateWithProperty(mainDisplay, mode->bitsperpixel, mode->width, mode->height, mode->refreshrate, kCGDisplayModeIsSafeForHardware, NULL);
+ CGDisplaySwitchToMode(mainDisplay, refDisplayMode);
+ DMGetGDeviceByDisplayID((DisplayIDType)mainDisplay, &gdhDisplay, false);
+
+ // Set pixel format with built attribs
+ // Note: specifying a device is *required* for AGL_FullScreen
+ pixelFormat = qaglChoosePixelFormat(&gdhDisplay, 1, attributes);
+ error = qaglGetError();
+ if (error != AGL_NO_ERROR)
+ {
+ Con_Printf("qaglChoosePixelFormat FAILED: %s\n",
+ (char *)qaglErrorString(error));
+ ReleaseWindow(window);
+ return false;
+ }
+ }
+
+ // Create a context using the pform
+ context = qaglCreateContext(pixelFormat, NULL);
+ error = qaglGetError();
+ if (error != AGL_NO_ERROR)
+ {
+ Con_Printf("qaglCreateContext FAILED: %s\n",
+ (char *)qaglErrorString(error));