//包含整个程序中可能用到的头文件#include<windows.h>#include<GL/gl.h>#include<GL/glaux.h>#include<GL/glu.h>#include<time.h>#include<stdlib.h> //记录方块位置的全局数组int a[10][10]={0};//窗口显示函数的声明void myinit(void);void CALLBACK myReshape(GLsizei w,GLsizei h);//显示第一种大方块的函数void CALLBACK display1();//显示第二种大方块的函数void CALLBACK display2();//显示第三种大方块的函数void CALLBACK display3();//显示第四种大方块的函数void CALLBACK display4();//显示第四种大方块的函数void CALLBACK display4(){ //产生0~9的随机数,确定方块出现在那一列 int order,record; srand((unsigned)time(0)); record=rand()%10; for(order=0;order<4;order++) a[order][record]=1; for(order=0;order<10;order++) { printf("\n"); for(record=0;record<10;record++) printf("%2d",a[order][record]); }}//显示第三种大方块的函数void CALLBACK display3(){ //产生0~9的随机数,确定方块出现在那一列 int order,record; srand((unsigned)time(0)); record=rand()%10; for(order=0;order<4;order++) a[order][record]=1; for(order=0;order<10;order++) { printf("\n"); for(record=0;record<10;record++) printf("%2d",a[order][record]); }}//显示第二种大方块的函数void CALLBACK display2(){ //产生0~9的随机数,确定方块出现在那一列 int order,record; srand((unsigned)time(0)); record=rand()%10; for(order=0;order<4;order++) a[order][record]=1; for(order=0;order<10;order++) { printf("\n"); for(record=0;record<10;record++) printf("%2d",a[order][record]); }}//显示第一种大方块的函数void CALLBACK display1(){ //产生0~9的随机数,确定方块出现在那一列 int order,record; srand((unsigned)time(0)); record=rand()%10; for(order=0;order<4;order++) a[order][record]=1; for(order=0;order<10;order++) { printf("\n"); for(record=0;record<10;record++) printf("%2d",a[order][record]); } }//取0~4的随机数函数的声明int num_rand();//取0~4的随机数函数的声明int num_rand(){ int make_rand; srand((unsigned)time(0)); make_rand=(rand()%4); return make_rand;}//窗口处理函数void myinit(void){ glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT);}//重定义窗口大小比例函数void CALLBACK myReshape(GLsizei w,GLsizei h){ glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(w<=h) glOrtho(-10.0,10.0,-10.0*(GLfloat)h/(GLfloat)w,10.0*(GLfloat)h/(GLfloat)w,-1.0,1.0); else glOrtho(-10.0*(GLfloat)w/(GLfloat)h,10.0*(GLfloat)w/(GLfloat)h,-10.0,10.0,-1.0,1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity();}