Add the ability to check if the pixel format was changed by wined3d, and if it was, allow the application to change it with a regular SetPixelFormat call.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- I have no clue why certain lines I didn't edit are in this patch. Not sure if it was something I did, but I couldn't see a difference between them. --- dlls/winex11.drv/opengl.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index c44c587bf14..e2643a9f37d 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -249,6 +249,7 @@ struct gl_drawable SIZE pixmap_size; /* pixmap size for GLXPixmap drawables */ int swap_interval; BOOL refresh_swap_interval; + BOOL mutable_pf; };
enum glx_swap_control_method @@ -532,7 +533,7 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) done: if(vis) XFree(vis); if(ctx) { - pglXMakeCurrent(gdi_display, None, NULL); + pglXMakeCurrent(gdi_display, None, NULL); pglXDestroyContext(gdi_display, ctx); } if (win != root) XDestroyWindow( gdi_display, win ); @@ -751,7 +752,7 @@ static const char *debugstr_fbconfig( GLXFBConfig fbconfig )
static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, struct wgl_pbuffer* pbuf) { int nAttribs = 0; - unsigned cur = 0; + unsigned cur = 0; int attr, pop; int drawattrib = 0; int nvfloatattrib = GLX_DONT_CARE; @@ -815,7 +816,7 @@ static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, struct wgl_ case WGL_TYPE_RGBA_FLOAT_ATI: pixelattrib = GLX_RGBA_FLOAT_BIT; break ; case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT: pixelattrib = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT; break ; default: - ERR("unexpected PixelType(%x)\n", pop); + ERR("unexpected PixelType(%x)\n", pop); } break;
@@ -924,7 +925,7 @@ static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, struct wgl_ case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV: case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV: case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV: - /** cannot be converted, see direct handling on + /** cannot be converted, see direct handling on * - wglGetPixelFormatAttribivARB * TODO: wglChoosePixelFormat */ @@ -1306,7 +1307,8 @@ static GLXContext create_glxcontext(Display *display, struct wgl_context *contex /*********************************************************************** * create_gl_drawable */ -static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel_format *format, BOOL known_child ) +static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel_format *format, BOOL known_child, + BOOL mutable_pf ) { struct gl_drawable *gl, *prev; XVisualInfo *visual = format->visual; @@ -1326,6 +1328,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel gl->refresh_swap_interval = TRUE; gl->format = format; gl->ref = 1; + gl->mutable_pf = mutable_pf;
if (!known_child && !GetWindow( hwnd, GW_CHILD ) && GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow()) /* childless top-level window */ { @@ -1384,13 +1387,13 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel /*********************************************************************** * set_win_format */ -static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format ) +static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format, BOOL mutable_pf ) { struct gl_drawable *gl;
if (!format->visual) return FALSE;
- if (!(gl = create_gl_drawable( hwnd, format, FALSE ))) return FALSE; + if (!(gl = create_gl_drawable( hwnd, format, FALSE, mutable_pf ))) return FALSE;
TRACE( "created GL drawable %lx for win %p %s\n", gl->drawable, hwnd, debugstr_fbconfig( format->fbconfig )); @@ -1437,12 +1440,14 @@ static BOOL set_pixel_format(HDC hdc, int format, BOOL allow_change) if ((gl = get_gl_drawable( hwnd, hdc ))) { int prev = pixel_format_index( gl->format ); + BOOL mutable_pf = gl->mutable_pf; release_gl_drawable( gl ); - return prev == format; /* cannot change it if already set */ + if (!mutable_pf) + return prev == format; /* cannot change it if already set */ } }
- return set_win_format( hwnd, fmt ); + return set_win_format( hwnd, fmt, allow_change ); }
@@ -1461,7 +1466,7 @@ void sync_gl_drawable( HWND hwnd, BOOL known_child ) if (!known_child) break; /* Still a childless top-level window */ /* fall through */ case DC_GL_PIXMAP_WIN: - if (!(new = create_gl_drawable( hwnd, old->format, known_child ))) break; + if (!(new = create_gl_drawable( hwnd, old->format, known_child, FALSE ))) break; mark_drawable_dirty( old, new ); XFlush( gdi_display ); TRACE( "Recreated GL drawable %lx to replace %lx\n", new->drawable, old->drawable ); @@ -1498,7 +1503,7 @@ void set_gl_drawable_parent( HWND hwnd, HWND parent ) return; }
- if ((new = create_gl_drawable( hwnd, old->format, FALSE ))) + if ((new = create_gl_drawable( hwnd, old->format, FALSE, FALSE ))) { mark_drawable_dirty( old, new ); release_gl_drawable( new ); @@ -2140,7 +2145,7 @@ static struct wgl_pbuffer *X11DRV_wglCreatePbufferARB( HDC hdc, int iPixelFormat object->fmt = fmt;
PUSH2(attribs, GLX_PBUFFER_WIDTH, iWidth); - PUSH2(attribs, GLX_PBUFFER_HEIGHT, iHeight); + PUSH2(attribs, GLX_PBUFFER_HEIGHT, iHeight); while (piAttribList && 0 != *piAttribList) { int attr_v; switch (*piAttribList) { @@ -2686,7 +2691,7 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int continue;
case WGL_SUPPORT_OPENGL_ARB: - piValues[i] = GL_TRUE; + piValues[i] = GL_TRUE; continue;
case WGL_ACCELERATION_ARB: @@ -2734,14 +2739,14 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int case WGL_BIND_TO_TEXTURE_RGBA_ARB: if (!use_render_texture_emulation) { piValues[i] = GL_FALSE; - continue; + continue; } curGLXAttr = GLX_RENDER_TYPE; if (!fmt) goto pix_error; hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, &tmp); if (hTest) goto get_error; if (GLX_COLOR_INDEX_BIT == tmp) { - piValues[i] = GL_FALSE; + piValues[i] = GL_FALSE; continue; } hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &tmp); @@ -2896,8 +2901,8 @@ static BOOL X11DRV_wglGetPixelFormatAttribivARB( HDC hdc, int iPixelFormat, int hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, piValues + i); if (hTest) goto get_error; curGLXAttr = 0; - } else { - piValues[i] = GL_FALSE; + } else { + piValues[i] = GL_FALSE; } } return GL_TRUE;