Reputation: 25154
When doing OpenGL we are constantly defining what Kind of Buffer we are dealing with. Even when OpenGL Superbible says that there are no really types to buffers, as they are just "buffers", someone has to provide always the Kind of Buffer.
So why is it important to always supply the buffer type as argument? Are there for every Buffer a reserved amount of memory? Are the Memory Locations different from different type of Buffers?
Upvotes: 1
Views: 376
Reputation: 45352
Well, there are different aspects to be considered here. First of all, OpenGL is just a API spec which will not enforce how things are implemented internally - it is agnostig towards any specific memory and cache architectures and such things.
Having said that, there are still some things guaranteed by the standard. And one ting is that the buffers are not "stringly typed". You do not create VBO, but just a buffer. You can use that as VBO, or as IBO, or as PBO, or UBO or whatever later un, even if the initial binding target was GL_ARRAY_BUFFER
. You can even bind the same buffer to different targets at the same time, like putting vertex and elemnt indices into the same buffer. So considering that, it is true that there a no different buffer types. The binding targets just give semantic meaning to the buffers at the time of there use. This is also just GL's standard bind-to-use and bind-to-modify approach.
However, that os only half of the story. The fact that you can do such things does not mean that it is a good idea to actually do them. Any sensible GL implementation will use the buffer target and the usage hints when creating the buffer as basis for deciding where to put it - into client RAM, into some GPU-mapped GART area, into the VRAM (if there are such things on a particular implementation). So you actually work against the optimizations of your GL implementation if you do not use the buffer as you created it, or use the same buffer for different things without a good reason to do so. And as a result, performance might not as good as it could be.
Upvotes: 2