# How to make PTB work on &quot;Retina&quot; display?

**URL:** https://psychtoolbox.discourse.group/t/how-to-make-ptb-work-on-quot-retina-quot-display/264
**Category:** Uncategorized
**Created:** [April 18, 2014, 6:29pm UTC](https://psychtoolbox.discourse.group/t/how-to-make-ptb-work-on-quot-retina-quot-display/264 "2014-04-18T18:29:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dxjonespix](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@dxjonespix](https://psychtoolbox.discourse.group/u/dxjonespix)
#### Post date: [April 18, 2014, 6:29pm UTC](https://psychtoolbox.discourse.group/t/how-to-make-ptb-work-on-quot-retina-quot-display/264/1 "2014-04-18T18:29:13Z")

</div>

PTB 3.0.11 does not handle screen resolutions properly for a "Retina" display, at least for OSX 10.9.2. &nbsp;Can anyone suggest a fix or workaround?
  

When the screen resolution is initially set to 1920x1200,

this resolution is correctly reported by Screen('Resolution',0),

and I can adjust the resolution to 2880x1800 (the native resolution),

but I cannot set it back to 1920x1200 without an error.

Oddly, I cannot even set the resolution to 1920x1200 when it is \*already\* that resolution.

  

Here is example code:

  

r = Screen('Resolution', 0)

r = Screen('Resolution', 0, r.width, r.height, r.pixelSize, r.hz)

  

OUTPUT:

r =&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; width: 1920

&nbsp; &nbsp; &nbsp; &nbsp;height: 1200

&nbsp; &nbsp; pixelSize: 32

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hz: 0

  

Error in function Resolution: Invalid pixel size argument

Illegal depth value

Error using Screen

Usage:

  

oldResolution=Screen('Resolution', screenNumber [, newwidth][, newheight][, newHz][, newPixelSize][, specialMode]);

  

Error in laptop\_resolution (line 7)

r = Screen('Resolution', 0, r.width, r.height, r.pixelSize, r.hz)

---

<div class="post-metadata">

### Author: ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)
#### Post date: [April 19, 2014, 3:07pm UTC](https://psychtoolbox.discourse.group/t/how-to-make-ptb-work-on-quot-retina-quot-display/264/2 "2014-04-19T15:07:18Z")

</div>

Either it's a PTB bug, or you provided the arguments to Screen('Resolution', ...); in the wrong order without double checking with the help "Screen Resolution?" after getting error messages. I wonder which it is?  
-mario

---

<div class="post-metadata">

### Author: ![dxjonespix](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@dxjonespix](https://psychtoolbox.discourse.group/u/dxjonespix)
#### Post date: [April 20, 2014, 6:28pm UTC](https://psychtoolbox.discourse.group/t/how-to-make-ptb-work-on-quot-retina-quot-display/264/3 "2014-04-20T18:28:05Z")

</div>

Hi Mario,
  

It is PTB bug. &nbsp;I am using the correct parameter order for Screen('Resolution', ...).

  

Here is some more example code and diagnostic output.

This code shows that NearestResolution correctly handles 2 available resolutions (2880x1800 and 1440x900), but it fails to handle the currently reported resolution (1920x1200) and instead reports 2048x1280 as the nearest.

  

CODE:

fprintf('Nearest Resolution to 2880 x 1800\n');

newres = NearestResolution(0, 2880, 1800)

  

fprintf('Nearest Resolution to 1440 x 900\n');

newres = NearestResolution(0, 1440, 900)

  

fprintf('Current Resolution ...\n');

res = Screen('Resolution', 0)

  

fprintf('Nearest Resolution to Current Resolution: %d x %d\n', res.width, res.height);

newres = NearestResolution(0, res.width, res.height)

  

OUTPUT:

Nearest Resolution to 2880 x 1800

newres =&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; width: 2880

&nbsp; &nbsp; &nbsp; &nbsp;height: 1800

&nbsp; &nbsp; pixelSize: []

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hz: 0

  

Nearest Resolution to 1440 x 900

newres =&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; width: 1440

&nbsp; &nbsp; &nbsp; &nbsp;height: 900

&nbsp; &nbsp; pixelSize: []

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hz: 0

  

Current Resolution ...

res =&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; width: 1920

&nbsp; &nbsp; &nbsp; &nbsp;height: 1200

&nbsp; &nbsp; pixelSize: 32

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hz: 0

  

Nearest Resolution to Current Resolution: 1920 x 1200

newres =&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; width: 2048

&nbsp; &nbsp; &nbsp; &nbsp;height: 1280

&nbsp; &nbsp; pixelSize: []

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hz: 0

---

<div class="post-metadata">

### Author: ![dxjonespix](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@dxjonespix](https://psychtoolbox.discourse.group/u/dxjonespix)
#### Post date: [April 20, 2014, 6:38pm UTC](https://psychtoolbox.discourse.group/t/how-to-make-ptb-work-on-quot-retina-quot-display/264/4 "2014-04-20T18:38:46Z")

</div>

I already replied, ... but here is some additional info.
  

NearestResolution does not seem to work properly for some supported resolutions,

or else Screen('Resolution') is misreported the current resolution, at least in some cases.

  

Here is what happens when I change the screen resolution using Mac OSX Preferences\>Display

then call Screen('Resolution') to get the current resolution,

and then call NearestResolution with the current width,height.

  

"Current Resolution" =\> "Nearest Resolution"

1024 x 640 =\> 1024 x 768 (wrong)

1280 x 800 =\> 1280 x 800 (correct)

1680 x 1050 =\> 1680 x 1050 (correct)

1920 x 1200 =\> 2048 x 1280 (wrong)

  

Mac OSX 10.9.2 on MacBookProRetina

---

<div class="post-metadata">

### Author: ![dxjonespix](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@dxjonespix](https://psychtoolbox.discourse.group/u/dxjonespix)
#### Post date: [April 21, 2014, 4:09pm UTC](https://psychtoolbox.discourse.group/t/how-to-make-ptb-work-on-quot-retina-quot-display/264/5 "2014-04-21T16:09:55Z")

</div>

I just confirmed that my MacBookProRetina does in fact work properly for several PTB demos I tried, as long as you first set Screen('Resolution') to be the native resolution (ie, highest resolution available, which is 2880x1800 on my 15" Retina display).
  

There were no glitches or timing issues.

  

If using native resolution is the only limitation to get PTB working on a retina display,

I think&nbsp;most people will be happy with that.

  

-- David
