We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a very simple processing sketch that is throwing a strange exception. I am running a windows 7 machine with Processing 2.2.1
PImage img;
void setup() {
size(500, 500, P3D);
img = createImage(500, 500, RGB);
img.set(10,10, color(255,0,0));
}
void draw() {
image(img,0,0);
}
throws this:
java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)
at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206)
at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
at javax.media.opengl.Threading.invoke(Threading.java:191)
at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:541)
at processing.opengl.PJOGL.requestDraw(PJOGL.java:688)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1651)
at processing.core.PApplet.run(PApplet.java:2256)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at processing.opengl.Texture.convertToRGBA(Texture.java:1077)
at processing.opengl.Texture.set(Texture.java:347)
at processing.opengl.PGraphicsOpenGL.updateTexture(PGraphicsOpenGL.java:6258)
at processing.opengl.PGraphicsOpenGL.getTexture(PGraphicsOpenGL.java:6122)
at processing.opengl.PGraphicsOpenGL$TexCache.getTexture(PGraphicsOpenGL.java:6918)
at processing.opengl.PGraphicsOpenGL.flushPolys(PGraphicsOpenGL.java:2464)
at processing.opengl.PGraphicsOpenGL.flush(PGraphicsOpenGL.java:2415)
at processing.opengl.PGraphicsOpenGL.endDraw(PGraphicsOpenGL.java:1712)
at processing.core.PApplet.handleDraw(PApplet.java:2406)
at processing.opengl.PJOGL$PGLListener.display(PJOGL.java:862)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:665)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:649)
at javax.media.opengl.awt.GLCanvas$10.run(GLCanvas.java:1289)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1119)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:994)
at javax.media.opengl.awt.GLCanvas$11.run(GLCanvas.java:1300)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Strangley, if I change the line
img.set(10,10, color(255,0,0));
to include a for loop such as
for (int i = 0; i < img.width*img.height; i++)
img.set(int(random(img.width)),int(random(img.height)), color(255,0,0));
or
for (int i = 0; i < img.width*img.height; i++)
img.set(i%img.width,i/img.width, color(255,0,0));
I don't get an exception. If I remove the for-loop the exception comes back!
Any ideas about what is going on here?!?
Answers
No exception @ Processing 2.0.2 here! :-?
I can reproduce a similar error (less detailed stack trace) in 2.1.1.
Why do you use the P3D mode in an apparently flat sketch?