OpenGL child windows [RFC]

Roderick Colenbrander thunderbird2k at gmx.net
Tue Apr 10 16:50:25 CDT 2007


Hi,

This is an updated version of the child window patch from Chris Robinson. I have added some fixes to it which were found by testing it with lots of programs.

Windowed OpenGL
Several options have been discussed over the years for solving the windowed opengl issues. The lazy option was to use pixmaps but you would lose hardware acceleration. A better way but similar was the use of pbuffers but still they are poorly supported by most drivers (only Nvidia has decent support).

One of the most attractive solutions is the use of glScissors/glViewport changes. This path works now if you apply ulrich his latest patch which is in bugzilla (2398). Though for optimal performance you need specific opengl extensions. Second a number of standard opengl calls requires changes and some aren't done yet (glReadPixels and friends) but right now it is one of the best solutions.

Another way of solving the windowed opengl problem is by using X child windows for the opengl window. In the end this results in the same as ulrich his glScissor work but with the advantage that it should work fast on all opengl implementations as it doesn't require special extensions. Further it doesn't require the patching of opengl calls.

OpenGL pixelformats
Next to the windowed opengl issues, there's the pixelformat limitation in Wine. Right now only one pixelformat can be used. Most programs use ChoosePixelFormat using which you can request a pixelformat but the call isn't guaranteed to give you back what you want. For this reason most programs aren't very critical.

These days more and more programs are more critical. They use wglChoosePixelFormatARB which does give you what you want or programs enumerate all pixelformats using DescribePixelFormat and choose what they want.

Anyway the issue is that the single pixelformat isn't enough anymore. A recent report from WoW on intel drivers is a proof of this http://bugs.winehq.org/show_bug.cgi?id=7866. The game didn't like the single format exported by Wine. Another example is the IKEA kitchen planner tool which uses DescribePixelFormat to enumerate all formats. It expects to find a match in a format. Right now it doesn't find any match and calls SetPixelFormat with iPixelFormat=0 (which is invalid).

Like the above two programs there are many other programs with issues due to pixelformats. I believe that perhaps a few of them are fixable (by adding more hacks or by lieing to programs). If we had more pixelformats, I think the issues could be fixed. OpenGL child windows would fix this issue as the child doesn't have to use the same pixelformat as its parent (!).

Summary
If we would use OpenGL child windows in Wine that would fix most windowed opengl issues and second it would allow us to use more pixelformats as a child window doesn't have to use the same pixelformat as its parent.


Patch
As mentioned before the patch was mainly made by Chris Robinson and I have added a few fixes to it to make it more compatible. Bascially a child window is allocated for a hdc during SetPixelFormat which needs to be called on every hdc before it can be used with opengl. That's basically the biggest change to the opengl code. For the rest some x11drv calls like SetWindowPos had to be patched in order to move the child window when needed.

Below you can find a list of tested programs and the results. As you can see it works correctly for most of the tested programs. Three of the tested programs don't work correctly of which two are not related to the use of child windows, so overall the result is good.

I'd like to know of more programs that work / don't work and I like feedback on the patch.

Properly working programs:
- Blender
- Google Earth
- Google SketchUp
- Lightwave 6 + 9
- MilkShape3D
- Terragen + Terragen2
- VLC opengl plugin
- Valve Hammer tool
- Weatherscope
- Q3Radiant

Unfixed programs:
- Truespace 6.5; The program uses OpenGL for its main window and uses some floating win32 toolbars. The child window obscures them, perhaps the SHAPE extension for X can be of any help here to cut parts away.

Other broken apps not child window related:
- NWN Model viewer; The program seems to do be using WGL in an illegal way but seems to get away with this without any failures on Windows. I don't know what's going on. It also never worked correctly before when there were X windows. It now behaves the same as before. Using ulrich his patch it works but that's basically an 'accident'. It isn't because the code is fixed.
- IKEA kitchen planner; The program uses multiple child windows one for a 3D preview which works fine and it uses one for drawing on a grid. When drawing things on the grid, the objects quickly disappear. There's some buffer swapping issue I guess. The same happens without the child window patch and using ulrich his patch.  So the issue is not related to child windows.

Regards,
Roderick Colenbrander
-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opengl.patch.gz
Type: application/x-gzip
Size: 8081 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20070410/3af0767c/opengl.patch.bin


More information about the wine-devel mailing list