Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5 and OpenGL with a Mac Retina display
Forum Updated to NodeBB v4.3 + New Features

Qt5 and OpenGL with a Mac Retina display

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.0k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    KeithS
    wrote on last edited by
    #1

    With Qt 4.8.6 on Mac Yosemite, I was using a QOpenGL widget, setting the glViewport() using the values passed in by resizeGL(). And then using:

    gluOrtho2D(m_World.left(), m_World.right(), m_World.bottom(), m_World.top());

    where m_World was my actual drawing coordinates. This all worked fine. The only bug was that Qt 4 did not handle icon sizes correctly on the retina display - they were twice as big as they should have been. This was fixed in Qt 5.x with the devicePixelRatio() command that allowed you to get the device pixel coordinate ratio.

    However, I', still not clear how to use it and where. Do I apply it to the viewport I use for mapping between world and viewport coords using:

    glGetIntegerv(GL_VIEWPORT, m_Viewport);
    and multiplying the m_Viewport coords by the devicePixelRatio() ? Reason is I am finding my data that has the bounding box of m_World is shifted and goes outside the viewport - it appears to be double the size it should be.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KeithS
      wrote on last edited by
      #2

      OK so the solution is to scale the viewport by devicePixelRatio(). And, if you're using textures, scale them too. and just about anything else that openGL is doing, as it is assuming your viewport coords are pixels, which they are not...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved