gldrawarrays does not draw anything

后端 未结 1 409
抹茶落季
抹茶落季 2021-01-27 00:12

I\'m trying to draw a triangle with VBOs. I do not see any pixels on the window. I do not see any GL_ERROR too.

Here is the code I am trying to run:

#inc         


        
相关标签:
1条回答
  • 2021-01-27 00:46

    When not using shaders (as I assume you don't), one cannot use theglEnableVertexAttribArray/glVertexAttribPointer methods.

    What you can do instead is to use glVertexPointer, which constructs a binding the the VBO when one is bound. The last parameter in this case specifies the offset in the buffer, which will be 0 in your case. (reference)

    Something like this should do the trick:

    glClear(GL_COLOR_BUFFER_BIT);
    glEnableClientState(GL_VERTEX_ARRAY);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glVertexPointer(3, GL_FLOAT, 0, 0);
    glDrawArrays(GL_TRIANGLES, 0, 3);
    glDisableClientState(GL_VERTEX_ARRAY);
    
    0 讨论(0)
提交回复
热议问题