回覆列表
  • 1 # teruk4854

    1.開啟vs2015,執行—devenv2在VisualC++下新建一個win32控制檯程式確定—下一步—完成3專案—管理Nuget程式包4瀏覽——在搜尋欄輸入NupenGL,安裝這兩個檔案包5程式測試#include#include#include#includestaticintyear=0,spin=0,day=0;staticGLintfogMode;constintn=100;constGLfloatR=1.0f;constGLfloatPi=3.1415926536f;voidDrawCircle(){inti;glClear(GL_COLOR_BUFFER_BIT);glBegin(GL_LINE_LOOP);for(i=0;i360)spin=spin-360;glutPostRedisplay();}voidmouse(intbutton,intstate,intx,inty){switch(button){caseGLUT_LEFT_BUTTON:if(state==GLUT_DOWN)glutIdleFunc(spinDisplay);break;caseGLUT_MIDDLE_BUTTON:if(state==GLUT_DOWN)glutIdleFunc(NULL);break;default:break;}}voidreshape(intw,inth){glViewport(0,0,(GLsizei)w,(GLsizei)h);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(60.0,(GLfloat)w/(GLfloat)h,0.5,20.0);glMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(0.0,10.0,10.0,0.0,0.0,0.0,0.0,1.0,0.0);}voidkeyboard(unsignedcharkey,intx,inty){switch(key){case"d":day=(day+10)%360;glutPostRedisplay();break;case"D":day=(day-10)%360;glutPostRedisplay();break;case"y":year=(year+5)%360;glutPostRedisplay();break;case"Y":year=(year-5)%360;glutPostRedisplay();break;case27:exit(0);break;default:break;}}intmain(intargc,char**argv){glutInit(&argc,argv);glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);glutInitWindowSize(400,400);glutInitWindowPosition(100,100);glutCreateWindow("OpengGL程式設計測試");init();//glutDisplayFunc(DrawCircle);glutDisplayFunc(display);glutReshapeFunc(reshape);//glutKeyboardFunc(keyboard);glutMouseFunc(mouse);glutMainLoop();return0;}

  • 中秋節和大豐收的關聯?
  • 常用於治療高血壓病的土單驗方有哪些?