IT);
auxSolidSphere(1.0); // 绘制半径为1.0的实体球
glFlush(); // 强制输出图像
auxSwapBuffers(); // 交换绘图缓存
Sleep(100);
}
void CALLBACK Idledisplay()
{
// x,y满足x2+y2=0.01。这样可以使物体沿该圆轨迹运动。
static float x=-.1,y=0.0;
static BOOL mark=TRUE;
static float step=.01;
x+=step;
if(x<=.1&&x>=-.1)
{
if(step>0)
y=sqrt(.01-x*x);
else
y=-sqrt(.01-x*x);
glTranslatef(x,y,0);
}
else
{
step=0-step;
}
display();
}
void CALLBACK myReshape(GLsizei w,GLsizei h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-3.5,3.5,-3.5*(GLfloat)w/(GLfloat)h, 3.5*(GLfloat)w/(GLfloat)h,-10,10);
else
glOrtho(-3.5*(GLfloat)w/(GLfloat)h,3.5* (GLfloat)w/(GLfloat)h,-3.5,3.5,-10,10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void main()
{
auxInitDisplayMode(AUX_DOUBLE|AUX_RGBA);
auxInitPosition(0,0,400,400);
auxInitWindow(" circle ");
myinit();
auxReshapeFunc(myReshape);
auxIdleFunc(Idledisplay);
auxMainLoop(display);
}
在Visual C++ 2005下编译
cl a.cpp /linkopengl32.lib glu32.lib glaux.lib user32.lib gdi32.lib kernel32.lib advapi32.lib