[Qt-interest] FBO & OpenGL drawing in a QGraphicsItem
John Clayton
john_clayton at me.com
Mon Dec 27 09:55:55 CET 2010
Hi
I'm trying to create a qgraphicsitem that can draw the reflection of any other qgraphicsitem. All my graphics items draw using OpenGL - so I'm assuming that there is always a GL context active.
My approach is this:
a) have my reflection graphics item contain a pointer to another graphics item - the reflection uses this other graphics item as its 'source' content
b) in the paint() method for the reflection, I will
0. create an FBO the size of the source bounding rect
1. request that the 'source' graphics item paint into the FBO
2. use Composition_DestinationIn to write a linear gradient over the FBO content
3. take the FBO texture and draw this into the reflection graphics item
My problem is that at stage 2, I don't see the linear gradient being drawn into the FBO. And at stage 3, I see the gradient, but the FBO texture *appears* to be corrupted.
Here's the relevant code:
http://pastebin.com/bTRTW29W
and here's a picture showing the 4 stages of rendering. Each picture relates to one saveFBO() call in the code. Its obvious to see that the 2/3 pictures are wrong. picture 2 should have a linear gradient imposed over it. Picture 3 *should* in my opinion be the same as 2.
http://idisk.me.com/john_clayton/Public/Pictures/Skitch/rubbish-20101227-094335.jpg
I believe that its something to do with the OpenGL state so far, as commenting out the FBO painters save/restore calls changes the appearance of the pictures.
Any help is hugely appreciated. Thank you.
--
John
More information about the Qt-interest-old
mailing list