Generating and drawing a circle

Hi guys!

I wanna know if its possible to create a shader with two parameters: the position and the radius and then it creates the vertices of a circle and send them to the application to store them?

Thank you.

Yes, but to be honest, this is something you can do just as fast on the CPU. Give the GPU the hard work.

Can you tell me how to do it? or send me a link with a demo?

Thank you.

I agree with Alfonse that this is something that you would rather do on the CPU, especially since you want to read it back to the CPU anyway. I suppose there are various ways to do it though. One method would be to render a 2r by 2r quad. In a fragment shader, discard fragments if the distance from the fragment to the center of the quad is not within [r - delta, r + delta] for some given delta. To get it back to the CPU, render to an FBO and read the texture.

An alternative approach would be to use a geometry shader.

Regards,
Patrick

http://en.wikipedia.org/wiki/Midpoint_circle_algorithm

I agree with you guys. I’m asking just to know how to do it for a very complex polygon or something like that.

The fragment shader is a possible solution but I know how to do it.

I think the answer I’m looking for is through the Geometry Shader. Can someone point me to a simple example please?

Thank you.