Currently having an issue with exporting a Processing-Application I developed.
So, (I know, bad practices), I hardcoded all the pixel values and now I added the pixelDensity(displayDensity()); line to work with my Hi-DPI display (else it’s tooo small).
When running it using the bin processing-java, it works. When running it from the application itself, it works. But if I export the application and run it through the executable it doesn’t. Neither have I found a solution, nor anything about it on the internet, so I thought maybe somebody here knows what’s going on.
Thanks for the reply, I checked and when running it through Processing or the executable it properly shows 2, when running it through the exported application is falsely shows 1.
// processing/core/src/processing/core/PApplet.java
public int displayDensity() {
if (display != SPAN && (fullScreen || present)) {
return displayDensity(display);
}
// walk through all displays, use 2 if any display is 2
for (int i = 0; i < displayDevices.length; i++) {
if (displayDensity(i+1) == 2) {
return 2;
}
}
// If nobody's density is 2 then everyone is 1
return 1;
}
/**
* @param display the display number to check
*/
public int displayDensity(int display) {
if (PApplet.platform == PConstants.MACOSX) {
// !! Not interesting in this case, removed it ;) !!
} else if (PApplet.platform == PConstants.WINDOWS ||
PApplet.platform == PConstants.LINUX) {
if (suggestedDensity == -1) {
// TODO: detect and return DPI scaling using JNA; Windows has
// a system-wide value, not sure how it works on Linux
return 1;
} else if (suggestedDensity == 1 || suggestedDensity == 2) {
return suggestedDensity;
}
}
return 1;
}
And also if you wonder where does the suggestedDensity variable comes from (inside the runSketch method) :
// Set the suggested density that is coming from command line
// (most likely set from the PDE based on a system DPI scaling)
sketch.suggestedDensity = density;
So if we suppose that one of fullscreen or present variables is true then it’s calling the displayDensity() method with the index of the display (it’s the same if not, it’s checking every screens).
In that function it checks if running on OSX or Linux / Windows. In our case it’s Linux so we check again if the display density is equal to -1 which is true if you didn’t pass the --density argument to the executable so it returns 1!!