vc環(huán)境下的OpenGL編程.ppt

vc環(huán)境下的OpenGL編程.ppt

ID:51489212

大?。?2.00 KB

頁數(shù):11頁

時間:2020-03-24

vc環(huán)境下的OpenGL編程.ppt_第1頁
vc環(huán)境下的OpenGL編程.ppt_第2頁
vc環(huán)境下的OpenGL編程.ppt_第3頁
vc環(huán)境下的OpenGL編程.ppt_第4頁
vc環(huán)境下的OpenGL編程.ppt_第5頁
資源描述:

《vc環(huán)境下的OpenGL編程.ppt》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫

1、vc環(huán)境下OpenGL編程:Win32應(yīng)用編程OpenGL學(xué)習(xí)資源網(wǎng)站:nehe.gamedev.net百度nehe教程一、程序主流程程序主進(jìn)程:WinMain創(chuàng)建窗口CreateGLWindow進(jìn)入主窗口消息循環(huán)退出二、OpenGL窗口創(chuàng)建及初始化程序主進(jìn)程:WinMain創(chuàng)建窗口CreateGLWindow進(jìn)入主窗口消息循環(huán)退出注冊窗口類:RegisterClass顯示設(shè)置:ChangeDisplaySettings調(diào)整窗口大小:AdjustWindowRectEx創(chuàng)建:CreateWindow

2、Ex選擇像素格式:ChoosePixelFormat設(shè)置像素格式:SetPixelFormat創(chuàng)建OpenGL渲染上下文:wglCreateContext激活OpenGL渲染上下文:wglMakeCurrent顯示窗口:ShowWindow調(diào)整OpenGL視口大?。篟eSizeGLSceneOpenGL繪制選項初始化:InitGLHDChDC=NULL;//基本圖形設(shè)備接口上下文,選擇和設(shè)置像素格式時使用HGLRChRC=NULL;//永久渲染上下文,創(chuàng)建和激活OpenGL渲染上下文時使用HWNDh

3、Wnd=NULL;//窗口句柄HINSTANCEhInstance;//應(yīng)用實例句柄三、調(diào)整OpenGL視口glViewport(0,0,width,height);//設(shè)置當(dāng)前視口大小glMatrixMode(GL_PROJECTION);//選擇投影矩陣模式glLoadIdentity();//重置投影矩陣//計算OpenGL觀察窗口參數(shù):視角、寬高比、近裁剪面、//遠(yuǎn)裁剪面gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.

4、0f);glMatrixMode(GL_MODELVIEW);//選擇模型矩陣模式glLoadIdentity();//重置模型矩陣四、OpenGL繪制選項初始化glShadeModel(GL_SMOOTH);//打開平滑陰影:glClearColor(0.0f,0.0f,0.0f,0.5f);//黑色背景glClearDepth(1.0f);//深度緩存初始化glEnable(GL_DEPTH_TEST);//打開深度測試glDepthFunc(GL_LEQUAL);//深度測試類型,GL_LEQ

5、UAL:當(dāng)前深度值小于或等于深度緩存中的深度值時進(jìn)行繪制glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);//高質(zhì)量投影計算五、OpenGL圖形繪制glClear(GL_COLOR_BUFFER_BIT

6、GL_DEPTH_BUFFER_BIT);//初始化顏色緩存和深度緩存glLoadIdentity();glTranslatef(-1.5f,0.0f,-6.0f);glRotatef(rtri,0.0f,1.0f,0.0f);glBegin(GL_T

7、RIANGLES);//繪制四菱錐glColor3f(1.0f,0.0f,0.0f);glVertex3f(0.0f,1.0f,0.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f(-1.0f,-1.0f,1.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f(1.0f,-1.0f,1.0f);glColor3f(1.0f,0.0f,0.0f);glVertex3f(0.0f,1.0f,0.0f);glColor3f(0.0f,0.0f,

8、1.0f);glVertex3f(1.0f,-1.0f,1.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f(1.0f,-1.0f,-1.0f);glColor3f(1.0f,0.0f,0.0f);glVertex3f(0.0f,1.0f,0.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f(1.0f,-1.0f,-1.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f(-1.0f,-1.0f,-1.0f)

9、;glColor3f(1.0f,0.0f,0.0f);glVertex3f(0.0f,1.0f,0.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f(-1.0f,-1.0f,-1.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f(-1.0f,-1.0f,1.0f);glEnd();//繪制立方體glLoadIdentity();glTranslatef(1.5f,0.0f,-7.0f);glRotatef

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文

此文檔下載收益歸作者所有

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學(xué)公式或PPT動畫的文件,查看預(yù)覽時可能會顯示錯亂或異常,文件下載后無此問題,請放心下載。
2. 本文檔由用戶上傳,版權(quán)歸屬用戶,天天文庫負(fù)責(zé)整理代發(fā)布。如果您對本文檔版權(quán)有爭議請及時聯(lián)系客服。
3. 下載前請仔細(xì)閱讀文檔內(nèi)容,確認(rèn)文檔內(nèi)容符合您的需求后進(jìn)行下載,若出現(xiàn)內(nèi)容與標(biāo)題不符可向本站投訴處理。
4. 下載文檔時可能由于網(wǎng)絡(luò)波動等原因無法下載或下載錯誤,付費完成后未能成功下載的用戶請聯(lián)系客服處理。