tags:

views:

214

answers:

5

Hey guys.

Circles are one of the basics geometric entities. Yet there is no primitives defined in openGl for this like lines or polygons. Why so? Its a little annoying to include custom headers for this all the time!

Any specific reason to omit it?

A: 

Because historically, video cards have rendered points, lines, and triangles.

You calculate curves using short enough lines so the video card doesn't have to.

Gilbert Le Blanc
+1 for the unfair downvote. This is a valid answer.
Xavier Ho
A: 

You could always use gluSphere (if a three-dimensional shape is what you're looking for).

If you want to draw a two-dimensional circle you're stuck with custom methods. I'd go with a triangle fan.

The primitives are called primitives for a reason :)

Jakob
+7  A: 

While circles may be basic shapes they aren't as basic as points, lines or triangles when it comes to rasterisation. The first graphic cards with 3D acceleration were designed to do one thing very well, rasterise triangles (and lines and points because they were trivial to add). Adding any more complex shapes would have made the card a lot more expensive while adding only little functionality.

But there's another reason for not including circles/ellipses. They don't connect. You can't build a 3D model out of them and you can't connect triangles to them without adding gaps or overlapping parts. So for circles to be useful you also need other shapes like curves and other more advanced surfaces (e.g. NURBS). Circles alone are only useful as "big points" which can also be done with a quad and a circle shaped texture, or triangles.

If you are using "custom headers" for circles you should be aware that those probably create a triangle model that form your "circles".

Maurice Gilden
@Maurice, can you explain what you meant by "Custom headers"?
Xavier Ho
It's from the question. I don't know what exactly Ram meant by that but I guess it's a library with some OpenGL utility functions.
Maurice Gilden
*paw-face* Right, I should have read the question first, hmm? Thanks.
Xavier Ho
+1  A: 

Saying this depends on resolution

LarsOn
+1  A: 

Because graphic cards operate on 3-dimensional points, lines and triangles. Circle requires curves or splines. It cannot be perfectly represented by "normal" 3d primitive, only approximated as N-gon (so it will look like a circle at certain distance). If you want circle - write routine yourself (isn't hard to do) - either draw it as N-gon, or make a square (2 triangles) and cut a circle out of it it using fragment shader (you can get perfect circle this way).

SigTerm
+1. To be pendantic, fragment shaders still only approximate the circle by the pixels on the screen. Not a perfect circle. =P
Xavier Ho
@Xavier Ho: Still, with a fragment shader you'll get perfect approximation almost at any distance from circle (at very close distance there might be a precision errors). Throw a bit of antialiasing into calculation, and there will be nothing to complain about.
SigTerm
"Perfect approximation" - I call oxymoron! And yes, you would be correct.
Xavier Ho
@Xavier Ho: "I call oxymoron!" :) (explaining just in case) I meant to say that it will be still made from square pixels, but there will be no "straight"(non-curved) line segments or wasted vertices as with traditional N-gon circle approximation.
SigTerm