wgl: Remove the pixel format limitation.

This commit is contained in:
Roderick Colenbrander 2008-02-22 20:40:00 +00:00 committed by Alexandre Julliard
parent 68467cf344
commit 8293a9ead0
1 changed files with 40 additions and 45 deletions

View File

@ -829,17 +829,10 @@ static int get_render_type_from_fbconfig(Display *display, GLXFBConfig fbconfig)
static BOOL init_formats(Display *display, int screen, Visual *visual) static BOOL init_formats(Display *display, int screen, Visual *visual)
{ {
int fmt_id, tmp_fmt_id, nCfgs, i; int fmt_id, nCfgs, i, run;
GLXFBConfig* cfgs; GLXFBConfig* cfgs;
GLXFBConfig fbconfig = NULL;
XVisualInfo *visinfo; XVisualInfo *visinfo;
VisualID visualid = XVisualIDFromVisual(visual);
int nOffscreenFormats = 0;
/* As mentioned in various parts of the code only the format of the main visual can be used for onscreen rendering.
* Next to this format there are also so called offscreen rendering formats (used for pbuffers) which can be supported
* because they don't need a visual. Below we use glXGetFBConfigs instead of glXChooseFBConfig to enumerate the fb configurations
* because this call lists both types of formats instead of only onscreen ones. */
cfgs = pglXGetFBConfigs(display, DefaultScreen(display), &nCfgs); cfgs = pglXGetFBConfigs(display, DefaultScreen(display), &nCfgs);
if (NULL == cfgs || 0 == nCfgs) { if (NULL == cfgs || 0 == nCfgs) {
ERR("glXChooseFBConfig returns NULL\n"); ERR("glXChooseFBConfig returns NULL\n");
@ -847,48 +840,50 @@ static BOOL init_formats(Display *display, int screen, Visual *visual)
return FALSE; return FALSE;
} }
/* Count the number of offscreen formats to determine the size for our pixelformat list */ WineGLPixelFormatList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nCfgs*sizeof(WineGLPixelFormat));
for(i=0; i<nCfgs; i++) {
pglXGetFBConfigAttrib(display, cfgs[i], GLX_FBCONFIG_ID, &tmp_fmt_id);
visinfo = pglXGetVisualFromFBConfig(display, cfgs[i]); /* Fill the pixel format list. Put onscreen formats at the top and offscreen ones at the bottom.
/* Onscreen formats have a corresponding XVisual, offscreen ones don't */ * Do this as GLX doesn't guarantee that the list is sorted */
if(!visinfo) { for(run=0; run < 2; run++)
nOffscreenFormats++; {
} else if(visinfo && visinfo->visualid == visualid) { for(i=0; i<nCfgs; i++) {
pglXGetFBConfigAttrib(display, cfgs[i], GLX_FBCONFIG_ID, &fmt_id); pglXGetFBConfigAttrib(display, cfgs[i], GLX_FBCONFIG_ID, &fmt_id);
fbconfig = cfgs[i]; visinfo = pglXGetVisualFromFBConfig(display, cfgs[i]);
XFree(visinfo);
}
}
TRACE("Number of offscreen formats: %d\n", nOffscreenFormats);
/* Allocate memory for all the offscreen pixelformats and the format of Wine's main visual */ /* The first run we only add onscreen formats (ones which have an associated X Visual).
WineGLPixelFormatList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (1+nOffscreenFormats)*sizeof(WineGLPixelFormat)); * The second run we only set offscreen formats. */
WineGLPixelFormatList[0].iPixelFormat = 1; if(!run && visinfo)
WineGLPixelFormatList[0].fbconfig = fbconfig; {
WineGLPixelFormatList[0].fmt_id = fmt_id; /* We implement child window rendering using offscreen buffers (using composite or an XPixmap).
WineGLPixelFormatList[0].render_type = get_render_type_from_fbconfig(display, fbconfig); * The contents is copied to the destination using XCopyArea. For the copying to work
WineGLPixelFormatList[0].offscreenOnly = FALSE; * the depth of the source and destination window should be the same. In general this should
WineGLPixelFormatListSize = 1; * not be a problem for OpenGL as drivers only advertise formats with a similar depth (or no depth).
WineGLPixelFormatOnScreenSize = 1; * As of the introduction of composition managers at least Nvidia now also offers ARGB visuals
* with a depth of 32 in addition to the default 24 bit. In order to prevent BadMatch errors we only
* list formats with the same depth. */
if(visinfo->depth != screen_depth)
continue;
/* Fill the list with offscreen formats */ TRACE("Found onscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id, WineGLPixelFormatListSize+1, i);
for(i=0; i<nCfgs; i++) { WineGLPixelFormatList[WineGLPixelFormatListSize].iPixelFormat = WineGLPixelFormatListSize+1; /* The index starts at 1 */
pglXGetFBConfigAttrib(display, cfgs[i], GLX_FBCONFIG_ID, &tmp_fmt_id); WineGLPixelFormatList[WineGLPixelFormatListSize].fbconfig = cfgs[i];
WineGLPixelFormatList[WineGLPixelFormatListSize].fmt_id = fmt_id;
WineGLPixelFormatList[WineGLPixelFormatListSize].render_type = get_render_type_from_fbconfig(display, cfgs[i]);
visinfo = pglXGetVisualFromFBConfig(display, cfgs[i]); WineGLPixelFormatList[WineGLPixelFormatListSize].offscreenOnly = FALSE;
/* We have found an offscreen rendering format when there is no visualinfo :) */ WineGLPixelFormatListSize++;
if(!visinfo) { WineGLPixelFormatOnScreenSize++;
TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", tmp_fmt_id, WineGLPixelFormatListSize+1, i); XFree(visinfo);
WineGLPixelFormatList[WineGLPixelFormatListSize].iPixelFormat = WineGLPixelFormatListSize+1; /* The index starts at 1 */ } else if(run && !visinfo) {
WineGLPixelFormatList[WineGLPixelFormatListSize].fbconfig = cfgs[i]; TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id, WineGLPixelFormatListSize+1, i);
WineGLPixelFormatList[WineGLPixelFormatListSize].fmt_id = tmp_fmt_id; WineGLPixelFormatList[WineGLPixelFormatListSize].iPixelFormat = WineGLPixelFormatListSize+1; /* The index starts at 1 */
WineGLPixelFormatList[WineGLPixelFormatListSize].render_type = get_render_type_from_fbconfig(display, cfgs[i]); WineGLPixelFormatList[WineGLPixelFormatListSize].fbconfig = cfgs[i];
WineGLPixelFormatList[WineGLPixelFormatListSize].offscreenOnly = TRUE; WineGLPixelFormatList[WineGLPixelFormatListSize].fmt_id = fmt_id;
WineGLPixelFormatListSize++; WineGLPixelFormatList[WineGLPixelFormatListSize].render_type = get_render_type_from_fbconfig(display, cfgs[i]);
} else {
XFree(visinfo); WineGLPixelFormatList[WineGLPixelFormatListSize].offscreenOnly = TRUE;
WineGLPixelFormatListSize++;
}
} }
} }