Results 1 to 2 of 2

Thread: Selection Buffer problem

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Brussel, Belgium
    Posts
    12

    Selection Buffer problem

    Hi !
    I have a problem with selection buffer.

    I'm drawing a grid of rectangles but when I click on the grid Opengl sets the number of hits to 1 and the number of the object hit is always 0

    Here's the code:

    void Mouse3D(int mouseX,int mouseY,Vector& v1,Vector& v2)
    {
    GLuint selectBuff[64];
    GLint hits, viewport[4];

    glSelectBuffer(64, selectBuff);
    glGetIntegerv(GL_VIEWPORT, viewport);

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glRenderMode(GL_SELECT);
    glLoadIdentity();
    gluPickMatrix(mouseX, viewport[3]-mouseY, 2, 2, viewport);

    gluPerspective(45.0f,(GLfloat)800/(GLfloat)600,1.0f,1000.0f);
    glMatrixMode(GL_MODELVIEW);
    camera.Set();

    bf.DrawCases();

    hits = glRenderMode(GL_RENDER);

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

    glMatrixMode(GL_PROJECTION);

    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    }

    bf.drawCases draws the grid. Each rectangle has one different color and one name with LoadName(numRect);

    Thanks

  2. #2
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    Re: Selection Buffer problem

    selection has to be done just right to work try looking at some sample code eg the red book , or in glut, also my site has an example (url in profile)

Similar Threads

  1. Selection buffer problem: All depths = 2147483648
    By varieux in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 06-18-2009, 12:16 PM
  2. Problem with Selection Buffer and Ortho mode
    By yaro_dup1 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-17-2003, 07:34 AM
  3. Selection Buffer problem ... Please help
    By SurGL in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-18-2001, 11:37 PM
  4. 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
  5. SELECTION BUFFER
    By fox in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-24-2000, 07:24 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