# glLoadName.. is there a limit

Hi,

Is there a limit on how many names can we push on the name stack using glLoadName in opengl (i am doing a selection problem here)

thanx

maybe glGetIntegerv( GL_MAX_NAME_STACK_DEPTH, … ) ?

glLoadName replaces the top-of-stack name. it does not increment or decrement the name stack position. glPushName and glPopName do.
The maximum number of possible names is 2^32-1.

So, the basic question should have been, how many names can we push onto the stack.

Well i guess your right. The question should have been that… anyway thanks for the help.

glLoadName replaces the top-of-stack name. it does not increment or decrement the name stack position. glPushName and glPopName do.
The maximum number of possible names is 2^32-1.

2^32 is the number of names that we can put in the stack ?

Thank you for the moment
Best regards
KurtCob

Try glGetIntegerv to retrieve the value of GL_MAX_NAME_STACK_DEPTH.

If you look at the red book (State variables appendix), the minimum depth of the name stack is said to be 64 (it looks pretty much like 2^6 rather than 2^32).

On Tom Nuydens’ site, in the hardware section, http://www.gamedeveloper.org/delphi3d/hardware/index.shtml, you can search for the name stack’s depth for several chipsets, you’ll find:
Geforce2 GTS: 128
i.e. 2^7.

I don’t think you can push 4 billion names onto the stack.

Moz, the number of names you can place on the stack is the whole range of an integer (excluding zero, therefore 2^32-1). An integer is, in OpenGL at least, 32 bits long.

64 as you mentioned, is the (minimum) number of names you can push into the stack.

>>The maximum number of possible names is 2^32-1.

Yes, what I said is that the name is an 32 bit unsigned int. The name stack itself is implementation dependend and guaranteed not to be smaller than 64 entries.

So if you really use glLoadName you can have as many as 2^32-1 different objects in the scene because the name stack pointer is never incremented or decremented.

I actually have not yet seen a necessity to use glPushName and glPopName at all except for the bottom name stack element.

Ok, I get your point now.

But it seemed to me that the original question was about the stack’s depth rather than about the number of possible names.

>>But it seemed to me that the original question was about the stack’s depth rather than about the number of possible names.

Right, and the first answer from Michael gave already the right clue. Nevertheless, you won’t hit the maximum stack depth using glLoadName ever.

Thanks for all the help. It seems when we do a glLoadName we simply replace the top of the stack , which means we just lost the entry for last object… so if we do 1 glPushName and 10 glLoadName we will effetively have 1 entry on the stack…? so that means we will get the same name for every selection hit that will occur…???

Pseudo algorithm:
1.) You call glLoadName before you draw the object.
2.) Draw the object. If the object would set pixels in the current view, you get the top of name stack element in the selection buffer.
3.) Goto 1. while not all named objects have been drawn.

That means the selection buffer grows which each hit and you always can check which object triggered that. No need for glPushName and glPopName as long as you don’t have hierarchical selection requirements.

Ok…now iget it… thanx a lot