How to force drawing at native resolution on retina screen?

I have a standalone juce application on OS/X and I’d like to draw the entire window at the native retina resolution (2880x1800).

I do not want to draw at 1440x900 in Juce and have the OS or Juce upscale that to retina resolution, because I have bitmaps that are already in proper retina resolution.

what is the recommended approach for doing this?

(PS I have read all the retina threads but frankly it remains a confusing topic. A good tutorial would be nice)

you do already, but your coordinate system do not consists of physical pixels anymore (like with html where 1px is not 1 physical pixel), just scale your image by half

you mean, draw at 2880x1800, then take the whole window and apply a .5 transform on it?

You can get the physical pixel scale factor from the Graphics context and use that to draw scaled images.
g.getInternalContext().getPhysicalPixelScaleFactor();

Also take a look at StandardCachedComponentImage inside Component.cpp for an example of doing this.

so you’d need to use 1440x900 everywhere, EXCEPT when drawing images? Then you have to do some deliberate scaling operation first before drawing the image? That’s horrible!

I was hoping there would be a nice clean, single coordinate system for all where you can draw everything at the native resolution, images included. And only then scale the whole of it down with a single transform

… I think you’re really misunderstanding.

There’s no tutorial needed, because you don’t need to change anything in your code to use higher-res displays. You already are drawing at retina resolution if your window is on a retina screen, but the coord system just isn’t necessarily 1:1 in terms of logical to physical pixels.

entirely possible the confusion is my own :slight_smile:

so I understand the following (forgive me if they are stupid questions):

for a retina screen I still have to work in a 1440x900 (logical) coordinate system. It’s just that I could choose to draw a line at non-integer coordinates. And if that non-integer coordinate/distance happens to be 0.5 it will translate to a 1 physical pixel distance on a retina screen ?

second, for any image I draw, I need to specify to Juce the scaling somewhere at drawing time. So I need to tell it: this image is really 200 physical pixels wide but please draw it at 100 pixels logical resolution in the 1440x900 coordinate system?

Yes, exactly!

Well, sort of, but that sound like the wrong way of looking at things…

You generally know how big you want the final image to be on your UI, so just draw it to fit in that space. I don’t think it makes much sense to pay much attention to its original resolution, just think in terms of “I want this image to fit within a certain rectangle”, and supply images that are a high enough resolution for them to look good on high-res displays.

OK understood!

one thing that’s still unclear to me: suppose I have a window with a single content component in it. This component is sized at 2880x1440, and bitmaps are drawn on it using their physical (retina-optimized) resolution

then we set a.5 affine transform on that component, so that it will have 1440x900 size after transformation

what happens when that window is rendered on a retina screen? Will it render at 1440x900 and then upscale (with information loss) ? Or will it know that on the retina screen the .5 transform would be canceled by the subsquent upscale, and therefore it should render at 2880x1800 without any down/upscale step inbetween?

Huh? There’s no up or down-scaling involved… I’m not sure why you seem so confused about this, why not just try it and look at the result! Don’t get hung up on these specific numbers and just base your sizes on the screen size.

I guess my mental model of all this is wrong

but if there’s no hidden upscaling anywhere that’s good to know, then I should be able to work in just any coordinate system and transform it to the final one at the end

will do some testing as you suggested! Thanks