Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22

Thread: Drawing lines in QPainter takes a lot of time

  1. #21
    Join Date
    Mar 2016
    Posts
    14
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Drawing lines in QPainter takes a lot of time

    As you said, I currently use the classical :
    Qt Code:
    1. // Setup our vertex buffer object.
    2. m_myVbo.create();
    3. m_myVbo.bind();
    4. m_myVbo.allocate(m_vertexData.constData(), m_floatCount * static_cast<int>(sizeof(GLfloat)));
    5. m_myVbo.release();
    To copy to clipboard, switch view to plain text mode 
    Sorry I don't actually have the skills to understand the second option with the CPU/GPU mapping

    The full project, configured for the GPU test (test 6) is available here : sources.zip
    The VBO setup is in myGLwidget_vertAndFrag.cpp at line 269.

    Could you send me the modif to do to test this option ? I'm interested too.

  2. #22
    Join Date
    Mar 2016
    Posts
    14
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Drawing lines in QPainter takes a lot of time

    Ok, I take my courage to understand the new method, and it was finally not the hard.
    I replaced :
    Qt Code:
    1. m_myVbo.bind();
    2. m_myVbo.write(0, m_vertexData.constData(), m_floatCount * static_cast<int>(sizeof(GLfloat)));
    3. glDrawArrays(GL_TRIANGLES, 0, m_vertexCount);
    4. m_myVbo.release();
    To copy to clipboard, switch view to plain text mode 
    by :
    Qt Code:
    1. m_myVbo.bind();
    2. auto ptr = m_myVbo.mapRange(0, m_vertexData.size()*int(sizeof(GLfloat)),
    3. QOpenGLBuffer::RangeInvalidateBuffer | QOpenGLBuffer::RangeWrite);
    4. memcpy(ptr, m_vertexData.data(), size_t(m_vertexData.size())*sizeof(GLfloat));
    5. m_myVbo.unmap();
    6.  
    7. glDrawArrays(GL_TRIANGLES, 0, m_vertexCount);
    8. m_myVbo.release();
    To copy to clipboard, switch view to plain text mode 
    But the performances were quite the same ; can't see the difference on GPU monitoring (load of around 90% for 50 000 lines).

Similar Threads

  1. Drawing Lines In Real Time (PyQt)
    By n3ziy in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2016, 20:09
  2. drawing lines on a canvas and move them dynamically
    By smrati.johri in forum Newbie
    Replies: 4
    Last Post: 7th April 2016, 23:35
  3. Drawing lines on qwtpolarplot
    By jerrychan in forum Qwt
    Replies: 3
    Last Post: 12th June 2013, 11:55
  4. drawing lines using qpainter from file
    By neutrino in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2013, 10:03
  5. Drawing row/column lines in QTreeWidget
    By warvimo in forum Newbie
    Replies: 0
    Last Post: 25th May 2012, 18:33

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.