Skip to main content
GameDev.net gamedev.net
🔒 Locked

Why glGenTextures

Started by Chimaira Apr 4, 2007 at 10:07 AM 1 replies 900+ views
Original Post
Chimaira
Chimaira
I've read some tutorials on textureloading in opengl and everyone seem to use some glGenTextures-function that IMO does nothing useful. It just returns some id-numbers in a intarray. My question is: is it realy necessary to call this function and use the values it throws out or can i use my own id-numbers? I've tried to not use this function and so far it works just like before. I just want to make sure that it doesn't do anything strange in the background that will cause my program to behave strange when i start to load tons of textures.
_the_phantom_
_the_phantom_
Yes, you can use it that way, for now, however it is recommended that you let the driver return an id number for you (this helps avoid clashes from mistakes in your own code and iirc helps the driver allocate things sanely as well).

Also, from the next version of OGL asking for a texture id (or indeed, VBO, VAO, GLSL and FBO ids) will be the only way to do it (this is a speed issue, when binding things the majority of the drivers time is taken up by performing various lookups to find the correct data from the id given).

So, in short, while it works, I wouldn't recommend providing your own ids; instead let OGL manage it for you.
Brother Bob
Brother Bob
glGenTexture, or any glGenWhatever for that matter, does nothing but returning an unused ID for you to use. Feel free to use your own ID manager if you like, it's perfectly OK.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.