Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Nvidia screen size and Struggling with code from a tutorial here on TGC forum

Author
Message
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 7th Dec 2021 01:15 Edited at: 7th Dec 2021 01:29
Hi,

I'm trying to learn form the tutorial in AppGameKit forum on detecting and setting screen sizes for different devices. I'm currently just trying to detect mine and set it in the program. In the following code I am not running the tutorial code as it is remed out. Part of it didn't work on my system anyway. Instead of 2 colors I needed 3 in the DrawLine() command for it to work.
All images won't load with link so they are at the bottom

Anyway with this code:


I get this set of numbers for my boarders:
ScrLeft -17
ScrTop 0
ScrRight 117
ScrBtm 100

With this code I get these boarders:


I get these boarders:
ScrLeft -39
ScrTop 0
ScrRight 139
ScrBtm 100
This is what i found my Nvidia Geforce GTX 1080 8GB set to. The 144mhz is just the max it can go. It is currently set to 60mhz. Installation set it to this by default.
Image at bottom

I'm not sure what to do. Not sure about code or setting graphics card to "Full Screen" or leave it at "Ratio" I just want to get my proper full screen boarders Currenly set at 1080p, 1920x1080
Any help on how to deal with graphics settings or code would be greatly appreciated
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.

Attachments

Login to view attachments
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 7th Dec 2021 01:53 Edited at: 7th Dec 2021 01:54
Ratio @ 60mhz should be fine.

if you use SetDisplayAspect(-1) it will use the full screen

Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 7th Dec 2021 02:13
Quote: "
if you use SetDisplayAspect(-1) it will use the full screen"


Thank you PartTimeCoder it worked, I have been fighting with this full screen thing for awhile. I'm starting to understand it better now
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 7th Dec 2021 02:49 Edited at: 7th Dec 2021 04:06
It worked to some degree, but the green line should be showing up at the right edge shouldn't it? If I leave the "-1" in the code the green line on right side is not on the edge, it's in a little. If I rem the "-1" out the green line disappears. Is there any way to get the line to appear at the edge and not in a little bit?




Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 7th Dec 2021 04:07 Edited at: 7th Dec 2021 04:08
I have figured out that the following code gets the line to appear on or really near the edge

Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
ando
4
Years of Service
User Offline
Joined: 21st Feb 2020
Location: Australia
Posted: 7th Dec 2021 04:45
Looks like you got it figured.
I'm just curious if it would help to use floats for width and height because it solved a problem I had.

BASIC appeared in May 1964. Lightning flashed, the wind roared and the Earth moved.
And nine months later I was born.
So here I am.
I am Basic.
Code is in my genes.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 7th Dec 2021 08:33
Quote: "I have figured out that the following"


Yeah your right, my bad, using aspect uses the percentage system so screen size is always 0 to 100 but GetMax* return real resolution values, soz, it was late! lol
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 7th Dec 2021 10:03 Edited at: 7th Dec 2021 12:52
Hi,
Which tutorial are you trying to follow?
Is it the one I wrote?
Here: https://forum.thegamecreators.com/thread/225869

The code looks familiar, so I suspect you may be.
The reason the Draw commands don't work is because in the time since I wrote that, TGC have updated AppGameKit to allow the use of alpha channels in the draw commands. It's a great update but it breaks any code created before the update.
The fix is to place FF after 0x in the colour definition to state that you want full opacity. (the order is Alpha, Blue, Green, Red)
For example:
The hexadecimal for full green in the old system was 0x00FF00 (no blue, full green, no red)
Now it is:
0xFF00FF00 (full opacity, no blue, full green, no red)

Of course, you don't have to use hexadecimal at all. You could use the MakeColor() commands instead.

So, the first bit of code you were trying but couldn't get to work should now read:

I have updated the original tutorial to reflect the changes TGC made when they updated AGK's draw commands.

As for the lines at the edge being slightly in from the edges, that's because they are being drawn at one 'unit' in. Since we are using the percentage system that is one percent of the screen width (which increases in size as the screen width increases).
You could insert it it by a floating point amount to get it closer to the edge but if you stick with drawing directly at the screen bounds they will run along the edge of the screen - just off it. That's because we're using integers in a floating point environment. Admittedly, not the best example to use in a tutorial!

If you really want to draw a line directly along the edge of the screen then you need to use floats in your calculations and you need to determine the size of the pixels used on your device, then offset the edge by the pixel width.
Like this:


Give me a shout if you have any other questions
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 7th Dec 2021 18:12
Yes it is your tutorial I'm working with. Holly cow lol I didn't know you could actually figure out the size of a pixel. I'll give this a try after work and post back how it went. I need to get this screen stuff down.
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 8th Dec 2021 03:51
I'm starting to understand it I think I know that the screen AppGameKit creates is 100x100 even if I set the window size to say... 1920x1080 and setting SetDisplayAspect(-1) it is still 100x100.

