PDA

View Full Version : How to get the coorrdinate lists?



hillxy
11-08-2002, 07:10 AM
Hi,
I am wondering whether there is a easy function in OpenGL to get the coordinate lists of points that locate inside a given Polygen? (I am doing ROI things)

Any idea?
Thanks

V-man
11-08-2002, 01:19 PM
Inside any mathematical polygon, there is an infinite number of points.

If you want the coordinates of the pixels of the projected polygon, then say so ...

V-man

bpeers
11-08-2002, 04:14 PM
Sounds like you want to do hit detection, I'm not sure ?
In that case, check out glRenderMode (GL_SELECT). The idea is to render only the region of interest (by changing the projection matrix) using a special mode, that doesn't render anything, but instead reports back to you (see glSelectBuffer) the "names" of the objects you render (specified using glPushName).

If you're interested in the geometry of the actual fragments being rendered, check out the feedback buffer instead (glFeedbackBuffer, glRenderMode (GL_FEEDBACK).

hillxy
11-11-2002, 07:30 AM
V-man, coordinates are pixel unit.
No render is required. I just want any
coordinates list inside a polygon.
for example,

inside polygon
(0,0)-(0,2)-(2,2)-(2,0)-(0,0)
I will have (1,1) as the output.


The real polygons may be arbitary shapes
even concave shape.

Any easy function for that? (If you formiliar with MATLAB, you know it is easily
implemented by 'roipoly' function.)

Thanks

V-man
11-11-2002, 08:55 AM
hillxy,

there isnt a function in GL that returns the rasterized coordinates, but you can always render your shape, and read the pixel buffer.

pseudocode:

clearscreen(BLACK);
selectcolor(WHITE);
renderobject();glReadPixels(mybuffer);
process(mybuffer);
That's the most straighforward method I think.

V-man