Concept behind OpenGL's 'Bind' functions

后端 未结 5 1338
旧时难觅i
旧时难觅i 2021-01-29 22:35

I am learning OpenGL from this tutorial. My question is about the specification in general, not about a specific function or topic. When seeing code like the following:

5条回答
  •  没有蜡笔的小新
    2021-01-29 23:14

    Binding a buffer to a target is something like setting a global variable. Subsequent function calls then operate on that global data. In the case of OpenGL all the "global variables" together form a GL context. Virtually all GL functions read from that context or modify it in some way.

    The glGenBuffers() call is sort of like malloc(), allocating a buffer; we set a global to point to it with glBindBuffer(); we call a function that operates on that global (glBufferData()) and then we set the global to NULL so it won't inadvertently operate on that buffer again using glBindBuffer().

提交回复
热议问题