Sign in to follow this  

glGenTextures redundant?

This topic is 3574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 3574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this