Results 1 to 3 of 3

Thread: Picking and glRotate

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Cologne, NRW, Germany
    Posts
    13

    Picking and glRotate

    Hi,

    i got a little problem here.

    on init o do:
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,500.0f);
    glMatrixMode(GL_MODELVIEW);

    on my frame-rendering i do:
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef(0.0f,0.0f,-75.0f);
    glRotatef(pitch,1.0f,0.0f,0.0f);
    glRotatef(heading,0.0f,1.0f,0.0f);
    glTranslatef(xtra,ytra,zoom);

    no i need to implement picking.

    what do i need beside the picking part (init of the buffer and switching to GL_SELECT) where to put my rotate stuf to place me at the right point in the world:
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    gluPickMatrix((GLdouble) mouse_x, (GLdouble) (viewport[3]-mouse_y), 1.0f, 1.0f, viewport);
    // Apply The Perspective Matrix
    gluPerspective(45.0f, (GLfloat) (viewport[2]-viewport[0])/(GLfloat) (viewport[3]-viewport[1]), 0.1f, 100.0f);
    glMatrixMode(GL_MODELVIEW);
    drawmydatawiththeglloadname();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

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

    Re: Picking and glRotate

    Have you looked through the red book. It's pretty clear on what to do. You can get a copy in PDF format from http://www.ime.usp.br/~massaro/opengl/redbook/

    Also I noticed that the depths specified in gluPerspective differ between the one to initialise and the one to pick. You need to keep them the same or you may miss some items you draw when picking.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Cologne, NRW, Germany
    Posts
    13

    Re: Picking and glRotate

    OH man as you said the 500/100 was the problem in the z.

    thanks a lot!

Similar Threads

  1. glRotate
    By Blacknight in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-21-2010, 11:40 PM
  2. glrotate
    By tpthyd in forum OpenGL: General
    Replies: 1
    Last Post: 02-11-2009, 04:12 AM
  3. Z-buffer picking, gluUnProject picking not working
    By Icetigris in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-29-2008, 10:38 AM
  4. glRotate and Picking problem
    By sadhu in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-21-2002, 08:15 AM
  5. glRotate
    By hatemagnet in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-01-2002, 12:58 PM

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