I have a deadline on this friday for a project (audition for the National Art Academy), so this is a slightly urgent call for help. I am working on this sketch where I control several different videos with alpha in realtime. I first used the animation codec because I've used it before, and gives fairly clean code. However, it peaks at max 12fps — even with small sizes.
Therefore, I am now trying to optimise the code using png-sequences instead. But I've run into a NullPointerException that I can't understand how to get pass. The problem seems to lay in the writing of the 2D PImage array (where 'i' is the video, and 'j' is the image). Are there anyone that understands what I'm doing wrong?
The full sketch is fairly big, so will only post snippets for now.
for (int i=0;i<vidName.length;i++) {
vid = new PImage[vidName.length][picNum[i]];
for (int j=0;j<picNum[i];j++) {
String name = vidName[i]+"_"+j+".png";
vid[i][j] = loadImage(name);
}
}
This is the setup() for filling the arrays. 'vidName.length' is a String with the names for the different sequences. 'picNum' is a String with the number of pictures in each folder. 'vid' is the 2D PImage array.
This is the draw(). 'playhead' is, yeah, the playhead. 'vidTime' is where the playhead is supposed to go. And I guess the PVector 'vidPos' is fairly obvious.
Any help or tips would be greatly appreciated! And shout out if I should post the full sketch as well or the full NullPointerException, but I think the problem lays within these lines.
EDIT:
The NPE mentions the draw(), so the problem probably lays there. For clearity: vidDraw() is a function called in draw(), were all the vid related code is.
Posting the NPE as well (is it best to past it as code or not?):
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at processing.core.PGraphics.image(PGraphics.java:3553)
at processing.core.PApplet.image(PApplet.java:12413)
at HumanChemistry_1_0_png_.vidDraw(HumanChemistry_1_0_png_.java:121)
at HumanChemistry_1_0_png_.draw(HumanChemistry_1_0_png_.java:63)
at processing.core.PApplet.handleDraw(PApplet.java:2270)
at processing.opengl.PGL$PGLListener.display(PGL.java:2643)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:576)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:561)
at javax.media.opengl.awt.GLCanvas$7.run(GLCanvas.java:1054)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1024)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:899)
at javax.media.opengl.awt.GLCanvas$8.run(GLCanvas.java:1065)
at javax.media.opengl.Threading.invoke(Threading.java:193)
at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:483)
at javax.media.opengl.awt.GLCanvas.paint(GLCanvas.java:537)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
at sun.awt.RepaintArea.paint(RepaintArea.java:241)
at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)
at java.awt.Component.dispatchEventImpl(Component.java:4820)
at java.awt.Component.dispatchEvent(Component.java:4572)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:710)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:669)
at java.awt.EventQueue$2.run(EventQueue.java:667)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:683)
at java.awt.EventQueue$3.run(EventQueue.java:681)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:680)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)