← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] OS X: Add Retina support to 3d-viewer

 

Hi Mario,

I am not an expert on this, but let me try…

Retina doesn’t expose the full resolution, but only half width/height.
So, one logical pixel gets 4 real pixels (2x2).

When non-Retina apps draw something like 100x100 pixels, it will be 200x200 native pixels in reality and OSX will interpolate.
That’s why it looks blurry then.

Don’t ask me why this has been done this way, but obviously this is the best way to avoid getting really tiny and unreadable things from non-Retina apps.

> On 23 Feb 2016, at 23:57, Mário Luzeiro <mrluzeiro@xxxxx> wrote:
> 
> -    glViewport( 0, 0, size.x, size.y );
> +#ifdef RETINA_OPENGL_PATCH
> +    const float scale_factor = GetBackingScaleFactor();
> +#else
> +    const float scale_factor = 1.0f;
> +#endif
> +    glViewport( 0, 0, size.x * scale_factor, size.y * scale_factor );

Read below first…
… I just copied that part from the GAL canvas, you will find the same there.

If you have enabled native resolution with the function below, it will only paint half width/height of the window.
So you have to scale accordingly.

> anyway..
> maybe you would like to add some comments / clarify in the source code near that special functionalities:
> +#ifdef RETINA_OPENGL_PATCH
> +    SetViewWantsBestResolution( true );
> +#endif

This is nothing official yet, it was done by Orson (I think) for GAL.
There is a KiCad specific wxWidgets patch for OS X that adds this function.
It tells OS X that we want to have native pixels for that drawing area, not the 2x2 interpolating thing.

> so you will explain or link to some place that explain the use of that function?

I hope it somewhat clarifies things.
As I said, I also just copied that stuff from GAL canvas.

It is on my list to try your branch in the next days.
If you can give me some hints where to best add those two snippets (initialisation and scaling), I’ll add it and send you a patch.


Regards,
Bernhard



Follow ups

References