glGenTextures question

Is the first texture name returned from glGenTextures always guaranteed to be 1 for the first call in your program?

In the 4.2 core spec it says nothing about it. So in general, you shouldn’t rely on the first name being one. Still, in my experience implementations tend to start with 1 and increment the following unused handles by one. This will of course not be valid if you have allocated space for objects 1-5, for instance, delete object 1, and then allocate space for two new objects. They will most likely be named 1 and 6.

Why does it matter? You’re supposed to remember the name anyway since you can’t really clean up yourself without knowing the name.

It sounds like you are a hard coder. Do not do that. Do not rely on predefined behavior. It is bad programming. For this texture case, make a texture class and create an object for each texture you’ll be creating. Let your class hold the value returned by glGenTextures. You should not care what that value is.

Adding to V-Man suggestion, which is a good one in an OO framework, DON’T use the destructor to call glDeleteTextures! If you create a temporary object you texture object will be destroyed once the object goes out of scope. You might want to check out the common mistakes wiki: Common Mistakes - OpenGL Wiki