Sign in to follow this  
neomax

OpenGL Is there any object selection mode in DirectX (like GL_SELECT render mode)?

Recommended Posts

I do mean the stuff like like glPushName, glPopName in OpenGl, where name stack is used during selection mode to allow sets of rendering objects to be uniquely identified: All primitives that would have been drawn near the cursor are identified and stored in the selection buffer (the perfomance issue is that in selection mode the drawing is restricted to a small region of the viewport near the cursor and thus the amount of calculations is dramatically reduced during rendering, since camera “views” only small area around the center of a picking region). After ending rendering the buffers containing names is read back in order to find out what objects are under cursor. Is there anything like this in DirectX?

Share this post


Link to post
Share on other sites
No, there's no such thing in Direct3D because it's not really a "Graphics API" thing. However, there are some utility functions in D3DX to help with this (D3DXIntersectTri or something similar).

What you're looking for is called "Picking", and there are some tutorials that cover it. A couple of tutorials can be found here (look in the articles section).

Share this post


Link to post
Share on other sites
for pixel-perfect picking, you can use colors. set unique colors to objects and then render them to a texture or to screen then take mouse position and just read pixel, compare unique colors of objects, which is not shown (masked). but so you have to draw the clickable objects twice. maybe you want to use more efficient picking method, using bounding boxes/spheres and rays. "introduction to dx game programming" book has good examples of that. hope helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this