void MakePolygon() { glClear(GL_COLOR_BUFFER_BIT); glClearColor(1.0,1.0,1.0,1.0); for(int i=0;i<=VertInd;i++) MakeDot(ToDraw->LocalSpaceList[i]); glColor3dv(ToDraw->Color); glBegin(GL_POLYGON); for(int i=0;i<=VertInd;i++) glVertex2dv(ToDraw->LocalSpaceList[i]); glEnd(); glLineWidth(2.0); glColor3d(0.0,0.0,0.0); glBegin(GL_LINE_LOOP); for(int i=0;i<=VertInd;i++) glVertex2dv(ToDraw->LocalSpaceList[i]); glEnd(); MakeDot(0,0); no2[0]=(ToDraw->NumVertices-VertInd)/10+'0'; no2[1]=(ToDraw->NumVertices-VertInd)%10+'0'; strcpy(hello3,"Vertices Left: "); strcat(hello3,no2); text(hello3,-0.22,-0.15,1); text(instructions,-0.2,-0.05,0); glutSwapBuffers(); }
int main() { BSTree T; int k; BSTree result; printf("建立二叉排序树,请输入序列, 以-1结束:\n"); CreateBST(&T); printf("先序遍历输出序列为:"); PreOrder(T); /* printf("\n请输入要查找的元素:"); fflush(stdin); scanf("%d",&k); result = SearchBST(T,k); if (result != NULL) printf("要查找的元素为%d\n",result->key); else printf("未找到!\n"); result = DelBST(T,k); printf("删除元素%d后的排序树先序遍历为\n",k); */ PreOrder(T); MakeDot(T); return 0; }
void simulate()//GLUT required function. { glClear(GL_COLOR_BUFFER_BIT); // glClearColor((rand()%100)/100.0,(rand()%100)/100.0,(rand()%100)/100.0,1.0); glClearColor(1.0,1.0,1.0,1.0); if(!Pause || let) {//Detect collisions for(i=0;i<NoOfLayers;i++) { for(j=0;j<BodiesPerLayer;j++) { if(layer[i][j].Exists) { if(wallL.Exists)DetectColl(layer[i][j],wallL); if(wallR.Exists)DetectColl(layer[i][j],wallR); if(ground.Exists)DetectColl(layer[i][j],ground); if(wallU.Exists)DetectColl(layer[i][j],wallU); for(k=i;k<NoOfLayers;k++) { for(l=(k==i)?j+1:0;l<BodiesPerLayer;l++) { if(layer[k][l].Exists) DetectColl(layer[i][j],layer[k][l]); } } } } } } //Render everything for(i=0;i<NoOfLayers;i++) { for(j=0;j<BodiesPerLayer;j++) { if(layer[i][j].Exists) layer[i][j].Render(); } } if(wallR.Exists)wallR.Render(); if(wallL.Exists)wallL.Render(); if(ground.Exists)ground.Render(); if(wallU.Exists)wallU.Render(); if(!Pause || let) {//Detect collisions for(i=0;i<NoOfLayers;i++) { for(j=0;j<BodiesPerLayer;j++) { if(layer[i][j].Exists) layer[i][j].Update(); } } if(wallL.Exists)wallL.Update(); if(wallR.Exists)wallR.Update(); if(ground.Exists)ground.Update(); if(wallU.Exists)wallU.Update(); let=0; } if(Pause)Button1=PlayButton; else Button1=PauseButton; strcpy(hello,""); if(Pause)strcpy(hello,"Simulation paused.\nPress 'N' for next frame."); if(Button1.isPressed(CurrMousePos))strcpy(hello,"Press for Play/Pause."); Button1.Render(); if(LayerManager.isPressed(CurrMousePos))strcpy(hello,"Press for Layer Manager."); LayerManager.Render(); if(lwall.isPressed(CurrMousePos))strcpy(hello,"Press for Left Wall Toggle."); lwall.Render(); if(rwall.isPressed(CurrMousePos))strcpy(hello,"Press for Right Wall Toggle."); rwall.Render(); if(uwall.isPressed(CurrMousePos))strcpy(hello,"Press for Ceiling Toggle."); uwall.Render(); if(gwall.isPressed(CurrMousePos))strcpy(hello,"Press for Ground Toggle."); gwall.Render(); text(hello,CurrMousePos[0]+0.01,CurrMousePos[1]+0.01); MakeDot(CurrMousePos); if(FirstTime)text("No Objects defined. Use Layer manager to add some layers.\nPlease don't close any window manually. This will end the program.",0.25,0.50); glutSwapBuffers(); }