2D texture-based visualization
The second visualization will also be a basic oscilloscope-type display of waveform data. However, previously, we used audio data to scale 3D slice cubes; this time, we'll render them all on a 2D plane using a shader that uses audio data as input.
Our RenderBox
library allows us to define new materials and shaders. In the previous projects, we built materials that use bitmap images for texture mapping onto the geometry as it's rendered. In this project, we'll paint the quad using the audio bytes array, using the byte value to control the position where we set a brighter color. (Note that the Plane
class was added to RenderBox
lib in Chapter 7, 360-Degree Gallery.)
Texture generator and loader
First, let's generate a texture structure to hold our texture data. In the VisualizerBox
class, add the following method to set up the texture in GLES. We can't use our normal texture pipeline, since it is designed to allocate a texture directly...