Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Sometimes Qt's paintGL does not draw OpenGL edge of Bullet's Physics colliders
Forum Updated to NodeBB v4.3 + New Features

Sometimes Qt's paintGL does not draw OpenGL edge of Bullet's Physics colliders

Scheduled Pinned Locked Moved Solved Game Development
4 Posts 1 Posters 800 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.
  • 8Observer88 Offline
    8Observer88 Offline
    8Observer8
    wrote on last edited by
    #1

    It works 50 by 50%:

    CollidersIsNotDrawn.gif CollidersIsDrawn.gif

    I call collider's drawing (m_pWorld->debugDrawWorld();) like this:

    void Widget::paintGL()
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        m_pWorld->debugDrawWorld();
    
        m_projViewMatrix = m_projMatrix * m_viewMatrix;
        m_pPlayer->position = m_pPlayerCollider->getPosition();
        m_pPlayer->rotation = m_pPlayerCollider->getRotation();
        m_pPlayer->draw(m_projViewMatrix);
        m_pGround->draw(m_projViewMatrix);
        m_pPlatforms->draw(m_projViewMatrix);
    }
    

    I have the DebugDrawer class that I inherit from btIDebugDraw. I override the drawLine method to transform the 1x1x1 cube to make a segment to draw. I draw the segment by calling m_pColliderEdge->draw(m_projViewMatrix); in the drawLine method.

    1 Reply Last reply
    1
    • 8Observer88 Offline
      8Observer88 Offline
      8Observer8
      wrote on last edited by 8Observer8
      #4

      Usually, this implies some sort of pointer problem.

      @newQOpenGLWidget thank you! You set a direction for me. I forgot to get the uMvpMatrix location in the ColliderEdge class. I will publish a simple example in the next time when I ask a question.

      Note. This answer is from StackOverflow

      1 Reply Last reply
      1
      • 8Observer88 Offline
        8Observer88 Offline
        8Observer8
        wrote on last edited by 8Observer8
        #2

        I tried to send a pointer to the QOpenGLWidget object to the DebugDrawer constructor:

        DebugDrawer(QOpenGLWidget *widget, btDynamicsWorld *pWorld, ColliderEdge *pColliderEdge);
        

        to keep it for makeCurrent but this did not help:

        void DebugDrawer::drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)
        {
            /* ... */
            m_pWidget->makeCurrent();
            m_projViewMatrix = projMatrix * viewMatrix;
            m_pColliderEdge->draw(m_projViewMatrix);
        }
        
        1 Reply Last reply
        0
        • 8Observer88 Offline
          8Observer88 Offline
          8Observer8
          wrote on last edited by
          #3

          I use a timer for redrawing:

          void Widget::animationLoop()
          {
              m_deltaTime = m_elapsedTimer.elapsed() / 1000.f;
              m_elapsedTimer.restart();
              m_pWorld->stepSimulation(m_deltaTime, 8);
              update();
          }
          
          1 Reply Last reply
          0
          • 8Observer88 Offline
            8Observer88 Offline
            8Observer8
            wrote on last edited by 8Observer8
            #4

            Usually, this implies some sort of pointer problem.

            @newQOpenGLWidget thank you! You set a direction for me. I forgot to get the uMvpMatrix location in the ColliderEdge class. I will publish a simple example in the next time when I ask a question.

            Note. This answer is from StackOverflow

            1 Reply Last reply
            1

            • Login

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