Reading Display scale factor? <Retina,non-Retina>
-
Hi guys,
When drawing bitmaps on the screen using BaseDraw::DrawTexture(), there is a difference between Retina and non-Retina displays. The scale factor is usually 1.0 for regular displays and 2.0 for Retina displays. When the scale factor is larger, the pixel size of the bitmap needs to increase accordingly.
Is there any way to retrieve this factor directly from the Cinema C++ SDK? I would expect this to be accessible in the BaseDraw or BaseView class.
I hope I’m asking correctly this time.
Thanks,
V.Let me know if you’d like further revisions!
@edit:
--- the size of the bitmap in pixels needs to increase accordingly. ----
just to be more clear. -
Hello @WTools3D,
Thank you for reaching out to us. There is unfortunately not a good way to do in the public API what you are trying to do. There is GeDialog.GetPixelRatio which will return in principle the value you desire. You will however have to open a dialog to get a meaningful reading at all, as the method will otherwise always just return the constant
1
(but even then the value might be incorrect, see below):Float GeDialog::GetPixelRatio() const { if (!cd) return 1.0; return C4DOS_Cu->GetPixelRatio(reinterpret_cast<const CBaseFrame*>(cd)); }
In the non-public
gui
framework there is a method to achieve the same, which acts as a quasi static method, since for the interface it sits on exist global instances. We brielfy talked internally about exposing thegui
framework roughly half a year ago, but it does not yet have come to pass.The problem with all this is that such information is of course display dependent and a user could use multiple displays with different DPI scalings each. So, when you use the
GeDialog
approach, you would have to make sure that the dialog is being opened on the screen where the drawport is you want to draw into. Effectively it is impossible to determine the DPI scale of a viewport with the public API at the moment, because even when one would fall back to native OS calls for getting the DPI scale for a screen, there is currently no way to find out on which screen a viewport does live on in the public API.Another option would be to apply for Maxon Registered Developer status which would give you access to the semi public drawport API. You could then get the
DrawportRef
for theBaseDraw
, get its handler, and then the DPI scale, i.e., do thisBaseDraw -> GetDrawPort -> GetRedrawHandler -> GetWindowScaleFactor
.The drawport API is semi-public for a reason. It is in larger parts undocumented, and we expect users to more or less swim on their own. We will provide some support, and there are also code examples, but it still is a semi-public API.
Cheers,
Ferdinand -
Thank you Ferdinand!
I'll continue in backstage with this topic.
V.