Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Login

    Reading Display scale factor? <Retina,non-Retina>

    Cinema 4D SDK
    c++
    2
    3
    397
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • WTools3DW
      WTools3D
      last edited by ferdinand

      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.

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @WTools3D
        last edited by ferdinand

        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 the gui 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 the BaseDraw, get its handler, and then the DPI scale, i.e., do this BaseDraw -> 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

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • WTools3DW
          WTools3D
          last edited by

          Thank you Ferdinand!
          I'll continue in backstage with this topic.
          V.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post