Making Linux application user interfaces richer with OpenGL

Ars at FOSSCamp: at a discussion session in Cambridge, developers discussed …

Ars was at FOSSCamp this weekend. Think of FOSSCamp as an "un-conference" without a set agenda where the minds behind open source projects get together and plot world domination (and, err, ways to improve their code). One fascinating session (and one that shows how FOSSCamp works and why it's so productive) was given by Mirco Müller, who discussed using OpenGL in GTK applications. Müller—the developer behind Cairo-Clock and the LowFat image viewer—talked about the state of OpenGL support in desktop applications and described various techniques that developers can use to make OpenGL content integrate better with conventional GTK user interfaces.

At the start of the session, Müller explained the reasons why developers might want to use OpenGL in GTK applications. Although Compiz offers some significant aesthetic improvements for desktop environments, it doesn't do much to improve the visual appearance of application user interfaces. In order to expand the potential for bling in open source software, developers will have to incorporate hardware-accelerated 3D rendering into the underlying widget toolkits. Developers in the GTK community have been reluctant to take such drastic steps because of the complexity involved and concerns about the detrimental impact of the unwanted API breakage that would likely result.

"Core GTK people haven't decided how they want to approach OpenGL integration yet," said Müller during the session. "It's still in the experimental phase."

Even though conventional Linux GUI toolkits haven't bought into bling just yet, application developers can take the first steps on their own by embedding OpenGL drawing areas in their programs. GTK application developers can use the GTK/GLExt bindings, which are very effective despite not yet being an official part of GTK. The GTK/GLExt bindings enable developers to incorporate interactive OpenGL drawing areas in GTK programs in a manner that is fully compatible with the conventional GTK event loop.

Unfortunately, developers find it difficult to make OpenGL elements look natural in conventional GTK applications. Müller points out that developers who are using OpenGL in GTK applications tend to smack a rectangular drawing area into a form surrounded by GTK widgets—an approach that significantly detracts from the fluidity of the user interface.

Müller encourages programmers to think about ways to make OpenGL more natural and seamless in GTK programs. He suggests, for instance, using the color data from the user's current GTK theme when rendering OpenGL elements, particularly backgrounds. He also explained how to apply gradients to the edges of an OpenGL rendering area to make it blend more gracefully with the rest of the user interface.

In addition to providing insight into various techniques for effective OpenGL programming, Müller also discusses various emerging GNOME technologies that provide increasingly-useful support for creating rich user interfaces. In particular, he discusses hardware-accelerated canvas libraries like Clutter and Pigment, which he describes as "playgrounds" for testing next generation rendering technologies.

Although Müller regards Clutter and Pigment as an important step towards the kind of user interface improvements he ultimately envisions, he is convinced that a more holistic approach is necessary. It's wrong to think just about the programming libraries, says Müller. He believes that it is also important to think about the people writing the applications. He elaborates by citing areas where he thinks that the developer community could be better served. He wants to see development tools for integrated GL development that are as easy to use as the Glade user interface design tool. Inspired by the success of the Tango project, Müller also sees a very clear need for uniform standards and guidelines that describe best practices for OpenGL integration and specify which animation effects to use in various contexts.

The session provoked much discussion. After Müller finished describing some of the important technologies that are presently being adopted by application developers to build visually rich interfaces, Mark Shuttleworth expressed some interest in finding ways to unify these disparate projects.

"There is very cool stuff happening in different places [but] it seems very fragmented," said Shuttleworth, referring to the open source projects mentioned by Müller. Shuttleworth believes that aesthetic improvements in desktop Linux applications would "kick serious ass" if there was a way to "get people excited about it as a vision." He then asked the session participants if there is a way to "get better alignment between the different groups that are doing cool stuff in this area."

Several attendees provided recommendations in response to Shuttleworth's question. Ubuntu community manager Jono Bacon suggested that the situation could be improved if the various libraries and technologies were more accessible to developers. In particular, he suggests "work[ing] closely to make sure those pieces are there, and present in a distro."

Another possibility that was discussed at length is the potential for events that bring together contributors from different parts of the stack so that they can find solutions collaboratively. Such events would include developers involved with Xorg, GTK, Compiz, OpenGL, and other relevant projects. This suggestion was enthusiastically supported by Compiz contributor Robert Carr, who commented that people know what they need to do to improve their own parts of the stack, but don't know what they need to do to improve integration of those parts.

One of the highlights of Müller's presentation was a technical demo. Müller created a program that displays live video captured from a webcam as a texture on an OpenGL surface. The video plays seamlessly as the surface is moved and turned.

Although Müller had little time to prepare, the session was very productive and informative. Much like open source programming projects, the session itself started out as the presentation of a single individual and transformed rapidly into an active, participatory dialog that sparked new ideas. Sessions like this illustrate thge unique value of events like FOSSCamp; stay tuned for more FOSSCamp and Ubuntu Developer Summit coverage from Ars over the next few days.