Drawing Bresenham’s Line- Algorithm in all quadrants

Posted by Yoyo2965259 on Stack Overflow See other posts from Stack Overflow or by Yoyo2965259
Published on 2013-11-07T15:33:32Z Indexed on 2013/11/07 15:53 UTC
Read the original article Hit count: 444

Filed under:

I am newbie for OpenGL. I am practicing the exercises from my textbook but I could not get the outputs which is should be in Bresenham's Line Algorithm in all quadrants.

Here's the coding:

#include <Windows.h>
#include <GL/glut.h>
void init(void) {
   glClearColor(0.0, 0.0, 0.0, 0.0);
   glShadeModel(GL_FLAT);
}
void BresnCir(void) {
   int delta, deltadash;
   glClear(GL_COLOR_BUFFER_BIT);
   glPointSize(3.0);
   int r = 150;
   int x = 0;
   int y = r;
   int D = 2 * (1 - r);
   glBegin(GL_POINTS);
   do {
      glVertex2i(x, y);
      if (D < 0) {
         delta = 2 * D + 2 * y - 1;
         if (delta <= 0) {
            x++;
            Right(x);
         } else {
            x++;
            y--;
            Diagonal(x, y);
         }
         glVertex2i(x, y);
      } else {
         deltadash = 2 * D - 2 * x - 1;
         if (deltadash <= 0) {
            x++;
            y--;
            Diagonal(x, y);
         } else {
            y--;
            Down(y);
         }
         glVertex2i(x, y);
      }
      if (D == 0) {
         x++;
         y--;
         Diagonal(x, y);
         glVertex2i(x, y);
      }
   } while (y > 0);
   glEnd();
   glFlush();
}
int main(int argc, char** argv) {
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
   glutInitWindowSize(400, 150);
   glutInitWindowPosition(100, 100);
   glutCreateWindow(argv[0]);
   init();
   glutDisplayFunc(BresnCir);
   glutMainLoop();
   return 0;
}

But, it keep comes out with errors C3861.

© Stack Overflow or respective owner

Related posts about opengl