diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index e743c585402..149b11d1bc5 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -124,6 +124,12 @@ struct WineGLInfo { char wglExtensions[4096]; }; +typedef struct wine_glpixelformat { + int iPixelFormat; + int fbconfig; + int fmt_index; +} WineGLPixelFormat; + static Wine_GLContext *context_list; static struct WineGLInfo WineGLInfo = { 0 }; static int use_render_texture_emulation = 0; @@ -134,6 +140,10 @@ static int swap_interval = 1; static const WineGLExtension *WineGLExtensionList[MAX_EXTENSIONS]; static int WineGLExtensionListSize; +#define MAX_GLPIXELFORMATS 32 +static WineGLPixelFormat WineGLPixelFormatList[MAX_GLPIXELFORMATS]; +static int WineGLPixelFormatListSize = 0; + static void X11DRV_WineGL_LoadExtensions(void); static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) { @@ -785,6 +795,69 @@ static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, Wine_GLPBuf return nAttribs; } +BOOL get_fbconfig_from_visualid(Display *display, Visual *visual, int *fmt_id, int *fmt_index) +{ + GLXFBConfig* cfgs = NULL; + int i; + int nCfgs; + int tmp_fmt_id; + int tmp_vis_id; + VisualID visualid; + + if(!display || !display) { + ERR("Invalid display or visual\n"); + } + visualid = XVisualIDFromVisual(visual); + + /* Get a list of all available framebuffer configurations */ + cfgs = pglXGetFBConfigs(display, DefaultScreen(display), &nCfgs); + if (NULL == cfgs || 0 == nCfgs) { + ERR("glXChooseFBConfig returns NULL\n"); + if(cfgs != NULL) XFree(cfgs); + return 0; + } + + /* Find the requested offscreen format and count the number of offscreen formats */ + for(i=0; i WineGLPixelFormatListSize)) { + ERR("invalid iPixelFormat %d\n", iPixelFormat); + return FALSE; } - /* We found an offscreen rendering format :) */ - else if(tmp_vis_id == 0) { - nFormats++; - TRACE("Checking offscreen format FBCONFIG_ID 0x%x at index %d\n", tmp_fmt_id, i); - if(iPixelFormat == nFormats) { - *fmt_index = i; - TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", tmp_fmt_id, iPixelFormat, i); - res = TRUE; - } + *fmt_index = WineGLPixelFormatList[iPixelFormat-1].fmt_index; + *fmt_count = WineGLPixelFormatListSize; + TRACE("Returning fmt_index=%d, fmt_count=%d for iPixelFormat=%d\n", *fmt_index, *fmt_count, iPixelFormat); + + return TRUE; +} + +/* Search our internal pixelformat list for the WGL format corresponding to the given fbconfig */ +static int ConvertPixelFormatGLXtoWGL(Display *display, int fbconfig) +{ + int i; + + /* Init the list of pixel formats when we need it */ + if(!WineGLPixelFormatListSize) + init_formats(display, DefaultScreen(display), visual); + + for(i=0; i