Advertisement

Is it proper to do picking like that?

Started by February 28, 2005 02:10 AM
2 comments, last by Brother Bob 19 years, 11 months ago
Hello everyone, at the moment I'm trying to get behind picking in OpenGL. Since I have problems understanding rendering in Selection Mode, I tried to think of an alternative way. Given is following example: I am developing a plain and simple 2D tilebased RPG, currently I'm going for the editor. Until now, I have drawn a grid and a quad with the desired tile (texture) inside each grid position within a scissor testing region. Drawing and scrolling works just fine, the next step would be the picking. I have read, that it is possible, to do picking by testing the pixel underneath the mouseposition for a change. So came up with following idea: I assign a unique color to each gridposition (i.e. position 25,12 has the rgb color 25,12,0). Then I clear the screen, render everything and test the pixel under my mousposition for a change. If a change occourded, I will get the color code, from which I can calculate the selected gridposition. Sounds pretty logical to me. But the thing that makes me think this is improper is: Since I am using textures for each gridposition I'd have to assign each gridpos its texture and render the whole thing again. Would that waste too much power or is it "ok", to do it like that (I know there is always more effetive ways to do things ;))? Any comments or ideas? Thanks ;)
As far as i know this is exactly what openGL does to do picking, so if you do this, you recreate the ogl picking algoritm
Advertisement
Neat! Thanks a lot ;)

*gets back to his C++ compiler and starts coding*
Quote:
Original post by Dybbuk
As far as i know this is exactly what openGL does to do picking, so if you do this, you recreate the ogl picking algoritm

It's not anywhere near how selection is performed in OpenGL. Selection mode doesn't even generate any fragments, but works exclusively with geometric primitives.

Selection in OpenGL works by determining whether a primitive intersects the clipping volume or not. The primitive is transformed as usual, and when it reaches the clipping stage, a hit is recorded if the primitive intersects the clip volume, otherwise a hit is not recorded. This is a mathematical selection test and is not dependent on the resolution of the rasterizer.

This topic is closed to new replies.

Advertisement