《C语言300行-投篮》由会员分享,可在线阅读,更多相关《C语言300行-投篮(7页珍藏版)》请在人人文库网上搜索。
1、include stdio.h#ifdef __APPLE__#include #else#include #endif#include #include #include #include #include static double a=0;static double b=0.2;static double t=0;static double t1=0;static double v=0;static double i=0;static double m=0;static double n=0;static double p,q,r,r1=1;static void resize(int 。
2、width,int height)/重绘回调函数const float ar=(float)width/(float)height;glViewport(0,0,width,height);/利用函数glViewport定义视区glMatrixMode(GL_PROJECTION);/投影矩阵glLoadIdentity();/ 重置坐标系统,使投影变换复位glFrustum(-ar,ar,-1.0,1.0,2.0,100.0);/利用函数glFrustum定义修剪区glMatrixMode(GL_MODELVIEW);glLoadIdentity();static void display(。
3、void)/显示回调glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);/清除颜色缓冲区和深度缓冲区t=t+t1*0.0001;glColor3d(1,0.6,0.6);/画图颜色灰红/绘制一个实心球,默认原点在屏幕中心与照相机重合glPushMatrix();glTranslated(-3+0.5*cos(a),-0.6+0.5*sin(a),-5);glRotated(0,0,0,0);glutSolidSphere(b,16,16);glPopMatrix();glColor3d(1,