View Full Version : glGenTextures question
05-06-2012, 02:18 AM
Is the first texture name returned from glGenTextures always guaranteed to be 1 for the first call in your program?
05-06-2012, 03:00 AM
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.
05-06-2012, 05:02 AM
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.
05-06-2012, 05:27 AM
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: http://www.opengl.org/wiki/Common_Mistakes#The_Object_Oriented_Language_Probl em
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.