Gingerbread NDK Awesomeness

[This post is by Chris Pruett, an outward-facing Androider who focuses on the world of games. —Tim Bray]

We released the first version of the Native Development Kit, a development toolchain for building shared libraries in C or C++ that can be used in conjunction with Android applications written in the Java programming language, way back in July of 2009. Since that initial release we’ve steadily improved support for native code; key features such as OpenGL ES support, debugging capabilities, multiple ABI support, and access to bitmaps in native code have arrived with each NDK revision. The result has been pretty awesome: we’ve seen huge growth in certain categories of performance-critical applications, particularly 3D games.

These types of applications are often impractical via Dalvik due to execution speed requirements or, more commonly, because they are based on engines already developed in C or C++. Early on we noted a strong relationship between the awesomeness of the NDK and the awesomeness of the applications that it made possible; at the limit of this function is obviously infinite awesomeness (see graph, right).

With the latest version of the NDK we intend to further increase the awesomeness of your applications, this time by a pretty big margin. With NDK r5, we’re introducing new APIs that will allow you to do more from native code. In fact, with these new tools, applications targeted at Gingerbread or later can be implemented entirely in C++; you can now build an entire Android application without writing a single line of Java.

Of course, access to the regular Android API still requires Dalvik, and the VM is still present in native applications, operating behind the scenes. Should you need to do more than the NDK interfaces provide, you can always invoke Dalvik methods via JNI. But if you prefer to work exclusively in C++, the NDK r5 will let you build a main loop like this:

void android_main(struct android_app* state) {
    // Make sure glue isn't stripped.
    app_dummy();

    // loop waiting for stuff to do.
    while (1) {
        // Read all pending events.
        int ident;
        int events;
        struct android_poll_source* source;

        // Read events and draw a frame of animation.
        if ((ident = ALooper_pollAll(0, NULL, &events,
                (void**)&source)) >= 0) {
            // Process this event.
            if (source != NULL) {
                source->process(state, source);
            }
        }
        // draw a frame of animation
        bringTheAwesome();
    }
}

(For a fully working example, see the native-activity sample in NDK/samples/native-activity and the NativeActivity documentation.)

In addition to fully native applications, the latest NDK lets you play sound from native code (via the OpenSL ES API, an open standard managed by Khronos, which also oversees OpenGL ES), handle common application events (life cycle, touch and key events, as well as sensors), control windows directly (including direct access to the window’s pixel buffer), manage EGL contexts, and read assets directly out of APK files. The latest NDK also comes with a prebuilt version of STLport, making it easier to bring STL-reliant applications to Android. Finally, r5 adds backwards-compatible support for RTTI, C++ exceptions, wchar_t, and includes improved debugging tools. Clearly, this release represents a large positive ∆awesome.

We worked hard to increase the utility of the NDK for this release because you guys, the developers who are actually out there making the awesome applications, told us you needed it. This release is specifically designed to help game developers continue to rock; with Gingerbread and the NDK r5, it should now be very easy to bring games written entirely in C and C++ to Android with minimal modification. We expect the APIs exposed by r5 to also benefit a wide range of media applications; access to a native sound buffer and the ability to write directly to window surfaces makes it much easier for applications implementing their own audio and video codecs to achieve maximum performance. In short, this release addresses many of the requests we’ve received over the last year since the first version of the NDK was announced.

Augmented Reality for SketchUp

The first time I saw Augmented Reality in action, I wondered if I’d accidentally fallen through a wormhole on the way to work; it’s the kind of thing you’d expect to see on Boba Fett’s BlackBerry. AR is downright futuristic.

In the 3D modeling sense, AR involves combining a live video stream with a 3D model to create the illusion that the model is a physical object in the real world. All you need is a webcam (the ones that are built in to many laptops work just fine), a 3D model (SketchUp takes care of that), a printed-out paper “target” and a piece of AR software that can put everything together. This video shows AR in action:

And here’s an illustration that shows the setup:

A simple Augmented Reality setup for SketchUp, using an external monitor to show the video output.

Thanks to an Italian outfit called Inglobe Technologies, SketchUp users have been able to ride the AR wave for a while now. They’ve just released version 2 of their AR-media Plugin for Google SketchUp. Three great things about this shiny, happy piece of tech:

  • It’s available for both Windows and Mac OSX.
  • It’s available in three flavors: Free (Personal Learning Edition), Professional Lite and Professional.
  • I was able to use it, which means that it can’t be that hard to figure out.

Start out by grabbing the Quick Start Guide; you’ll find the relevant links about halfway down the plugin’s webpage. Follow Steps 2 and 3 to download and install the software; the free Personal Learning Edition will let you see how everything works without spending any money. After that, achieve instant gratification (my favorite kind) by skipping ahead to Step 6 in the Quick Start Guide: “Creating your first Augmented Reality Scene”.

DoubleCAD XT and SketchUp

Having been here for almost seven years, I’ve concluded that there are as many SketchUp workflows as there are SketchUp users. Trying to recommend a single catch-all combination of tools and methods is like stapling Jell-O to a piece of paper — difficult, messy and ill-advised. When tools like DoubleCAD XT (and DoubleCAD XT Pro) from IMSI/Design come along, things get a little easier to explain.

Most SketchUp modelers who design things for a living spend their time somewhere between the second and third dimensions. Models are 3D, but construction (or fabrication) requires 2D documents. Often, those 2D drawings are too complex to use LayOut in SketchUp Pro to make; LayOut isn’t a dedicated drafting tool, after all.

A SketchUp model imported into DoubleCAD XT Pro

DoubleCAD XT is (as its name implies) most certainly a full-featured CAD tool. It’s more affordable than AutoCAD LT, and it “holds hands” with SketchUp better than any other CAD system on the market. Among other things, DoubleCAD XT:

  • exports COLLADA files which you can open in SketchUp
  • imports .SKP files natively
  • imports and recognizes SketchUp layers
  • generates viewports from scenes in your models
  • converts components into DoubleCAD blocks automatically

If you’re a Windows user who routinely creates 2D documents, you owe it to yourself to give DoubleCAD a whirl. The no-cost version (did I forget to mention that DoubleCAD XT is free?) is extremely capable, and the Pro version adds lots, lots more for US$695.

GWT 2.1.1 is now available

Back in October of this year we released GWT 2.1, with a framework and set of tools that made it easy to build business web apps. Since then we’ve had some great feedback from the GWT community, and today we’re happy to announce that we’ve incorporated that feedback into our latest release, GWT 2.1.1. The specifics of this release are detailed below, but if you’re interested in getting started you can do so here.

For Eclipse users, simply click on the “Google updates available” icon in the lower left hand corner of your screen, or select the “Help->Check for Updates” menu item.

Alongside this release, we’ve also updated the Google Plugin for Eclipse and GWT Designer. Both can be installed via the links below.

The main release updates for each product include:

GWT SDK

GWT’s RequestFactory component, introduced in GWT 2.1, received a lot of attention, both from the GWT team at Google and from the GWT open source community at large. Based on this feedback, we’ve added the following:

  • A service layer, which includes support for non-static service objects
  • Value object support
  • Multiple methods calls on a single request

Google Plugin for Eclipse

  • Improved UiBinder error reporting within SpringSource Tool Suite (STS)
  • Optimized the IDE experience by removing unused Java builders and leveraging the AspectJ fixes in the latest STS release
  • Updated Speed Tracer to perform a full J2EE publish before launching

GWT Designer

If you have questions or want to provide some feedback, we’d love to hear it, and the best place to do so is in the Google Web Toolkit Group.