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 & HelpSyntax Questions › Multithreading for multiple monitors
Page Index Toggle Pages: 1
Multithreading for multiple monitors (Read 633 times)
Multithreading for multiple monitors
Mar 2nd, 2008, 8:47am
 
Hello. I'm developing a program in Processing which will be displayed in a museum, for a company I'm working for. The problem is, I need to use a touchscreen to interact with a projection, i.e. I have to display different visual patterns depending on what the users clicks on the touchscreen menu, and then use the mouseX,mouseY coordinated of the users finger to navigate the other monitor.

Ok, so far so good, as I figured I could just write a client/server program, having the server be the first monitor (ie, the projection on the wall) and the client the second monitor (ie, the touchscreen). Such that I can connect them both through a localhost connection, and have no problems in telling the first program window to go to monitor 1 and the second program window go to monitor 2.

Is this feasible? Can I just do something like
Code:

import java.lang.Thread;
MyServer server=new MyServer;

void setup(){
server.start();
}
void draw(){
//Draw whatever the server receives from the client.
//Ie. Button 1 pressed - Display slideshow 1, else draw..
//etc.
}

class MyServer extends Thread{
public void run(){
//keep receiveing client packets, and storing it
//in an input buffer.
}
}


And the client something like:

Code:

import java.lang.Thread;
MyClient client=new MyClient;

void setup(){
client.start();
}
void draw(){
//Draw menu, if button 1 pressed, send to server
//"button 1 pressed"
//and then turn black, display a cursor and start sending
//mouseX,mouseY coordinates to the server
}

class MyClient extends Thread{
public void run(){
//keep sending whatever the client puts in the
//output buffer to be sent to the server
}
}



Can it be done as easy? I'm aware and know how to use locks and etc, just want to know if such design would work inside Processings IDE, or if I would have to use my full blown NetBeans IDE to extend the PApplet and etc?

Please tell me it can be done, I need to build this in  the next week :/

Thanks for the help!

***EDIT***

Of course, if anyone can suggest some other solution on how to use a touchscreen to control another Processing program or make one Processing program for 2 monitors, please let me know. I will me most thankful.
Re: Multithreading for multiple monitors
Reply #1 - Mar 3rd, 2008, 12:21am
 
Couldn't you run both screens from the same app window by extending your desktop to both displays and then using one half for the projection If not, you should check out Daniel Shiffman's MostPixelsEver library to synch up various machines in a local network. We've just completed a project which originally used this library, but ran into a few race condition/freeze issues with it though (apparently MPE is more stable on OSX than on Windows). I then wrote a conceptually similar library from scratch using a single thread UDP network model instead, which proved to be more stable and has been running for several weeks now without hiccups. There's a sensor grid connected to the server machine, which then broadcasts the input data along with a heartbeat to all clients. You'll be able to subclass the server and attach your own user data instead.

Am in the process to get this project isolated from any project specifics & out of the door asap, but unfortunately it will not happen in time for you to benefit from...
Re: Multithreading for multiple monitors
Reply #2 - Mar 3rd, 2008, 5:47am
 
Yeah, I'm taking a look at MPE, although I'm not very happy yet.

The problem with using half the screen is that I'm not sure how to start the app at the exact same position every time the museum starts up the program in the morning at opening time, or even if I can do dual-screen full screen.

That's still an option, but I have to check this issues first.

Thanks anyway, and be sure to release your code! Smiley

Re: Multithreading for multiple monitors
Reply #3 - Mar 3rd, 2008, 10:40am
 
Try something like:
Code:
  frame.setLocation(0,0);

straight after your size(...); line.
Re: Multithreading for multiple monitors
Reply #4 - Mar 3rd, 2008, 5:22pm
 
Hey, thanks a lot. I'll try it out .
Re: Multithreading for multiple monitors
Reply #5 - Mar 3rd, 2008, 6:39pm
 
some more info is here (notes from my class):

http://itp.nyu.edu/varwiki/BigScreens/FullScreenHacks

Toxi's UDP magic is very exciting, I will be teaching the same course next fall and plan on doing a major overhaul of the library (fixing freezing issues, better error checking of dropped clients, etc.)  This will likely happen later this semester or over the summer!

Page Index Toggle Pages: 1