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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:59:36+00:00 2026-05-29T07:59:36+00:00

I am drawing a mesh of triangles using glDrawElements and would like to be

  • 0

I am drawing a mesh of triangles using glDrawElements and would like to be able to pick/select a triangle using the mouse click. The mesh of triangles can be very big.

In fixed-function OpenGL there is the possibility of using GL_SELECT:
http://content.gpwiki.org/index.php/OpenGL:Tutorials:Picking
.. However I am only interested in using OpenGL core profile.

Another possibility would be to use ‘color coding’:

http://www.lighthouse3d.com/opengl/picking/index.php?color1

http://www.opengl.org/resources/faq/technical/selection.htm

.. but as far as I know its not possible to indicate per triangle information yet when using glDrawElements?

Finally I could do CPU based picking by shooting a pick ray through the mouse location, but this would be quite slow since I guess I would have to transform the triangles on the CPU, so I would prefer a GPU based solution.

Does anyone have a suggestion on what is the best way do picking when using glDrawElements in OpenGL core profile?

  • 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-29T07:59:37+00:00Added an answer on May 29, 2026 at 7:59 am

    About the ‘color coding’ approach, you could use gl_PrimitiveID to fill the color coded buffer(s) using a proper fragment shader, this would basically give you the index of the drawn triangle.

    About the CPU based picking, you could use an existing library that handles the acceleration structures, and ray-mesh intersection, such as Bullet or Opcode.

    The ‘best’ option for you depends of your use case, hard to tell.

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

Sidebar

Related Questions

I found this in the PowerVR mesh drawing code and I don't really know
While drawing graphics in 2D, how can I handle the depth of a picture
We are developing an drawing application for iOS and android. I am using cubic
I'm drawing a 3d scene in 5-6 drawcalls, but I have about 60000-65000 triangles
When drawing an editable Polygon on a map using Google's V3 API, is there
I am currently drawing a Bitmap to a SurfaceView using Canvas.drawBitmap() . This seems
I am drawing some points in an array using glVertex2f(), and I need to
I'm drawing an object (say, a cube) in OpenGL that a user can rotate
I'm drawing a blank here; I can't find it, unless I'm really overlooking something
I am drawing a graph on a <canvas> that requires expensive calculations. I would

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.