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.

Newcomers AppGameKit Corner / Can't get setwindowsize to work with getdevicewidth and getdeviceheight

Author
Message
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 12th Apr 2018 22:20 Edited at: 12th Apr 2018 22:21
The setwindowsize is not accepting the parameters for getdevicewidth and height. It keeps reverting back to the last actual numbers I put in. I would think I should not be getting any black borders on this, but I am.

What do I need to do to ensure my window size aligns with my Displayaspect on Windows? I want to set this up correctly on mobile, but its very hard to do when flying "blind".



Attachments

Login to view attachments
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 13th Apr 2018 00:03 Edited at: 13th Apr 2018 00:12
I seem to be getting different results every time I change something and run on mobile with broadcast. And now I am getting different results even when I change no code... Is broadcast unreliable? Is landscape unreliable?
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 13th Apr 2018 00:11
And again, I keep testing in broadcast. It works 50% of the time on iPhone and Android. I literally change nothing except hit the broadcast button to restart it. How am I not getting a consistent result?

What is going on?
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 13th Apr 2018 00:27 Edited at: 17th Apr 2018 03:31
So... more testing.. if I do not set any windowsize, virtualsize or aspectratio it defaults to aspectratio... Im not sure how setaspectratio breaks it... but it does.


The bad thing is on the iPhone if I start the app with the phone in the typical portrait mode orientation it does not default to landscape despite my code SetOrientationAllowed ( 0, 0, 1, 1 ). Andriod works. Is that a broadcast bug, or will this also occur if I send my app to the iStore?

But the setwindowsize will still not accept getdevicewidth and getdeviceheight on Windows.

This also will not work.
w# = GetDeviceWidth()
h# = GetDeviceHeight()
SetWindowSize( w#, h#, 0 )
SetVirtualResolution(GetDeviceWidth(), GetDeviceHeight())

This does not work:
SetWindowSize( GetDeviceWidth(), GetDeviceHeight(), 0 )
SetVirtualResolution(GetDeviceWidth(), GetDeviceHeight())

This does work:
SetWindowSize( 1366, 768, 0 ) // but no way to know what monitor the user is using why????????????????
SetVirtualResolution(GetDeviceWidth(), GetDeviceHeight())
The virtual resolution is correct. The window size will not change!!!!!!!!!!!!!!!!!!!!!!

Why in the world can I not set my window screen based off my monitor? It literally has no effect unless I use actual integer numbers and not variables.
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 13th Apr 2018 09:34
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 13th Apr 2018 19:18
Quote: "Repeat
Until GetDeviceWidth() > GetDeviceHeight"


Neat
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Dybing
13
Years of Service
User Offline
Joined: 12th Sep 2011
Location: Bergen, Norway
Posted: 13th Apr 2018 21:00 Edited at: 13th Apr 2018 21:03
Here's how I do it:



For testing on say WIndows for any device resolution and aspect, I just change the 'aspectMode' variable to one of the presets in the following SELECT/CASE. Where I can add any resolutions I wish if needed. Makes it easy to test all most common resolutions without actually owning all those devices.
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 15th Apr 2018 03:22 Edited at: 15th Apr 2018 03:46
Wow... Amazing. Thank you so much, smallg and Dybing. I redid all my sprites today to work with aspect ratio. You guys are bad ass.

smallg, your code works great for android, but for iphone I have to flip the phone around like 6 times(otherwise it stays in the endless loop). Not sure what is up with the iPhones and making it so difficult to force landscape mode. And I have no idea how this is AGK's fault but once I exit AppGameKit I have to lock the phone to get it back to portrait mode. No other app has caused that bug.

Login to post a reply

Server time is: 2024-11-21 16:09:24
Your offset time is: 2024-11-21 16:09:24