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

  1. #1
    Guest

    picking again.....

    here is my code for a picking method with the mouse. when i have an object picked i try to move it but all the objects move. i know this is to do with the pushMatrix and pop matrix but i thought i had that done. am i calling them in the wrong place or what am i doing wrong. thanks.

    GLuint selectBuff[BUFSIZE];
    GLint hits, viewport[4];
    glSelectBuffer(BUFSIZE, selectBuff);
    glGetIntegerv(GL_VIEWPORT, viewport);
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glRenderMode(GL_SELECT);
    glLoadIdentity();
    gluPickMatrix(x, viewport[3]-0.1,0.1, viewport);

    glOrtho(0, 0, 0, 0, 0, 0);
    glMatrixMode(GL_MODELVIEW);

    displayfn();

    hits=glRenderMode(GL_RENDER);

    printf ("hits = %d\n", hits); glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

    if(hits > 0)
    picked = selectBuff[3];

    then i have something like

    if(picked){
    glTranslatef(0.5,0.5,0.5);
    }

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2002
    Location
    Kingston, Jamaica, W.I.
    Posts
    268

    Re: picking again.....

    As pointed out in your last post you need to save before trying to translate a single object and restore it afterwards.

    i.e
    if(picked){
    glPushMatrix();
    glTranslatef(0.5,0.5,0.5);
    glPopMatrix();
    }

    [This message has been edited by Furrage (edited 03-15-2002).]

Posting Permissions

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