help me with coding cpp+glut

just want ask if anybody here have or can teach me how to create circle using bresenham method with coding that using reflection,translate,rotate and scale.

Hi !

The bresenham algorithm is used to draw straight lines and have nothing to do with circles, you can use sin/cos to calculate sample points on a circle and use the brsenham algorithm to draw line segments between thoose sample points.

If you search google you will get help on the bresenham algorithm, if you do want to do it yourself instead of letting openGL do it (use glbegin( GL_LINE_STRIP); ).

OpenGL does not support reflection, but it can be faked a number of ways, a number of descriptions on this is also available with a quick google search.

Any OpenGL tutorial will explain how to do transformations.


The bresenham algorithm is used to draw straight lines and have nothing to do with circles
Excuse me, but Bresenham worked hard not only on lines but on circles and xy radius ellipses too.

Java code :

More detailed explanation :

OpenGL does support reflection depending on your definition. In this context the reflection discussed may be the symmetry exploits for fast circle drawing.

This has nothing to do with OpenGL, about all you’d use OpenGL for is to draw an final image or plot points in 2D. You should use OpenGL to draw a circle with a lineloop without Bresenham’s algorithm if this is anything other than an exercise.

thank to all for the information…i appreciate that…

hi mikael,
just want to ask,do you have any example create circle using brensenham using C++?for your information i have coding using java to create cirlce but unfortunely i did not familiar with it.can u help me?

Hi !

Sorry had no idea he did circles also :slight_smile:
you can use the java code pretty much as it is, java and C++ is very much alike in terms of syntax, the Point() and myLine() methods do the drawing (a point or a line) and that would be done with OpenGL in your case I guess.

This is how you draw points and lines with OpenGL…

 glBegin( GL_POINTS);
 glvertex2d( x, y);

 glbegin( GL_LINES);
 glVertex2d( x1, y1);
 glVertex2d( x2, y2);


thank mikael

hi zbuffer,
do u have any example that is using C++ to create cirlce using bresenham?i’m fail when i’m create using Java that u give me…thank you…