SlideServe
Menu
Préférences
© SlideServe · v2026

3D Game Programming Lab1- GLUT Programming

shelly avatar
25 diapositives · 577 Views · Sep 13, 2014

3D Game Programming Lab1- GLUT Programming. Ming-Te Chi Department of Computer Science  National Chengchi University. Outline. Code blocks 下載及安裝 Glut bin file 下載及配置 建立一個 glut 範例程式 Example[Bounce]. Code::Blocks 下載. 下載網址 http://www.codeblocks.org/. 點選 Download.

3D Game Programming Lab1- GLUT Programming - slide 1
01 / 253D Game Programming Lab1- GLUT Programming
1 / 17

Télécharger la présentation

3D Game Programming Lab1- GLUT Programming
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. 3D Game ProgrammingLab1- GLUT Programming Ming-Te Chi Department of Computer Science  National Chengchi University

  2. Outline • Code blocks下載及安裝 • Glut bin file下載及配置 • 建立一個glut範例程式 • Example[Bounce]

  3. Code::Blocks下載 • 下載網址 • http://www.codeblocks.org/

  4. 點選Download

  5. 點選 ”Download the binary release”

  6. 請依照所適用之OS作下載(在此僅以windows 系統做示範教學) 兩者選一點擊下載

  7. 安裝Code Blocks

  8. 依照內定

  9. 選擇安裝位置

  10. 執行Code Blocks

  11. Glut bin file下載及配置 • 下載網址 • http://www.xmission.com/~nate/glut.html

  12. Install glut • After you download and open the GLUT bin zip file Do the following! Copy glut32.dll to  c:\windows\system32 or c:\windows\SysWOW64 (win 64) Copy glut32.lib to  c:\program files\CodeBlocks\mingw\lib Copy glut.h to c:\program files\CodeBlocks\mingw\include\GL

  13. Freeglut( 另一個glut選擇 ) • http://files.transmissionzero.co.uk/software/development/GLUT/freeglut-MinGW.zip Copy freeglut.dll to  c:\windows\system32 or c:\windows\SysWOW64 (win 64) Copy libfreeglut.a to  c:\program files\CodeBlocks\mingw\lib Copy freeglut.h, freeglut_std.h, and freeglut_ext.h to c:\program files\CodeBlocks\mingw\include\GL

  14. 建立一個gluttemplate • File -> New -> Project

  15. 選擇GLUT • 為project命名

  16. 指定路徑至MinGW • 直接按下Finish

  17. 按下 (F9) to Build and run 則會出現以下執行畫面

  18. static void key(unsigned char key, int x, int y) { case '+': slices++; stacks++; case '-': if (slices>3 && stacks>3) { slices--; stacks--; } } //The number of geometry stacks and slices can be adjusted using the ‘+’ and ‘-’ keys.

  19. Troubleshooting in windows • add at line 18: #include <windows.h>

  20. 如果放對位置,但仍找不到glut.h • 請依下面流程,檢查路徑是否有你預期的一樣

  21. BOUNCE

  22. Example [Bounce] void glutTimerFunc (unsigned int msecs, void(*func)(int value), int value); Key Function *Registers a timer callback to be triggered in a specified number of milliseconds. • msecs:Number of milliseconds to pass before calling the callback. • func:The timer callback function. • value:Integer value to pass to the timer callback.

  23. Bounce animation • …

  24. void TimerFunction(int value) { // Reverse direction left 、right 、top 、bottom edge if(x1>windowWidth-rsize || x1<0) xstep=-xstep; if(y1>windowHeight-rsize || y1<0) ystep=-ystep; //Check bounds if(x1>windowWidth-rsize) x1=windowWidth-rsize-1; if(y1>windowHeight-rsize) y1=windowHeight-rsize-1; //Actually move the square x1+=xstep; y1+=ystep; //Redraw the scene with new coordinates glutPostRedisplay(); glutTimerFunc(33,TimerFunction,1); //self recall per 33msecs. }

  25. 參考教學網址: • http://www.codeblocks.org/ • http://www.xmission.com/~nate/glut.html • http://www.sci.brooklyn.cuny.edu/~goetz/codeblocks/glut/ • http://www.opengl.org/sdk/docs/man/