Hello Rendering

Rendering with RenderScript is a little bit more complicated than simply invoking a script function, and requires a little more work before you can see anything on the screen. You will need to:

  • Create a script that does the rendering.
  • Create a RenderScriptGL context object.
  • Create a class that extends RSSurfaceView.
  • Set your RSSurfaceView as the content view for your activity.

Creating a Rendering Script

Our first rendering script will be extremely simple as it will only change the background color to some random color. The script is shown in Listing 9–5 and is in a file called hellorendering.rs. The names of the RenderScript files are important as they define the resource name (in that case R.raw.hellorendering, which is simply ...

Get Pro Android Apps Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.