Jump to content
  • Advertisement
Sign in to follow this  
shirsoft

glGenTextures redundant?

This topic is 3790 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
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.

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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!