View Full Version : Creating a region
09-18-2005, 01:29 AM
I am trying to move from an old 2d program (Mac OSX) to 3d and now need to convert some code that tested whether a sprite was inside a (flat) region. The region was created previously by using Quickdraw commands (ie ovals and rects) into a Rgn. Then the test was
if ( PtInRgn( spritePoint, myRegion ) ).......
where spritePoint was the x,y coordinate of the sprite.
Is it possible to use a similiar approach under OpenGL ??
09-19-2005, 05:35 AM
IMO you should solve these tests with math in your application. You could go ahead and (ab)use occlusion queries or "selection" to implement intersection tests and the like, but I wouldn't recommend it. It's pretty hairy to do, especially if you're relatively new to OpenGL, and it just won't be as efficient as an application side solution.
Finding out whether a point is inside a circle is just a vector subtraction, a dot product and a comparison. I don't know anything about QuickDraw, but I suspect that it performs these tests in software as well.
09-20-2005, 12:12 PM
Many thanks for this reply. It sounds like I need to constrain the region to a simple shape (circle, oval, lozenge) for this approach to work. In this case I can do that so it's over to the maths now. Thanks again.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.