So I load an image which definitely needs to be a lot bigger than 100x100 to show up correctly or close as possible after the sprite is scaled down to 100x100. The issue is to figure out what size of image to create for full screen without it stretching along the X axis. Can you get the image for full screen on pc/mac to display without stretching or is that only possible with a window? For full screen I know there is math involved and I'll have to learn that lol
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 8th Dec 2021 09:00
You can not have a variable screen size and not stretch an image, there has to be some resizing going on, what most games do is use image sizes to suit 720p, 1080p, 2k, 4k etc ..... and load in the set that suites the users res and aspect this minimizes the image distortion when scaling a 1920x1080 to a 4k screen ....

yeah I know, hassle! for a hobby game I would not bother with all that

if you want your images to remain the same size they are in your image app then yes, you must use a static non resizable window

also, setting SetImageMagFilter, SetImageMinFilter to 0 can help avoid blurring in some cases (0 sets pixel mode)
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th Dec 2021 10:38 Edited at: 8th Dec 2021 10:44
There's an old adage that you can't fit a square peg into a round hole. The same is true for images; you can't fit a square image into a rectangular window without stretching it.

If you want a full screen image to be represented on any screen without stretching then as PTC says, you will need to make a number of images for each possible screen.
That might sound very daunting at first because there are very many different sizes of screen available. However, it's not the screen size that you need to be concerned with but the aspect ratio (width/height) and for that there are far fewer to choose from.
The most common is 16:9 which is the aspect ratio of HD TV's (1920x1080 is 16:9)
Many new phones are now extending that to 18:9 (which is the same as 2:1 but nobody ever calls it that - twice as wide as it is high).
Then there are slight variances on that: 18.5:9 19:9, 16:10, 17:9 etc.
And of course, Apple have to be different and do things "Their way" which means that iPads all have an aspect ratio of 4:3 which is a real pain in the apps for developers!

How many of those you want to cater for is entirely up to you. You could just make one image and let it stretch to fit or make many images and let the app choose the one that fits best. I find you can generally get away with just two or three depending on how exact you need it it be.
You definitely need a 16:9 image because that is the most popular and if you are developing for Apple then you will also need a 4:3 image. Beyond that is personal preference, there's only minor stretching from 16:9 to 18:9 but it might be noticeable (depending on the image) but it's very unlikely you'd notice any stretching form 18:9 to 18.5:9.

The only way to be sure is to experiment. Simulate different devices by changing the window size with SetWindowSize() and decide if it needs it's own image for that aspect ratio.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 8th Dec 2021 12:34 Edited at: 8th Dec 2021 12:35
Quote: "There's an old adage"


Not without some *distortion*



Quote: "So I load an image which definitely needs to be a lot bigger than 100x100 to show up correctly"


No, 100x100 is the full screen in percent, if you want the image fullscreen when using aspect set it to 100x100, when using aspect forget pixels, think in percent %%%%

or, convert the numbers so you can work in pixels and use %%%%
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th Dec 2021 13:33 Edited at: 8th Dec 2021 13:34
From your initial post it seems you are trying to get things to look the same on every device. So you need to avoid using SetDisplayAspect(-1) because that will do the opposite of what you are trying to do! Instead use SetDisplayAspect(1) to give you square pixels (as stated in my tutorial).
The help files for SetDisplayAspect() clearly describe the problems with using SetDisplayAspect(-1)
Quote: "Use an aspect ratio of -1 to use the device aspect ratio (fills the whole screen without black borders, but will cause stretching and look different on every device) An alternative method of filling the screen which avoids this problem is to use SetScissor with the values 0,0,0,0."


Quote: "100x100 is the full screen in percent"

Not if you are doing it properly it isn't. If you are following my system so that it is correct for all screen sizes then 100x100 is a square in the middle of the screen.

If you want to create an image that fills the screen without stretching, then you need to create an image suitable for that aspect ratio.
For example: An HD screen (16:9) You could create an image that is 1920x1080 and it will fill the screen without stretching. However, you can also create an image half that size (960x540) and it will still fill the screen without distortion but will have the pixels magnified (four pixels for every one) which might be ok depending on the type of image you are using. If it's a space background with stars and nebulae (for example) then you could probably get away with a much small image (480x270).

But making your image 100x100 will distort it no matter what screen display system you are using
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 8th Dec 2021 14:45
Do you know if there is a one size fits all screen resolution that *most* monitors are capable of supporting? (desktop only)

Also is the display aspect dependent on the resolution or the physical screen size ...

