glGenTextures redundant?

Started by
4 comments, last by shirsoft 16 years, 1 month ago
I was just browsing through some of old code, and I noticed that code didnt use glGenTextures to generate texture id. They directly go ahead with BindTexture and TexImage. I looked up on the spec and it says that GenTextures just marks them as used nothing more. I am wondering why would someone avoid a simple call?
The longest battle is the battle within
Advertisement
I don't know the exacts of GL, but the way I see it is:

GenTextures //gives you a handle to an address of the texture on the gpu
glBindTexture //the texutre u want to mess with
glTexImage // you tell it how big the texture is and send it, gives you the handle


I think that because you first bind a texture as 2D,1D,3D etc, it sets it to that forever. I think that if you don't call genTexture, then GL doesn't know if this texture is initialized or not....?

http://www.opengl.org/sdk/docs/man/xhtml/glBindTexture.xml

I would think genTextures does a little bit else maybe inside, like a valid check for something. Otherwise it is pointless.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

It is correct that you can make an OpenGL Application that uses textures without ever calling glGenTextures. glBindTexture is the actual call that creates the texture and not glGenTextures. glGenTextures just remembers which texture ids are already in use and gives you the ones that are still free. But it is not required to use glGenTextures. You can as well generate your own ideas.
While you can use your own ids it is advised by NV and AMD/ATI that you don't; by generating ids via OpenGL you give a driver a bit of a heads up on what is coming, by forcing your own ids on the driver it has no idea what to expect.

glGenTextures() exists for a reason; use it.

Also, if you don't use glGenTextures then you need to make sure you are generating unique ids and who wants to write extra code? [smile]

(also, as a side note, whenever GL3 appears you won't be able to use your own texture/vbo/fbo/whatever ids any more, you must ask GL for them, so you might as well get into the habit of using them)
Maybe it's just me but sometimes ATi's texture IDs look like pointers.
I agree that not using GenTextures should be considered a bad practice.

Previously "Krohm"

Thanks a lot guys. I will roll this in the next release of our code. I wish i could find the developers who wrote it. They were supposedly really good at this so I wonder what they thought
The longest battle is the battle within

This topic is closed to new replies.

Advertisement