Cairo/OpenGL (was Re: methods for license conversion)

Bert Freudenberg bert at freudenbergs.de
Mon Jul 9 08:57:50 UTC 2007


On Jul 9, 2007, at 1:10 , sig wrote:

> On 06/07/07, Blake <blake at kingdomrpg.com> wrote:
>> On Thu, 05 Jul 2007 14:14:50 -0700, tim Rowledge  
>> <tim at rowledge.org> wrote:
>>
>> > Don't know the answer to that one; I was under the impression  
>> that Cairo
>> > was 'just' graphics but I haven't really researched it per se.  
>> Given
>>
>> It's vector graphics, though you can build a UI with it. I  
>> (incorrectly)
>> thought it mapped to native tools.
>>
> About Cairo, as noted on site:
> Cairo is a 2D graphics library with support for multiple output
> devices. Currently supported output targets include the X Window
> System, Win32, image buffers, PostScript, PDF, and SVG file output.
> Experimental backends include OpenGL (through glitz), Quartz, and XCB.
>
> 1 fact: i assume it proposes a cross-platform layer of abstraction on
> top of existing graphics libraries (like DirecX/OpenGL whatever).
> 2nd fact, i dont like: its 2D only.

Since Morphic is 2D, too, that's a perfect match.

> I prefer to directly use OpenGL (which is already a cross-platform)
> and provides enough capabilities to develop a UI using 2D graphics or
> 3D (like composite desktops/games e.t.c). I think using OpenGL
> directly for creating UI is better choice for squeak.
> I implemented a scratch replacement of Canvas/Display stuff to use GL
> via FFI for drawing morphic with squeak. Premiliary, based on rough
> calculations it renders desktop 3 to 5 times faster than currently
> used Balloon/BitBlt.

Nice. I'd expect roughly the same from a native Cairo back-end.

> Also, i noticed that changes needed to make use
> of GL with morphic architecture is minimal, and opening a wide range
> perspective for creating a stunning and fast UI for squeak, not
> limited by third-party libraries, which providing own abstraction
> layer(s).

If speed is all you care about, then I agree. Recreating the quality  
Cairo provides based on an OpenGL layer is hard, though. Cairo is not  
so much about abstraction, but about providing a consistent rendering  
model and reliable high-quality results on any 2D output device from  
screen to printers.

> Anyways, to use modern graphics cards features with squeak, we have no
> choice but to use some of the existing external libraries.

Agreed.

> And OpenGL is a winner here, without a doubt.

I beg to differ. For one, there are two major platform with  
unreliable OpenGL hw support.

But more importantly, OpenGL goes for quick-and-dirty, whereas Cairo  
does the-right-thing. Cairo chooses quality and reliability over raw  
performance (while performance still is adequate for interactive  
use). For a comparison and introduction see, for example,

	http://people.freedesktop.org/~keithp/tutorials/cairo/cairo- 
tutorial.pdf

This is not to say OpenGL is useless, far from it. But for high- 
quality 2D graphics, Cairo is clearly the better choice, *and* it's  
simple to use both if you need both 2D and 3D graphics:

	http://cairographics.org/OpenGL/

The current Cairo-backed graphics system for Squeak ("Rome") uses the  
software rasterizer of Cairo, which does not give a lot of speed-up  
(but looks awesome). However, folks at impara have combined Rome and  
HostWindows, thus rendering directly to OS windows using Cairo. That  
should be much faster while still providing high quality. Not sure of  
the current state of this, though.

- Bert -





More information about the Squeak-dev mailing list