diff options
author | José Fonseca <jfonseca@vmware.com> | 2014-11-19 18:10:39 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2014-11-19 21:05:20 +0000 |
commit | a819167f7daf8fe060efd75d02825b082f1fd255 (patch) | |
tree | 33c3d0d9205c7336af91233c4d7832eae203bb04 | |
parent | bcd5a7d93770a1cd83a574c9d1026a45d48cc309 (diff) |
wgl: Ensure PIXELFORMATDESCRIPTOR members are zeroed.
I suddenly started seeing many simple GL apps, including wglinfo,
choosing Microsoft GDI OpenGL implementation, even though hardware
accelerated pixel formats were available.
It turned out that:
- the screen was in 16bpp mode (some WHCK tests have the nasty habit
of doing that)
- NVIDIA opengl driver only reports R5G6B5 pixel formats (ie no alpha
bits) in this case
- non-zero cAlphaBits was being passed to ChoosePixelformat (or in the
wglinfo case, garbage, as the structure wasn't being properly zeroed)
- ChoosePixelFormat will choose a SW pixel format if has to in order to
honour non-zero cAlphaBits.
At least on the wglinfo and friends case the alpha bits are not needed,
so this change will make sure that HW accelerated formats will be chosen
before SW ones.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
-rw-r--r-- | src/wgl/sharedtex_mt.c | 6 | ||||
-rw-r--r-- | src/wgl/wglinfo.c | 1 | ||||
-rw-r--r-- | src/wgl/wglthreads.c | 3 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/wgl/sharedtex_mt.c b/src/wgl/sharedtex_mt.c index 161b2bba..073b1005 100644 --- a/src/wgl/sharedtex_mt.c +++ b/src/wgl/sharedtex_mt.c @@ -118,7 +118,7 @@ initMainthread(void) { WNDCLASS wc = {0}; HWND win; - PIXELFORMATDESCRIPTOR pfd = {0}; + PIXELFORMATDESCRIPTOR pfd; int visinfo; wc.lpfnWndProc = WndProc; @@ -147,6 +147,7 @@ initMainthread(void) Error("Couldn't obtain HDC"); } + memset(&pfd, 0, sizeof(pfd)); pfd.cColorBits = 24; pfd.cDepthBits = 24; pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; @@ -405,7 +406,7 @@ threadRunner (void *arg) { struct thread_init_arg *tia = (struct thread_init_arg *) arg; struct window *win; - PIXELFORMATDESCRIPTOR pfd = {0}; + PIXELFORMATDESCRIPTOR pfd; int visinfo; win = &Windows[tia->id]; @@ -419,6 +420,7 @@ threadRunner (void *arg) if(tia->id > 0) WaitForSingleObject(Windows[tia->id - 1].hEventInitialised, INFINITE); + memset(&pfd, 0, sizeof(pfd)); pfd.cColorBits = 24; pfd.cDepthBits = 24; pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; diff --git a/src/wgl/wglinfo.c b/src/wgl/wglinfo.c index 30b13079..b6285eca 100644 --- a/src/wgl/wglinfo.c +++ b/src/wgl/wglinfo.c @@ -123,6 +123,7 @@ print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine, return; } + memset(&pfd, 0, sizeof(pfd)); pfd.cColorBits = 3; pfd.cRedBits = 1; pfd.cGreenBits = 1; diff --git a/src/wgl/wglthreads.c b/src/wgl/wglthreads.c index 27dca10f..2ee42e2e 100644 --- a/src/wgl/wglthreads.c +++ b/src/wgl/wglthreads.c @@ -430,7 +430,7 @@ create_window(struct winthread *wt, HGLRC shareCtx) int ypos = (wt->Index / 8) * (width + 20); HWND win; HDC hdc; - PIXELFORMATDESCRIPTOR pfd = {0}; + PIXELFORMATDESCRIPTOR pfd; int visinfo; HGLRC ctx; @@ -463,6 +463,7 @@ create_window(struct winthread *wt, HGLRC shareCtx) Error("Couldn't obtain HDC"); } + memset(&pfd, 0, sizeof(pfd)); pfd.cColorBits = 24; pfd.cDepthBits = 24; pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; |