/* Dibujo de linea */ #include #include /* arreglo N x M */ #define N 400 #define M 400 int n=N; int m=M; /* Use unsigned bytes for image */ GLubyte image[N][M][3]; lineaBresenham (int x1, int y1, int x2, int y2) { int dx, dy, x, y, *dep, *ind, incDep, incInd, incP1, incP2, p, escalones, i, sdx, sdy,t; if (x1 y2) { t=x1; x1=x2; x2=t; t=y1; y1=y2; y2=t; } dx = abs(x2-x1); dy = abs(y2-y1); if (dx) { sdx = dx/(x2-x1); } else { sdx = 0; } if (dy) { sdy = dy/(y2-y1); } else { sdy = 0; } if (dx > dy) { escalones = dx; incP1 = dy*2; incP2 = incP1 - 2*dx; p = incP1 - dx; dep = &y; ind = &x; incDep = sdy; if (x2