From 8739c414e67ab196473f9379dc641e0b70e0e62f Mon Sep 17 00:00:00 2001 From: maraakate Date: Sat, 11 Mar 2023 17:28:23 -0500 Subject: [PATCH] Choose best PFD based on display BPP for Win32. Only allow stencil buffer in 32BPP for Win32. Add 24BPP PFD for Win32. --- drivers/glide/wgl.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/drivers/glide/wgl.c b/drivers/glide/wgl.c index 9443a98..f30f446 100644 --- a/drivers/glide/wgl.c +++ b/drivers/glide/wgl.c @@ -36,6 +36,7 @@ PIXELFORMATDESCRIPTOR pfd[] = { 1, /* version number */ PFD_DRAW_TO_WINDOW | /* support window */ PFD_SUPPORT_OPENGL | /* support OpenGL */ + PFD_SWAP_COPY | PFD_DOUBLEBUFFER, /* double buffered */ PFD_TYPE_RGBA, /* RGBA type */ 16, /* color depth */ @@ -51,11 +52,33 @@ PIXELFORMATDESCRIPTOR pfd[] = { 0, /* reserved */ 0, 0, 0 /* layer masks ignored */ }, -{ +{ + sizeof(PIXELFORMATDESCRIPTOR), /* size of this pfd */ + 1, /* version number */ + PFD_DRAW_TO_WINDOW | /* support window */ + PFD_SUPPORT_OPENGL | /* support OpenGL */ + PFD_SWAP_COPY | + PFD_DOUBLEBUFFER, /* double buffered */ + PFD_TYPE_RGBA, /* RGBA type */ + 24, /* color depth */ + 8, 0, 8, 8, 8, 16, /* color bits */ + 8, /* alpha buffer */ + 24, /* shift bit */ + 0, /* no accumulation buffer */ + 0, 0, 0, 0, /* accum bits ignored */ + 24, /* z-buffer */ + 8, /* stencil buffer */ + 0, /* no auxiliary buffer */ + PFD_MAIN_PLANE, /* main layer */ + 0, /* reserved */ + 0, 0, 0 /* layer masks ignored */ +}, +{ sizeof(PIXELFORMATDESCRIPTOR), /* size of this pfd */ 1, /* version number */ PFD_DRAW_TO_WINDOW | /* support window */ PFD_SUPPORT_OPENGL | /* support OpenGL */ + PFD_SWAP_COPY | PFD_DOUBLEBUFFER, /* double buffered */ PFD_TYPE_RGBA, /* RGBA type */ 32, /* color depth */ @@ -166,10 +189,15 @@ wglChoosePixelFormat (HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd) { int i, numPixelFormats, bestIndex = -1; const PIXELFORMATDESCRIPTOR *ppfdBest = NULL; + DEVMODE dm; + + /* FS: Choose the best PFD based on our display BPP. */ + memset(&dm, 0, sizeof(DEVMODE)); + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm); WINLOG((eff, "%s:\n", __FUNCTION__)); - if (ppfd->dwFlags != (ppfd->dwFlags & + if (ppfd->dwFlags != (ppfd->dwFlags & ( PFD_DRAW_TO_WINDOW | PFD_DRAW_TO_BITMAP | @@ -263,7 +291,7 @@ wglChoosePixelFormat (HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd) continue; } - if (ppfd->cStencilBits && !ppfdCandidate->cStencilBits) { + if (ppfd->cStencilBits && !ppfdCandidate->cStencilBits && (dm.dmBitsPerPel == 32)) { /* FS: Stencil buffer only available on 32bpp */ if (!YES("wgl.ignore.stencilbuffer")) continue; } @@ -271,6 +299,11 @@ wglChoosePixelFormat (HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd) continue; } + /* FS: Choose the best PFD based on our display BPP. */ + if ((dm.dmBitsPerPel > 0) && (ppfdCandidate->cColorBits != dm.dmBitsPerPel)) { + continue; + } + /* ** See if candidate is better than the previous best choice */