Important: Please read the Qt Code of Conduct -

QOpenGLWidget doesn't draw some of my objects

  • I have some 1300 objects that draw themselves in a loop like this:

    void svGLWidget::paintGL()
        auto f = GLFunctions();
        m_drawingFacilities.glFunctions = f;
        m_drawingFacilities.projection = m_projection;
        m_drawingFacilities.modelview  = m_modelview;
        m_drawingFacilities.viewDir = ViewDirection();
        m_drawingFacilities.upDir   =   UpDirection();
        auto objs = EnabledObjectsIntersectingViewVolume();
        for (auto it : objs)
                    m_drawingFacilities, *it->second.m_vs_sptr.get(),
        if (m_state == &m_state_drawSelectonFrame)

    The project is complicated enough that I cannot place here all code involved.
    When I upload too many objects on the scene, some of them are not visible. In debug I can see that their Draw() function is invoked, but they don't show up on the screen anyway. It is not a clipping planes issue. When I delete e.g. ~1200 objects, reducing number of objects on the screen, then objects appear on the view that didn't draw themselves earlier. And they stay on the screen if I load the deleted objects back, though I don't know if any of newly loaded objects don't draw themselves — there's no easy way to tell that.

    So how do I fix it?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you have any depth test enabled ?

  • Yes, but I don't see how that can be a problem. There may be 2 objects beside (even intersecting) each other and only one of them is visible.

  • Lifetime Qt Champion

    It was just a guess as you didn't explain how you were painting your objects nor if they are on top of each other.

Log in to reply