Why are sketches larger with the Default Renderer than with P2D? Should I be concerned?

Hello,
Beginner question, not sure what is happening. Or which size is correct.
If I don’t include P2D, the sketch appears much larger.
Is this normal? Or is there a setting somewhere I need to address?

Processing 4.04b4
Windows 10, RTX 2080Ti, 3840 x 2160 monitor.


It doesnt happen to me. Try calling println(displayDensity()); or something, that would tell you, how do the 500x500 pixels fit within that window.

Hmmm… They both say “2” with println(displayDensity())
Any other thoughts? Is this bad?


Well, you have a high-dpi screen. That might be the thing. displayDensity() just returns 2 if you have a high-dpi screen or 1 if you don’t. (displayDensity(), PApplet.pixelDensity())
Try to run the same sketch on a 1080p monitor. These are my results on my 1920x1080 screen:


If you don’t specify a renderer in the size(width, height) method, the default renderer will be chosen, which is JAVA2D. (PApplet.createGraphics(), PApplet.size())

You can also try size(500, 500, FX2D), see what happens. (size())
You can try println(width, height) or save("path") to see, what the PApplets PGraphics really is.
You can also experiment with pixelDensity(density) and println(sketchPixelDensity()) , (pixelDensity(), PApplet.sketchPixelDensity())

There are many bugs with Processing 4 and sketch windows, so this might be one of them. One bug that happened to me is with surface.setResizable(true), where when you try to resize the sketch window, it throws an error or just simply freezes.


You are better off still using Processing 3 and its outdated Java 8 (or whatever it uses) until most of the bugs are fixed.

1 Like

Sounds good. I can stick with 3 until i understand what’s happening!
Thank you.