Processing in Java: canvas size + image cleanup

How can I make my processing canvas in a Java project run/look exactly like it does when I use the processing IDE for this project?

I’m using P4 beta (I also get this issue with P3) as graphics library for a java project I’m working on. The issue is that when I’m using the processing IDE the canvas size, say 800x800 looks great and it appears as though there’s some clean up and image processing going on. However, when I’m not using this IDE and running in java it looks like garbage and the image is huge.


Are you running P3 or P4 on a high resolution display, like 4K?

You may want to do some tests with the displayDensity() as it may be upscaling graphics and then looking poorly.

Best wishes

PS: Remember not to bite your nails…

I think it’s a 1080p laptop. But I’m absolutely going to try displayDensity(), thank you for the refrence!

pixelDensity(2) is not applicable to my display unfortunately. I’m thinking there’s some setting the Processing IDE applies where it downscales everything to make it look nicer (like supersampling or downsampling the buffer is what I believe is happening).

For example, without the P4/P3 IDE and using java, 800x800 is huge, but 800x800 in the P4/P3 IDE is a great size, looks like it’s actually 600x600 on my display, and everything is smooth but not blurry. Here are some pictures to demonstrate the issue:

This was generated in the Processing IDE

This was generated with java using P4 as a GL

Please share your code as this will allow the community to debug with you further.

1 Like

Not necessary, just figured it out.

For some reason, the default processing renderer (a.k.a size(x,y); type calls) gives dense pixels.
when you pass the P3D renderer to size, it gives the same results as if I were programming in the P4 IDE.

Thanks for your engagement!

If anyone finds this thread with the same issue, make sure you make a “natives” folder in your project folder, then copy the “os-processor64/32” into natives. So for me, right in my project folder I have this: natives\windows-amd64
where windows-amd64 is copied directly from processing 4’s core\library

then I got a an openGL context and used GL2 for my project instead, bascially boosted it off of processing so I don’t have to deal with the backend management and just go put pixels on the screen (the only drawing is done with GL.POINTS in one method)

tldr: P3D good (with GL2), default renderer bad

If you’re curious to see the project though I’ll post a link when it’s done/released

1 Like