To render a clod terrain, I have successfully implemented the VAR extension. I am now trying use the VBO extension.
I’ve read the spec and numerous posts at various forums, but I am still uncertain as how to implement some VAR functionality in VBO.
For initializing VAR, I allocate one large physical buffer. I then define several logical buffers and assign a fence to each logical buffer.
When rendering, I start with the first buffer and fill that with a patch of terrain. I called glDrawElements(). Typically, that patch would not completely fill the buffer, so I add another patch, and call glDrawElements(). Note that the patches are of varying sizes. I repeat this process of adding patches until the buffer is filled. I then set a fence. I move to the next buffer, test the fence, and begin
writing patches as before. Through testing, I have allocated enough memory such that the fence test always suceeds, but you never know.
So, OpenGL renders with each glDrawElements() call, while I am still filling the same or next logical buffer with a patch. Fences
prevent me from overwriting data that is still being used. The frame rate and the triangles/sec is great.
How do I implement this using the VBO extension?
As I understand, after I write to a buffer object, I must then render that buffer object, and I cannot write to that buffer object again until OpenGL is finished rendering. So, if that buffer object was allocated as 4 mb and I only used 1 mb, the remaining memory goes unused. I would like to continue filling that buffer, as I did with VAR. With VAR, I minimized the amount of wasted memory using logical buffers.
It seems that I must allocate many, many buffer objects to mimic that same thing in VAR. Based on my VAR testing, if I only
allocate a few buffer objects, I’m sure that OpenGL would not be finished rendering the first buffer object by the time I’ve filled that last. The performance would drop as I have to wait until the first buffer object is finished, before I can write to it again. Is allocating a large number of buffer objects bad as I suspect?
I think VBO is going to hurt the performance of my terrain renderer.
Hopefully, I misunderstand VBO, or there may be suggestions to correct this problem.