I’m doing it the wrong way. I’ll stick to floats then.
I’m not sure why. You understood it back when I explained it. Then GClements came along with his “fixed-point” stuff (technically a legitimate phrase, but not correct OpenGL terminology), and now you don’t get it.
Just forget everything he wrote
I’m not aware of the inner working of the openGL/client but what I meant was when you create for instance a vertex buffer as an array in the client, and pass it to openGL. You’ll probably laugh reading this but I speculate that openGL creates a corresponding array of bytes in video memory (doesn’t matter when but probably at the time of using glBufferData() ) so the point is that there would be 2 data sets with the same data.
When I said “your memory”, I didn’t mean “addressable on the CPU”. I meant “you told OpenGL to allocate it, you told OpenGL what to fill it with, and it won’t go away until you tell OpenGL to delete it.”
The money you put in a bank account is still your money, even though it’s not physically in your possession right now. A buffer object is like that.
But you are right that immediately after calling glBufferData, there are two copies of your data. One in the pointer you gave to glBufferData, and one in your buffer object’s storage.
But I haven’t seen anywhere somebody to free up the array after passing it to openGL.
By “the array”, I’m going to assume you’re talking about “the pointer passed to glBufferData”.
Well, most tutorial code doesn’t allocate that memory directly anyway. They usually use C-style arrays, like this:
glm::vec4 IAmAnArray[] = { ... };
Those are either stack variables or globals. Either way, C++ will clean them up for you.
You only need to be concerned about freeing memory that you directly allocated.
If you were talking about the buffer object itself, yes, most tutorials are kinda… stupid about that. When your application destroys the OpenGL context, all objects in OpenGL will also be destroyed. So most tutorials ignore the whole memory management thing in favor of just dropping it on the floor.
Of course, such tutorials forget that the entire point of a tutorial is to teach something. Like, for example, managing OpenGL memory objects.