PGraphics issue using P2D/P3D

edited February 2015 in Android Mode

Hi, I'm really interested in using PGraphics for Android, after several tests I found out that without specs, the render in createGraphics works fine, but when I use P2D or P3D it gets an error. This is an example code:

PGraphics pg;

void setup() {
  pg = createGraphics(40, 40, P2D);
}

void draw() {
  pg.beginDraw();
  pg.background(100);
  pg.stroke(255);
  pg.line(20, 20, mouseX, mouseY);
  pg.endDraw();
  image(pg, 9, 30); 
  image(pg, 51, 30);
}

public String sketchRenderer() {
  return P2D; 
}

It throws:

Cannot run the OpenGL renderer outside the main thread, change your code
so the drawing calls are all inside the main thread, 
or use the default renderer instead.
FATAL EXCEPTION: GLThread 485
java.lang.NullPointerException
    at processing.opengl.PGraphicsOpenGL.beginPixelsOp(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.readPixels(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.loadPixels(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.initCache(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.getTexture(Unknown Source)
    at processing.opengl.PGraphicsOpenGL$TexCache.getTexture(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.flushPolys(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.flush(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.endDraw(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)

And the same thing happens using createGraphics with P3D. I don't know if the Andriod mode supports that feature or if there is something missing.

Thanks ahead.

Tagged:

Comments

  • edited March 2015

    Not a specialist in Android, but I recall that to create PGraphics in non-default mode, you must have a size() call in the same mode.
    At least worth a try... :-)

  • Thanks, but using that Size() call, it gets the same result because the Android mode is not necessary.

  • @Merkkien== i think that it is a problem with the android rules about UI thread; as soon as possible i ll give a look at that.

  • @Merkkien== 1) are you using emulator or device? - If device which one and platform? 2) OpenGL ES2 is not supported till 15; in your manifest which is the min SDK? 3) is GPU on? is Haxim installed?

  • @Merkkien: tested. ---works fine on real device with KitKat ---so i think that you can solve uour problem creating an emulator as i told you(min target API 15 or more, platform 4.4, _GPU on, Haxim)...

  • @akenaton: The idea is using it in devices, i've it tested in several Smartphones, like Samsung Galaxy S3 with JellyBean 4.3, or the Motorola MotoG with KitKat 4.4.4, getting the same error.

    I'll like to know what device did you use?, if there is any special settings on Android and what Target SDK is required, or why do you think am i getting that error?

    Thanks.

  • @merkkien: i have tested successfully with sony XPeria Z + kitKat + Eclipse manifest:: minSdk 18, target 18 (though min sdk 15 is supposed to work) i will test as soon as possible with Samsung Nexus 5 + gingerbread but i am quite sure that it does not work have you tried compiling with eclipse?

  • Thanks @akenaton.

    It worked on Eclipse, but after checking in detail, i noticed that the Eclipse i was using has an old version of Processing-android. So i think it's a bug from Processing-android v3.

Sign In or Register to comment.