Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS Zoomed mode problem. #331

Open
Difference opened this issue Feb 3, 2018 · 15 comments
Open

IOS Zoomed mode problem. #331

Difference opened this issue Feb 3, 2018 · 15 comments

Comments

@Difference
Copy link

Monkey does not size it's window to the full extent, when iPhone has it's setting to "Zoomed"
(goto Settings, display & Brightness, “Display Zoom.” turned on )

Forum topic: [http://monkeycoder.co.nz/forums/topic/how-can-i-get-the-device-width-and-height]

As you can see on the forum , Monkey 2 Window is 1136x640, but iPhone screen is 1364x750

To reproduce, you must also have a complete launch screen image set, can be made with [https://github.com/raphaelhanneken/Iconizer/releases]

To reproduce:

 
Namespace myapp
 
#Import "<std>"
#Import "<mojo>"
 
Using std..
Using mojo..
 
Class MyWindow Extends Window
 
 	Field _nw:Int
 	Field _nh:Int

 
	Method New( title:String="Size test mojo app",width:Int,height:Int,flags:WindowFlags=Null )
 
		Super.New( title,width,height,flags )
		
		_nw = Width
		_nh = Height
		
	End
 
	Method OnRender( canvas:Canvas ) Override
	
		App.RequestRender()
	
		canvas.Clear(Color.Red)
		canvas.Color = Color.DarkGrey
		canvas.DrawRect(RenderRect)
	
		canvas.Color = Color.White
	
		canvas.DrawText( "NWidth: " + _nw + " NHeight:  " + _nh,Width/2,Height/2,.5,.5 )
		canvas.DrawText( "Width: " + Width + " Height:  " + Height,Width/2,Height/2+40,.5,.5 )
	End
	
End
 
Function Main()
 
	Local app:=New AppInstance
	
	#If __DESKTOP_TARGET__
	
	Local win:= New MyWindow("test",640,480)

	#Elseif __MOBILE_TARGET__
	Local win:= New MyWindow("test",3000,3000, WindowFlags.HighDPI | WindowFlags.Fullscreen )
	 
	#endif

	App.Run()
End
@Difference
Copy link
Author

Found out that "Note that iPhone 6 will use the 320pt (640px) resolution if you have enabled the 'Display Zoom' in iPhone > Settings > Display & Brightness > View."

[https://stackoverflow.com/questions/25754942/how-to-enable-native-resolution-for-apps-on-iphone-6-and-6-plus/25755436#25755436]

So Monkey Window should probably fit that when zoomed mode is on.

@blitz-research
Copy link
Owner

blitz-research commented Feb 4, 2018

The following test shows desktop size=568,320 (ie: non-retina) and window rect=1136,640.

Not quite sure what to do about desktop size yet, but apart from that is this correct? Anything else I need to do?


Namespace myapp

#Import "<std>"
#Import "<mojo>"

Using std..
Using mojo..

Global size:Vec2i

Class MyWindow Extends Window

	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )

		Super.New( title,width,height,flags|WindowFlags.HighDPI|WindowFlags.Fullscreen )
		
		ClearColor=Color.Red
	End

	Method OnRender( canvas:Canvas ) Override
	
		App.RequestRender()
	
		canvas.DrawText( "Hello World! size="+size+", width="+Width+", height="+Height,Width/2,Height/2,.5,.5 )
	End
	
End

Function Main()

	New AppInstance
	
	size=App.DesktopSize
	
	New MyWindow
	
	App.Run()
End

@nitrologic
Copy link

sdl2 snippet searching __IPHONE_8_0 definition makes educational reading

        if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
            /* Set the scale to the natural scale factor of the screen - the
             * backing dimensions of the OpenGL view will match the pixel
             * dimensions of the screen rather than the dimensions in points. */
#ifdef __IPHONE_8_0
            if ([data.uiwindow.screen respondsToSelector:@selector(nativeScale)]) {
                scale = data.uiwindow.screen.nativeScale;
            } else
#endif

@Difference
Copy link
Author

I tried to reproduce in the simulator (by deleting splash screen 750x1364), but alas I can only make it happen on the real device. Let me know if theres is anything I can hack away at myself to test.
Thanks for making the simulator target btw! :-)

@blitz-research
Copy link
Owner

blitz-research commented Feb 4, 2018 via email

@blitz-research
Copy link
Owner

blitz-research commented Feb 4, 2018

sdl2 snippet searching __IPHONE_8_0 definition makes educational reading

To you maybe but I personally have no idea WTF is going on. Mobile stuff always makes me feel like I've recently undergone some kind of lobotomy...

Although I guess the nativeScale property looks like it could be useful for finding 'real pixel res'?

@Difference
Copy link
Author

Difference commented Feb 4, 2018

According to your second post above, 640 res is 'normal' if zoom is enabled?
Yes, I think you are right, it should go to 640, but it looks wrong because it does not fit to the screen as seen in this screenshot.

d3ajebmi9pvsjgw63nac1dn8cjen797a

@blitz-research
Copy link
Owner

blitz-research commented Feb 4, 2018 via email

@Difference
Copy link
Author

Any chance of you getting your hands on a iPhone 6 or similar?
I have spent a day trying fixing this from the Monkey /Xcode side of things with no luck.

@blitz-research
Copy link
Owner

blitz-research commented Feb 5, 2018 via email

@blitz-research
Copy link
Owner

blitz-research commented Feb 5, 2018 via email

@Difference
Copy link
Author

Difference commented Feb 7, 2018

I've made a little progress: By hardcoding a size into mojo->window->GetFrame() I can make the rendering fill the screen. I'll make some more experiments and report back.

This is obviously only debuggable on a physical device.

@blitz-research
Copy link
Owner

blitz-research commented Feb 7, 2018 via email

@Difference
Copy link
Author

Difference commented Feb 7, 2018

Progress!
In mojo->window->GetFrame() _mousescale is truncated to it's integer part.
Replacing Return New Recti( x,y,x+w,y+h ) * _mouseScale with

Return New Rectf( x,y,x+w,y+h ) * _mouseScale

results in a fullscreen Monkey canvas in both Zoomed and non-zoomed mode on iPhone 6. YAY!

The reported resolution is still off. Taking a screenshot in Zoomed mode, shows that iPhone correctly goes to 640x1136, but Monkey reports the res as 750 x 1331 (close to the hardware res that is 750x1334)

Screenshot and resolution is fine in non-zoomed mode as both run at 750x1334.

@Difference
Copy link
Author

Looking at the code, it seems Monkey (with the above fix) will create a canvas that's 750 x 1331 and scale that to Zoomed iPhone's resolution of 640x1136. That is better than not fitting the screen, but of course not optimal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants