Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: use VBO to define color & vertex variable in GPU

  1. #1

    use VBO to define color & vertex variable in GPU

    I added this to the initialization part:
    Code :
    verticesSize = sizeof(vertices);
    colorsSize   = sizeof(colors);
     
    glGenBuffers(2, vbods);                       
     
    glBindBuffer(GL_ARRAY_BUFFER, vbods[VERTEX]); 
     
    glBufferData(GL_ARRAY_BUFFER,
                 sizeof(vertices)+sizeof(colors),
                 vertices, GL_STATIC_DRAW );
     
    glBufferSubData(GL_ARRAY_BUFFER, sizeof(vertices), sizeof(colors), colors);
     
    glEnableClientState(GL_VERTEX_ARRAY); 
    glEnableClientState(GL_COLOR_ARRAY);

    and this to the render part:
    Code :
    glBindBuffer(GL_ARRAY_BUFFER, vbods[VERTEX]);
    glVertexPointer(2, QVector3D, 0, 0);   
    glColorPointer(3, GL_FLOAT, 0, (GLvoid *) (ANGLE_COUNT * RANGE_COUNT * 6));

    though, I get errors in the functions glBufferData, It cannot cast it from QVector3D to GLvoid*, do you have any idea?

    vertices is defined as
    QVector<QVector3D>
    Last edited by saman_artorious; 06-22-2013 at 01:16 AM.

  2. #2
    vertices.constData
    solved the problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •