OpenGL中使用glutDisplayFunc(myDisplay),myDisplay里面的代码不显示
生活随笔
收集整理的這篇文章主要介紹了
OpenGL中使用glutDisplayFunc(myDisplay),myDisplay里面的代码不显示
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用了OpenGL自帶的glut庫來做窗口,使用了
glutMouseFunc(myMouse);
glutDisplayFunc(myDisplay);
glutReshapeFunc(myReshape);
myMouse函數
myMouse 1 void myMouse(int button,int state,int x,int y)2 {3 if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)4 {5 if(count<3)6 {7 drawDot(x,screenHeight-y);8 pt[count].x = x;9 pt[count].y = screenHeight - y; 10 count++; 11 glFlush(); 12 } 13 else 14 { 15 count = 0; 16 drawDot(x,screenHeight-y); 17 pt[count].x = x; 18 pt[count].y = screenHeight - y; 19 count++; 20 glFlush(); 21 } 22 } 23 else if (button ==GLUT_LEFT_BUTTON && state == GLUT_UP) 24 { 25 if (count==3) 26 { 27 28 glFlush(); 29 } 30 31 } 32 }其中的drawdot是畫點函數。此時glut窗口上會繪制出點,但如果把這里的drawdot去掉,加在myDisplay函數中,卻不繪制點,奇怪!必須刷新下,才繪制點。
pt[3], count都是全局靜態變量。
myDisplay函數
myDisplay 1 void myDisplay(void)2 {3 glClear(GL_COLOR_BUFFER_BIT);4 5 if (count!=0)6 {7 for (int i=0;i<count;i++)8 {9 drawDot(pt[i].x,pt[i].y); 10 } 11 } 12 13 glFlush(); 14 }?
轉載于:https://www.cnblogs.com/infiniti/archive/2012/12/19/2825208.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的OpenGL中使用glutDisplayFunc(myDisplay),myDisplay里面的代码不显示的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux 配置 clang++ SD
- 下一篇: Apache 配置的性能调优