How OpenGL generate OBJ Name?

I ask this question because I’m developing a multi-card(or multi-machine) rendering app,I hook my app’s OpenGL API call,and repeat this call to a different RC.So if RC1 create a 3 textures and 2 VBOs,RC2 also had the same objs because every OpenGL API call in RC1 is repeated in RC2,but the textures’ & VBOs’ name in RC2 is same as in RC1?

Such as the first texture allocated in RC1 is named 0x01,so in RC2 is it also named 0x01?the first VBO in RC1 is named 0x11,so in RC2 is it also named 0x11?

If RC1 & RC2 are in a same process,the obj’s name is identical,so how about RC1 & RC2 are not in a same process?How if RC1 & RC2 are in different machine?

Which OpenGL object follow the name generator rule like texture?What I know is VBO,FBO,List,so

is there other object like the same?

It is not specified how GL generates name in the spec.

For textures and VBO, GL implementations return values starting from 1 and keep going up.
If you delete a object, another call to glGen**** could return the same ID or it might not.

For shaders, GL implementation might return values starting 1 and going up or it might return a high value light 2825637 and starts incrementing from there.

If you want to be on the safe side, do not rely on them!

Actually in OpenGL 2.x there is an easy way to make sure they are identical!

Just don’t use glGen****, but generate names yourself.

OpenGL 2.x has the (silly) way to create object names, when they are used. That means, when you glBind a texture-name, gl will do a hash-lookup and if the name does not exist, it will create it.

So glGen**** is not necessary to use.

HOWEVER this is, in my opinion, real bad style. Also it won’t work with gl 3.0, since there you are forced to let gl generate the names.

Therefore i would not advise you to do it. I just want to point out, that there IS a reliable way. IF anything else is too complex or you just need to get it done, you might consider it. If you find a better alternative, use that.

Jan.

Originally posted by Jan:
[b] Actually in OpenGL 2.x there is an easy way to make sure they are identical!

Just don’t use glGen****, but generate names yourself.

OpenGL 2.x has the (silly) way to create object names, when they are used. That means, when you glBind a texture-name, gl will do a hash-lookup and if the name does not exist, it will create it.

So glGen**** is not necessary to use.

HOWEVER this is, in my opinion, real bad style. Also it won’t work with gl 3.0, since there you are forced to let gl generate the names.

Therefore i would not advise you to do it. I just want to point out, that there IS a reliable way. IF anything else is too complex or you just need to get it done, you might consider it. If you find a better alternative, use that.

Jan. [/b]
Thank Jan,do you mean I can write my own algorithm to generate name for texture,VBO,FBO,PBO?

do you mean I can write my own algorithm to generate name for texture,VBO,FBO,PBO?
Yes.

Unfortunately, 2.1 allows you to basically pass any non-0 32-bit integer to any of the glBind* functions, and the OpenGL implementation will have to work with it.

The glGen* functions exist only as a way for the user to ask the system for an unused object name. Calling, for example, glGenBuffer does not tell the system to create the actual buffer object; you have to glBind it and call glBufferData to do that.

However, I would like to second Jan’s point that it is really bad style to do this. Basically, all doing it does is saves you from having to store the integer name yourself (because presumably anytime you want the texture name, you can recompute it with your hash algorithm). And saving a few 32-bit integers isn’t worth the effort nor the lack of object-orientedness.

Originally posted by Korval:
[b] [quote]do you mean I can write my own algorithm to generate name for texture,VBO,FBO,PBO?
Yes.

Unfortunately, 2.1 allows you to basically pass any non-0 32-bit integer to any of the glBind* functions, and the OpenGL implementation will have to work with it.

The glGen* functions exist only as a way for the user to ask the system for an unused object name. Calling, for example, glGenBuffer does not tell the system to create the actual buffer object; you have to glBind it and call glBufferData to do that.

However, I would like to second Jan’s point that it is really bad style to do this. Basically, all doing it does is saves you from having to store the integer name yourself (because presumably anytime you want the texture name, you can recompute it with your hash algorithm). And saving a few 32-bit integers isn’t worth the effort nor the lack of object-orientedness. [/b][/QUOTE]Thanks Korval,but can I use my own name generate algorithm to program object and shader object of “GLSL” ext

I am not absolutely sure, whether it is also possible with shader-names and such, but i would think so.

Simply try it out. If it is not allowed, you should get an error immediately. Also, you could take a look into the spec of those extensions and check out what they say about the glGenShader/**** functions. If it is said, that they are mandatory, you have your answer.

Sorry, i cannot give you definite answers, i never tried to actually do it that way.

Jan.