PGraphic: beginDraw() keeps throwing Null Pointer Exceptions...
in
Core Library Questions
•
1 year ago
I'm having some very strange problems with my code, and I have been so far baffled.
Even the beginDraw() example sketch is throwing a Null Pointer Exception:
PGraphics pg;
void setup() {
size(100, 100);
pg = createGraphics(80, 80, P2D);
}
void draw() {
pg.beginDraw();
pg.background(100);
pg.stroke(255);
pg.line(40, 40, mouseX, mouseY);
pg.endDraw();
image(pg, 10, 10);
}
...giving this error:
Exception in thread "Animation Thread" java.lang.NullPointerException
at processing.opengl.PGL.getString(PGL.java:1029)
at processing.opengl.PGraphicsOpenGL.getGLParameters(PGraphicsOpenGL.java:6076)
at processing.opengl.PGraphicsOpenGL.beginDraw(PGraphicsOpenGL.java:1547)
at sketch_120907a.draw(sketch_120907a.java:29)
at processing.core.PApplet.handleDraw(PApplet.java:2120)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:197)
at processing.core.PApplet.run(PApplet.java:1998)
at java.lang.Thread.run(Thread.java:680)
I'm running Processing 2.0b1 on a relatively new MacBook Pro (Mountain Lion). This code works fine in Processing 1.5.1, but I'm still getting a lot of weird behavior in all versions, from sketches that previously worked fine. I thought at first it was a result of the new Java 1.6 update 35 that was pushed yesterday, but I've tried different sketches on a friend's computer with update 33 and Processing 2.0a7 and it returned the same results. Any ideas? Is it an OpenGL issue?
1