[cairo] API Shakeup wrapup: The plan going forward
David Reveman
davidr at novell.com
Sun Feb 27 12:45:28 PST 2005
On Sat, 2005-02-26 at 15:14 +1100, Nathan Hurst wrote:
> On Fri, 25 Feb 2005, Bill Spitzak wrote:
>
> > Nathan Hurst wrote:
>
> >> The problem with perspective is that beziers are not closed under
> >> perspective transforms, so you have to decide how closely you want to
> >> approximate the transform. Does this belong in cairo, or rather in a
> >> separate lib?
> >
> > Bezier's are in fact correctly calculated if you do them in affine space by
> > interpolating the x,y,w values of the 3d projected control points. The
> > resulting point on the screen is x/w, y/w.
>
> You mean if you project them?
>
> > I think I heard that this also allows Bezier to produce correct conic
> > sections.
>
> Yes, they're (basically) NURBs.
>
> > Even ignoring that, I certainly have made quite nice looking 3D "projections"
> > in PostScript by projecting the bezier control points and then having it
> > interpolate the resulting points in 2d.
>
> Sure, but they aren't correct. Just like you can make a reasonable
> perspective warp of a textured triangle using linear interpolation. My
> point is that we should be careful about adding random 'niftyness' to
> cairo, particularly if it involves compromises. If the user wants 3d
> stuff, should they instead be looking at opengl?
I'm afraid the answer today is yes, but I'd like it to be, No.
"If you want to do 3d, you should instead be using OpenGL", I've heard
this from more than one person and I don't like it. OpenGL is NOT a good
API for the average programmer, it's huge and with some parts that are
almost never accelerated, not convenient for simple 3d applications and
you really have to know what modern hardware and drivers accelerate well
to write efficient programs. You might very well end up writing a
program that runs fine on two year old hardware, but to make it really
utilize the hardware available today or tomorrow you might need to
rewrite the whole thing.
Microsoft Avalon will make it really easy for developers to write simple
efficient 3d applications in Windows.
I'm not sure cairo is the answer, but I think we need something that is
sort of doing for 3d what cairo is doing for 2d.
I think that having some basic 3d stuff in cairo would be useful, but
it's of course important that it doesn't complicates the 2d stuff.
My suggestion is that we start with only supporting perspective
transforms of patterns. That's well defined and already supported by at
least the image, xlib and glitz backend. All we need to do for this to
work is to make sure we expose a 3x3 matrix and not a 3x2 matrix in the
API (which I think is a good idea anyway) and fix so that the matrix
computations in cairo_matrix.c can handle full 3x3 matrices.
cairo_pattern_set_matrix will interpret the matrix as a perspective
transformation matrix but cairo_concat_matrix could still interpret it
as an affine transform.
-David
More information about the cairo
mailing list