winex11: Initialize the OpenGL format list at startup and simplify the conversion routines.

This commit is contained in:
Alexandre Julliard 2012-08-15 15:32:24 +02:00
parent b8cc4d50ef
commit b908a72635
1 changed files with 68 additions and 118 deletions

View File

@ -136,7 +136,6 @@ typedef struct wine_glpixelformat {
GLXFBConfig fbconfig; GLXFBConfig fbconfig;
int fmt_id; int fmt_id;
int render_type; int render_type;
BOOL offscreenOnly;
DWORD dwFlags; /* We store some PFD_* flags in here for emulated bitmap formats */ DWORD dwFlags; /* We store some PFD_* flags in here for emulated bitmap formats */
} WineGLPixelFormat; } WineGLPixelFormat;
@ -192,6 +191,8 @@ static inline struct glx_physdev *get_glxdrv_dev( PHYSDEV dev )
static struct list context_list = LIST_INIT( context_list ); static struct list context_list = LIST_INIT( context_list );
static struct WineGLInfo WineGLInfo = { 0 }; static struct WineGLInfo WineGLInfo = { 0 };
static WineGLPixelFormat *pixel_formats;
static int nb_pixel_formats, nb_onscreen_formats;
static int use_render_texture_emulation = 1; static int use_render_texture_emulation = 1;
static BOOL has_swap_control; static BOOL has_swap_control;
static int swap_interval = 1; static int swap_interval = 1;
@ -212,7 +213,7 @@ static const char *opengl_func_names[] = { ALL_WGL_FUNCS };
#undef USE_GL_FUNC #undef USE_GL_FUNC
static void X11DRV_WineGL_LoadExtensions(void); static void X11DRV_WineGL_LoadExtensions(void);
static WineGLPixelFormat* ConvertPixelFormatWGLtoGLX(Display *display, int iPixelFormat, BOOL AllowOffscreen, int *fmt_count); static void init_pixel_formats( Display *display );
static BOOL glxRequireVersion(int requiredVersion); static BOOL glxRequireVersion(int requiredVersion);
static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) { static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) {
@ -628,6 +629,7 @@ static BOOL has_opengl(void)
} }
X11DRV_WineGL_LoadExtensions(); X11DRV_WineGL_LoadExtensions();
init_pixel_formats( gdi_display );
return TRUE; return TRUE;
failed: failed:
@ -904,24 +906,19 @@ static BOOL check_fbconfig_bitmap_capability(Display *display, GLXFBConfig fbcon
return !dbuf && (value & GLX_PIXMAP_BIT); return !dbuf && (value & GLX_PIXMAP_BIT);
} }
static WineGLPixelFormat *get_formats(Display *display, int *size_ret, int *onscreen_size_ret) static void init_pixel_formats( Display *display )
{ {
static WineGLPixelFormat *list; WineGLPixelFormat *list;
static int size, onscreen_size; int size = 0, onscreen_size = 0;
int fmt_id, nCfgs, i, run, bmp_formats; int fmt_id, nCfgs, i, run, bmp_formats;
GLXFBConfig* cfgs; GLXFBConfig* cfgs;
XVisualInfo *visinfo; XVisualInfo *visinfo;
wine_tsx11_lock();
if (list) goto done;
cfgs = pglXGetFBConfigs(display, DefaultScreen(display), &nCfgs); cfgs = pglXGetFBConfigs(display, DefaultScreen(display), &nCfgs);
if (NULL == cfgs || 0 == nCfgs) { if (NULL == cfgs || 0 == nCfgs) {
if(cfgs != NULL) XFree(cfgs); if(cfgs != NULL) XFree(cfgs);
wine_tsx11_unlock();
ERR("glXChooseFBConfig returns NULL\n"); ERR("glXChooseFBConfig returns NULL\n");
return NULL; return;
} }
/* Bitmap rendering on Windows implies the use of the Microsoft GDI software renderer. /* Bitmap rendering on Windows implies the use of the Microsoft GDI software renderer.
@ -970,7 +967,6 @@ static WineGLPixelFormat *get_formats(Display *display, int *size_ret, int *onsc
list[size].fbconfig = cfgs[i]; list[size].fbconfig = cfgs[i];
list[size].fmt_id = fmt_id; list[size].fmt_id = fmt_id;
list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]); list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]);
list[size].offscreenOnly = FALSE;
list[size].dwFlags = 0; list[size].dwFlags = 0;
size++; size++;
onscreen_size++; onscreen_size++;
@ -983,7 +979,6 @@ static WineGLPixelFormat *get_formats(Display *display, int *size_ret, int *onsc
list[size].fbconfig = cfgs[i]; list[size].fbconfig = cfgs[i];
list[size].fmt_id = fmt_id; list[size].fmt_id = fmt_id;
list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]); list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]);
list[size].offscreenOnly = FALSE;
list[size].dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_GENERIC_FORMAT; list[size].dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI | PFD_GENERIC_FORMAT;
size++; size++;
onscreen_size++; onscreen_size++;
@ -1009,7 +1004,6 @@ static WineGLPixelFormat *get_formats(Display *display, int *size_ret, int *onsc
list[size].fbconfig = cfgs[i]; list[size].fbconfig = cfgs[i];
list[size].fmt_id = fmt_id; list[size].fmt_id = fmt_id;
list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]); list[size].render_type = get_render_type_from_fbconfig(display, cfgs[i]);
list[size].offscreenOnly = TRUE;
list[size].dwFlags = 0; list[size].dwFlags = 0;
size++; size++;
} }
@ -1020,74 +1014,49 @@ static WineGLPixelFormat *get_formats(Display *display, int *size_ret, int *onsc
XFree(cfgs); XFree(cfgs);
done: pixel_formats = list;
if (size_ret) *size_ret = size; nb_pixel_formats = size;
if (onscreen_size_ret) *onscreen_size_ret = onscreen_size; nb_onscreen_formats = onscreen_size;
wine_tsx11_unlock(); }
return list;
static inline BOOL is_valid_pixel_format( int format )
{
return format > 0 && format <= nb_pixel_formats;
}
static inline BOOL is_onscreen_pixel_format( int format )
{
return format > 0 && format <= nb_onscreen_formats;
} }
/* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones. /* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones.
* In our WGL implementation we only support a subset of these formats namely the format of * In our WGL implementation we only support a subset of these formats namely the format of
* Wine's main visual and offscreen formats (if they are available). * Wine's main visual and offscreen formats (if they are available).
* This function converts a WGL format to its corresponding GLX one. It returns a WineGLPixelFormat * This function converts a WGL format to its corresponding GLX one.
* and it returns the number of supported WGL formats in fmt_count.
*/ */
static WineGLPixelFormat* ConvertPixelFormatWGLtoGLX(Display *display, int iPixelFormat, BOOL AllowOffscreen, int *fmt_count) static WineGLPixelFormat* ConvertPixelFormatWGLtoGLX(Display *display, int iPixelFormat, BOOL AllowOffscreen)
{ {
WineGLPixelFormat *list, *res = NULL;
int size, onscreen_size;
if (!(list = get_formats(display, &size, &onscreen_size ))) return NULL;
/* Check if the pixelformat is valid. Note that it is legal to pass an invalid /* Check if the pixelformat is valid. Note that it is legal to pass an invalid
* iPixelFormat in case of probing the number of pixelformats. * iPixelFormat in case of probing the number of pixelformats.
*/ */
if((iPixelFormat > 0) && (iPixelFormat <= size) && if (is_valid_pixel_format( iPixelFormat ) &&
(!list[iPixelFormat-1].offscreenOnly || AllowOffscreen)) { (is_onscreen_pixel_format( iPixelFormat ) || AllowOffscreen)) {
res = &list[iPixelFormat-1]; TRACE("Returning fmt_id=%#x for iPixelFormat=%d\n",
TRACE("Returning fmt_id=%#x for iPixelFormat=%d\n", res->fmt_id, iPixelFormat); pixel_formats[iPixelFormat-1].fmt_id, iPixelFormat);
return &pixel_formats[iPixelFormat-1];
} }
if(AllowOffscreen)
*fmt_count = size;
else
*fmt_count = onscreen_size;
TRACE("Number of returned pixelformats=%d\n", *fmt_count);
return res;
}
/* Search our internal pixelformat list for the WGL format corresponding to the given fbconfig */
static WineGLPixelFormat* ConvertPixelFormatGLXtoWGL(Display *display, int fmt_id, DWORD dwFlags)
{
WineGLPixelFormat *list;
int i, size;
if (!(list = get_formats(display, &size, NULL ))) return NULL;
for(i=0; i<size; i++) {
/* A GLX format can appear multiple times in the pixel format list due to fake formats for bitmap rendering.
* Fake formats might get selected when the user passes the proper flags using the dwFlags parameter. */
if( (list[i].fmt_id == fmt_id) && ((list[i].dwFlags & dwFlags) == dwFlags) ) {
TRACE("Returning iPixelFormat %d for fmt_id 0x%x\n", list[i].iPixelFormat, fmt_id);
return &list[i];
}
}
TRACE("No compatible format found for fmt_id 0x%x\n", fmt_id);
return NULL; return NULL;
} }
static int pixelformat_from_fbconfig_id(XID fbconfig_id) static int pixelformat_from_fbconfig_id(XID fbconfig_id)
{ {
WineGLPixelFormat *fmt; int i;
if (!fbconfig_id) return 0; if (!fbconfig_id) return 0;
fmt = ConvertPixelFormatGLXtoWGL(gdi_display, fbconfig_id, 0 /* no flags */); for (i = 0; i < nb_pixel_formats; i++)
if(fmt) if (pixel_formats[i].fmt_id == fbconfig_id) return i + 1;
return fmt->iPixelFormat;
/* This will happen on hwnds without a pixel format set; it's ok */ /* This will happen on hwnds without a pixel format set; it's ok */
return 0; return 0;
} }
@ -1170,20 +1139,17 @@ static int glxdrv_wglDescribePixelFormat( HDC hdc, int iPixelFormat,
int value; int value;
int rb,gb,bb,ab; int rb,gb,bb,ab;
WineGLPixelFormat *fmt; WineGLPixelFormat *fmt;
int ret = 0;
int fmt_count = 0;
if (!has_opengl()) return 0; if (!has_opengl()) return 0;
TRACE("(%p,%d,%d,%p)\n", hdc, iPixelFormat, nBytes, ppfd); TRACE("(%p,%d,%d,%p)\n", hdc, iPixelFormat, nBytes, ppfd);
if (!ppfd) return nb_onscreen_formats;
/* Look for the iPixelFormat in our list of supported formats. If it is supported we get the index in the FBConfig table and the number of supported formats back */ /* Look for the iPixelFormat in our list of supported formats. If it is supported we get the index in the FBConfig table and the number of supported formats back */
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &fmt_count); fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */);
if (ppfd == NULL) { if (!fmt) {
/* The application is only querying the number of pixelformats */ WARN("unexpected format %d\n", iPixelFormat);
return fmt_count;
} else if(fmt == NULL) {
WARN("unexpected iPixelFormat(%d): not >=1 and <=nFormats(%d), returning NULL!\n", iPixelFormat, fmt_count);
return 0; return 0;
} }
@ -1193,8 +1159,6 @@ static int glxdrv_wglDescribePixelFormat( HDC hdc, int iPixelFormat,
return 0; return 0;
} }
ret = fmt_count;
memset(ppfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); memset(ppfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR); ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
ppfd->nVersion = 1; ppfd->nVersion = 1;
@ -1294,7 +1258,7 @@ static int glxdrv_wglDescribePixelFormat( HDC hdc, int iPixelFormat,
dump_PIXELFORMATDESCRIPTOR(ppfd); dump_PIXELFORMATDESCRIPTOR(ppfd);
} }
return ret; return nb_onscreen_formats;
} }
/*********************************************************************** /***********************************************************************
@ -1303,8 +1267,6 @@ static int glxdrv_wglDescribePixelFormat( HDC hdc, int iPixelFormat,
static int glxdrv_wglGetPixelFormat( HDC hdc ) static int glxdrv_wglGetPixelFormat( HDC hdc )
{ {
struct x11drv_escape_get_drawable escape; struct x11drv_escape_get_drawable escape;
WineGLPixelFormat *fmt;
int tmp;
TRACE( "(%p)\n", hdc ); TRACE( "(%p)\n", hdc );
@ -1313,19 +1275,13 @@ static int glxdrv_wglGetPixelFormat( HDC hdc )
sizeof(escape), (LPSTR)&escape )) sizeof(escape), (LPSTR)&escape ))
return 0; return 0;
if (!escape.pixel_format) return 0; /* not set yet */ if (!is_valid_pixel_format( escape.pixel_format )) return 0; /* not set yet */
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, escape.pixel_format, TRUE, &tmp); if (!is_onscreen_pixel_format( escape.pixel_format ))
if (!fmt)
{
ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", escape.pixel_format);
return 0;
}
if (fmt->offscreenOnly)
{ {
/* Offscreen formats can't be used with traditional WGL calls. /* Offscreen formats can't be used with traditional WGL calls.
* As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */ * As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */
TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", fmt->iPixelFormat); TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", escape.pixel_format);
return 1; return 1;
} }
TRACE("(%p): returns %d\n", hdc, escape.pixel_format); TRACE("(%p): returns %d\n", hdc, escape.pixel_format);
@ -1360,7 +1316,7 @@ static BOOL glxdrv_wglSetPixelFormat( HDC hdc, int iPixelFormat, const PIXELFORM
} }
/* Check if iPixelFormat is in our list of supported formats to see if it is supported. */ /* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &value); fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */);
if(!fmt) { if(!fmt) {
ERR("Invalid iPixelFormat: %d\n", iPixelFormat); ERR("Invalid iPixelFormat: %d\n", iPixelFormat);
return FALSE; return FALSE;
@ -1422,7 +1378,6 @@ static struct wgl_context *glxdrv_wglCreateContext( HDC hdc )
struct x11drv_escape_get_drawable escape; struct x11drv_escape_get_drawable escape;
struct wgl_context *ret; struct wgl_context *ret;
WineGLPixelFormat *fmt; WineGLPixelFormat *fmt;
int fmt_count = 0;
TRACE( "(%p)\n", hdc ); TRACE( "(%p)\n", hdc );
@ -1431,7 +1386,7 @@ static struct wgl_context *glxdrv_wglCreateContext( HDC hdc )
sizeof(escape), (LPSTR)&escape )) sizeof(escape), (LPSTR)&escape ))
return 0; return 0;
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, escape.pixel_format, TRUE /* Offscreen */, &fmt_count); fmt = ConvertPixelFormatWGLtoGLX(gdi_display, escape.pixel_format, TRUE /* Offscreen */);
/* We can render using the iPixelFormat (1) of Wine's Main visual AND using some offscreen formats. /* We can render using the iPixelFormat (1) of Wine's Main visual AND using some offscreen formats.
* Note that standard WGL-calls don't recognize offscreen-only formats. For that reason pbuffers * Note that standard WGL-calls don't recognize offscreen-only formats. For that reason pbuffers
* use a sort of 'proxy' HDC (wglGetPbufferDCARB). * use a sort of 'proxy' HDC (wglGetPbufferDCARB).
@ -1712,7 +1667,6 @@ static struct wgl_context *X11DRV_wglCreateContextAttribsARB( HDC hdc, struct wg
struct x11drv_escape_get_drawable escape; struct x11drv_escape_get_drawable escape;
struct wgl_context *ret; struct wgl_context *ret;
WineGLPixelFormat *fmt; WineGLPixelFormat *fmt;
int fmt_count = 0;
TRACE("(%p %p %p)\n", hdc, hShareContext, attribList); TRACE("(%p %p %p)\n", hdc, hShareContext, attribList);
@ -1721,7 +1675,7 @@ static struct wgl_context *X11DRV_wglCreateContextAttribsARB( HDC hdc, struct wg
sizeof(escape), (LPSTR)&escape )) sizeof(escape), (LPSTR)&escape ))
return 0; return 0;
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, escape.pixel_format, TRUE /* Offscreen */, &fmt_count); fmt = ConvertPixelFormatWGLtoGLX(gdi_display, escape.pixel_format, TRUE /* Offscreen */);
/* wglCreateContextAttribsARB supports ALL pixel formats, so also offscreen ones. /* wglCreateContextAttribsARB supports ALL pixel formats, so also offscreen ones.
* If this fails something is very wrong on the system. */ * If this fails something is very wrong on the system. */
if(!fmt) if(!fmt)
@ -1818,14 +1772,13 @@ static struct wgl_pbuffer *X11DRV_wglCreatePbufferARB( HDC hdc, int iPixelFormat
{ {
struct wgl_pbuffer* object = NULL; struct wgl_pbuffer* object = NULL;
WineGLPixelFormat *fmt = NULL; WineGLPixelFormat *fmt = NULL;
int nCfgs = 0;
int attribs[256]; int attribs[256];
int nAttribs = 0; int nAttribs = 0;
TRACE("(%p, %d, %d, %d, %p)\n", hdc, iPixelFormat, iWidth, iHeight, piAttribList); TRACE("(%p, %d, %d, %d, %p)\n", hdc, iPixelFormat, iWidth, iHeight, piAttribList);
/* Convert the WGL pixelformat to a GLX format, if it fails then the format is invalid */ /* Convert the WGL pixelformat to a GLX format, if it fails then the format is invalid */
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, TRUE /* Offscreen */, &nCfgs); fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, TRUE /* Offscreen */);
if(!fmt) { if(!fmt) {
ERR("(%p): invalid pixel format %d\n", hdc, iPixelFormat); ERR("(%p): invalid pixel format %d\n", hdc, iPixelFormat);
SetLastError(ERROR_INVALID_PIXEL_FORMAT); SetLastError(ERROR_INVALID_PIXEL_FORMAT);
@ -2162,14 +2115,13 @@ static BOOL X11DRV_wglSetPbufferAttribARB( struct wgl_pbuffer *object, const int
static BOOL X11DRV_wglChoosePixelFormatARB( HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, static BOOL X11DRV_wglChoosePixelFormatARB( HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList,
UINT nMaxFormats, int *piFormats, UINT *nNumFormats ) UINT nMaxFormats, int *piFormats, UINT *nNumFormats )
{ {
int gl_test = 0;
int attribs[256]; int attribs[256];
int nAttribs = 0; int nAttribs = 0;
GLXFBConfig* cfgs = NULL; GLXFBConfig* cfgs = NULL;
int nCfgs = 0; int nCfgs = 0;
int it; int it;
int fmt_id; int fmt_id;
WineGLPixelFormat *fmt; int start, end;
UINT pfmt_it = 0; UINT pfmt_it = 0;
int run; int run;
int i; int i;
@ -2232,24 +2184,26 @@ static BOOL X11DRV_wglChoosePixelFormatARB( HDC hdc, const int *piAttribIList, c
{ {
for (it = 0; it < nCfgs && pfmt_it < nMaxFormats; ++it) for (it = 0; it < nCfgs && pfmt_it < nMaxFormats; ++it)
{ {
gl_test = pglXGetFBConfigAttrib(gdi_display, cfgs[it], GLX_FBCONFIG_ID, &fmt_id); if (pglXGetFBConfigAttrib(gdi_display, cfgs[it], GLX_FBCONFIG_ID, &fmt_id))
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");
continue; continue;
} }
/* Search for the format in our list of compatible formats */ /* During the first run we only want onscreen formats and during the second only offscreen */
fmt = ConvertPixelFormatGLXtoWGL(gdi_display, fmt_id, dwFlags); start = run == 1 ? nb_onscreen_formats : 0;
if(!fmt) end = run == 1 ? nb_pixel_formats : nb_onscreen_formats;
continue;
/* During the first run we only want onscreen formats and during the second only offscreen 'XOR' */ for (i = start; i < end; i++)
if( ((run == 0) && fmt->offscreenOnly) || ((run == 1) && !fmt->offscreenOnly) ) {
continue; if (pixel_formats[i].fmt_id == fmt_id && (pixel_formats[i].dwFlags & dwFlags) == dwFlags)
{
piFormats[pfmt_it] = fmt->iPixelFormat; piFormats[pfmt_it++] = i + 1;
TRACE("at %d/%d found FBCONFIG_ID 0x%x (%d)\n", it + 1, nCfgs, fmt_id, piFormats[pfmt_it]); TRACE("at %d/%d found FBCONFIG_ID 0x%x (%d)\n",
pfmt_it++; it + 1, nCfgs, fmt_id, piFormats[pfmt_it]);
break;
}
}
} }
} }
@ -2272,7 +2226,6 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int
int hTest; int hTest;
int tmp; int tmp;
int curGLXAttr = 0; int curGLXAttr = 0;
int nWGLFormats = 0;
TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues); TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues);
@ -2284,7 +2237,7 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int
/* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supported. /* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supported.
* We don't have to fail yet as a program can specify an invalid iPixelFormat (lets say 0) if it wants to query * We don't have to fail yet as a program can specify an invalid iPixelFormat (lets say 0) if it wants to query
* the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */ * the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, TRUE /* Offscreen */, &nWGLFormats); fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, TRUE /* Offscreen */);
if(!fmt) { if(!fmt) {
WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat); WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat);
} }
@ -2295,7 +2248,7 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int
switch (curWGLAttr) { switch (curWGLAttr) {
case WGL_NUMBER_PIXEL_FORMATS_ARB: case WGL_NUMBER_PIXEL_FORMATS_ARB:
piValues[i] = nWGLFormats; piValues[i] = nb_pixel_formats;
continue; continue;
case WGL_SUPPORT_OPENGL_ARB: case WGL_SUPPORT_OPENGL_ARB:
@ -2501,7 +2454,7 @@ get_error:
return GL_FALSE; return GL_FALSE;
pix_error: pix_error:
ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc, iPixelFormat, nWGLFormats); ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc, iPixelFormat, nb_pixel_formats);
return GL_FALSE; return GL_FALSE;
} }
@ -2696,7 +2649,7 @@ static BOOL X11DRV_wglSetPixelFormatWINE(HDC hdc, int format)
TRACE("(%p,%d)\n", hdc, format); TRACE("(%p,%d)\n", hdc, format);
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, format, FALSE /* Offscreen */, &value); fmt = ConvertPixelFormatWGLtoGLX(gdi_display, format, FALSE /* Offscreen */);
if (!fmt) if (!fmt)
{ {
ERR( "Invalid format %d\n", format ); ERR( "Invalid format %d\n", format );
@ -2934,13 +2887,10 @@ static BOOL glxdrv_SwapBuffers(PHYSDEV dev)
XVisualInfo *visual_from_fbconfig_id( XID fbconfig_id ) XVisualInfo *visual_from_fbconfig_id( XID fbconfig_id )
{ {
WineGLPixelFormat *fmt; int format = pixelformat_from_fbconfig_id( fbconfig_id );
fmt = ConvertPixelFormatGLXtoWGL(gdi_display, fbconfig_id, 0 /* no flags */); if (!format) return NULL;
if(fmt == NULL) return pglXGetVisualFromFBConfig(gdi_display, pixel_formats[format - 1].fbconfig);
return NULL;
return pglXGetVisualFromFBConfig(gdi_display, fmt->fbconfig);
} }
static BOOL create_glx_dc( PHYSDEV *pdev ) static BOOL create_glx_dc( PHYSDEV *pdev )