benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.35k stars 237 forks source link

pixelDensity(2) in P2D/P3D makes sketch run at scaled down 1/4 the windows size outside Processing IDE #763

Closed gabrielsalvador closed 1 year ago

gabrielsalvador commented 1 year ago

When not using the processing IDE, thus creating a sketch by extending the PApplet class in inteliJ, when I try to run the sketch at a higher pixel density I get this:

Screenshot 2023-08-04 at 00 11 54

Also it outputs the following to the console: "The sketch has been resized from 1280x820 to 640x410 by the operating system. This happened outside Processing, and may be a limitation of the OS or window manager."

I'm on macOS 13 on apple silicon and i'm using the version 4.3's jars downloaded from the website.

I am willing to investigate and work out a fix for this, I just need some guidance as I'm not familiar with the code base.

knupel commented 1 year ago

I'm not a specialist of IntelliJ. Are you set the rendering or displaying in IntelliJ or in Processing ? Because if you set the size out of the Processing, maybe Processing don't know this information. I remenber I had a similar problem when I play with the shader and the PGraphics... to solve I just multiply my size by pixelDensity... Are you ask on the forum?

gabrielsalvador commented 1 year ago

I'm not a specialist of IntelliJ. Are you set the rendering or displaying in IntelliJ or in Processing ? Because if you set the out the Processing, maybe Processing don't know this information. I rembemeber I hade a similar probleme when I play with the shader and the PGraphics... to solve I just multiply my size by pixelDensity... Are you as on the forum?

i'm doing this:

public class Sinesthesia extends PApplet {
    public static void main(String[] args) {
        PApplet.main("me.gabrielsalvador.core.Sinesthesia");
    }

    public void settings() {
        size(1280,820, P2D);
        pixelDensity(displayDensity());
    }
            .
            .
            .
}

I'm not on the forum, should I be?

knupel commented 1 year ago

for the forum go to https://discourse.processing.org/ it's a good place for discussion or coding problem. Here it's for the bugs or improvement of core code.

About your code when I read pixelDensity(displayDensity()); that's smell weird. Because you try to pass the current displayDensity() to the function pixelDensity(int arg); try to println(displayDensity()) before and after, to see something change. I think no, I suppose the result return 2 in both of case.

public void settings() {
        size(1280,820, P2D);
        println(displayDensity());
        pixelDensity(displayDensity());
        println(displayDensity());
    }

Look https://processing.org/reference/pixelDensity_.html for more detail

benfry commented 1 year ago

As @knupel mentions, this is a better discussion for the forum until there's an actual bug identified. I haven't seen this when I build apps in IntelliJ and cannot support every configuration that might be in place.

As for things to try, I'd look into whether calling System.setProperty("sun.java2d.uiScale.enabled", "false"); (or setting to true) before calling PApplet.main() does anything, or System.setProperty("sun.java2d.uiScale", "2") (or 1) and see if you can get the results you want.

gabrielsalvador commented 1 year ago

this fixed it

As @knupel mentions, this is a better discussion for the forum until there's an actual bug identified. I haven't seen this when I build apps in IntelliJ and cannot support every configuration that might be in place.

As for things to try, I'd look into whether calling System.setProperty("sun.java2d.uiScale.enabled", "false"); (or setting to true) before calling PApplet.main() does anything, or System.setProperty("sun.java2d.uiScale", "2") (or 1) and see if you can get the results you want.

benfry commented 1 year ago

Which exact setting fixed it?

gabrielsalvador commented 1 year ago

Which exact setting fixed it?

System.setProperty("sun.java2d.uiScale.enabled", "false");