Re: canvas notes



On Fri, 2005-09-09 at 20:23 -0400, Havoc Pennington wrote:
> On Fri, 2005-09-09 at 09:53 +0200, Alexander Larsson wrote:
> > * OpenGL
> 
> Any thoughts on that 3D vs. 2D thing? i.e. it seems like we want to be
> able to mix OpenGL and Cairo at will, but it isn't clear to me what that
> really means.
> 
> Kind of a similar question to is a compositing manager best done with
> RENDER or GL as the foundation maybe...

All sane UIs I've seen are predominantly 2D, so clearly the focus should
be on 2D. However, 3D stuff can be useful at times as part of a 2D UI,
either as separate rendered objects (e.g. a 3d bar chart or icon) or
used as an effect (e.g. the transitions in keynote).

The first case is basically embedding a view of a 3D scene in a 2D
canvas. I.E. a 3D scene description + a camera description. The 3D view
is then rendered on the canvas such that it integrates nicely (i.e. it
won't have a great opaque black rectangle background, so you'll be able
to see the canvas behind rendered 3d objects). The scene graphs aren't
really the same, but rather the 2D scene graph references a view into a
3D scene graph. 

The second case is basically the opposite, the embedding of a canvas
into a 3D scene graph. For instance embedding your whole canvas on the
side of a spinning cube. By this we can tell that the 3D scene graph
must be able to reference 2D canvas as "texture objects" in some way.

I don't think the complexity of the 3D used in the canvas will be very
high, so the 3D scene graph doesn't have to be incredibly complex. For
instance, one don't imagine Doom III style full-screen, hundreds of megs
of texture memory, enormous levels, dynamic lighting, complex object
interaction 3D worlds. Instead you want something simpler that makes it
easier to do the sort of things you're more likely to want.

One nice aspect of an approach like this is that you can focus initially
on the 2D part, because the 3D part is so separated from the 2D scene
graph and APIs. 

The only question is how the rendering is gonna happen and how the 3D
rendering will affect how we do the 2D rendering. For 2D rendering using
cairo is a clear no-brainer. For 3D, opengl is the same. How do we
combine them? One approach is to use cairo-on-gl (glitz) so that all
rendering is done using opengl. Another approach is to draw the 3D views
on an alpha pixmap and render that in cairo. I don't think the state of
3D support in X is yet at a place where we can decide what the best
approach is.

Interestingly, this is pretty much how Microsoft seem to be handling 3D
in Avalon, as can be seen in this blog entry:

http://blogs.msdn.com/greg_schechter/archive/2004/05/22/139744.aspx

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's an otherworldly hunchbacked astronaut who must take medication to keep 
him sane. She's a virginal belly-dancing bodyguard with a flame-thrower. They 
fight crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]