is VertexAttribPointer needed after each BindBuffer?

前端 未结 2 2052
耶瑟儿~
耶瑟儿~ 2021-02-02 01:42

I noticed that unless I re-call VertexAttribPointer, there\'s not input to shaders after a BindBuffer. Is that necessary? The shaders may not change in writing but only the buff

2条回答
  •  心在旅途
    2021-02-02 02:25

    According to OpenGL OpenGL specifications, page 51 (Buffer Object State), the state corresponding to the array pointers stores the buffer ID. That means that if you want to change the buffer object to draw with, you need to recall glVertexAttribPointer function.

    glBindBuffer(1);
    glVertexPointer(...);
    glDrawArrays(...); /// Drawing will use buffer 1
    
    glBindBuffer(2);
    glDrawArrays(...); /// Drawing will still use buffer 1
    
    glVertexPointer(...);
    glDrawArrays(...); /// Drawing will now use buffer 2
    

提交回复
热议问题