Reputation: 20780
I have the fallowing situation using vertex buffers in OpenGL on iPad: - render some objects with 30 FPS - delete the objects and create new ones(kill all entities and spawn others) - render the new objects
The FPS drops to 10 for few seconds and slowly recovers to 30. I used some timers and I saw that render time increases from 30ms to 100ms for few seconds. Update time is increasing only when loading new objects(one frame) and send to render time is constant. I think the problem is with vertex buffers caching. Is there a way to force caching instead of waiting for OpenGL to do so? Do you have other opinions about this problem?
Upvotes: 1
Views: 218
Reputation: 78914
Another possible option would be to not destroy the objects and recreate them but rather update the data in them using glBufferSubData()
.
This may still not solve the caching problem because you're still putting new data in the buffer but I think it is guaranteed to be faster than destroying and recreating the buffer.
With this change in place, another thing you can try is to play with the usage
parameter of glBufferData()
and change it to GL_DYNAMIC_DRAW
or GL_STREAM_DRAW
. these are supposed to give OpenGL a hint that the buffers are changing frequently and perhaps that will drive it to optimize the caching appropriately.
Upvotes: 2