Jump to content
  • Advertisement
Sign in to follow this  
Revelation60

Too many items to pick ( GL_MAX_NAME_STACK_DEPTH)

This topic is 4082 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

Hi, For my game sokoban I've got very large levels. To do pathfinding, the player must select a position. But in those large levels, there are over 128 (my GL_MAX_NAME_STACK_DEPTH) positions, so I can't pick all of them. What should I do now?

Share this post


Link to post
Share on other sites
Advertisement
Why do you need to put all names on the stack at the same time? Isn't it enough to just keep one name at the stack at any time; the name of the piece you want to select?

Share this post


Link to post
Share on other sites
I'm afraid I don't understand. The way I do it is that I draw the level and give all the empty tiles a name. Then I start processing hits. Is that a bad idea?

Share this post


Link to post
Share on other sites
The idea is correct, but I believe you take the wrong approach with where you put the names. Since you mention the name stack depth limiting you to that amout of names, I assume you push a new name each time you draw an object.

That's not what you should do. Unless you want to select a hierarchy of objects (picking an object, and you want to know who it's parent is, and the parent's parent, and so on, up to a limit to 128 parents in your case). You just want to select independent objects.

for o = all objects to draw
glLoadName(o.name);
draw(o);
end

The depth pf the stack is irrelevant since you only need one name to be on the stack.

Share this post


Link to post
Share on other sites
I've replaced my glPushName() into glLoadName. Now my code looks like this:


int c = 0;
for (int i = 0; i < FGameData[FThisLevel].FLevelWidth; i++)
for (int j = 0; j < FGameData[FThisLevel].FLevelHeight; j++)
{
glLoadName(c);
glBegin(GL_QUADS);
glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y, z);
glTexCoord2f(1.0f, 0.0f); glVertex3f(x, y, z + 5);
glTexCoord2f(1.0f, 1.0f); glVertex3f(x + 5, y, z + 5);
glTexCoord2f(0.0f, 1.0f); glVertex3f(x + 5, y, z);
glEnd();
c++;
}

Unfortunately, this doens't work :(
Am I still doing something wrong?

Share this post


Link to post
Share on other sites
Have you properly initialized the name stack by calling glInitNames and pusing at least one name onto the stack? glLoadName replaces the top of the stack, but the stack is empty after initialization.

Share this post


Link to post
Share on other sites
I suggest you post some more code then. How you set up, draw and process the hits. Preferably a complete and compilable example stripped of everything not essential to the problem.

Share this post


Link to post
Share on other sites
I found the problem!:)

It had something to do with the handling, not with the selection itself. But still, thank you for you time and help with glLoadNames!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!