第二章 開(kāi)發(fā)環(huán)境的建立_第1頁(yè)
第二章 開(kāi)發(fā)環(huán)境的建立_第2頁(yè)
第二章 開(kāi)發(fā)環(huán)境的建立_第3頁(yè)
第二章 開(kāi)發(fā)環(huán)境的建立_第4頁(yè)
第二章 開(kāi)發(fā)環(huán)境的建立_第5頁(yè)
已閱讀5頁(yè),還剩18頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、主講:汪日偉Email:2參考教材:OpenGL編程權(quán)威指南(第六版)http:/http:/ C+ & OpenGL gl庫(kù): GL.H OPENGL32.LIB, opengl32.dll glu庫(kù) GLU.H GLU32.LIB glu32.dll glut庫(kù) glut.h glut32.lib glut32.dll#include / OpenGL32#include / GLu32#include / GLut #pragma comment( lib, opengl32.lib) #pragma comment( lib, glu32

2、.lib) #pragma comment( lib, glut32.lib) / GLut #pragma comment( linker, /subsystem:windows /entry:mainCRTStartup ) 功能 創(chuàng)建OpenGL程序 框架 創(chuàng)建Glut窗口 在窗口中繪制一個(gè)三角形The main part of the program. GLUT is used to open the OpenGL window, and handle input from the user void glutInit(int *argc, char *argv); Parameter

3、s:argc - A pointer to the unmodified argc variable from the main function. argv - A pointer to the unmodified argv variable from the main function. void glutInitWindowPosition(int x, int y); Parameters:x - the number of pixels from the left of the screen. -1 is the default value, meaning it is up to

4、 the window manager to decide where the window will appear. If not using the default values then you should pick a positive value, preferably one that will fit in your screen.y - the number of pixels from the top of the screen. The comments mentioned for the x parameter also apply in here. void glut

5、InitWindowSize(int width, int height); Parameters: width - The width of the window height - the height of the window void glutInitDisplayMode(unsigned int mode) Parameters: mode - specifies the display mode GLUT_RGBA or GLUT_RGB - default color mode. GLUT_INDEX - selects a color index mode. GLUT_SIN

6、GLE - single buffer window GLUT_DOUBLE - double buffer window GLUT_ACCUM - The accumulation buffer GLUT_STENCIL - The stencil buffer GLUT_DEPTH - The depth buffer int glutCreateWindow(char *title); Parameters: title - sets the window title void glutReshapeFunc(void (*func)(int width, int height); Pa

7、rameters:func - The name of the function that will be responsible for setting the correct perspective when the window changes size. void glutDisplayFunc(void (*func)(void); Parameters: func - the name of the function to be called when the window needs to be redrawn. Note: it is illegal to pass NULL

8、as the argument to this function. void glutIdleFunc(void (*func)(void); Parameters: func - The name of the function that will be called whenever the application is idle. void glutSwapBuffers(); / GLUT_DOUBLEThe function cause the front and back buffers to switch thereby showing what was previously d

9、rawn in the back buffer. void glutKeyboardFunc(void (*func) (unsigned char key, int x, int y); Parameters:func - The name of the function that will process the normal keyboard events. Passing NULL as an argument causes GLUT to ignore normal keys. func: 處理普通按鍵消息的函數(shù)的名稱。第一個(gè)表示按下的鍵的ASCII碼,其余兩個(gè)為當(dāng)鍵按下時(shí)當(dāng)前的鼠標(biāo)

10、位置。鼠標(biāo)位置是相對(duì)于當(dāng)前客戶窗口的左上角而言的。 void glutSpecialFunc(void (*func) (int key, int x, int y); Parameters:func - The name of the function that will process the special keyboard events. Passing NULL as an argument causes GLUT to ignore the special keys. GLUT_KEY_F1 F1 function key GLUT_KEY_F2 F2 function key G

11、LUT_KEY_F3 F3 function key GLUT_KEY_F4 F4 function key GLUT_KEY_F5 F5 function key GLUT_KEY_F6 F6 function key GLUT_KEY_F7 F7 function key GLUT_KEY_F8 F8 function key GLUT_KEY_F9 F9 function key GLUT_KEY_F10 F10 function key GLUT_KEY_F11 F11 function key GLUT_KEY_F12 F12 function key GLUT_KEY_LEFT L

12、eft function key GLUT_KEY_RIGHT Up function key GLUT_KEY_UP Right function key GLUT_KEY_DOWN Down function key GLUT_KEY_PAGE_UP Page Up function key GLUT_KEY_PAGE_DOWN Page Down function key GLUT_KEY_HOME Home function key GLUT_KEY_END End function key GLUT_KEY_INSERT Insert function key int glutGetModifiers(void); 1:GLUT_ACTIVE_SHIFT: 返回它,當(dāng)按下SHIFT鍵或按下CAPS LOCK. 注意兩者同時(shí)按下時(shí),不會(huì)返回這個(gè)值。 2:GLUT_ACTIVE_CTRL: 按下CTRL鍵。 3:GLUT_ACTIVE_ATL: 按下ATL鍵。 void processNormalKeys(unsigned char key, int x, int y) if (key = 27) exit(0); else if (key=r) int mod = glutGetModifiers (); if (mod = GLUT_ACTIVE_ALT)

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論