[cairo] 3d and 2d
Timur Pocheptsov
Timur.Pocheptsov at cern.ch
Sun Jan 11 22:13:40 PST 2009
Thank you very much!
-----Original Message-----
From: Chris Wilson [mailto:chris at chris-wilson.co.uk]
Sent: Sun 1/11/2009 4:56 PM
To: Timur Pocheptsov
Cc: cairo at cairographics.org
Subject: Re: [cairo] 3d and 2d
On Sun, 2009-01-11 at 16:21 +0100, Timur Pocheptsov wrote:
> Hello.
>
> I hope, I can ask my question in this mailing list.
>
> Is it possible to combine 2D and 3D graphics "in one picture" using cairo for 2D rendering and OpenGL for 3d?
Yes. In theory it should be possible to use cairo-glitz to render
directly to the same OpenGL buffer - but I'd strongly advise not to do
that. ;-)
http://cairographics.org/OpenGL/ is a good introduction.
The common technique, that allows for caching of dynamic 2D content and
will probably integrate much more easily with your OpenGL framework, is
to simply use cairo to render to an image surface and use that as a
texture. The caveat here is that cairo works in a premultiplied
colorspace and OpenGL, typically, does not. You can either unpremultiply
the image surface when you transfer it to the texture, or you can
manipulate blend modes and work with premultiplied colors yourself.
Looking to the future, it will be possible (for a limited subset of
drivers and architectures alas) to use Cairo to render directly to the
texture, utilizing available hardware accelerate. You may be able to do
something akin to this today by using the xlib backend and the OpenGL
texture-from-pixmap extensions - again not supported by all drivers.
Hope this helps, and have fun using Cairo!
-ickle
More information about the cairo
mailing list