We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I need to run a sketch on two monitors. The main window on the primary monitor needs to be dragable and the secondary window needs to fill the entire second screen. I don't need to be able to interact with the secondary window, It's just needed to display images.
If there is no way this could work fullscreen on both monitors could work for me aswell. I didn't have any luck with following the information from my searches, so I came here to ask.
Answers
http://forum.processing.org/two/discussions/tagged?Tag="--display"
I went trough these tagged discussions and tryed a couple of things but it didn't realy get me any further.
http://forum.processing.org/two/discussion/10937/multiple-sketches
Alright, thanks so far. I managed to get 2 dragable windows from this example but I cant realy figure out where to put the ARGS_FULL_SCREEN and "--display=1".
That template was "hidden" as a commented out line: ;)
//runSketch(new String[] { ARGS_FULL_SCREEN, "Full Window" }, another);
As I've mentioned, just place the extra configs before the "title" of the sketch.
Thus for your own runSketch(), that would be something like:
runSketch(new String[] { "--full-screen", "--display=1", "My Projector" }, projector);
Don't forget to use displayWidth & displayHeight for the sub-sketch's size():
size(displayWidth, displayHeight, JAVA2D);
Just some extra tips: Java's classes & interfaces use the UpperCamelCase for their names.
Therefore it's
class ProjectorSketch
, notclass projectorSketch
! :PAnd of course, ARGS_FULL_SCREEN is the corresponding constant for "--full-screen". ;;)
Thanks. It works as intended now.
Glad it did! Just forgot to tell that "--full-screen" got a
@Deprecated
alias too: "--present".That's an important detail when we need to use the old Processing 1.5.1 version. :-\"
Of course, "--present" works for all Processing versions! :ar!
I'm having problems getting a variable from the main window into the second one. I get the error "Cannot make a static reference to the non-static field".
In order for the
static
"minion" sketches to access any member from their "oversëer", that member needs to be declared asstatic
too. Same for the other way around! O:-)https://Processing.org/reference/static.html
I can't quite wrap my head around it yet. Got an example that does that?
Sorry I've forgotten to add that in order to access some
static
member, we also need to specify the name of its class/interface! :-\"That is, if we needed to access main sketch's projector field from inside ProjectorSketch nested class, besides declaring the former as
static
, we'd need something like:Name_of_Main_PDE_File.projector
Anyways, forget that for now! B/c since you're using runSketch() instead main() in order to ignite the PApplet classes, we don't need them to be either
static
norpublic
! :-bdBy getting rid of the
static
declaration, those classes become inner classes of the main sketch top class! And therefore, they're fully able to access any members from the latter! \m/From your updated example below, take notice that the now inner class ProjectorSketch can access the field member projector from the top sketch class: :D
Alright, tried It and it works nicely. Thanks again.
I seem to be unable to use
loadImage("filename.png")
in the second window. It works fine in the main window.runSketch(new String[] { "--display=1", "Projector", sketchPath }, projector);
args[0]
inside projector's inner sketch.args[0]
to inner sketch's own sketchPath:sketchPath = args[0];
.protected
toprivate
! X(args[0]
inside the "ignited" sketches. :-@Surprise! I've got a more streamlined fix which probably is gonna keep working even on later Processing versions! <:-P After doing some more research and running this simple test below:
I've become aware of a "new" runSketch()'s config parameter called "--sketch-path="! :-$
And that's exactly the very "trick" used by the PDE to pass for our regular sketches the sketchPath to use for I/O operations! :-B
We merely need to do the same for our own special instantiated sketches. :D
runSketch(new String[] { "--display=1", "--sketch-path=" + sketchPath(""), "Projector" }, projector);
And w/ some tiny modifications, like changing displayWidth to screenWidth, the same sketch works even in Processing 1!