We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › multiple PApplets-> animation thread problems
Page Index Toggle Pages: 1
multiple PApplets-> animation thread problems (Read 1183 times)
multiple PApplets-> animation thread problems
Aug 18th, 2007, 1:52pm
 
hi there,

I'm developping an application that uses up to 4 screens.
Basically i create n frames, each holding it's own PApplet. It works quite well... sometimes. I do have problems with initiating the PApplets correctly. setup() does not get called every time for every PApplet. Well, it randomly works, but I can't figure out whats preventing the PApplet to init itself correctly sometimes.

The code pretty much is like the example showed here:
http://dev.processing.org/reference/core/javadoc/processing/core/PApplet.html

Except that I have a "main"-class, that creates several "ExampleFrame"'s.

Any thoughts what might be the cause of the animation thread not starting? Ah, I forgot: the first PApplet works all the time, it's nr 2,3, and 4 that I'm having troubles with.

EDIT: just some mor info...
after the first PApplet being created (its the main gui), the main-class constructs a second PApplet and passes a reference to the gui-applet to it. the constructor of the second applet runs correctly. Even init() gets called on the new applet. But after that, the second applet just hangs, no setup() or draw() is called. While the first applet runs just fine. Like I said, this happens randomly, sometimes all the applets initialize correctly.

thanks,
patrick
Re: multiple PApplets-> animation thread proble
Reply #1 - Aug 19th, 2007, 12:40am
 
what sort of renderers are you using, and what sort of things are you doing inside the setup() and main() methods?
Re: multiple PApplets-> animation thread proble
Reply #2 - Aug 19th, 2007, 10:14am
 
... or you could ask shiffman about the status of MPE:
http://www.shiffman.net/2007/03/02/most-pixels-ever/

F
Re: multiple PApplets-> animation thread proble
Reply #3 - Aug 19th, 2007, 9:42pm
 
hi, thank you for the hints, problem solved!

When i was creating a barebones-version for posting here, I found the problem. It was stupid, really:

Basically PApplet's size()-method was called with 0 width and height sometimes. I accessed the frame-object from within size() directly to get it's dimensions. But because the applet was created IN the constructor of the frame object, frame was not always completely initialised when accessing its bounds. So it sometimes returned 0 instead of the real width/height.

The OPENGL-renderer seems to just die silently, when created with size(0,0,OPENGL);

I guess in Processing IDE the size()-dimensions get corrected by the preprocessor to be at least 200/200?

Here's the eclipse project for download, if someone's interested (stripped out all the code for my application. it now just finds the available screens and places a window with a PApplet on the first two; and lets them know about eachother):
http://www.extrapixel.ch/processing/framesTest.zip

Fjen, i considered MPE, but i want my app to run on one single machine. And because i need only one PApplet be loop()ing at a time, performance is ok.

Thanks!
Re: multiple PApplets-> animation thread proble
Reply #4 - Aug 21st, 2007, 12:39pm
 
just updated the multi-screen example. It should now be working on OS X & Windows. Tested configurations:
Macbook Pro with external screen
PC with dual graphics card
PC with internal graphics & additional 4-head matrox card

http://www.extrapixel.ch/processing/framesTest.zip

Run it from eclipse or use the included Ant-Build file to create a launchable Jar.
Page Index Toggle Pages: 1