freeglut第一步

來源:互聯網
上載者:User

標籤:

 1 #include <GL/freeglut.h> 2  3 static void RenderSceneCB() 4 { 5     glClear(GL_COLOR_BUFFER_BIT); 6     glutSwapBuffers(); 7 } 8  9 static void InitializeGlutCallbacks()10 {11     glutDisplayFunc(RenderSceneCB);12 }13 14 15 int main(int argc, char** argv)16 {17     glutInit(&argc, argv);18     glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);19     glutInitWindowSize(1024, 768);20     glutInitWindowPosition(100, 100);21     glutCreateWindow("Tutorial 01");22 23     InitializeGlutCallbacks();24 25     glClearColor(0.0f, 0.0f, 0.0f, 0.0f);26 27     glutMainLoop();28     29     return 0;30 }
View Code

glutInit(&argc, argv);

初始化glut,可以在命令列中使用‘-sync‘ 和 ‘-gldebug’參數來進行調試錯誤。

glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);

配置渲染參數,GLUT_DOUBLE:代表使用雙緩衝機制;GLUT_RGBA:渲染色彩採用格式。

glutDisplayFunc(RenderSceneCB);

註冊渲染函數(每一幀都會調用)

glClear(GL_COLOR_BUFFER_BIT); 
glutSwapBuffers();

渲染時,先清除之前的渲染資料,然後把後台渲染資料切換到前台完成重新渲染

 

freeglut第一步

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.