opengl初探部分代碼

opengl初探部分代碼

ID:25325529

大小:81.00 KB

頁數(shù):6頁

時間:2018-11-19

opengl初探部分代碼_第1頁
opengl初探部分代碼_第2頁
opengl初探部分代碼_第3頁
opengl初探部分代碼_第4頁
opengl初探部分代碼_第5頁
資源描述:

《opengl初探部分代碼》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫

1、將Onsize代碼替換成如下的代碼,使前述的平行投影變成透視投影voidCMyOpenGLView::OnSize(UINTnType,intcx,intcy){glViewport(0,0,cx,cy);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(45,(float)cx/(float)cy,0.1,15);glMatrixMode(GL_MODELVIEW);glLoadIdentity();}以下是修改Draw方法的代碼,以實現(xiàn)不同的功

2、能//2D圖形繪制glClearColor(0,0,0,1);glClear(GL_COLOR_BUFFER_BIT

3、GL_DEPTH_BUFFER_BIT);glLoadIdentity();glShadeModel(GL_SMOOTH);glTranslatef(-1.5f,1.0f,-7.0f);glColor3f(1.0f,0.0f,0.0f);glBegin(GL_TRIANGLES);glVertex3f(0.0f,1.0f,0.0f);glVertex3f(-1.0f,-1.0f,0.0f);glVer

4、tex3f(1.0f,-1.0f,0.0f);glEnd();glTranslatef(3.0f,0.0f,0.0f);glColor3f(0.0f,0.0f,1.0f);glBegin(GL_QUADS);glVertex3f(-1.0f,1.0f,0.0f);glVertex3f(-1.0f,-1.0f,0.0f);glVertex3f(1.0f,-1.0f,0.0f);glVertex3f(1.0f,1.0f,0.0f);glEnd();glTranslatef(-1.5f,-2.5f,0.0f);glColo

5、r3f(1.0f,1.0f,0.0f);glLineWidth(2.0f);glBegin(GL_LINE_LOOP);for(inti=0;i<200;i++)glVertex3f(1.0*float(sin(2*3.14*i/200)),1.0*float(cos(2*3.14*i/200)),0.0);glEnd();SwapBuffers(m_hDC);glFlush();//陰暗處理glClearColor(0,0,0,1);glClear(GL_COLOR_BUFFER_BIT

6、GL_DEPTH_BUFF

7、ER_BIT);glLoadIdentity();glShadeModel(GL_SMOOTH);//設(shè)置平滑插值glTranslatef(-1.5f,1.0f,-7.0f);glColor3f(1.0f,0.0f,0.0f);glBegin(GL_TRIANGLES);glColor3ub(255,0,0);glVertex3f(0.0f,1.0f,0.0f);glColor3ub(0,255,0);glVertex3f(-1.0f,-1.0f,0.0f);glColor3ub(255,255,0);glVerte

8、x3f(1.0f,-1.0f,0.0f);glEnd();glTranslatef(3.0f,0.0f,0.0f);glColor3ub(0,255,255);glBegin(GL_QUADS);glVertex3f(-1.0f,1.0f,0.0f);glVertex3f(-1.0f,-1.0f,0.0f);glVertex3f(1.0f,-1.0f,0.0f);glVertex3f(1.0f,1.0f,0.0f);glEnd();glTranslatef(-1.5f,-2.5f,0.0f);glColor3f(1.

9、0f,1.0f,0.0f);glLineWidth(2.0f);glBegin(GL_LINE_LOOP);for(inti=0;i<200;i++)glVertex3f(1.0*float(sin(2*3.14*i/200)),1.0*float(cos(2*3.14*i/200)),0.0);glEnd();SwapBuffers(m_hDC);glFlush();//3D圖形glClearColor(0,0,0,1);glClear(GL_COLOR_BUFFER_BIT

10、GL_DEPTH_BUFFER_BIT

11、);glLoadIdentity();glTranslatef(-2.0f,0.0f,-8.0f);glBegin(GL_TRIANGLES);//正面glColor3ub(217,167,22);glVertex3f(0.0f,1.0f,0.0f);glVertex3f(-1.0f,-1.0f,1.0f);glVertex3f(1.0f,-1

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

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

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