openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

[idea] macOS - seamless retina window (high res or not)

Open dimitre opened this issue 10 months ago • 9 comments

I finally found everything to make retina work with a seamless window. Basically everything will work the same and only pixel density will change.

It is working great in the fork I'm using. I'll explain what the changes are if anybody wants to port to OF.

GLFW window size and mouse will not be doubled in retina. everything is the same. I've just removed pixelcoordscale, not relevant anymore. we have to consider the framebuffer size and window size and have the appropriate GLFW callbacks. ofMatrixStack::getRenderSurfaceSize() have to consider currentWindow->getFramebufferSize();

I'm using always high resolution on PLIST now, so the window decorations are not pixelated (title bar and colored buttons) this can be switched in ofWindowSettings, so GLFW will handle the way framebuffer works.

// In this fork there is only ofWindowSettings, no inheritance for settings
	ofWindowSettings settings;
	settings.highResolutionCapable = true;

Some related commits: https://github.com/dimitre/openFrameworks/commit/001cec06b36c66a64373ceb563cb5ca21f4bd0f5 https://github.com/dimitre/openFrameworks/commit/aa82c6b8188960a11db8bb8f44333e57275d9067 https://github.com/dimitre/openFrameworks/commit/ba9de37749a37b6030c483f25d90a7da6748c0d7

dimitre avatar Mar 09 '25 13:03 dimitre

I'll keep using settings.highResolutionCapable = false for some pixel sharp fonts interface. They can get a little bit blurry on retina. but much better for smooth fonts

dimitre avatar Mar 09 '25 13:03 dimitre

Last missing detail, fixing ofDrawBitmapString, by changing

		rViewport = getCurrentViewport();

to

		rViewport = matrixStack.getFullSurfaceViewport();
Image Image

dimitre avatar Mar 10 '25 15:03 dimitre

@dimitre this looks like a great middle ground solution. Def be worth a PR immediately after 0.12.1

ofTheo avatar Mar 10 '25 16:03 ofTheo

one more commit to complete ofDrawBitmapString https://github.com/dimitre/openFrameworks/commit/cae4e9e23a787b187a6d2072749ddb19f8d5841c

dimitre avatar Mar 13 '25 17:03 dimitre

Thanks for digging into this. I figured it was be more or less straightforward, just finding all the detailed spots to adjust to the right calls.

danomatika avatar Apr 02 '25 19:04 danomatika

Great @danomatika testing is welcome this fork has a different project generator and libs, works for macos and linux only https://github.com/dimitre/ofworks/

dimitre avatar Apr 09 '25 17:04 dimitre

Retina support is 99% ready. if anybody can jump and help with 3d camera matrix multiplication adjustment it would be great! cc @openframeworks/2d-3d Image

dimitre avatar Oct 18 '25 14:10 dimitre

Wow - awesome work @dimitre !! Did you get TTF fonts figured out to? For me that was the biggest hurdle.

I can have a look at the camera stuff. Do you have a branch for this?

ofTheo avatar Oct 18 '25 17:10 ofTheo

Yes it is working in ofworks fork instructions to bootstrap installation on this link https://github.com/dimitre/ofworks/

or if you prefer just clone this branch https://github.com/dimitre/openframeworks/tree/ofworks

Other changes in this fork are needed, since I fixed some stuff in GLFW Window. Everything draws with correct dimensions, but ofTexture is drawing with non retina resolutions. It would be great to add a parameter to ofTexture (and ofFbo) to have variable internal density.

About Typography I think we should not handle internally anymore, just keep as it is until the time to rewrite using external libs

dimitre avatar Oct 18 '25 19:10 dimitre