A Question about Vertex Buffer
I am a beginner with Direct3D, and I have a question about Vertex Buffer:
Should I create a Vertex Buffer when I render a frame every time,
Or
Create a Vertex Buffer big enough only one time?
Thanks!
Create it the first time it''s needed. Delete it when it''s not needed anymore. Store it in between frames. Do NOT delete and recreate every frame, that will slow you down... alot.
I cannot undertand it clearly, could you please explain "Delete it when it''s not needed anymore" in detail, giving me a example is better.
i don''t know when it''s not needed.
thanks.
i don''t know when it''s not needed.
thanks.
When you're done with it. Like when you have no instances of the buffer left, or at the end of the program.
For example, you create a buffer for your object, load the vertices into the buffer, and save that as a member variable. When, in the game, the object is destroyed, you delete that vertex buffer. Or, like me, you create a vertex buffer for each type of object, for example I could have 12 box objects that have the same vertex buffer. Once all 12 of them have been destroyed, I delete the buffer. Usually you create a manager to hold the buffers and to know how many objects are using each buffer, and when the number using it is 0 it deletes it. If you then create another object after all have been destroyed you'd have to recreate it, but that's better than creating a new one for each object. Or you could just keep everything loaded until the end of the program and then delete it to avoid what I mentioned, but use up more memory.
[edited by - Erzengeldeslichtes on September 1, 2003 1:48:34 AM]
For example, you create a buffer for your object, load the vertices into the buffer, and save that as a member variable. When, in the game, the object is destroyed, you delete that vertex buffer. Or, like me, you create a vertex buffer for each type of object, for example I could have 12 box objects that have the same vertex buffer. Once all 12 of them have been destroyed, I delete the buffer. Usually you create a manager to hold the buffers and to know how many objects are using each buffer, and when the number using it is 0 it deletes it. If you then create another object after all have been destroyed you'd have to recreate it, but that's better than creating a new one for each object. Or you could just keep everything loaded until the end of the program and then delete it to avoid what I mentioned, but use up more memory.
[edited by - Erzengeldeslichtes on September 1, 2003 1:48:34 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement