[Qt-interest] FBO & OpenGL drawing in a QGraphicsItem

Chris Meyer cmeyer1969+qt at gmail.com
Thu Dec 30 05:12:42 CET 2010


Hi John,

>From the look of the scroll bars on the screen shots, it looks like
you're using a Mac. Are you using Qt-Carbon or Qt-Cocoa?

We've had similar "garbage" problems on the Carbon version that seemed
to go away on the Cocoa version.

-Chris

On Mon, Dec 27, 2010 at 12:55 AM, John Clayton <john_clayton at me.com> wrote:
> 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
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list