Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6555401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:48:57+00:00 2026-05-25T12:48:57+00:00

I’m working on a little example, where I have loaded an object from a

  • 0

I’m working on a little example, where I have loaded an object from a wavefront file – and am trying to get my picking right, I’ve gone over this and a few tutorials about 10 times… but must be missing something. Was wondering if anyone could provide an extra set of eyes.

I’ve used a saved list to draw the object, which appears fine on the screen… At the moment, when gl_select(x, y) runs, I get a hit no matter what, and if I enable the translate/rotate code (which is currently commented out) – I get no hits what-so-ever.

Relevant code blocks:

// gl_select, is called when the mouse is clicked, with its x and y coords
void gl_select(int x, int y)
{
    GLuint buff[256];
    GLint hits;
    GLint view[4];

    //Buffer to store selection data
    glSelectBuffer(256, buff);

    //Viewport information
    glGetIntegerv(GL_VIEWPORT, view);

    //Switch to select mode
    glRenderMode(GL_SELECT);

    //Clear the name stack!
    glInitNames();

    //Fill the stack with one element
    glPushName(0);

    //Restric viewing volume
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();

    //Restrict draw area
    gluPickMatrix(x, y, 1.0, 1.0, view);
    gluPerspective(60, 1, 0.0001, 1000.0);

    //Draw the objects onto the screen
    glMatrixMode(GL_MODELVIEW);

    //Draw only the names in the stack
    glutSwapBuffers();
    DrawSavedObject();

    //Back into projection mode to push the matrix
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();

    hits = glRenderMode(GL_RENDER);

    cout << hits;

    //Back to modelview mode
    glMatrixMode(GL_MODELVIEW);
}

And the draw functions:

void DrawSavedObject()
{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glColor3f(1.0,0.0,0.0);

    //translate and rotate
    //glRotated(rotation,0.0,0.0,1.0);
    //glTranslated(7.0, 7.0, 0.0);

    //Draw the saved object
    glLoadName(7);
    glCallList(list_object);

    glutSwapBuffers();
}

And where the list is saved:

void SaveDisplayList(){     
    glNewList(list_object, GL_COMPILE);

    glVertexPointer(3, GL_DOUBLE, 3*sizeof(GLdouble), vertices);
    glEnableClientState(GL_VERTEX_ARRAY);
    glDrawElements(GL_TRIANGLES, verticesSize ,GL_UNSIGNED_INT, triangles);

    glDisableClientState(GL_VERTEX_ARRAY);

    glEndList();
}

Sorry again for the chunkiness of the code blocks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:48:58+00:00Added an answer on May 25, 2026 at 12:48 pm

    A few things to consider here:

    • OpenGL selection mode is deprecated and never was HW accelerated, except on a few SGI boxes and 3DLabs GPUs.

    • DisplayLists don’t mix with Vertex Arrays.

    • Why do you call glutSwapBuffers right before drawing your list of saved objects? Makes absolutely no sense at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.