summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2020-04-16 23:10:13 +0200
committerErik Faye-Lund <erik.faye-lund@collabora.com>2020-04-20 11:48:51 +0200
commit12a2b4cca99891ea2e09506301e7eba0b96d1584 (patch)
treec31b63ff90a317875b634baafa045d377559a4fd
parent27813895adef5866e9aee62975c7f5965cd9c601 (diff)
wglgears: error properly when no pixel-format is found
If we're too strict with our requirements, we should properly report the issue. We shouldn't assert, and we should list the requirements so it's easy to understand why. Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--src/wgl/wglgears.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/wgl/wglgears.c b/src/wgl/wglgears.c
index 7f0d7742..fd506dfd 100644
--- a/src/wgl/wglgears.c
+++ b/src/wgl/wglgears.c
@@ -411,10 +411,8 @@ make_window(const char *name, int x, int y, int width, int height)
hDC = GetDC(hWnd);
pixelFormat = ChoosePixelFormat(hDC, &pfd);
- if (!pixelFormat) {
- printf("ChoosePixelFormat failed\n");
- exit(1);
- }
+ if (!pixelFormat)
+ goto nopixelformat;
SetPixelFormat(hDC, pixelFormat, &pfd);
hRC = wglCreateContext(hDC);
@@ -461,11 +459,9 @@ make_window(const char *name, int x, int y, int width, int height)
pixelFormat = 0;
if (!wglChoosePixelFormatARB_func(hDC, int_attribs, float_attribs, 1,
- &pixelFormat, &numFormats)) {
- printf("wglChoosePixelFormatARB failed\n");
- exit(0);
- }
- assert(numFormats > 0);
+ &pixelFormat, &numFormats) ||
+ !numFormats)
+ goto nopixelformat;
PIXELFORMATDESCRIPTOR newPfd;
DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &newPfd);
@@ -481,6 +477,16 @@ make_window(const char *name, int x, int y, int width, int height)
ShowWindow(hWnd, SW_SHOW);
SetForegroundWindow(hWnd);
SetFocus(hWnd);
+ return;
+
+nopixelformat:
+ printf("Error: couldn't get an RGB, Double-buffered");
+ if (samples > 0)
+ printf(", Multisample");
+ if (use_srgb)
+ printf(", sRGB");
+ printf(" pixelformat\n");
+ exit(1);
}
static void