I completely agree with @datenwolf's recommendation, but wanted to provide some more reasoning. I would only call glGen*()
for multiple names if it's the most convenient thing to do. If you already have an array of names anyway, and want to create them all at once, then go ahead and use a single call. But it's definitely not worth jumping through any hoops, and I can't imagine a realistic scenario where it would help performance.
The glGen*()
calls only create object names (which is the official OpenGL terminology, even though many people call them "ids"), not objects. The actual object is only created the first time you bind a name. So there's no possible gain from creating multiple objects at once, the only (insignificant) gain is from generating multiple names at once.
I can think of two related reasons why generating the names isn't much more than a drop in the ocean:
- It doesn't happen at a high frequency. What you should typically worry about are calls that are made very frequently, like state update calls that are made between draw calls, and the draw calls themselves.
Name generation typically happens at a moderate frequency during setup, and rarely later. Maybe you'll create a new buffer or texture every once in a while, but this is mostly insignificant compared to how often you bind textures or buffers.
- It is tied to much more expensive operations. You only generate as many names as you need for creating the actual objects. And creating the object is much more expensive than generating the name. If you picture everything that needs to happen for creating a typical object (various memory allocations, state setup, etc), generating the name is an insignificant part.