Can't use the method lights() or directionalLight() in my drawing.

edited March 2016 in Android Mode

All the time I try to use some light releted method like lights() or directionalLight() the console is returning to me the error FATAL EXCEPTION: GLThread 10295 java.lang.NullPointerException. Can someone tell me what could it be?

the drawing method:

void draw(){

    background(0);

    lights(); //because of the method the error happens...

    float tempOrientation = (float) ((int) (accelerometerY * 1000)) / 1000;

    camera(width/2.0 + tempOrientation * width/10, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0);

    pointLight(200, 200, 200, width/2, height/2, 200);

    centerLine();
    drawBall();
    drawPlayer();
    drawEnemy();
    scoreText();

    println("-------");
    println("X: " + accelerometerX);
    println("Y: " + accelerometerY);
    println("Z: " + accelerometerZ);
    println("-------");
}

the error in console:

FATAL EXCEPTION: GLThread 10295
java.lang.NullPointerException
FATAL EXCEPTION: GLThread 10295
java.lang.NullPointerException
    at processing.opengl.PGL.loadVertexShader(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.getPolyShader(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:1524)
    at processing.opengl.PGL.loadVertexShader(Unknown Source)
    at processing.opengl.PGraphicsOpenGL.getPolyShader(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:1524)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)

Answers

  • error looks like it's in either the shader or in the code that loads the shader, neither of which you've supplied...

  • edited March 2016

    I'm making a very simple version of 3d pong and I've read that the method lights() loads the default values for light effect on the objects in the 3d environment. The game works just fine without this method but when I call lights() to give some light effects on my objects the error happens. I tried others like directionalLight(), pointLight(), ambientLight(), all of them the error is the same.

    I'm not using any shaders though, just this simple method for light effects.

    my setup is the following just to give an exemple of what I'm doing if it can help:

    void setup(){
    
        orientation(LANDSCAPE);
        size(displayWidth, displayHeight, P3D);
    
        ball = new PVector(width/2, height/2);
        player = new PVector(width, height/2);
        enemy = new PVector(0, height/2);
    
        ballSpeedX = width/100;
        ballSpeedY = width/100;
    
    
        enemySpeed = width/150;
    
        ballSize = width/40;
    
        sensor = new KetaiSensor(this);
        sensor.start();    
    }
    
  • is this android?

Sign In or Register to comment.