A3D Image/Shape acceleration
in
Android Processing
•
2 years ago
Hi all,
Dave
I am building something akin to a side-scrolling game in Android and am struggling with performance issues.
Can anyone tell me the best way to render the images in this sketch. Are there any techniques for rendering something like this quicker? I have been reading about VBOs and Display Lists, but I'm a little confused as to how to achieve hardware acceleration in 2D using the Android renderer. These images could easily be SVG if it helps.
Any pointers would be greatly appreciated.
Thanks
Dave
int offset = 64; int numberOfComponents = 14; int speed = 5; int numImages = 4; PImage[] imgs = new PImage[numImages]; Component[] pointComponents = new Component[numberOfComponents]; float[] yValues = { 0, 64, 128, 192, 256, 320, 384, 0, 64, 128, 192, 256, 320, 384, }; void setup() { size(800, 480, A2D); orientation(LANDSCAPE); for (int i = 0; i < imgs.length; i++) { imgs[i] = loadImage(i+".png"); } for (int i = 0; i < pointComponents.length; i++) { pointComponents[i] = new Component(i*offset, yValues[i]); } } void draw() { background(0); for (int i = 0; i < pointComponents.length; i++) { pointComponents[i].run(); } fill(255); text(frameRate, 40, 400); } class Component { PImage componentGraphic; float x, y; int index; String a; Component(float x, float y) { this.x = x; this.y = y; index = int(random(numImages)); } void run() { display(); move(); cycle(); } void display() { for (int i = 0; i < imgs.length; i++) { image(imgs[index], x, y+(i*offset)); } } void cycle() { if (x <= -60) { x=width; } } void move() { x -= speed; } }
1