用鼠标滑轮控制图像放大缩小,求帮助!!!
#include <GL/glut.h>#include<stdio.h>
#include<stdlib.h>
int R=100;
void bresenham_arc(int r)//bresenham函数
{
int x,y,d;
x=0;y=r;d=1-r;
while(x<=y)
{
glBegin(GL_POINTS );
glVertex2f(x,y);
if(d<0)
d+=2*x+3;
else
{
d+=2*(x-y)+5;
y--;
}
x++;
glVertex2f(x,y);
glVertex2f(x,-y);
glVertex2f(-x,y);
glVertex2f(-x,-y);
glVertex2f(y,x);
glVertex2f(y,-x);
glVertex2f(-y,x);
glVertex2f(-y,-x);
glEnd();
}
}
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT); //清除颜色缓存
glPushAttrib(GL_POINT_BIT);
glBegin(GL_POINTS);
glColor3f(0.0f,10.0f,36.0f); //圆的颜色的变化
glVertex2f(0.0f,0.0f);
glEnd();
glPopAttrib();
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
bresenham_arc(R); //圆的半径的控制
glFlush();
}
void Init()
{
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_FLAT);
}
void Reshape(int w,int h)
{
glViewport(200,250,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-100,(GLdouble)w,-100,(GLdouble)h);
}
void mouse(int KEY)
{
switch(KEY)
{
case GLUT_KEY_UP:
R+=20;
case GLUT_KEY_DOWN:
R-=20;
break;
default:
break;
}
}
int main(int argc ,char*argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutInitWindowPosition(100,100);
glutInitWindowSize(600,600);
glutCreateWindow("Bresenham ?");
Init();
glutDisplayFunc(myDisplay);
glutReshapeFunc(Reshape);
glutMouseFunc(mouse);
glutMainLoop();
system("color 07");
return 0;
}
在这个程序的运行下有:error C2664: 'glutMouseFunc' : cannot convert parameter 1 from 'void (int)' to 'void (__cdecl *)(int,int,int,int)'
None of the functions with this name in scope match the target type
这就是这个运行的问题