Author Topic: screen size  (Read 3312 times)

0 Members and 1 Guest are viewing this topic.

Offline Donald Foster

  • Newbie
  • Posts: 63
    • View Profile
screen size
« on: January 17, 2021, 10:14:43 am »
Hello all,

For those who has a 15.5" or 15.6" laptop, what is the max width and height screen size to use in _newscreen () and still properly fit on the screen?

Thanks, Donald

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: screen size
« Reply #1 on: January 17, 2021, 10:32:18 am »
_DESKTOPWIDTH and _DESKTOPHEIGHT
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Donald Foster

  • Newbie
  • Posts: 63
    • View Profile
Re: screen size
« Reply #2 on: January 17, 2021, 11:31:38 am »
Thanks Steve,

I haven't had a 15.6" laptop in years. I use a desktop and my wife has a 17" laptop. I need the know max number of pixels that will fit across a 15.6" laptop. So when I write a game, It will fit on your screen. I previously made a game, Doubles Wild, that would not fit on some of your screens properly. I will will use a Full Screen option for those with larger monitors.

Thanks, Donald

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: screen size
« Reply #3 on: January 17, 2021, 11:46:53 am »
The best way to want compatibility on different displays is not to hard set the position in pixels of the various graphic buttons. Determine their position as a percentage. Then everything will always be where it should be, regardless of the screen size.

Offline Donald Foster

  • Newbie
  • Posts: 63
    • View Profile
Re: screen size
« Reply #4 on: January 17, 2021, 12:22:10 pm »
Never mind, I will set it for 1200 x 738, that should fit. I really needed to maximize the width, so I can fit everything in.

Thanks, Donald

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: screen size
« Reply #5 on: January 17, 2021, 12:49:16 pm »
Never mind, I will set it for 1200 x 738, that should fit. I really needed to maximize the width, so I can fit everything in.

Thanks, Donald

What you might want, Donald, is to implement a scale factor to your program, such as this below:

