Retina with iDisplay

Because Xojo is rather unuseable on my 1600x something monitor in Retina resolution I thought I’d borrow the iPad of the sister for testing. But I can’t get Xojo to recognize the second display as Retina. I’ve got the usual code:

[code]Function getRetinaScalingFactor(ParentWindow as Window) As Integer

dim RetinaScaleFactor as Integer
#If TargetCocoa Then
Declare Function BackingScaleFactor Lib “AppKit” Selector “backingScaleFactor” (target As WindowPtr) As Double
RetinaScaleFactor = BackingScaleFactor(ParentWindow)
#Else
RetinaScaleFactor = 1
#Endif
Return RetinaScaleFactor

End Function[/code]

But the RetinaScaleFactor is always 1. I know that it works when I set my main monitor to Retina.

Using Xojo 2014r2. Mac OS 10.9.4. iPad Retina.

Your post made me look for solutions, and I ran into this :
http://www.makeuseof.com/tag/how-to-use-your-ipad-or-iphone-as-a-second-monitor-ios/

From their review, it seems only Mini-Display can use Retina resolution ?

That’s a great link, thanks Michel. However, they don’t say anything about Mini-Display and Retina. Only that the others don’t support Retina :frowning:

iDisplay was easy to setup. The lag isn’t too bad on my elderly MacPro.

Bad bad bad bad!

This method is not reliable and is not recommend by Apple for doing Retina work at all, (if you don’t believe me check Apple’s documentation).

I have a feature request to remove this POS code from the Xojo guide <https://xojo.com/issue/34924>.

The feedback report also includes the correct way to asses if you should be drawing Retina content or not.

Using this code causes the wrong mind set and sets people off in the wrong direction of building Retina ready applications.

@Sam: thanks for the tip with the second declare. So far nobody complained about my Retina implementation - well, except for the missing Retina DataGrid. I don’t think many people have a secondary monitor.

@Sam: stupid question. But what exactly does your declare do? I put in a rect and get out a rect. So I would assume that the ration of the rects gives the RetinaScaleFactor. Sigh… I think I’ll leave my code as it is for now.

So how to use this?

declare function CGContextConvertRectToDeviceSpace lib AppKit ( context as integer, rect as CGRect) as CGRect Dim userRect as CGRect = CGRectMake( x,y,w,h ) Dim repRect as CGRect = CGContextConvertRectToDeviceSpace( g.Handle( g.HandleTypeCGContextRef ), userRect )

I connect to a iPad Air with Retina display using Air Display. I can use a resolution of 2048x1536,but it does not report retina scalingfactor. I can set “Use Retina resolution” in the Air Display preferences, but this does not have an effect on the reported scalingfactor. So it looks like the iPad Air retina display cannot be used to test a retina enabled app.

Function imScalingFactor(Extends G As Graphics) As Single #If TargetCocoa Declare Function CGContextConvertSizeToDeviceSpace Lib "ApplicationServices" (Context As Integer, UserSize As CGSize) As CGSize If System.IsFunctionAvailable("CGContextConvertSizeToDeviceSpace","ApplicationServices") Then Dim UserSize As CGSize UserSize.Width = 100 UserSize.Height = 100 Dim Handle As Integer = G.Handle(Graphics.HandleTypeCGContextRef) Dim DeviceSize As CGSize = CGContextConvertSizeToDeviceSpace(Handle,UserSize) Return DeviceSize.Width / UserSize.Width Else Return 1 End If #Else // TODO: check hirez for windows or linux devices Return 1 #EndIf End Function

The testproject for xojo plus a codesigned retina enabled built version of it can be downloaded from here:
http://osswald.com/xojo/test/sftest.zip

This is a screenshot from the connected iPad display:

Thank you Oswald.
If you could add checking for Windows too this would be very useful for a lot of people.

So now, if I wanted to use my iPad as a second monitor, I have to choose between iDisplay, Air Display, and the three other described in the comparison report I had found.

Now I am completely confused. I tend to trust better members of the forum since they cannot be suspected of commercial bias, but what would make iDisplay better than Air Display, or the other way around ?

@Michel: Oliver seems to have the same experience that I had. You CAN’T use the iPad as retina testing device. And the matter of iDisplay vs. Air Display is just hat the §$%& app store doesn’t do trial versions and I had to decide which app to buy.

[quote=125950:@Christoph De Vocht]So how to use this?

declare function CGContextConvertRectToDeviceSpace lib AppKit ( context as integer, rect as CGRect) as CGRect Dim userRect as CGRect = CGRectMake( x,y,w,h ) Dim repRect as CGRect = CGContextConvertRectToDeviceSpace( g.Handle( g.HandleTypeCGContextRef ), userRect )[/quote]

RepRect will contain the dimensions of the source image that you need to draw, including the offset.

Lets say you have two images 100 x 100 & 200 x 200, you pass in your target rectangle (i.e. 100 x 100 ) and the OS returns which source rectangle to use.

This code shouldn’t be used to figure out what the scaling factor is, in fact if you’re figuring out what the scaling factor is to configure your interface, then you’re doing it wrong.

Xojo doesn’t support Retina, but the underlying OS does and in many cases for free. If you utilize the OS to do it for you, it becomes a no brainer.
For icons in your interface you should switch to using NSImage, either MacOSLib, MBS or the Retina Kit. When drawing vector graphics in the interface, use the g.draw functions (which use the OS functions).
Don’t cache custom controls, if you really want to cache, then learn how to utilize CGLayers (as these are faster and Retina compliant).
For drawing pre-loaded graphics, use NSImage.[quote=125969:@Beatrix Willius]@Michel: Oliver seems to have the same experience that I had. You CAN’T use the iPad as retina testing device. And the matter of iDisplay vs. Air Display is just hat the §$%& app store doesn’t do trial versions and I had to decide which app to buy.[/quote]
Have you tried a Retina ready application (not your own, but another)?