Use of Vertex Array Objects and Vertex Buffer Objects

前端 未结 2 2035
耶瑟儿~
耶瑟儿~ 2020-12-12 17:23

I am trying to understand these two, how to use them and how they are related. Let\'s say I want to create a simple terrain and a textured cube. For both objects I have the

2条回答
  •  离开以前
    2020-12-12 17:49

    Your question is not easily answerable here, but rather in a tutorial. You probably already know these two websites, but if not, I'm leaving the references.

    OGLDEV

    OpenGL-Tutorial.org

    Now trying to elucidate your questions, a Vertex Array Object is an OpenGL object designed with the goal of reducing API overhead for draw calls. You can think of it as a container for a Vertex Buffer and its associated states. Something similar perhaps to the old display-lists. Normally, there is a 1 to 1 relationship between a VAO and a VBO; that is, each VAO contains a unique VBO. But this is not strictly necessary. You could have several VAOs referencing the same VBO.

    The simplest way to model this in code, I think, would be for you to have a VAO class/type and a method to attach a VBO to it. Then give an instance of VAO to each mesh. The mesh in turn can have a reference to a VBO type that may be its own or a shared one.

提交回复
热议问题