Skip to content
This repository was archived by the owner on Aug 14, 2018. It is now read-only.
This repository was archived by the owner on Aug 14, 2018. It is now read-only.

Creating a custom renderer #64

Open

Description

@kiwistrongis

Moved from processing/processing#2390
Hi there, just working on something that will resolve the problems SMT was having with the latest version of processing - a custom renderer. I have it working fully on the desktop on Windows and Linux ( can't test on mac ). I ran into a problem on Android however.

This works on the desktop:

void setup(){
    size( 800, 600, Renderer.class.getName());
}
void draw(){
    background( 30);
    fill( 200, 100, 100, 200);
    noStroke();
    rect( 10, 10, 100, 100);
}
/*
public int sketchWidth() {
    return 800;
}
public int sketchHeight() {
    return 600;
}
public String sketchRenderer() {
    return Renderer.class.getName();
}
*/
public static class Renderer extends PGraphics3D {
    public Renderer(){
        super();}
}

However this fails on android:

void setup(){
    //size( 800, 600, Renderer.class.getName());
}
void draw(){
    background( 30);
    fill( 200, 100, 100, 200);
    noStroke();
    rect( 10, 10, 100, 100);
}

public int sketchWidth() {
    return 800;
}
public int sketchHeight() {
    return 600;
}
public String sketchRenderer() {
    return Renderer.class.getName();
}

public static class Renderer extends PGraphics3D {
    public Renderer(){
        super();}
}

With the following logcat output:

D/AndroidRuntime(17635): 
D/AndroidRuntime(17635): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(17635): CheckJNI is OFF
D/AndroidRuntime(17635): Calling main entry com.android.commands.am.Am
D/AndroidRuntime(17635): Shutting down VM
D/AndroidRuntime(17649): 
D/AndroidRuntime(17649): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(17649): CheckJNI is OFF
D/AndroidRuntime(17649): Calling main entry com.android.commands.pm.Pm
D/AndroidRuntime(17649): Shutting down VM
I/AndroidRuntime(17649): NOTE: attach of thread 'Binder Thread #3' failed
D/AndroidRuntime(17713): 
D/AndroidRuntime(17713): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(17713): CheckJNI is OFF
D/AndroidRuntime(17713): Calling main entry com.android.commands.am.Am
D/AndroidRuntime(17713): Shutting down VM
I/AndroidRuntime(17713): NOTE: attach of thread 'Binder Thread #3' failed
D/AndroidRuntime(17741): Shutting down VM
E/AndroidRuntime(17741): FATAL EXCEPTION: main
E/AndroidRuntime(17741): java.lang.RuntimeException: Unable to start activity ComponentInfo{processing.test.asdf/processing.test.asdf.asdf}: java.lang.NullPointerException
E/AndroidRuntime(17741):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1960)
E/AndroidRuntime(17741):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1985)
E/AndroidRuntime(17741):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
E/AndroidRuntime(17741):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
E/AndroidRuntime(17741):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(17741):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(17741):    at android.app.ActivityThread.main(ActivityThread.java:4447)
E/AndroidRuntime(17741):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(17741):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(17741):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(17741):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(17741):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(17741): Caused by: java.lang.NullPointerException
E/AndroidRuntime(17741):    at android.view.ViewGroup.addViewInner(ViewGroup.java:3342)
E/AndroidRuntime(17741):    at android.view.ViewGroup.addView(ViewGroup.java:3214)
E/AndroidRuntime(17741):    at android.view.ViewGroup.addView(ViewGroup.java:3184)
E/AndroidRuntime(17741):    at processing.core.PApplet.onCreate(Unknown Source)
E/AndroidRuntime(17741):    at android.app.Activity.performCreate(Activity.java:4466)
E/AndroidRuntime(17741):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092)
E/AndroidRuntime(17741):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1924)
E/AndroidRuntime(17741):    ... 11 more

Help of any kind would be nice. Advice as to where to look and the like would be great.

Activity

  1. Calsign commented on Mar 13, 2014

    @Calsign

    Take a look around line 470 of processing.core.PApplet:

    if (sketchRenderer().equals(JAVA2D)) {
      surfaceView = new SketchSurfaceView(this, sw, sh);
    } else if (sketchRenderer().equals(P2D) || sketchRenderer().equals(P3D)) {
      surfaceView = new SketchSurfaceViewGL(this, sw, sh, sketchRenderer().equals(P3D));
    }
    

    Then, a little bit later:

    window.setContentView(surfaceView);
    

    There is simply no code to accommodate for a custom renderer. I don't know what steps would be necessary to get around this... but this should be enough to get you going in the right direction.

  2. kiwistrongis commented on Mar 13, 2014

    @kiwistrongis
    Author

    :S Thanks, I had a feeling this was the case, but didn't know where to look. I'll take a look to see if it can be worked around tomorrow, but I'm not optimistic :(.

  3. self-assigned this
    on Jun 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions