Reputation: 9
#include <GL/glut.h>
#include <stdio.h>
#include <math.h>
int x0,y0,xn,yn;
void bresenham(void)
{
int dx,dy,m,pk,xk,yk,k;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0,0,0);
setPixel(x0,y0);
dx=xn-x0;
dy=yn-y0;
pk=2*dy-dx;
m=dy/dx;
xk=x0;
yk=y0;
if(m>0 && m<1)
{
for(k=0;k<dx-1;k++)
{
if(pk<0)
{
xk++;
pk=pk+2*dy;
}
else
{
xk++;
yk++;
pk=pk+2*dy-2*dx;
}
setPixel(xk,yk);
}
}
glFlush();
}
int main (int argc,char **argv)
{
printf("enter starting points");
scanf("%d",&x0);
scanf("%d",&y0);
printf("enter endpoints");
scanf("%d",&xn);
scanf("%d",&yn);
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowPosition(50,25);
glutInitWindowSize(500,250);
glutCreateWindow("Bresenham Line");
init();
glutDisplayFunc(bresenham);
glutMainLoop();
return 0;
}
void init(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0,400.0,0.0,400.0);
}
void setPixel(GLint x,GLint y)
{
glColor3f(255,255,255);
glBegin(GL_POINTS);
glVertex2f(x,y);
glEnd();
}
the error is:
4 8 C:\Users\Hewlett\Documents\bresenham1.c [Error] 'y0' redeclared as different kind of symbol ,4 14 C:\Users\Hewlett\Documents\bresenham1.c [Error] 'yn' redeclared as different kind of symbol .
Can anyone tell why it is showing y0 &yn are redeclared as different kind of symbol
Upvotes: 0
Views: 110
Reputation: 52083
why it is showing y0 &yn are redeclared as different kind of symbol
Because you are:
The y0(), y1(), and yn() functions shall compute Bessel functions of x of the second kind of orders 0, 1, and n, respectively.
Switch to different names or don't #include <math.h>
.
Upvotes: 1