Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

PGraphics unpredictable and unconsistent behaviour in Android mode

$
0
0

I'm developing an Android live wallpaper and I'm struggling with various problems the PGraphics objects have when rendering. The main problem is the impossibility to clear a PGraphics object with alpha values every frame, and everything I've tried works lika a charm in Java mode.

I'm using P2D as main renderer and the default for the Graphics object one because a whant to obtain a scaled pixel effect using the OpenGL nearest neighbor trick, but that same trick cannot be applied to a PGraphics rendering (so I use default + noSmooth() for this one). After Drawn everything on the PGraphic object, I scale the image on screen using the copy() method.

The result should be an image composed by PImage and PGraphics objects, but these last does not clean after a clear() or background(0,0) call so the image upon them is additive. The clear() call in particular gives me a tiny performances drop, while background(255,255) does its job so it's working fina as method.

I've tried every possible turnaround but nothing has the same performances/appearence as should be in this common way not working because of these problems. I don't know if I'm missing something or if I'm too stupid to figure out a simple solution.

here is a piece of the code that works on Java mode and does not work in Android mode:

pioggia.beginDraw();
pioggia.background(0,0);     //or clear()
for(int i = 0; i<gocceNum; i++){
   gocce[i][2] = (gocce[i][2]+gocceSpX*0.25)%back1.width;
   gocce[i][3] = (gocce[i][3]+gocceSpY*0.25)%back1.height;
   pioggia.set((int)gocce[i][2],(int)gocce[i][3], #355B4A);
}
pioggia.endDraw();
copy(pioggia, (int)quantize(disp*0.4, scalaH), 0, sw, sh, 0, 0, width, height);

"pioggia" is the PGraphics object, gocce is a 2D array of float values. Any help or hint would be super awesome ç_ç


Viewing all articles
Browse latest Browse all 941

Trending Articles