cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.28k stars 939 forks source link

MacOS X: Using window size instead of frame buffer size #2318

Open IntellectualKitty opened 7 months ago

IntellectualKitty commented 7 months ago

On my Mac, content is drawn only in the lower left quarter of the window because the frame buffer is 2x2 times the resolution of the window on the Retina display thingy.

I'm notccompletely fluent on the details, I just have experience with this with GLFW. And they solve this -- and explain it pretty clearly, too! -- by using glfwGetFramebufferSize instead of glfwGetWindowSize for the call to glViewport.

paulhoux commented 7 months ago

Isn't this somehow being solved using the Cinder function toPixels()? Or is there a problem with window creation only, which may not be accessible code for the average user?

See also: https://github.com/cinder/Cinder/blob/4e27a4a5e66fd63000e98afa09d0d0419119ee6b/include/cinder/app/Window.h#L301C1-L312C74

IntellectualKitty commented 7 months ago

It's been a while since I used Cinder, but the OpenGL ShadowMapping sample is a nice base for me to build from, and Cinder is always easy to work with.

Anyway, when built and ran the sample, it was drawing to the lower-left quarter of the window, a symptom I often come across on my Mac, hence my familiarity with it.

I don't know if toPixels() solves this or not. I did try to find a getFramebufferSize() as a counterpart to getWindowSize() in the App code, but didn't find anything. (That's the standard solution that I'm familiar with.)

My issue is that an app should draw to the whole window right out of the box. But thanks for the tip about toPixels()!

IntellectualKitty commented 7 months ago

I've checked, and toPixels() is being called when the viewport is being set with the window size.

When I take out the toPixels() call, it doesn't change. I did notice that getContentScale(), which is what toPixels() uses, defaults to 1.0f...

IntellectualKitty commented 7 months ago

I apologize. This may or may not be the issue. The architecture and base SDK settings are incorrect for the current main branch (I freshly downloaded Cinder) when using CMake to generate an Xcode project for the library; the samples seem to have the same erroneous settings as well (e.g., x486_64).

Resetting the architecture to standard architectures and the base SDK to macOS in the pull-down list for both the library and the samples seems to work. I was able to run other samples now, and they are scaled correctly, when they didn't build before.

Sadly, the ShadowMapping still doesn't work, but I'm on a new project now, and don't have time to figure out what's wrong. I started modifying it and who knows what I did to it...

Anyway, I hope the information is helpful.

Thanks again!

paulhoux commented 7 months ago

Thanks for your report, anyway! I currently do not have access to a Mac, so I can't attempt to fix your issue myself. But it seems to me that getContentScale() should return something else than 1.0.

On Windows, I seem to recall that the application manifest needs to be changed to enable high pixel density settings. And perhaps something similar needs to be done on the Mac. If your SDK or other settings are out of date, that probably doesn't help.

Perhaps someone else finds time to look at this. The information presented above may help.

axjxwright commented 7 months ago

On Windows, I seem to recall that the application manifest needs to be changed to enable high pixel density settings. And perhaps something similar needs to be done on the Mac. If your SDK or other settings are out of date, that probably doesn't help.

Yep, to opt out of retina mode you can set High Resolution Capable to NO in your Info.plist