thunderbird2k at gmx.net
Tue Oct 24 17:07:44 CDT 2006
This patch reimplements opengl32's wglGetProcAddress. The endresult is a more reliable function which doesn't directly call X functions.
The OpenGL function wglGetProcAddress can be used to retrieve function pointers to OpenGL functions implemented by opengl32.dll. This can be core GL/WGL 1.2 functions which are exported to the outside but this can also be GL/WGL extensions which aren't visible from the outside.
In case of core functions GetProcAddress was called on opengl32.dll itself. In case of GL extensions we maintain a table containing all known OpenGL extensions. The table contains the function name, a function pointer to the native GL extension and a function pointer to a OpenGL thunk for handling calling convention differences.
During wglGetProcAddress we searched this table for a thunk and stored the function pointer to the native GL function inside it.
This native function pointer was retrieved using glXGetProcAddress. A note which we need to make is that glXGetProcAddress is a very unreliable function in the sense that it doesn't have to return NULL when a function isn't found whereas wglGetProcAddress returns NULL when a function wasn't found. We never did any checks to verify if the call was available. In theory this isn't needed as apps should check whether an extension is available before calling wglGetProcAddress.
This patch changes the whole behavior of wglGetProcAddress and tries to make it more reliable aswell. First of all I have extended the thunks table with function pointers for wgl extensions. These entries aren't really needed as similar stuff is inside winex11.drv but it simplifies the code and the table contains the name of the GL extension the function belongs to aswell. In case a function isn't found we can report which WGL extension isn't supported yet. I'll come back to this later as this is part of the reliability improvements.
Again first we check if a function is a 'core' 1.2 function using GetProcAddress. When this isn't the case we are dealing with a GL/WGL extension. In that case we search the extension table for the function and then check whether the extension (GL_ARB_foobar ..) required by the function is available. If it is we continue and let the newly added 'wine_wglGetProcAddress' retrieve the WGL/GL function pointers or else we fail. This extension check is what improves the reliability of 'glXGetProcAddress'.
You'll also notice another small change associated with this patch. The function wglGetIntegerv is an internal 'wine extension'-like function it is now accessed using wine_wglGetProcAddress instead of directly loading it from winex11.drv. Now the only things which we load from winex11.drv are the wine_tsx11_lock/unlock functions.
I have tested this patch using a number of OpenGL demos and some games. It appeared to work correctly.
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 30351 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20061025/5dbf04ec/wgl_getprocaddress.patch-0001.bin
More information about the wine-patches