We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm wondering how you can make the window contain (for example) 640x480 pixels, but be able to stretch to set sizes (and resolutions) like 1920x1080, 1600x900, 1366x768, 1280x768, 800x600 etc. This feature is seen a lot in games where you have configuration options to change the game resolutions (as well as choose between fullscreen and windowed).
I know how to resize the window normally by calling the setup() function again with different values for size, but this changes the number of pixels being worked with and will not stretch the window and its contents. Also, because it changes the number of pixels, large chunks of my programs may start to produce unwanted and/or unpredictable results unless I program using percentages of the screen rather than absolute pixel values, this can become tedious and sometimes plain unfeasible.
Thank you for your time!
Answers
If you use Processing's drawing functions, you can use
scale()
- however, if you use per-pixel operations (loadPixels()
, etc.), this won't work...Yup, that's a problem which I want to avoid..
You can do everything in a PGraphics (or PImage if you only do pixel operations) that is 640x480 and just stretch-draw that to the sceen, regardless of how big the screen is. Then your canvas is of constant size, namely 640 x 480.
Just an extra. I've heard about that smooth() influences the resizing quality.
For JAVA2D, use
smooth(4)
. For the OPENGL 1s, try outsmooth(8)
. :-jThanks everybody! The PGraphics solution seems like the way to go, I looked through some old forum posts and saw that you could have PImages within the PGraphic using the .image() function on the PGraphic and passing the PImage variable name to it, so now I don't have to worry about image files I load into my program! Will look into PGraphics more, I've never really used it before