glGenTextures redundant?
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?
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.
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.
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)
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.
I agree that not using GenTextures should be considered a bad practice.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement