PDA

View Full Version : Drawing many user facing objects



jas511
09-13-2011, 09:49 AM
In my application, I draw a large sphere to represent a planet. On that planet, I might draw thousands of shapes that must be user facing. To ensure they are always user facing, I draw them in 2d. However, because I am disabling the depth test to draw in 2d, even when the planet is rotated, objects that should be on the backside of planet end up showing through and I need to do some manual calculations to determine if they should be drawn (and this is much slower since I'm doing them on the CPU).

Is there a way that I can mix 2D and 3D drawing, but still somehow account for depth. So, in this example, only the 2D objects on the user facing side of the planet would show?

Or is there a faster way to determine if a point should be displayed rather having to calculate this on the cpu for each point?

Thanks,
Jeff

McLeary
09-13-2011, 09:55 AM
Take a look at glRasterPos function

http://www.opengl.org/sdk/docs/man/xhtml/glRasterPos.xml

You define the position in 3D to raster something, and OpenGL will take care of visibility for you.

jas511
09-13-2011, 10:25 AM
McLeary,

Thanks for the reply. I'm a little confused how this will help though. I'm not doing pixel drawing operations, I'm still using glVertexArrays operation to draw the shapes, just in 2d.

Thanks,
Jeff

mhagain
09-13-2011, 04:56 PM
Google for "billboarding" - this is what you need.

jas511
09-23-2011, 10:25 AM
Sorry for the slow reply. Yes, I have been looking for billboarding...I will continue down this path. Thanks.