composition mode with GLGraphicsItem¶

117 views
Skip to first unread message

M

unread,
Apr 7, 2013, 6:46:00 AM4/7/13
to pyqt...@googlegroups.com
Hi Luke,

I really appreciate the work you have been doing with pyqtgraph.I am prototyping my application right now, and it only takes a few lines of code to try things.  

I have a question regarding composition mode with GLGraphicsItem. I have multiple images loaded with GLImageItem and have set the transparancy in the alpha channel of these images. Still I am not seeing the images with transparancy. I have noticed you have a setCompositionMode for ImageItem. Does this work in a similar way for the GLGraphicsItem? Where and how do I set the blending effect in my view widget?

Thanks!

Gr. M

Luke Campagnola

unread,
Apr 7, 2013, 9:23:38 AM4/7/13
to pyqt...@googlegroups.com
Hello,

Transparency is a tricky subject in OpenGL. The features you want exist, but the API is a little different than for QGraphicsView and it takes some attention to detail to get it right. (see, for example, http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-10-transparency/#Order_Independent_Transparency)

The most important things are 1) the glBlendFunc must be set up appropriately (this is roughly equivalent to setCompositionMode) and 2) transparent items must be drawn after anything else they are to be blended with (usually opaque items). (see http://www.pyqtgraph.org/documentation/3dgraphics/glgraphicsitem.html#pyqtgraph.opengl.GLGraphicsItem.GLGraphicsItem.setDepthValue) The major exception to this rule is when glBlendFunc produces results that are the same regardless of the order of rendering. 

If you just want standard alpha-blending, GLImageItem should work as-is. For other types of compositing, most GLGraphicsItems make use of the setGLOptions method (http://www.pyqtgraph.org/documentation/3dgraphics/glgraphicsitem.html#pyqtgraph.opengl.GLGraphicsItem.GLGraphicsItem.setGLOptions) for controlling things like glBlendFunc.  However, I see now that I never implemented setGLOptions for GLImageItem. This will be fixed in the next release, or you can get the fixed code from here: http://bazaar.launchpad.net/~luke-campagnola/pyqtgraph/inp/view/head:/pyqtgraph/opengl/items/GLImageItem.py  (but please don't pull the entire repository; it has a few critical bugs in it at the moment).

Luke

M

unread,
Apr 9, 2013, 10:28:43 AM4/9/13
to pyqt...@googlegroups.com
Hi Luke,

Thanks for this. I got it to work.

Best

Reply all
Reply to author
Forward
0 new messages