Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: picking errors

  1. #1
    Junior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    picking errors

    Hello,
    I'm trying to create a function, that returns the name, of the quad you have your mouse on(I want to do the hover thing like you can do in HTML).
    But for some strange reason, I get two(or maybe more) errors.
    The first one is:
    This command would cause a stack underflow. The offending command isignored, and has no other side effect than to set the error flag.
    And the second is:
    Invalid Name parameter.
    My function:
    Code :
    short Menu::Selected(int x, int y)
    {
    	GLuint selectbuf[512];
    	GLint viewport[4];
    	GLint hits;
    	glGetIntegerv(GL_VIEWPORT, viewport);
     
    	glSelectBuffer(512, selectbuf);
    	glRenderMode(GL_SELECT);
     
    	glInitNames();
    	glPushName(0);
     
    	glMatrixMode(GL_PROJECTION);
    	glPushMatrix();
    	glLoadIdentity();
     
    	gluPickMatrix((GLdouble)x, (GLdouble)(viewport[3] - y), 2.5, 2.5, viewport);
    	gluOrtho2D(-5.0, 5.0, -5.0, 5.0);
     
    	DrawMenu(true);
     
    	glMatrixMode(GL_PROJECTION);
    	glPopMatrix();
    	glFlush();
    	glPopName();
     
    	hits = glRenderMode(GL_RENDER);
     
    	GLuint *tmp;
    	tmp = selectbuf;
    	GLuint names = *tmp;
    	cout << "Number of names on the stack: " << names << endl;
    	tmp++;
    	cout << "Minimum z window value: " << *tmp << endl;
    	tmp++;
    	cout << "Maximum z window value: " << *tmp << endl;
    	cout << "hits: " << hits << endl;
    	tmp++;
    	cout << "First hit: " << *tmp << endl;
    	if(names > 0)
    		return *tmp+1;
    	else
    		return 0;
    }
    Because my code is quite identicall to the functions proces****s and pickSquares from the example picksquare.c from the OpenGL red book, it's a mistery to me why I get these errors.
    My function DrawMenu([..]) is like this:
    Code :
    for(int i = 0;i < x;i++)
    {
    dosomecalculations();
    glLoadName(i);
    drawsomething();
    }
    Could anyone help me in the right direction why it might not work?
    Thanx in advance,
    Hylke

  2. #2
    Junior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: picking errors

    I just need a hint, you don't have to debug the hall code.
    Just a clue is most probably enough.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •