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. [SOLVED]Allocate QVector data in QOpenGLBuffer

[SOLVED]Allocate QVector data in QOpenGLBuffer

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.9k 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.
  • N Offline
    N Offline
    Nexelen
    wrote on last edited by
    #1

    Hello! Im tried allocate QVector data in QOpenGLBuffer but its not work. Why? Can i allocate QVector data in QOpenGLBuffer?
    @QVector<QVector2D> points;
    points.push_back(QVector2D(-0.90f, -0.90f));
    points.push_back(QVector2D(0.85f, -0.90f));
    points.push_back(QVector2D(-0.90f, 0.85f));
    points.push_back(QVector2D(0.90f, -0.85f));
    points.push_back(QVector2D(0.90f, 0.90f));
    points.push_back(QVector2D(-0.85f, 0.90f));
    m_vertexPositionBuffer.create();
    m_vertexPositionBuffer.setUsagePattern(QOpenGLBuffer::StreamDraw);
    if(!m_vertexPositionBuffer.bind())
    {
    qWarning()<<"Could not bind vertex buffer to the context";
    return;
    }
    m_vertexPositionBuffer.allocate(points.constData(), points.length());@

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2
      1. Make sure that your OpenGL context is current at that point

      2. The second argument to allocate() should be the actual size in bytes not the number of elements. E.g.

      @
      m_vertexPositionBuffer.allocate(points.constData(), points.length() * sizeof(QVector2D));
      @

      1. Make sure your vertex attribute data specification matches 2D vectors of floats.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Nexelen
        wrote on last edited by
        #3

        This! :D thank you!
        [quote author="ZapB" date="1393775844"]

        1. The second argument to allocate() should be the actual size in bytes not the number of elements. E.g.

        @
        m_vertexPositionBuffer.allocate(points.constData(), points.length() * sizeof(QVector2D));
        @

        [/quote]

        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