gpt4 book ai didi

Bresenham线算法编译错误?

转载 作者:行者123 更新时间:2023-11-30 15:06:07 25 4
gpt4 key购买 nike

#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();
}

错误是:

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 .

谁能告诉我为什么它显示 y0 &yn 被重新声明为不同类型的符号

最佳答案

why it is showing y0 &yn are redeclared as different kind of symbol

因为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.

切换到不同的名称或不切换 #include <math.h> .

关于Bresenham线算法编译错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39412610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com