作业帮 > 综合 > 作业

大家看看我的程序为什么不能绘制出图来,我想点一下鼠标就在鼠标的位置画个圆

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/16 17:19:46
大家看看我的程序为什么不能绘制出图来,我想点一下鼠标就在鼠标的位置画个圆
#include
#include
#include
#include
#include
float mousex=0,mousey=0;
void init (void)
{
glClearColor (0.0,0.0,0.0,0.0);
gluOrtho2D (0.0,400.0,0.0,300.0);
}
void reshape(int w,int h)
{
glViewport(0,0,(GLsizei) w,(GLsizei) h);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT) ;
glColor3f(1.0,0.0,0.0) ;
glFlush() ;
}
void redisplay(void)
{
int xd=0,yd=0,r=40,x,y,xb,yb,xf,yf,d,x1b,y1b,x1f,y1f;
glTranslatef(mousex,mousey,0);
x=0;
y=r;
d=1-r;
glBegin(GL_POINTS);
while(x
glTranslatef函数可以用变量作参数的
mousex和mousey要有初值的.
试试把 redisplay()放在glutDisplayFunc(display) 里,似乎是循环中没有成功调用执行 redisplay();