High Resolution Capable / Retina

Hello, I’m a bit lost on how to manage retina screen with openframework.

I tried to set High Resolution Capable option to YES from the openframeworks-info.plist file, so the windows title looks fine, but depending of the windows width I set the result is different. Does this plist parameter is the right way to manage retina screen ?

My display is a native 3840x2160, so if I setup a windows of 1920x1080, the windows cover a quarter of my screen and the pixelScreenCoordScale is = 2 so it’s seems ok for me. But, if I setup a windows of 1921x1080 the pixelScreenCoordScale = 1, this issue seems to only appears on the width parameter, not the height one.

If anyone have any tips on how to manage high resolution screen it would be super nice :slight_smile:

Anyone encounter this issue ? Do I have to open an issue on github ?
Thanks :slight_smile:

Still did not find a solution, is it an issue on my side only or do other people encouter that issue ?

I also have a HiDPI screen and I just use openFrameworks without any special settings. Do you have a specific way you want to use it where you need to take the high pixel density into account? The common problem for high density screens I guess is that text looks small but then you just set a larger font size if you want to print something. I guess it could be an issue if you want to share your program with someone who has a lower density screen.

Sorry for the super late reply. In fact, I want to know how to manage Retina when creating a software made both for high density display and standard display. For people who have a high density display I want to offer a good quality, as you can see bellow when not using the High Resolution Capable flag the graphics looks a bit blurry. So to do this my first guess to manage the size of the graphics was to use the
pixelScreenCoordScale variable but as I said in my first post this variable seems buggy depending of size used in the setup. Do you have any idea how to manage this ?

Without High Resolution Capable flag :


With High Resolution Capable flag :

I’ve search a bit today, and it seems that the issue is in the ofAppGLFWWindow class. Indeed, the value (pixelScreenCoordScale) calculated in the Setup() function is wrong, contrary to those calculated in resize_cb(). So If a callback is triggered on resize_cb(), for example with ofSetWindowShape() the values are right.

Is there an issue in this code ? For the pixelScreenCoordScale, will it be correct to divide framebufferW by tmpWindowW to get the right value ?

	int framebufferW, framebufferH, tmpWindowW, tmpWindowH;
	glfwGetFramebufferSize(windowP, &framebufferW, &framebufferH);
	glfwGetWindowSize( windowP, &tmpWindowW, &tmpWindowH );
    

	//this lets us detect if the window is running in a retina mode
	if( framebufferW != tmpWindowW){


		pixelScreenCoordScale = (float)framebufferW / (float)windowW;
pixelScreenCoordScale = (float)framebufferW / (float)windowW;
		if( pixelScreenCoordScale < 1 ){
			pixelScreenCoordScale = 1;
		}

		if(targetWindowMode == OF_WINDOW){
			auto position = getWindowPosition();
			setWindowShape(windowW, windowH);
			setWindowPosition(position.x, position.y);
		}
	}

According to the commit log, maybe @roymacdonald or @arturo are the best suited to tell me their advice ?

Thank you :slight_smile:

@Poulp

for me this returns 2 - does it not for you ( when High Resolution Capable is set to YES)?

#include "ofApp.h"
#include "ofAppGLFWWindow.h"

//--------------------------------------------------------------
void ofApp::setup(){	

    int scale = ((ofAppGLFWWindow *)(ofGetWindowPtr()))->getPixelScreenCoordScale();
    cout << " scale is " << scale << endl;
}

If you get 1, could you try the macOS nightly build at the bottom of the download page?

Thanks!
Theo

Hello Theo, and thank you very much for your help. In fact when I use your code with High Resolution Capable set to Yes, I get different result depending on the resolution I set in ofSetupOpenGL();.

In my case, my screen physical resolution is 3840x2160. In my graphics configuration (macOs) my scaled resolution is 2560x1440. If in ofSetupOpenGL(); the width is equal or below 2560 (opening a window being half of my width screen) the scale value is 2, but if I want to open a window bigger than half of my width screen and I set in ofSetupOpenGL(); a width greater than 2560 the scale value is 1.

Internally, the scale value is a 0 < float < 2, so when the value is wrong the function using this value return wrong value (for example ofGetWidth()).

Is it a bug ?

Hey @Poulp thanks for explainig this. I’ll take a look at it later today… It sounds as it might be a bug, not sure though.
best

I’m not super advanced in C++ and GLFW but if I can help you in any way, let me know.

Hello, and sorry to ask again, but did you get the time to look at this ? Have a good day !

Hi,
Yes, I took a look at this and there happens to be another really weird issue. It seems to be something that glfw is doing. As you say, the values calculated when the window is resized are correct, but when the window is created these are not, because, on one side glfw returns a new window that it is not necessarily the size you ask for it to be, thus the rest of the values are calculated wrong. I need to take a deeper look into glfw, in order to sort this out. btw, I begin to get this odd behaviors when the window is > 1920 .

Thank you for the update ! I 'll try to look more into that issue but I’m not as good as you with glfw, so as soon as you find a fix, let us know on this thread :slight_smile:

1 Like

BTW, can you open an issue about this in https://github.com/openframeworks/openframeworks/issues and tag me? (same user name as here)

It’s done :slight_smile:

1 Like