Multiple simultaneous visualizations

Now that we have a collection of visualizations, we can enhance the app to run more than one at a time and switch between them.

To support multiple concurrent visualizations, replace the activeViz variable in VisualizerBox with a list of visualizations:

public List<Visualization> visualizations = new ArrayList<Visualization|();

Then, cycle through the list in each of the VisualizerBox method that use it. We always want to set up all of them, but then only draw (preDraw, postDraw) the active ones:

 public void setup() { audioTexture = genTexture(); fftTexture = genTexture(); for (Visualization viz : visualizations) { viz.setup(); } } public void preDraw() { for (Visualization viz : visualizations) { viz.preDraw(); ...

Get Cardboard VR Projects for Android 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.