wgl: Put the core functionality of X11DRV_SetPixelFormat in a separate function.

This is needed for a new X11DRV_SetPixelFormatWINE function which allows you to change the pixel format multiple times.
This commit is contained in:
Roderick Colenbrander 2008-04-23 20:40:43 +00:00 committed by Alexandre Julliard
parent 56a41706c7
commit 2823e1d219
1 changed files with 56 additions and 46 deletions

View File

@ -1441,41 +1441,29 @@ int X11DRV_GetPixelFormat(X11DRV_PDEVICE *physDev) {
return physDev->current_pf; return physDev->current_pf;
} }
/** /* This function is the core of X11DRV_SetPixelFormat and X11DRV_SetPixelFormatWINE.
* X11DRV_SetPixelFormat * Both functions are the same except that X11DRV_SetPixelFormatWINE allows you to
* * set the pixel format multiple times. */
* Set the pixel-format id used by this DC static BOOL internal_SetPixelFormat(X11DRV_PDEVICE *physDev,
*/
BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
int iPixelFormat, int iPixelFormat,
const PIXELFORMATDESCRIPTOR *ppfd) { const PIXELFORMATDESCRIPTOR *ppfd) {
WineGLPixelFormat *fmt; WineGLPixelFormat *fmt;
int value; int value;
HWND hwnd; HWND hwnd;
TRACE("(%p,%d,%p)\n", physDev, iPixelFormat, ppfd); /* SetPixelFormat is not allowed on the X root_window e.g. GetDC(0) */
if(get_glxdrawable(physDev) == root_window)
{
ERR("Invalid operation on root_window\n");
return FALSE;
}
if (!has_opengl()) { /* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
ERR("No libGL on this box - disabling OpenGL support !\n"); fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &value);
return FALSE; if(!fmt) {
} ERR("Invalid iPixelFormat: %d\n", iPixelFormat);
return FALSE;
/* SetPixelFormat is not allowed on the X root_window e.g. GetDC(0) */ }
if(get_glxdrawable(physDev) == root_window)
{
ERR("Invalid operation on root_window\n");
return FALSE;
}
/* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &value);
if(!fmt) {
ERR("Invalid iPixelFormat: %d\n", iPixelFormat);
return FALSE;
}
if(physDev->current_pf) /* cannot change it if already set */
return (physDev->current_pf == iPixelFormat);
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value); pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value);
@ -1507,24 +1495,46 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
FIXME("called on a non-window, non-bitmap object?\n"); FIXME("called on a non-window, non-bitmap object?\n");
} }
physDev->current_pf = iPixelFormat; physDev->current_pf = iPixelFormat;
if (TRACE_ON(wgl)) { if (TRACE_ON(wgl)) {
int gl_test = 0; int gl_test = 0;
gl_test = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_FBCONFIG_ID, &value); gl_test = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_FBCONFIG_ID, &value);
if (gl_test) { if (gl_test) {
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n"); ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
} else { } else {
TRACE(" FBConfig have :\n"); TRACE(" FBConfig have :\n");
TRACE(" - FBCONFIG_ID 0x%x\n", value); TRACE(" - FBCONFIG_ID 0x%x\n", value);
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_VISUAL_ID, &value); pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_VISUAL_ID, &value);
TRACE(" - VISUAL_ID 0x%x\n", value); TRACE(" - VISUAL_ID 0x%x\n", value);
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value); pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value);
TRACE(" - DRAWABLE_TYPE 0x%x\n", value); TRACE(" - DRAWABLE_TYPE 0x%x\n", value);
}
} }
} return TRUE;
return TRUE; }
/**
* X11DRV_SetPixelFormat
*
* Set the pixel-format id used by this DC
*/
BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
int iPixelFormat,
const PIXELFORMATDESCRIPTOR *ppfd) {
TRACE("(%p,%d,%p)\n", physDev, iPixelFormat, ppfd);
if (!has_opengl()) {
ERR("No libGL on this box - disabling OpenGL support !\n");
return FALSE;
}
if(physDev->current_pf) /* cannot change it if already set */
return (physDev->current_pf == iPixelFormat);
return internal_SetPixelFormat(physDev, iPixelFormat, ppfd);
} }
/** /**