# Screen resolution hdpi confusion

**URL:** https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320
**Category:** Beginners
**Created:** [May 26, 2021, 8:35pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320 "2021-05-26T20:35:04Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![fish233](https://avatars.discourse-cdn.com/v4/letter/f/838e76/32.png) [@fish233](https://discourse.processing.org/u/fish233)
#### Post date: [May 26, 2021, 8:35pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/1 "2021-05-26T20:35:04Z")

</div>

Hello, semi noob here. I recently switched from a win10 1920x1080 laptop to an m1 MacBook. I made a lot of sketches with size(1080,1080) last year. these displayed nice on the hd screen, but with the MacBook apparently behaving as 1440x900 (and its actually a 2560x1600 screen?) I cannot preview the sketches properly + they look ugly as hell upscaled. now I read a bit about pixelDensity etc. but it’s still confusing the hell out of me… is there a simple way to just have the processing render being displayed as ‘true’ 1080x1080 on this screen? if possible, without really having to adapt the sketches? thanks!

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [May 26, 2021, 8:47pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/2 "2021-05-26T20:47:22Z")

</div>

Hi @fish233 ,

From the [documentation](https://processing.org/reference/pixelDensity_.html) of the `pixelDensity()` method :

> This function is new with Processing 3.0. It makes it possible for Processing to render using all of the pixels on high resolutions screens like Apple Retina displays and Windows High-DPI displays. This function can only be run once within a program and it must be used right after **size()** in a program without a **setup()** and used within **setup()** when a program has one. The **pixelDensity()** should only be used with hardcoded numbers (in almost all cases this number will be 2) or in combination with **displayDensity()** as in the third example above.

So you can set it to `2` to use your HDPI display 😋

```auto
void setup() {
  size(100, 100);
  pixelDensity(2);
}

void draw() {
  // ...
}

```

---

<div class="post-metadata">

### Author: ![fish233](https://avatars.discourse-cdn.com/v4/letter/f/838e76/32.png) [@fish233](https://discourse.processing.org/u/fish233)
#### Post date: [May 26, 2021, 8:55pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/3 "2021-05-26T20:55:35Z")

</div>

Hey @josephh , thanks for your reply! I just tested with an empty sketch.  
both  
` void setup(){ size(900,900); };`  
and  
` void setup(){ size(900,900); pixelDensity(2); };`  
give the same window size over here… I’m really confused

edit: double checked with some old sketches, does not work over here 😕 pixelDensity(2) doesn’t change anything. could this be Big Sur/M1 related?

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [May 26, 2021, 9:34pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/4 "2021-05-26T21:34:26Z")

</div>

Ok yes this is confusing I admit, from the [`pixelWidth()`](https://processing.org/reference/pixelWidth.html) documentation page :

> When **pixelDensity(2)** is used to make use of a high resolution display (called a Retina display on OS X or high-dpi on Windows and Linux), the width and height of the sketch do not change, but the number of pixels is doubled. As a result, all operations that use pixels (like **loadPixels()** , **get()** , **set()** , etc.) happen in this doubled space. As a convenience, the variables **pixelWidth** and **pixelHeight** hold the actual width and height of the sketch in pixels. This is useful for any sketch that uses the **pixels[]** array, for instance, because the number of elements in the array will be **pixelWidth\*pixelHeight** , not **width\*height**.

So it looks it’s only affecting functions that directly manipulate pixels and I suppose shape functions are not affected…

Maybe someone else can clarify on that?

Can you also try to print out the result of [`displayDensity()`](https://processing.org/reference/displayDensity_.html) after setting the pixel density?

---

<div class="post-metadata">

### Author: ![fish233](https://avatars.discourse-cdn.com/v4/letter/f/838e76/32.png) [@fish233](https://discourse.processing.org/u/fish233)
#### Post date: [May 26, 2021, 9:44pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/5 "2021-05-26T21:44:17Z")

</div>

quickly checked (need to grab some sleep): displayDensity() prints out 2, regardless setting pixelDensity(2) or not.

but since I’m using a lot of shapes/primitives in those older sketches i fear this might not be really useful for me. ideally a global render window scaling factor would be really nice (and maybe more convenient)

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [May 26, 2021, 9:52pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/6 "2021-05-26T21:52:48Z")

</div>

> [@fish233](#):
>
> ideally a global render window scaling factor would be really nice

you can still use the [`scale()`](https://processing.org/reference/scale_.html) function to do that tought 😉

---

<div class="post-metadata">

### Author: ![fish233](https://avatars.discourse-cdn.com/v4/letter/f/838e76/32.png) [@fish233](https://discourse.processing.org/u/fish233)
#### Post date: [May 26, 2021, 9:57pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/7 "2021-05-26T21:57:46Z")

</div>

ok wait, but I render all my animations as image sequence in png/tiff, if I’m using scale() these are going to be scaled too right? I want those to be 1080x1080 and preferably the render window displayed as ‘true’ 1080x1080 so it fits my screen 🙂

---

<div class="post-metadata">

### Author: ![fish233](https://avatars.discourse-cdn.com/v4/letter/f/838e76/32.png) [@fish233](https://discourse.processing.org/u/fish233)
#### Post date: [May 27, 2021, 6:52am UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/8 "2021-05-27T06:52:41Z")

</div>

ok I found some semi workaround. setting display scaling to 1680x1050 (highest possible) in display settings only 30px get chopped off. also tried this [GitHub - avibrazil/RDM: Easily set Mac Retina display to higher unsupported resolutions](https://github.com/avibrazil/RDM) but does not seem to work here. still kinda feels lame that a 600$ win10 laptop can display 1080x1080 window without probs but the triple priced MacBook can’t.

Hence i think it would be really nice if the render window could be ‘unscaled’ relative to hdpi screens, being displayed at true screen pixel resolution.

---

<div class="post-metadata">

### Author: ![fish233](https://avatars.discourse-cdn.com/v4/letter/f/838e76/32.png) [@fish233](https://discourse.processing.org/u/fish233)
#### Post date: [May 27, 2021, 1:45pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/9 "2021-05-27T13:45:56Z")

</div>

just found out, in openFrameworks there is a ‘High resolution capable’ bool flag in build .plist, this does exactly what i would like. Don’t know how feasible this is but would be really nice to have this in Processing too!

---

<div class="post-metadata">

### Author: ![pechpo](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pechpo](https://discourse.processing.org/u/pechpo)
#### Post date: [November 19, 2021, 3:35pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/10 "2021-11-19T15:35:54Z")

</div>

I met exactly the same problem on surface pro 7. I think there should be a flag like this indeed.

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [September 15, 2026, 2:35pm UTC](https://discourse.processing.org/t/screen-resolution-hdpi-confusion/30320/11 "2026-09-15T14:35:43Z")

</div>

I have similar issues with P3D on Win 10 with 1920x1050 on my Laptop with a high-density monitor (I think) (or 1280x720 with pixelDensity(1) (I think)). The problem: The command `fullScreen(P3D);` does not work (and pixelDensity(1); does not help).

P2D or JAVA2D (the default) runs normal.

Sketch ran previously on the same laptop but with external monitor. Does the Sketch store video settings somewhere hidden?

I use this now, but it’s not nice,

```auto
//-------------------------------------------------------------------------

void setup() {
  pixelDensity(1);
  fullScreen(P3D, 1); // size( 1920, 1000, P3D );
  windowResize(1920, 1000);
  windowMove(0, 0);

  println(displayWidth, displayHeight);

  // Smaragd/Nightblack
  background(10, 20, 15);

  // Give the window the focus
  surface.setVisible(true);

  println("\nEnd of setup.");
}

```

Chrisir
