I can draw a circle with the algorithm. However, the boundary looks weird, the pixels look so separate from each other. I want them to be closer. I have tried to bigger the point size. But the result is not that much good. So, I was thinking that maybe it would be better if I can completely fill the pixel.(I suppose it's square shaped.) How do I do that or do you have any better idea? It looks like this now:
Drawing circle with Bresenham's Algorithm on OpenGL
3.7k views Asked by Sammy AtThere are 3 answers
Judging by your jpeg, I wonder if what you think is one pixel in world space, actually isn't. Perhaps your projection matrix isn't doing quite what you think it is.
Is GL_POINT_SMOOTH enabled? -- It's possible that this is messing with things. Those pixels look strangely round.
Assuming that using this algorithm is important to you (and you're not interested in methods that may be more efficient), you could draw a quad for each "pixel" instead of using GL_POINTS.
Without code, it's hard to diagnose the problem. The actual layout of the pixels looks correct for that algorithm. It appears that you're using a projection matrix that isn't translating world space directly to screen space, though.
Try using an orthographic projection where you can assure that one offset in world coordinates is worth exactly one pixel in screen space.
use sin/cos method, then you can draw lines from one point to another, also it allows you to change the polygon detail too, not to mention its much easier to fill the circle then too (draw triangles from middle to edges).
if you use higher detail, the result will be almost the same as Bresenham.