[cairo] Cairo + OpenGL + GTK

Michael Dominic K. mdk at mdk.am
Tue Sep 4 01:19:56 PDT 2007

On 8/27/07, Larry Lewis <lewislp at yahoo.com> wrote:
> What's the recommended approach for achieving OpenGL-accelerated drawing
> of Cairo in a GTK window?  I'm rendering lots of bitmaps with a little vector
> drawing thrown in for good measure, and the huge performance jump in
> cairogears on the COMP and SHADOW tests using the GLX backend
> is encouraging.

Currently there is no reliable way to use fully OpenGL-accelerated
cairo drawing. Probably your best bet is to draw to a cairo image
surface and convert that to a GL texture. This is is the way Clutter
does it at the moment. Note that this is not accelerated (the cairo
drawing happens fully on the software side) and you need to unmultiply
alpha before you pass it to GL. Check
http://people.freedesktop.org/~macslow/ for examples how to do this.

Theoretically you could also use glitz with cairo but unless you're
running on nvidia and using a very small subset of operations, you're
going to get significantly worse performance than with software

Carl has posted a very nice reply/comment regarding OpenGL & cairo on
my blog, I highly recommend reading it:


I'm currently working on a fully accelerated OpenGL backend for cairo.
At this point I'm mostly interested in getting cairo acceleration in
native OpenGL programs or libraries using it (ie. Clutter).
Transparent integration with X (mentioned by Carl in the comment) is
of course very interesting, but out of scope for now (much much more


More information about the cairo mailing list