Drawing trajectory

Hi I am trying to render an aiming line for my game where you shoot a ball. I found a formula for calculating the trajectory for a body but it´s not accurate. Has anyone tried anything similar or have any tip what might be wrong? It works ok in the begining of the line with more error towards the end.

Code:
            float startX = 400.0f + mVelX * 33.0f;
      float startY = mVelY * 31.0f + 10.0f;
      float endX = startX;
      float endY = startY;

      float speed = mVel.Length();
      float time = 0.0f;

      for(int i = 0; i < 5; i++)
      {
         time = i * 0.075f;
         
         endX = startX + mVelX * speed * time;
         endY = startY + mVelY * speed * time + gravity * (time * time);
         
         //Create line segment

              }

Original thread: https://box2d.org/forum/viewtopic.php?t=4510