Years ago games would just set the screen resolution they required and set it back when its done and its done from a single function call "ChangeDisplaySettingsEx" and available monitor modes can be retrieved with "EnumDisplayDevices", I wrote a plugin for another program back in Windows7 for this stuff but it seems to have become defunct over the years and I am wondering if that is because of the array of physical screen sizes available today its just easier to use a system like yours..

I have half a dozen or so various size old monitors hanging around here I might have a test with this later if I can find all the leads lol
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th Dec 2021 14:59 Edited at: 8th Dec 2021 15:13
Quote: "Do you know if there is a one size fits all screen resolution that *most* monitors are capable of supporting? (desktop only)"

That depends if you are talking about windowed mode or full screen. If windowed mode then any window smaller than the smallest available should do. (640x480 was the go-to safe option for many years)
If full screen then there's no telling what you might be faced with (tiny laptop vs ultra-wide wrap around).

Quote: "Also is the display aspect dependent on the resolution or the physical screen size"

It's the same thing.
It's width/height in landscape (or height/width in portrait). It makes no difference if you are windowed, full-screen or on a mobile device. It doesn't matter if you are counting the number of pixels or the physical dimensions measured in cm, inches or the average length of the common field mouse, it's still width/height
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 9th Dec 2021 01:34
Quote: "You can not have a variable screen size and not stretch an image, there has to be some resizing going on, what most games do is use image sizes to suit 720p, 1080p, 2k, 4k etc ..... and load in the set that suites the users res and aspect this minimizes the image distortion when scaling a 1920x1080 to a 4k screen ....

yeah I know, hassle! for a hobby game I would not bother with all that

if you want your images to remain the same size they are in your image app then yes, you must use a static non resizable window

also, setting SetImageMagFilter, SetImageMinFilter to 0 can help avoid blurring in some cases (0 sets pixel mode)"


I am going to try those 2 commands out tonight or tomorrow. I will post back.


Quote: "There's an old adage that you can't fit a square peg into a round hole. The same is true for images; you can't fit a square image into a rectangular window without stretching it.

If you want a full screen image to be represented on any screen without stretching then as PTC says, you will need to make a number of images for each possible screen.
That might sound very daunting at first because there are very many different sizes of screen available. However, it's not the screen size that you need to be concerned with but the aspect ratio (width/height) and for that there are far fewer to choose from.
The most common is 16:9 which is the aspect ratio of HD TV's (1920x1080 is 16:9)
Many new phones are now extending that to 18:9 (which is the same as 2:1 but nobody ever calls it that - twice as wide as it is high).
Then there are slight variances on that: 18.5:9 19:9, 16:10, 17:9 etc.
And of course, Apple have to be different and do things "Their way" which means that iPads all have an aspect ratio of 4:3 which is a real pain in the apps for developers!

How many of those you want to cater for is entirely up to you. You could just make one image and let it stretch to fit or make many images and let the app choose the one that fits best. I find you can generally get away with just two or three depending on how exact you need it it be.
You definitely need a 16:9 image because that is the most popular and if you are developing for Apple then you will also need a 4:3 image. Beyond that is personal preference, there's only minor stretching from 16:9 to 18:9 but it might be noticeable (depending on the image) but it's very unlikely you'd notice any stretching form 18:9 to 18.5:9.

The only way to be sure is to experiment. Simulate different devices by changing the window size with SetWindowSize() and decide if it needs it's own image for that aspect ratio."


Thank you, I will definately do some experimenting on ratios. I will be supporting PC, Android, MacOS and iOS

Quote: "I'm just curious if it would help to use floats for width and height because it solved a problem I had."


Thank you, yea I will switch the variables to floats. I will post back

Quote: "No, 100x100 is the full screen in percent, if you want the image fullscreen when using aspect set it to 100x100, when using aspect forget pixels, think in percent %%%%

or, convert the numbers so you can work in pixels and use %%%%"


I will give this a shot too.

I will post back after I try the things here if I get through them all. I may find one of these suggestions works good. Thank you all for your input. I will post back how it went
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Dec 2021 15:37
The whole percentage environment was always a weird concept to me. I find it infinitely easier to use pixels and work off the size of the virtual resolution.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 9th Dec 2021 16:37
Me too, but I am trying to get my head round it as it seems to have some advantages, its broken my 9Patch routines though! lol
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Dec 2021 18:36
There's no question that Virtual Resolution is far easier to use but the percentage system is the the way to go if you want to use a full screen of unknown size without distortion or black bars.
Unseen Ghost
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 14th Dec 2021 00:43
So far I have tested the following display settings with the same images and it looks good so far

1920x1080 Windows 10

1440x900 MacBook Air laptop

One image made at 1920x1080 and the other 1920x1440 ran in the same program at the same time and they both look good at the above settings
Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.

Login to post a reply

Server time is: 2024-11-23 09:31:25
Your offset time is: 2024-11-23 09:31:25