日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

OpenGL中使用glutDisplayFunc(myDisplay),myDisplay里面的代码不显示

發(fā)布時間:2025/6/15 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OpenGL中使用glutDisplayFunc(myDisplay),myDisplay里面的代码不显示 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

使用了OpenGL自帶的glut庫來做窗口,使用了

glutMouseFunc(myMouse);
glutDisplayFunc(myDisplay);
glutReshapeFunc(myReshape);

myMouse函數(shù)

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是畫點(diǎn)函數(shù)。此時glut窗口上會繪制出點(diǎn),但如果把這里的drawdot去掉,加在myDisplay函數(shù)中,卻不繪制點(diǎn),奇怪!必須刷新下,才繪制點(diǎn)。

pt[3], count都是全局靜態(tài)變量。

myDisplay函數(shù)

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 }

?

轉(zhuǎn)載于:https://www.cnblogs.com/infiniti/archive/2012/12/19/2825208.html

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的OpenGL中使用glutDisplayFunc(myDisplay),myDisplay里面的代码不显示的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。