Tomas Carnecky wrote: > comments? > Why do I have the impression that when it comes to x11drv/opengl nobody wants to take the responsibility. I won't submit a patch until someone says 'tom, your approach looks good, improve this and then submit a patch to wine-patches' or 'tom, no, this won't work because ... try to change this ... move the code there ... don't do that, it will break this' etc. I don't want to know whether the implementation details are ok, I just want to know whether the general idea (the flags field) is acceptable.
I did the changes I've described and it does work, but I won't work on it any further (eg. make it independent of my previous patches) unless I get a green light. In the attachment is the latest patch I've applied to my local tree, you see that it requires the X11DRV_[S|G]ET_FLAGS escape code which I've added in one of my previous patches. Maybe that gives you an better idea of what I'm trying to do. tom
117000e2604e102f41632dcbe3a5e454f9d218b9 diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index ac0f401..7490015 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -173,6 +173,16 @@ inline static Font get_font( HDC hdc ) return font; } +inline static BOOL is_pbuffer( HDC hdc ) +{ + long flags; + enum x11drv_escape_codes escape = X11DRV_GET_FLAGS; + + if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, + sizeof(flags), (LPSTR)&flags )) return False; + return ((flags & X11DRV_FLAG_PBUFFER) == X11DRV_FLAG_PBUFFER); +} + /*********************************************************************** * wglCreateContext (OPENGL32.@) @@ -571,8 +581,9 @@ BOOL WINAPI wglMakeCurrent(HDC hdc, TRACE(" make current for dis %p, drawable %p, ctx %p\n", ctx->display, (void*) drawable, ctx->ctx); ret = glXMakeCurrent(ctx->display, drawable, ctx->ctx); NtCurrentTeb()->glContext = ctx; - if(ret && type == OBJ_MEMDC) { + if(ret && type == OBJ_MEMDC && !is_pbuffer(hdc)) { ctx->do_escape = TRUE; + glDrawBuffer(GL_FRONT); } } LEAVE_GL(); diff --git a/dlls/opengl32/wgl_ext.c b/dlls/opengl32/wgl_ext.c index 6c708f9..2304ccb 100644 --- a/dlls/opengl32/wgl_ext.c +++ b/dlls/opengl32/wgl_ext.c @@ -75,6 +75,22 @@ inline static BOOL is_damaged( HDC hdc ) return ((flags & X11DRV_FLAG_DAMAGED) == X11DRV_FLAG_DAMAGED); } +inline static BOOL set_pbuffer_flag( HDC hdc ) +{ + long flags; + enum x11drv_escape_codes escape = X11DRV_GET_FLAGS; + + if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, + sizeof(flags), (LPSTR)&flags )) return False; + + escape = X11DRV_SET_FLAGS; + flags |= X11DRV_FLAG_PBUFFER; + if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, + sizeof(flags), (LPSTR)&flags )) return False; + + return True; +} + /* Some WGL extensions... */ static const char *WGL_extensions_base = "WGL_ARB_extensions_string WGL_EXT_extensions_string"; static char *WGL_extensions = NULL; @@ -1088,6 +1104,7 @@ HDC WINAPI wglGetPbufferDCARB(HPBUFFERAR hDC = CreateCompatibleDC(object->hdc); SetPixelFormat(hDC, object->pixelFormat, NULL); set_drawable(hDC, object->drawable); /* works ?? */ + set_pbuffer_flag(hDC); TRACE("(%p)->(%p)\n", hPbuffer, hDC); return hDC; } diff --git a/include/wine/x11drv_escape.h b/include/wine/x11drv_escape.h index af69ce0..ed7940d 100644 --- a/include/wine/x11drv_escape.h +++ b/include/wine/x11drv_escape.h @@ -22,6 +22,7 @@ #ifndef __WINE_X11DRV_ESCAPE_H #define __WINE_X11DRV_ESCAPE_H #define X11DRV_FLAG_DAMAGED ( 1 << 0 ) +#define X11DRV_FLAG_PBUFFER ( 1 << 1 ) #define X11DRV_ESCAPE 6789 enum x11drv_escape_codes