Code: QB64: [Select]
  1. CONST WorkEnvironmentMaxX = 1920, WorkEnvironmentMaxY = 1080
  2.  
  3. SCREEN _NEWIMAGE(ScaleX(1024), ScaleY(720), 32)
  4.  
  5. PRINT "Program Size, Scaled is:"; ScaleX(1024), ScaleY(720)
  6. PRINT "The center of the program window is at: "; ScaleX(512), ScaleY(360)
  7. CIRCLE (ScaleX(512), ScaleY(360)), ScaleX(5), -1 'And here's a circle in the center (which in this case assumes the screen changed by the same ratio, or else I'd need to use an ellipse here to keep the image perfect.)
  8.  
  9.  
  10.  
  11. FUNCTION ScaleX (P AS INTEGER)
  12.     ScaleX = P * _DESKTOPWIDTH \ WorkEnvironmentMaxX
  13.  
  14. FUNCTION ScaleY (P AS INTEGER)
  15.     ScaleY = P * _DESKTOPHEIGHT \ WorkEnvironmentMaxY

Set the two work environment CONST to whatever the resolution is on the machine you're writing the code on, and then reference your X/Y variables after scaling them.  This type of approach should work really well for you, if you're using LINE and _PUTIMAGE for your graphics, but it might need a little tweaking with CIRCLE, as you're not guaranteed that the end user has the same screen ratio as you do.  If you want to account for that type of situation, then you'll want to use two screens (one to work on, the other to scale and fit the current display settings), or else you'd want to use ellipses so you can scale them on both the X and Y axis to fit perfectly. 

Try the above out on your system and see how it works for you.  Then change your screen resolution, and watch how the values scale to keep things in perspective.  You'd write the program using the coordinates that fit your native resolution, and just use ScaleX, ScaleY to let them adjust to whatever screen the end-user has available.  It's really about that simple.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Donald Foster

  • Newbie
  • Posts: 63
    • View Profile
Re: screen size
« Reply #6 on: January 17, 2021, 01:28:58 pm »
Thank you Steve on the information on scaling. That is all new to me and I will study it and try ti implement it sometime time.
I originally used the screen size of 1024 x 728 on my 15.6" laptop because I knew the window would fit on a CRT monitor. However, most people are using laptops and when I created a window _NEWIMAGE(1024, 728, 256) and moved it to the left side of the screen, I have a lot of empty space on the right side. What I'm trying to find out is what number can I substitute 1024 that will stretch the window across to the other side? I don't have a 15.6" laptop to try numbers with. If I set it to 1200 and 1248 would had fit, I needed to know that. I don't want make a game that is too wide for their screen, even though FULL SCREEN may fix their problem, but they my end up with extra space at the top and bottom of the screen. I don't want any of my graphics stretched or distorted.

Thanks Donald

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: screen size
« Reply #7 on: January 18, 2021, 12:13:03 am »
@Donald Foster

If I may add my 1⅞ cents worth...



Still keeping in mind ALL of what is said above - you may wish to consider reading the link below:-


https://docs.microsoft.com/en-us/windows/win32/win7devguide/high-dpi?redirectedfrom=MSDN


On my laptop (15"), which has a native resolution of 3200x1800, initially (a year ago) I had all sorts of trouble in that many applications (QB64 included) ended up tiny (as if those applications were programmed using pixel numbers from say HD screens). My display is classified as a Q3 - sort of saying 3K. Many PC laptops already have 4K and newer high quality MACs, if I understand correctly, have high Retina displays (???). Already there is talk about 8K TV displays so I would expect 8K computer displays will soon follow.

Despite wishful suggestions from many, things like "Scaling" just did not work (still had  ⅖ size fonts displayed etc) - eventually was all sorted out (related to High DPI settings - and in this regard "scaling" was of NO use at all on my system Windows 10 x64).

You may wish to keep in mind that those with high DPI settings (>144) may have problems (tiny screens instead of full screens) with your programs - simply because they may not adjust settings on their computers individually to your program requirements. Scaling may not help them either.

As a side note - I recently noticed on my laptop (with appropriate HDPI settings for QB64), where 99.99% of QB64 programs I write are "launched" from the QB64 IDE, that when I ran the .exe program by itself (i.e. no QB64 IDE) the program display screens are yet a DIFFERENT size again (in fact bigger so font size might be ⅞ instead of ⅖ and therefore much more pleasant to work with) - eventually I will try to sort the difference out to be automatically adjusted (to maintain consistency between IDE mode AND pure exe mode) but I suspect that I will have to configure individually for EACH exe)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: screen size
« Reply #8 on: January 18, 2021, 12:11:54 pm »
Hello all,

For those who has a 15.5" or 15.6" laptop, what is the max width and height screen size to use in _newscreen () and still properly fit on the screen?

Thanks, Donald

My 15.5+ diagonal laptop screen reads 1380 x 768 for _DESKTOPWIDTH and height.
I keep my Toolbar on the left side to give me maximum drawing height to screen and title bar takes 20-40 s.t
1280 x 720 fits bigger windows and leaves access to toolbar and Exit on Title bar.

Those are figures you asked for but obviously people put toolbars at different locations and are willing to go without on _FULLSCREEN.

You can design a window small enough to fit any screen and then scale x and y independently so there is NO distortion when you stretch a window into a larger screen. I did that with Android apps for SmallBASIC that you could view screen either in landscape or portrait view, it's a pain but it is possible to make something that translates without distortion.


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: screen size
« Reply #9 on: January 18, 2021, 12:29:42 pm »
Screen size has became a complicated thing to sort out with modern OSes.  I just purchased an Alienware laptop which is running at 3840x2160 resolution, but it has a windows scale factor of 200%, so QB64 reads and reacts to it as a 1920x1080 resolution!

Kind of makes me wonder what the heck the use is, to have a 4k display, when DPI is scaled 200+ percent, by default.  But, of course, if you don’t scale your display in such a manner, the 16pt text is so damn tiny that you’ll need a magnifying glass to read and interact with it!

There comes a point, in my opinion, when enough is enough with screen size.  There’s absolutely no good reason for a 15in laptop to run at 4k, or higher, resolution, unless you’re duplicating the display on an 80in television!
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!