I’m switching again and again from my home station with multiple screens to my laptop… At home, I use the fullScreen(3) option, but working on my laptop screen I mostly use size(640,360).
Rather than always comment/uncomment lines, I’d like to add a statement in setup() —or maybe settings() — to decide by itself…
How could I get informations on the display configuration to do this ?
It’s a really small issue, I know, but it bother me anyway…
Are you using the Processing IDE or some other tool?
The problem with looking at displayWidth/displayHeight is that fullScreen(…) / size(…) must be the first line in setup(). So you can’t do much there unless you evaluate a function or variable in there. You can’t pass width, height parameters to fullScreen and unless you want not to use fullScreen you shouldn’t use size(…) in Processing 3.x apparently.
You might be better off just leaving the fullScreen call the same and just changing which display to use in preferences. I don’t know how else Processing would have any idea which of the displays you want to run the sketch on at the moment.
Using this, I’m able to set the location of the draw window in laptop only mode, so that it doesn’t overlap the editor and then, my issue is fixed…
… BUT there’s still things I don’t understand. Unplugging my third screen, I got these lines in my console :
Display 3 does not exist, using the default display instead.
Display 1 is sun.awt.CGraphicsDevice@5649fd9b
Display 2 is sun.awt.CGraphicsDevice@6adede5
It looks to me that if Processing can retrieve these informations, there should be a way for me to get and use them, no ?
There’s a difference between Java (and indirectly, Processing) knowing what displays exist and knowing which one you want to use. It might be possible to call a function inside size() or fullScreen() if you could work out what that function should do, but it needs to be able to do so without any input.
Not sure if stuff in setup can safely use pre-defined variables, but if you always use the same screens you could create some kind of mapping from pre-defined sizes to the display you think it. That would be useless for production, so to speak, but fine for development purposes.
It can’t – at least, size() in setup() can’t – but that is what settings() is for.
The settings() function is new with Processing 3.0. It’s not needed in most sketches. It’s only useful when it’s absolutely necessary to define the parameters to size() with a variable. settings() / Reference / Processing.org