06-07-2024, 08:05 AM
(06-07-2024, 04:37 AM)TerryRitchie Wrote: Is there a reason why _WIDTH and _HEIGHT can't update when the screen size changes? Why the need for separate _RESIZEWIDTH and _RESIZEHEIGHT?
Try this:
Code: (Select All)
SCREEN _NEWIMAGE(640, 480, 32) 'let's set the screen to a nice size that we know exactly what it'll be
_DELAY .5 'make certain everything has time to do its stuff
PRINT _WIDTH, _HEIGHT, _RESIZEWIDTH, _RESIZEHEIGHT 'now, all these numbers should match.
SLEEP 'give you time to check the screen to make certain they do
_DELAY .2
_KEYCLEAR
$RESIZE:SMOOTH
DO
CLS
PRINT "Grab any corner and drag the screen to resize it, please!"
PRINT _WIDTH, _HEIGHT, _RESIZEWIDTH, _RESIZEHEIGHT
_LIMIT 30
_DISPLAY
LOOP UNTIL _KEYHIT
Now, as you can see when you grab the corner of that window and drag it, the _WIDTH and _HEIGHT don't change. Your SCREEN is still 640 x 480 pixels in size -- but look at the SIZE of those pixels! If you drag the screen to 1280 x 960, those pixels are all now TWICE as large as they were before.
The _WIDTH and _HEIGHT of the SCREEN didn't change.
The _RESIZEWIDTH and _RESIZEHEIGHT of the WINDOW did.
Two completely different things. One relates to the SCREEN coordinates. The other relates to the WINDOW size.
Now, try it with $RESIZE:ON
Code: (Select All)
$COLOR:32
SCREEN _NEWIMAGE(640, 480, 32) 'let's set the screen to a nice size that we know exactly what it'll be
_DELAY .5 'make certain everything has time to do its stuff
PRINT _WIDTH, _HEIGHT, _RESIZEWIDTH, _RESIZEHEIGHT 'now, all these numbers should match.
SLEEP 'give you time to check the screen to make certain they do
_DELAY .2
_KEYCLEAR
$RESIZE:ON
DO
CLS , White
PRINT "Grab any corner and drag the screen to resize it, please!"
PRINT _WIDTH, _HEIGHT, _RESIZEWIDTH, _RESIZEHEIGHT
_LIMIT 30
_DISPLAY
LOOP UNTIL _KEYHIT
Run the above, get to the white screen, and then grab a corner and drag.
Your screen stays the same size of 640 x 480. It never changes.
If you grab the right corner and drag it to the right, the _RESIZEWIDTH will increase, and there'll be a black gap of nothing to the right side of your program screen (kinda like the black bars you often see on TVs when a 16:9 widescreen show tries to show on a 4:3 old standard TV).
Resize:On requires the programmer to decide what to do with things manually. Do you want to stretch the pixels like RESIZE:STRETCH does? Do you want to resize the program to fit the new Window, like the QB64PE IDE does? Do you want to maintain aspect ratio, like most video players would? Or can you just drag one side to make the screen wider, without affecting the height?
Your program SCREEN and thus its WIDTH and HEIGHT doesn't change one bit, until you manually process and decide what to do with that _RESIZE event.
And it's _RESIZEWIDTH and _RESIZEHEIGHT that gives you the information back so you can do that.