白虎佩恩 白虎佩恩
关注数: 5 粉丝数: 205 发帖数: 1,078 关注贴吧数: 23
不懂就问,为什么我的程序显示白屏? # include<gl/GLUT.H> # include<iostream> using namespace std; static GLfloat spin = 0.0; //control the spin of graphic static GLfloat scale = 0.5; // control the scale of graphic static GLfloat moveX = 0.0; //control the moving of graphic static GLfloat moveY = 0.0; //control the moving of graphic int colorId = 2; // Indicate the color of graphic int graphicId = 11; //Indicate the type of graphic int backgroundId = 22; //Indicate the style of background void initial() { glClearColor(0.75f, 0.75f, 0.75f, 1.0f); glColor3f(0.0f, 0.0f, 0.0f); } void glTrianf(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { glBegin(GL_TRIANGLES); { glVertex2f(x0, y0); glVertex2f(x1, y1); glVertex2f(x2, y2); } glEnd(); } void changeSize(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1.5f, 1.5f, -1.5f, 1.5f); } void display() { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //replace the current matrix with the identity matrix glRotatef(spin, 1.0f, 0.0f, 0.0f); glTranslatef(0.0, moveY, 0.0); glTranslatef(moveX, 0.0, 0.0); glScalef(scale, scale, scale); switch (backgroundId) //change background's color { case 21:glClearColor(0.75f, 0.0f, 1.0f, 1.0f); break; case 22:glClearColor(0.75f, 0.75f, 1.0f, 1.0f); break; case 23:glClearColor(1.75f, 1.75f, 0.75f, 1.0f); break; case 24:glClearColor(1.75f, 1.0f, 1.55f, 1.0f); break; case 25:glClearColor(0.0f, 1.0f, 0.75f, 1.0f); break; } switch (colorId) // change graphic's color { case 1: glColor3f(0.0f, 0.0f, 0.0f); break; case 2: glColor3f(1.0f, 0.0f, 0.0f); break; case 3: glColor3f(0.0f, 0.0f, 1.0f); break; case 4: glColor3f(0.0f, 1.0f, 0.0f); break; case 5: glColor3f(1.0f, 1.0f, 1.0f); break; } glClear(GL_COLOR_BUFFER_BIT); switch (graphicId) { case 11:glTrianf(-1.0, -1.0, 1.0, -1.0, 0.0, 1.0); break; case 12:glRectf(-1.0, -1.0, 1.0, -1.0); break; } glFlush(); } void spinDisplay() { spin += 2.0; if (spin > 360.0) spin -= 360.0; glutPostRedisplay(); } void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) glutIdleFunc(spinDisplay); break; } } void keyboard(unsigned char key, int x, int y) { if (key == 's') scale += 0.1; if (key == 'd') scale -= 0.1; glutPostRedisplay(); } void specialKeys(int key, int x, int y) { if (key == GLUT_KEY_UP) moveY += 0.05; // move up if (key == GLUT_KEY_DOWN) moveY -= 0.05; // move down if (key == GLUT_KEY_LEFT) moveX -= 0.05; // move left if (key == GLUT_KEY_RIGHT) moveX += 0.05; //move right glutPostRedisplay(); } void ProcessMenu(int value) { if (value >= 1 && value <= 10) { colorId = value; } else if (value >= 11 && value <= 20) { graphicId = value; } else if (value >= 21 && value <= 30) { backgroundId = value; } else if (value == 100) { exit(0); } glutPostRedisplay(); } int main(int argc,char*argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(400, 400); glutInitWindowPosition(100, 100); glutCreateWindow("triangle or rectangle"); //Color Menu int glutColorMenu = glutCreateMenu(ProcessMenu); glutAddMenuEntry("Black", 1); glutAddMenuEntry("Red", 2); glutAddMenuEntry("Blue", 3); glutAddMenuEntry("Green", 4); glutAddMenuEntry("White", 5); //Graphic Menu int glutGraphicMenu = glutCreateMenu(ProcessMenu); glutAddMenuEntry("Triangle", 11); glutAddMenuEntry("Rectangle", 12); //Background Menu int glutBackgorundMenu = glutCreateMenu(ProcessMenu); glutAddMenuEntry("Style1", 21); glutAddMenuEntry("Style2", 22); glutAddMenuEntry("Style3", 23); glutAddMenuEntry("Style4", 24); glutAddMenuEntry("Style5", 25); int glutExitMenu = glutCreateMenu(ProcessMenu); glutAddMenuEntry("Exit", 100); int glutMenu = glutCreateMenu(ProcessMenu); glutAddSubMenu("Change Color", glutColorMenu); glutAddSubMenu("Change Graphic", glutGraphicMenu); glutAddSubMenu("Change Background", glutBackgorundMenu); glutAddSubMenu("Exit", glutExitMenu); glutAttachMenu(GLUT_RIGHT_BUTTON); glutDisplayFunc(display); glutReshapeFunc(changeSize); glutSpecialFunc(specialKeys); glutMouseFunc(mouse); glutKeyboardFunc(keyboard); initial(); glutMainLoop(); return 0; }
评一个我心目中的NBA历史一阵 注:评定的原则是攻防兼备,这支队伍可以不用每场拿100多分,但是一定可以限制任何一支其他球队的得分。名单如下: SG:我想这是最没悬念的位置了,地板流与空中作业同样擅长,攻防具佳,毫无疑问的迈克尔乔丹。 SF:拉里伯德。为什么我不选詹姆斯?为什么我要选詹姆斯!我需要的是一个打球更聪明灵活,关键时刻在乔丹遇到严防时可以站出来得分的球员,还有一个可以用垃圾话影响比赛的人。 PG:加里佩顿。OK,我既没有选择斯托克顿也没有选择魔术师。理由是这名控卫当然要有足够出色的组织能力,那么当我在斯托克顿和魔术师之间犹豫不决的时候我想到了什么呢?防守!NBA历史上有出色组织能力的控卫其实很多,从鲍勃库西到保罗,但是既有优秀组织能力又有强悍防守的只有一个,那就是佩顿,唯一一个以PG身份拿下最佳防守球员的人。 PF:比尔拉塞尔。没错他是个C……但是以他2米08的身高在当今联盟也只能打PF了吧?他可以在防守端和篮板上给予球队足够的支援,在这样一支巨星云集的球队里真的不需要再添一个刷分的了。 C:沙奎尔奥尼尔。这是最犹豫的位置了,我没有选择大梦,海军上将,猩猩还有天勾以及张伯伦。理由是……他。最。胖。……这并不是一个荒谬的理由,庞大的身躯能使得奥尼尔无论在地位背身拱、要位以及挡拆上都更有优势。
1 下一页