1

After many years with Processing IDE, I missed Intellij IDEA too much so I went back for it but Processing stays on :wink:

However, the shapes drawn are way less sharp than in the real PDE, for example, a simple circle is rendered differently using both time the latest version of Processing available 4.1.2, Java 17, the same PC and the same monitor :

In PDE :

public void setup() {
    size(500, 500);
}


public void draw() {
    background(40);
    noStroke();
    fill(255);
    circle(width/2, height/2, 400);
    saveFrame("./PDE.png");
    noLoop();
}

and the result is :

saveFrame() or direct view using Processing IDE

With Intellij however :

import processing.core.PApplet;

public class Main extends PApplet {

    public void settings() {
        size(500, 500);
    }


    public void draw() {
        background(40);
        noStroke();
        fill(255);
        circle(width/2, height/2, 400);
        saveFrame("Intellij IDEA.png");
        noLoop();
    }
    public static void main(String... args) {
        Main pt = new Main();
        PApplet.runSketch(new String[]{"testRendering"}, pt);
    }
}

the saveFrame() is exactly the same as with Processing IDE but the real view in the sketch is :real view in the sketch with Intellij

I guess that it is a problem of renderer but I can't change it using fullScreen(P2D) for example because it throws errors. The only solution I found were using Maven but I am not so I'd rather find a solution for my problem.

Grusat
  • 43
  • 8
  • Check if You have 1.25 UI scalling in Windows Screen Settings? – Mruk Feb 04 '23 at 11:47
  • @Mruk I don’t have the problem with the processing’s IDE either…I guess the screen settings aren’t in fault – Grusat Feb 04 '23 at 13:58
  • 1
    Processing's IDE is ignoring global Windows settings. Just make a test how it is in Idea and write the conclusion for us. – Mruk Feb 04 '23 at 14:18
  • Ok I didn’t know that ! I will try it, I just assumed it wasn’t that because the 2 images are of the same size although one was taken through Intellij and the other with Processing’s IDE – Grusat Feb 04 '23 at 14:42
  • I have indeed the 1.25 UI scaling in Windows and putting it at 100% makes the anti-aliasing work ! However would it be possible to put 100% only in Intellij and not affect the rest of my Windows ? – Grusat Feb 04 '23 at 15:51
  • By the way - Where in the Project Structure did You import processing.core? – Mruk Feb 05 '23 at 08:51
  • 1
    I imported the Processing/core/library in the libraries tab of the project structure, everything compiles and the import in my code is well recognized – Grusat Feb 05 '23 at 09:26
  • OK, here is working solution for Your question: -Dsun.java2d.uiScale=1.0 (https://stackoverflow.com/a/48623068/4885365) – Mruk Feb 05 '23 at 14:03

1 Answers1

3

This problem arises because the window is being scaled (according to windows scaling settings) but its content is not rendered in a higher resolution (hence the "jaggies").

It's a problem only with the default (Java AWT) renderer. To fix it:

  • Call System.setProperty("sun.java2d.uiScale", "1") before PApplet.runSketch() -- this will prevent the window from being scaled.

An alternative solution is to use the JavaFX renderer (size(500, 500, FX2D)), which seems to behave correctly (the content renders at a higher resolution).

If however high DPI scaling is not desired with the FX2D renderer, you can call System.setProperty("prism.allowhidpi", "false")to disable it.

micycle
  • 3,328
  • 14
  • 33