Retina/High Resolution Capable/HiDPI example?

Hi All

Does anyone have an example of how to correctly setup an openFrameworks app to run on a Retina display Mac?

I’m running on a 2019 MacBook Air which has a screen resolution of 2560x1600, and I have scaling set to ‘default’ which results in openFrameworks giving me a screen size of 1440x900, so the scale factor is a somewhat painful 1.77777777.
I tried the other scaling options including a 1280x800 one which would have had a nice 2.0 scale factor but still no joy.

Tried with ‘High Resolution Capable’ in the .plist set to YES and NO, always the same.

One unexpected thing I spotted was that it is not just the contents of the window getting scaled( which I expected) but also the window title bar and contents, here is a screenshot of a terminal window on top of the openFrameworks app with Xcode in the background:

Is the OS doing the window decoration? I wouldn’t have expected it to not be in true screen space resolution?!?

I’m running of0.11.0 on Mojave 10.14.6 right now, is this the reason for the pain?

That should work right out of the box.
Can you try with the latest nightly build instead? You can download at openframeworks.cc/download/ just scroll down a bit.

I am on mojave as well and I have no troubles with retina res, yet I am using the development master branch, which should be the same as the nightly build.

About the window decoration, I would think that it is handled by the OS, yet you can also see that issue when you use a system dialog, as when you call ofSystemLoadDialog(); no idea why it is like this.

1 Like

I have tried those like 3 days ago, and it’s running weirdly.
I’m curious of the issue too, as I’m not sure my setup is correct.

I did manage to get the correct screen resolution on a seperate 4K screen, with High Resolution Capable to YES, and this main.cpp - credit to an other post on the forum, :slight_smile: - :

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

#define WIDTH 3840
#define HEIGHT 2160

//========================================================================
int main( ){
    ofGLFWWindowSettings settings;
//    settings.windowMode = OF_WINDOW;
    settings.windowMode = OF_FULLSCREEN;
//    settings.decorated = false;
    settings.monitor = 1;
    settings.setSize(WIDTH, HEIGHT);
    shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
    
    mainWindow->enableSetupScreen();
    mainWindow->setWindowShape(WIDTH, HEIGHT);
    glm::vec2 sSize = mainWindow->getScreenSize();
    cout << "screen size = " << ofToString(sSize) << endl;
    
    glm::vec2 actualSize = mainWindow->getScreenSize();
    cout << "actual size = " << ofToString(actualSize) << endl;
    shared_ptr<ofApp> mainApp(new ofApp);
    ofRunApp(mainWindow, mainApp);
    ofRunMainLoop();
    
}

ofApp.cpp::setup(){

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

Every other configuration seem to give me something not right…

Can’t have the right screen resolution however if using my macBook Pro 2880 x 1800 screen:
with the same setup but a different size for WIDTH and HEIGHT, it returns the wrong screen sizes…

with :slight_smile:

#define WIDTH 2048
#define HEIGHT 1280

i get : screen size = 3360, 2100 actual size = 3360, 2100 scale is 2

Any Ideas @roymacdonald ?

I’m running the latest nighly build, on Catalina 10.15.6 Beta (19G60d).

++

P

@roymacdonald

I downloaded the nightly build and now I get a smaller window, progress!

I’ve measured the window size according to other apps running on the system and it appears the windows size I’m getting back from ofGetWindowHeight/Width() is matching the correctly scaled size in other apps multiplied by the getPixelScreenCoordScale which for some reason is being returned as 2, and the windows decoration too is looking clean and crisp like just like other native windows.

Stretching the window to full width or setting to full screen I see a size of 2880x1800, which is exactly 2x the 1440x900 resolution that the OS default scaling is suggesting I should be seeing.
I’m curious as to why this is not the screen resolution of the device 2560x1600, is MacOS behind the scenes pretending that the desktop is 2880x1800 and scaling everything down to 2560x1600 to fit to the actual display?

I haven’t looked (yet!), but are the differences between the 0.11.0 version and the nightly build significant in just this area to fix this resolution issue? I’d like to stick with the 0.11.0 distro, and do a small patch if there is one to fix this rather than switch to the nightly build and possibly inherit some other unknown changes that might effect things elsewhere…

That’s working then. Now everything will be drawn smaller, actually in the native pixel size of the retina display.
Tip: if you use ofxGui, you can call ofxGuiEnableHiResDisplay(); in the setup and it will scale the whole gui so it looks correctly…

I have no idea but it could be. Try to draw black vertical lines of 1 pixel wide separated by one pixel over a white background and see if you get a crisp pattern drawn or just a gray thing. That might give you an idea. (There might be other issues affecting this too, not sure, just guessing).

No, there are alot of other fixes as well. I often work on the github master (nightly build) as it tends to have the less amount of issues. Between 0.11.0 and the nightly build there should not be any change that will break your code, only fixes to some issues and improvements in some other areas. Yet, if you are working on some project which uses 0.11.0 and it is ok, just stick with it. :slight_smile:

2 Likes

I’ll switch to the nightly build and see if there are any issues, though it’s sounds like I’ll be fine. Any idea when the next release (0.11.1??) is due?

Thanks for you help!

Definitely. It is more than fine.

No idea. :confused: