How To Use VBO in QT with opengl es?



  • when I was using qt with opengl es, in my render code, I used VBO in the way just like in win32 project, the code is the following:

    @
    void DrawMesh()

    {
    #if 1
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    GLuint buf1,buf2;
    glGenBuffers(1,&buf1);
    glBindBuffer(GL_ARRAY_BUFFER,buf1);
    GLfloat a[]={
    0.0f, 0.0f, 0.0f, 0.0f,
    1.0f, 0.0f, 0.0f, 1.0f,
    0.0f, 1.0f, 0.0f, 2.0f
    };

    GLushort index[] = {
    0,1,2
    };
    glBufferData(GL_ARRAY_BUFFER,12sizeof(GLfloat),a,GL_STATIC_DRAW);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,4
    sizeof(GL_FLOAT),0);
    glGenBuffers(1,&buf2);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,buf2);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER,3*sizeof(GLushort),index,GL_STATIC_DRAW);
    glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_SHORT,0);
    glDisableClientState(GL_VERTEX_ARRAY);
    #endif
    }
    @

    when run to “glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_SHORT,0);” error occured “Unhandled exception at 0×0239faec in hellogl_es2.exe: 0xC0000005: Access violation reading location 0×00000000. ”
    I want to know why this happened?
    here if I remove VBO parts, no error occured, how to use VBO in QT?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.