How many VAO and VBOs

As far as I understand: VAO is a certain state. If I bind VAO, add some VBOs and element buffers for directions and things, I can save a certain state of the object (s) that I want to draw and activate, and easily draw them later along the way when I want to display the material. Correctly?

So, does VBO contain actual data, and VAO is just a “wrapper object” that contains pointers to all the buffers that I defined for it?

Changing VAOs is expensive (how are VBOs changing ?!). I am currently loading into Meshes and combining them with models. Each model uses its own VAO and has a VBO (with vertices) and an element buffer with their indices.

Now that I understand this, this is crap, because every object in my world (which has a model) uses its own VAO. Not a problem for ~ 30 objects in my world, but I want to do it right, and in the future there may be hundreds or thousands of objects, and then performance will greatly decrease.

Thus, many objects are “the same” in terms of their models. I mean, if, for example, you have a certain type of Tree in the world, you probably use the same model several times, only in different places.

Now how can I do this? Do I have to manually track my VAOs as: (the pseudocode is next!)

treesVAOId = 1;
rabbitsVAOId = 2;

and then if I load the model, just check if the ID has already been linked (how?) and added another set of VBOs (or even added to the right VBO? if so, how?)

. , . , , VAO VBO , ?

, ... , ( ) .

, , VAO VBOs .

+4
2

, , , , . , , - ( XML JSON).

:

VAO , , , , .. , VBO VAO, . , , , VAO, VBOs, VBO.

(, ) . VAO (, , ). ? , - . , , . , , , . composite .

, , ..

( ) ? . . , . , ( , ..) . , , . , . , , VAO . singleton .

:

ModelHandle footman = resMan->getModel("footman.model");
//.....
footman->setLocation(x,y,z);
footman->draw();

getModel ( "footman.model" ) ,

MeshHandle resMan->getMesh("footman1.mesh");

. getMesh . , , , VAO, . VAO, . VAO.

, - , . , node, .

- . :

  • singleton ?
  • , , , , ? singleton , :
 
    ResourceHandle h1 = Singleton<ResourceMan>::instance->getResource("foo");
    ResourceMan myPrivateManager;
    ResourceHandle h2 = myPrivateManager.getResource("bar");

VAO - , . , - .

, , . , . (.. ) VAO, VAO . ? , .

, , . VAO, , , , .

:

http://www.gamedev.net/page/resources/_/technical/game-programming/a-resource-manager-for-game-assets-r3807

http://www.gamedev.net/page/resources/_/technical/game-programming/a-simple-fast-resource-manager-using-c-and-stl-r2503

:

http://www.gameenginebook.com/

+8

VAO , . , , . , , VAO/ . , , VAO 6 /. 60 , VAO 100 000 .

, , VAO. , , , . . , VAO 1000 /.

, . ( ). , VAO .

, , , , , . . , , . , , , , .

, , . , , , . , . , TreeShape, (VAO VBO) . . , , Tree, , / , TreeShape, , VAO/VBO, TreeShape, Tree , .

+2

All Articles