Results 1 to 5 of 5

Thread: selection

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

    selection

    Hello,
    I would like to use selection for picking.
    As I understand, every geometric primitive which is in the viewing volume, causes a hit right?
    If you have a couple of triangles, which are only one name, they only cause one hit.
    My OpenGL redbook says this about glLoadname:
    Replaces the value at the top of the name stack with name.[..]
    So glLoadName(blaat); would equal to:
    Code :
    glPopName();
    glPushName(blaat);
    But here's the thing I don't understand.
    All my code examples of my book look like this:
    Code :
    glLoadName(x);
    drawsomething();
    glLoadName(x+1);
    drawsomething2();
    glLoadName(x+2);
    drawsomething3();
    [..]
    But doesn't that *delete* the last value in the stack and then add a new one to it?
    So if I understand it right, it would lost all information about the geometric primitives except for the last(because the stack contains only one thing)(which is not the case).
    IMHO it would be more logical that it would look like this:
    Code :
    glPushName(x);
    drawsomething();
    glPushName(x+1);
    drawsomething2();
    glPushName(x+2);
    drawsomething3();
    [..]
    What's wrong with my way of thinking?
    Thanx Hylke

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: selection

    Hi !

    You have to remember that all selection is done while it is "rendered" so if you use glLoadName you will get the hit that was active when the object is selected, if you use glPushName you will get all hits that are pushed for each hit instead.

    Mikael

  3. #3
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: selection

    Ok, thanx.
    But I only don't understand about the glPushName().
    Could you try to explain it more easyer?
    Thanx Hylke

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,102

    Re: selection

    For every hit, you get the whole content of the name stack at the time when the hit occurs.

    glLoadName(1); // stack = 1
    draw();
    glLoadName(2); // stack = 2
    draw();
    glLoadName(3); // stack = 3
    draw();

    Assuming every draw function produces a hit, you will get 3 hits:
    1
    2
    3

    glPushName(1); // stack = 1
    draw();
    glPushName(2); // stack = 1 2
    draw();
    glPushName(3); // stack = 1 2 3
    draw();

    Now you'll get these 3 hits:
    1
    1 2
    1 2 3

  5. #5
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: selection

    Ok thanx, I think I finally understand it now.
    Hyke

Similar Threads

  1. Need help with selection
    By Dylan K in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 06-11-2008, 10:21 AM
  2. Which selection is better?
    By ehsan2004 in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 06-01-2005, 01:32 PM
  3. selection
    By schailan in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 06-13-2002, 08:22 AM
  4. selection
    By schailan in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 06-11-2002, 08:49 AM
  5. Is using selection buffer for selection or picking slow?
    By mohsin in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-11-2001, 03:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean