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 526285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:45:36+00:00 2026-05-13T08:45:36+00:00

I’m using gluUnProject to cast a ray into the scene and adding a primitive

  • 0

I’m using gluUnProject to cast a ray into the scene and adding a primitive there. What I’m trying to do is now accurately pick existing primitives, so if I have 3 spheres I could click on one to delete it.

I think the solution would somehow check if the ray intersected with an object and check if its the closest to the casting origin. My solution so far is primitive and surrounds all objects with a bounding cube, is there anyway to simply to do this accurately for say spheres using:

does the ray intersect with ( object)

or

returnRayIntersections(ray);

Last thing, I’m using OpenGL with GLUT.

Thanks everyone,
Laurence

  • 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-13T08:45:36+00:00Added an answer on May 13, 2026 at 8:45 am

    Another good way to implement picking in OpenGL is like this:

    Draw your scene into the back buffer, using a unique color for each primitive that you want to select. If you are using a 24 bit mode, the colors can simply be #000001, #000002 etc. Turn off lighting, fog etc so that the colors you specify are the exact colors the pixels are going to take.

    Don’t blit the back-buffer to the screen (don’t use glSwapBuffers). Instead, use glReadPixels to read the GL back-buffer into a memory buffer. After this you have a memory bitmap that you can read a pixel value from, corresponding to the location of the mouse on-screen. The color value you read out from this can easily then be mapped to the primitive (since it’s going to be #000001, #000002 etc).

    Here’s some more information on this style of selection. This is what I like to use, since it has one advantage over the GL_SELECTION mode. If the 3D scene is unchanging and the mouse is being moved over it, I can get one copy of the back-buffer and then quickly estimate which entity is under the mouse, by simply referencing the appropriate pixel in my memory bitmap. I don’t have to use any GL calls at all until the scene changes. Since my application has a lot of mouse hovering over a 3D scene and I need to quickly know which entity the mouse is floating over, I found this method really fast.

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

Sidebar

Ask A Question

Stats

  • Questions 366k
  • Answers 366k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The answer is very simple. The data when it was… May 14, 2026 at 4:32 pm
  • Editorial Team
    Editorial Team added an answer I've read that apple does care about the number of… May 14, 2026 at 4:32 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure why it needs to go into the… May 14, 2026 at 4:32 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.