Drawing circle with Bresenham's Algorithm on OpenGL [closed]
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question 开发者_JAVA技巧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:
http://img690.imageshack.us/i/circlev.jpg/
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.
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.
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.
精彩评论