版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
實(shí)驗(yàn)1.(1)三角形:#include<glut.h>//glut.hincludesgl.handglu.hvoidinit(void){glClearColor(0.0,0.0,0.0,0.0);}Jvoidreshape(ntw,inth){glViewport(0,0,(GLsizei)w,(GLsizei)h);glMatrixMode(GL_PROJECTION);//指定哪一個(gè)矩陣是當(dāng)前矩陣glLoadIdentity();//重置當(dāng)前指定的矩陣為單位矩陣。gluOrtho2D(-1.0,1.0,-1.0,1.0);//Theparaare:(left,right,bottom,top)定義二維正交投影矩陣glMatrixMode(GL_MODELVIEW);//指定哪一個(gè)矩陣是當(dāng)前矩陣}voiddisplay(void){glClear(GL_COLOR_BUFFER_BIT);//CleartheframebufferglColor3f(0.0,1.0,0.0);//SetcurrentcolortogreenglBegin(GLPOLYGON);//DrawthetriangleglVertex2f(-0.7,-0.7);glVertex2f(0.7,-0.7);glVertex2f(0,0.7);glEnd();glFlush();//Forcetodisplaythenewdrawingsimmediately}intmain(intargc,char**argv){glutInit(&argc,argv);//InitializeGLUTfunctioncallingsglutInitWindowSize(400,400);glutInitWindowPosition(200,100);//innumbersofpixelsglutCreateWindow("GreenTriangle");glutDisplayFunc(display);//iscreatedorre-drewinit();//InvokethisfunctionforinitializationglutMainLoop();//Entertheeventprocessingloop
return0;//Indicatenormaltermination//(RequiredbyANSIC)}//操作,定義事件回調(diào)函數(shù)(2)點(diǎn):voiddisplay(){glClear(GL_COLOR_BUFFER_BIT);//CleartheframebufferglColor3f(0.0,1.0,0.0);//SetcurrentcolortogreenglPointSize(10.);glBegin(GLPOINTS);glVertex2i(0.5,0.5);glEnd();glFlush();//Forcetodisplaythenewdrawingsimmediately}(3)線段:voiddisplay(){glClear(GLCOLORBUFFERBIT);//CleartheframebufferglColor3f(0.0,1.0,0.0);//SetcurrentcolortogreenglLineWidth(3.0);glBegin(GL_LINES);
glVertex3f(0.,0.,0.);glVertex3f(0.,1.,0.);glEnd();glFlush();//Forcetodisplaythenewdrawingsimmediately}(4)四邊形:voiddisplay(){glClear(GL_COLOR_BUFFER_BIT);//CleartheframebufferglColor3f(1.0,0.0,0.0);//SetcurrentcolortogreenglRectf(0.6,0.3,0.2,0.8);intvertex1[]={0.6,0.3};intvertex2口={0.2,0.8};glRectiv(vertex1,vertex2);glFlush();//Forcetodisplaythenewdrawingsimmediately}2.立方體:3.voidreshape(ntw,inth){glViewport(0,0,w,h);glMatrixMode(GLPROJECTION);glLoadIdentity();glOrtho(-3.0,3.0,-3.0,3.0,-3.0,3.0);}voiddisplay(){glClear(GL_COLOR_BUFFER_BIT);//CleartheframebufferglMatrixMode(GLMODELVIEW);glLoadIdentity();gluLookAt(1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0);glutWireCube(0.5);glutSwapBuffers();glColor3f(0.0,1.0,0.0);glBegin(GLLINELOOP);//GreenglVertex3f(0.,0.,0.);glVertex3f(0.,2,0.);glVertex3f(2,2,0.);glVertex3f(2,0.,0.);glEnd();glColor3f(1.0,1.0,0.0);glBegin(GLLINELOOP);//YellowglVertex3f(0.,0.,2);glVertex3f(2,0.,2);glVertex3f(2,2,2);glVertex3f(0.,2,2);glEnd();glColor3f(0.0,1.0,1.0);glBegin(GL_LINES);//CyanglVertex3f(0.,0.,0.);glVertex3f(0.,0.,2);glVertex3f(0.,2,0.);glVertex3f(0.,2,2);glVertex3f(2,0.,0.);glVertex3f(2,0.,2);glVertex3f(2,2,0.);glVertex3f(2,2,2);glEnd();glFlush();//Forcetodisplaythenewdrawingsimmediately}3.(1)三角形條帶■stripvoiddisplay(){glClear(GL_COLOR_BUFFER_BIT);//CleartheframebufferGLfloatv0[]={0.,0.3},v1[]={0.2,0.6},v2[]={0.4,0.3},v3[]={0.5,0.6},v4[]={0.6,0.3},v5[]={0.8,0.6},glColor3f(1.0);glBegin(GLTRIANGLESTRIP);//三角形條帶函數(shù)glVertex2fv(v0);glVertex2fv(v1);glVertex2fv(v2);glVertex2fv(v3);glVertex2fv(v4);glVertex2fv(v5);glEnd();glFlush();//Forcetodisplaythenewdrawingsimmediately}3.(2)三角形扇形GLfloatv0[]={0.,0.3},v1[]={0.3,0.7},v2[]={0.5,0.65},v3[]={0.5,0.5},v4[]={0.45,0.4},v5[]={0.3,0.35},glColor3f(1.0);glBegin(GL_TRIANGLE_FAN);〃共享一個(gè)頂點(diǎn)glVertex2fv(v0);glVertex2fv(v1);glVertex2fv(v2);glVertex2fv(v3);glVertex2fv(v4);glVertex2fv(v5);glEnd();glFlush();//Forcetodisplaythenewdrawingsimmediately}實(shí)驗(yàn)二1.點(diǎn)glColor3f(0.0,1,0,0.0);glPointSize(3.);glBegin(GLPOINTS);glVertex3f(0.1,0,5,0);glColor3f(1.0,1,0,0.0);glPointSize(5.);glBegin(GL_POINTS);glVertex3f(0.5,0,5,0);glColor3f(1.0,0,0,0.0);glPointSize(10.);glBegin(GLPOINTS);glVertex3f(0.3,0,4,0);glColor3f(0.0,0,0,1.0);glPointSize(1.);glBegin(GLPOINTS);glVertex3f(0.2,0,6,0);glColor3f(1.0,1,0,1.0);glPointSize(4.);glBegin(GLPOINTS);glVertex3f(0.3,0,5,0);glEnd();glFlush();//Forcetodisplaythenewdrawingsimmediately)2直線glColor3f(0.0,1,0,0.0);glLineWidth(1.0);glBegin(GLLINES);glVertex3f(0.3,0.1,0.0);glVertex3f(0.3,0.5,0.0);//垂直距離glColor3f(1.0,1,0,0.0);glLineWidth(3.);//寬度glBegin(GLLINES);glVertex3f(0.2,0,1,0.0);glVertex3f(0.2,0,5,0.0);glColor3f(1.0,0,0,0.0);glLineWidth(5.);glBegin(GLLINES);glVertex3f(0.5,0,1,0.0);glVertex3f(0.5,0,5,0.0);glEnd();glFlush();//Forcetodisplaythenewdrawingsimmediately)3,直線,虛線,點(diǎn)劃線glColor3f(1.0,0,0,0.0);glLineWidth(2.0);glBegin(GL_LINES);glVertex2f(0.0,0.3);glVertex2f(0.8,0.3);glEnd();glColor3f(1.0,0,0,0.0);glEnable(GLLINESTIPPLE);glLineStipple(1,0x0101);glLineWidth(2.0);glBegin(GL_LINES);glVertex2f(0.0,0.5);glVertex2f(0.8,0.5);glEnd();glColor3f(1.0,0,0,0.0);glEnable(GLLINESTIPPLE);glLineStipple(1,0xffcc);glLineWidth(2.0);glBegin(GL_LINES);glVertex2f(0.0,0.8);glVertex2f(0.8,0.8);glEnd();
.頂點(diǎn)不同顏色的三角形平滑填充glShadeModel(GLSMOOTH);glBegin(GL_TRIANGLES);glColor3f(0.0,0,0,1.0);glPointSize(5.0);glVertex2f(0.3,0.3);glColor3f(1.0,0,0,0.0);glPointSize(5.0);glVertex2f(0.4,0.6);glColor3f(1.0,1,0,0.0);glPointSize(5.0);glVertex2f(0.5,0.4);glEnd();.調(diào)用glPolygonMode(face,displayMode);
.兩個(gè)正方形混合glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUSSRCALPHA);//混合glColor4f(0.0,1.0,0.0,0.5);//SetcurrentcolortogreenglRectf(0.6,0.3,0.2,0.8);intvertex1[]={0.6,0.3};intvertex2[]={0.2,0.8};glRectiv(vertex1,vertex2);glColor4f(0.0,0.0,1.0,0.5);//SetcurrentcolortogreenglRectf(0.5,0.2,0.1,0.5);intvertex3口={0.5,0.2};intvertex4口={0.1,0.5};glRectiv(vertex3,vertex4);[n回KglEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA,GL_ZERO);glEnable(GL_BLEND);glBlendFunc(GL_ONE,GL_ZERO);說(shuō)明:用函數(shù)glBlendFunc(sFactor,dFactor)選擇調(diào)和因子的值產(chǎn)生不同的混合效果,有GL_ONE,GL_ZERO,GL_SRC_ALPHAGL_DST_ALPHA,GL_ONE_MINUS_SRC_ALPHA等實(shí)驗(yàn)三1.平移glMatrixMode(GLMODELVIEW);glColor3f(1.0,1,0,0.0);glRectf(0.6,0,3,0,2,0.8);glColor3f(1.0,0,0,0.0);glTranslatef(-0.5,-0.3,0.0);glRectf(0.6,0,3,0,2,0.8);旋轉(zhuǎn):glColor3f(1.0,1,0,0.0);glRectf(0.6,0,3,0,2,0.8)glLoadIdentity();glRotatef(90.0,0,0,0,0,1.0);glRectf(0.6,0,3,0,2,0.8);■3line縮放:glColor3f(0.0,1,0,1.0);glLoadIdentity();glScalef(-0.5,1.0,1.0);glRectf(0.6,0,3,0,2,0.8);3.桌子繪制voidtable(){glColor3f(0.0,1,0,1.0);glRectf(-0.5,0,3,0.5,-0.3);glColor3f(1.0,1,0,0.0);glRectf(-0.4,0,25,0.4,0.15);glColor3f(1.0,1,0,0.0);glRectf(-0.4,0,25,-0.3,-0.15);glColor3f(1.0,1,0,0.0);glRectf(0.3,0,25,0.4,-0.15);glColor3f(1.0,1,0,0.0);glRectf(-0.4,-0.15,0.4,-0.25);glColor3f(1.0,0,2,0.0);glRotatef(-45.0,0,0,0,0,1.0);glTranslatef(0.15,0.35,0.0);glRectf(-0.3,-0.15,0.3,-0.25);glLoadIdentity();glColor3f(1.0,0,2,0.0);glRotatef(-90,0.0,0,0,1.0);glTranslatef(-0.35,-0.15,0.0);glRectf(-0.3,-0.15,0.3,-0.25);glLoadIdentity();glColor3f(1.0,0,2,0.0);glRotatef(-90,0.0,0,0,1.0);glTranslatef(-0.65,0.15,0.0);glRectf(-0.3,-0.15,0.3,-0.25);glLoadIdentity();glColor3f(1.0,0,2,0.0);glRotatef(-90,0.0,0,0,1.0);glTranslatef(-0.2,0,6,0.0);glRectf(-0.3,-0.15,0.3,-0.25);)voiddisplay(){glClear(GLCOLORBUFFERBIT|GL_DEPTH_BUFFER_BIT);//CleartheframebufferglMatrixMode(GLMODELVIEW);glPushMatrix();glRotatef(-45.0,0,0,0,0,1.0);table();glPopMatrix();glFlush();}.4.編程繪制羅馬字母IV和XIV:voidword(){glColor3f(1.0,1.0,1.0);glBegin(GLLINES);glVertex2f(-0.25,0.3);glVertex2f(-0.2,0.3);glEnd();glColor3f(1.0,1.0,1.0);glBegin(GL_LINES);glVertex2f(-0.25,0.0);glVertex2f(-0.15,0.0);glEnd();glColor3f(1.0,1.0,1.0);glBegin(GL_LINES);glVertex2f(-0.2,0.0);glVertex2f(-0.2,0.3);glEnd();glColor3f(1.0,1.0,1.0);glBegin(GL_LINES);glVertex2f(-0.2,0.3);glVertex2f(-0.1,0.3);glEnd();glColor3f(1.0,1.0,1.0);glBegin(GL_LINES);glVertex2f(0.1,0.3);glVertex2f(0.2,0.3);glEnd();}voidlines(){glMatrixMode(GLMODELVIEW);glLoadIdentity();glColor3f(1.0,1.0,1.0);glRotatef(30,0.0,0.0,1.0);glTranslatef(0.03,0.04,0.0);glRectf(-0.01,0.3,0,0);glLoadIdentity();glColor3f(1.0,1.0,1.0);glRotatef(-30,0.0,0.0,1.0);glTranslatef(-0.03,0.04,0.0);glRectf(0.01,0.3,0,0);)X:voidlines(){glMatrixMode(GL_MODELVIEW);glLoadIdentity();glColor3f(1.0,1.0,1.0);glRotatef(28,0.0,0.0,1.0);glTranslatef(0.03,0.0,0.0);glRectf(-0.01,0.35,0,-0.35);glLoadIdentity();glColor3f(1.0,1.0,1.0);glRotatef(-28,0.0,0.0,1.0);glTranslatef(-0.03,0.0,0.0);glRectf(0.01,0.35,0,-0.35);)voidword(){glMatrixMode(GL_MODELVIEW);glColor3f(1.0,1.0,1.0);glBegin(GL_LINES);glVertex2f(-0.2,0.32);glVertex2f(-0.1,0.32);glBegin(GLLINES);glVertex2f(0.1,0.32);glVertex2f(0.2,0.32);glEnd();}voiddisplay(){glClear(GLCOLORBUFFERBIT|GLDEPTHBUFFERBIT);//CleartheframebufferglPushMatrix();glScalef(1.0,-1.0,1.0);word();glScalef(1.0,-1.0,1.0);word();lines();glPopMatrix();glFlush();)實(shí)驗(yàn)四1.繪制房子voidreshape(ntw,inth)(glViewport(0,0,w,h);glMatrixMode(GL_PROJECTION);glLoadIdentity();|glOrtho(-3.0,3.0,-3.0,3.0,-3.0,3.0);}voiddisplay(){glClear(GLCOLORBUFFERBIT);//CleartheframebufferglMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0);glutSwapBuffers();glShadeModel(GLFLAT);glColor3f(1.0,1.0,1.0);glBegin(GLLINELOOP);glVertex3f(0.4,-0.4,-0.4);glVertex3f(0.4,0.2,-0.4);glVertex3f(0,0.4,-0.4);glVertex3f(-0.4,0.2,-0.4);glVertex3f(-0.4,-0.4,-0.4);glEnd();glColor3f(1.0,1,0,1.0);glBegin(GL_LINE_LOOP);glVertex3f(0.5,-0.4,0.6);glVertex3f(0.4,0,2,0.4);glVertex3f(0,0,4,0.4);glVertex3f(-0.4,0,2,0.4);glVertex3f(-0.3,-0.4,0.5);glEnd();glColor3f(1.0,1,0,1.0);glBegin(GL_LINES);//CyanglVertex3f(0.4,-0.4,-0.4);glVertex3f(0.5,-0.4,0.6);glVertex3f(0.4,0.2,-0.4);glVertex3f(0.4,0,2,0.4);glVertex3f(0,0.4,-0.4);glVertex3f(0,0,4,0.4);glVertex3f(-0.4,0.2,-0.4);glVertex3f(-0.4,0,2,0.4);glVertex3f(-0.4,-0.4,-0.4);glVertex3f(-0.3,-0.4,0.5);glEnd();glFlush();)2.voidinit(){glClear(GL_COLOR_BUFFER_BIT);glMatrixMode(GLMODELVIEW);gluLookAt(1.0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0.0);glMatrixMode(GL_MODELVIEW);glFrustum(-0.4,0.5,-0.2,0.2,-0.2,0.6)實(shí)驗(yàn)五刪除代碼glEnable(GL_LIGHT0);//theearth/*glPushMatrix();glTranslatef(RAD*cos(theta),RAD*sin(theta),0.);glRotatef(23.5,0.,1.,0.);glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,pink);glMaterialfv(GLFRONTANDBACK,GLDIFFUSE,pink);glMaterialfv(GLFRONTANDBACK,GLSPECULAR,light0color);glMaterialfv(GLFRONTANDBACK,GLSHININESS,matshininess);glLineWidth(2.);glBegin(GL_LINES);glVertex3f(0.,0.,.5);glVertex3f(0.,0.,-.5);glEnd();glScalef(.33,.33,.33);glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,cyan);glMaterialfv(GLFRONTANDBACK,GLDIFFUSE,cyan);glMaterialfv(GLFRONTANDBACK,GLSPECULAR,light0color);glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,mat_shininess);gluSphere(Q2,1.,50,50);glPopMatrix();*///theearth'sequatorialplane/*glPushMatrix();glTranslatef(RAD*cos(theta),RAD*sin(theta),0.);glRotatef(23.5,0.,1.,0.);glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,clear);glMaterialfv(GLFRONTANDBACK,GLDIFFUSE,clear);glMaterialfv(GLFRONTANDBACK,GLSPECULAR,light0color);glMaterialfv(GLFRONTANDBACK,GLSHININESS,matshininess);glBegin(GL_QUADS);glVertex3f(-5.*D,-D,0.);glVertex3f(5.*D,-D,0.);glVertex3f(5.*D,D,0.);glVertex3f(-5.*D,D,0.);glEnd();glPopMatrix();*/1.2關(guān)閉光照glDisable(GL_LIGHTING);Thi白aiHhWpf'&grMiifrfijf&undthe力1.3去除太陽(yáng)的光照處理(LIGHT1)和著色處理,觀察效果13The粉3日K工progpess-iomgroundthewn1.4基于i.i,使用以下代碼,觀察全局環(huán)境光的效果glLightfv(GL_LIGHT1,GL_POSITION,light1_position);glLightfv(GL_LIGHT1,GL_AMBIENT,ambient_c010r);glLightModelfv(GL_LIGHT_MODEL_AMBIENT,black);■'Theearth'spro^res-^ionaroLindfchesunglEnable(GL_LIGHT1);
基于1.1,使用以下代碼觀察效果:glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,white);glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,black);r-■r-■Theearth'sprogrewionaroundthesun「回基于1.1,局部環(huán)境光設(shè)置為紅色,環(huán)境光材質(zhì)設(shè)為藍(lán)色,觀察效果;GLfloatambient_color口={1.0,0.0,0.0,1.0};//局部環(huán)境光glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,blue);//環(huán)境光材質(zhì)r?'ITheearth'sprogressionaruyndtheiun基于1.1,只打開(kāi)漫反射的效果,改變光源1的位置,觀察漫反射角度對(duì)光照效果的影響;GLfloatlight1position[]={1.0,5.0,10.0,0.0};glLightfv(GLLIGHT1,GLPOSITION,light1position);glLightfv(GL_LIGHT1,GL_SPECULAR,light1_color);glShadeModel(GLFLAT);glLightfv(GLLIGHT1,GLPOSITION,light1position);glLightfv(GL_LIGHT1,GL_DIFFUSE,light1_color);基于1.1,只打開(kāi)鏡面反射的效果,分別進(jìn)行以下設(shè)置,觀察鏡面反射角度對(duì)光照效果的影響(將光澤度值設(shè)置小一些)只改變光源1的位置GLfloatmat_shininess[]={15.0};glLightfv(GL_LIGHT1,GL_POSITION,light1_position);glLightfv(GL_LIGHT1,GL_SPECULAR,light1_color);glEnable(GLLIGHT1);glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,light0_color);glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,mat_shininess);11Theearth'sprogressionaroundthesun只改變視點(diǎn)的位置gluLookAt(0.0,50.0,3.0,2.0,3.0,-1.0,0.0,0.0,1.0);■J"11Theearth'sprogressionaroundthesun只改變視點(diǎn)的位置gluLookAt(0.0,50.0,3.0,2.0,3.0,-1.0,0.0,0.0,1.0);■J"TheCiarth'sprogressionaroundthesun同時(shí)改變光源1和視點(diǎn)的位置■卜Theearth'sprogressionaroLindthesun基于1.1,為光源1定義聚光燈,并調(diào)整3個(gè)參數(shù),觀察光照效果(參數(shù)為GL_SPOT_DIRECTIQNGL_SPOT_CUTOFFGL_SPOT_EXPONENT基于1.1,建立光線衰減模型,分別調(diào)整常量、一次和二次衰減參數(shù)(參數(shù)為GL_CONSTANT_ATTENUATIOGL_LINEAR_ATTENUATION3L_QUADRATIC_ATTENUADO毗察光照效果;GLfloatspot_direction[]={0.0,0.0,-1.0};glLightfv(GLLIGHT1,GLSPOTDIRECTION,spotdirection);glLightf(GLLIGHT1,GLSPOTCUTOFF,50.0);glLightf(GL_LIGHT1,GL_SPOT_EXPONENT,2.5);1.11基于1.1,分別使用GL_FLAT和GL_SMOOT刪察這兩種不同著色處理,并分析;GLFLATGL_SMOOTH前者是使用線性插值方式填充,后者是默認(rèn)為填充的顏色。參照texturel.c的例子,在Photoshop生成一幅2D紋理圖,并映射在立方體表面;#include<stdlib.h>#include<stdio.h>#include<math.h>voidmyinit(void);voidmakeImage(void);/*讀取紋理*/#defineTEXWIDTH256#defineTEXHEIGHT256GLubytetexImage[TEX_WIDTH][TEX_HEIGHT][3];voidreadTexture(void)(FILE*fd;GLubytech;inti,j,k;fd=fopen("HongKong.256.256.raw","rb");for(i=0;i<TEX_WIDTH;i++)//foreachrowTOC\o"1-5"\h\z(for(j=0;j<TEXHEIGHT;j++)//foreachcolumn(for(k=0;k<3;k++)//readRGBcomponentsofthepixel}fclose(fd);}voidmyinit(void)(glClearC010r(0.0,0.0,0.0,0.0);glEnable(GLDEPTHTEST);glDepthFunc(GL_LESS);readTexture();glPixelStorei(GL_UNPACK_ALIGNMENT,1);/*定義紋理*/glTexImage2D(GLTEXTURE2D,0,3,TEXWIDTH,TEXHEIGHT,0,GLRGB,GLUNSIGNEDBYTE,&texImage[0][0][0]);/*控制濾波*/glTexParameterf(GLTEXTURE2D,GLTEXTUREWRAPS,GLCLAMP)glTexParameterf(GLTEXTURE2D,GLTEXTUREWRAPT,GLCLAMP)glTexParameterf(GLTEXTURE2D,GLTEXTUREMAGFILTER,GLNEAREST);glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);/*說(shuō)明映射方式*/glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);/*啟動(dòng)紋理映射*/glEnable(GL_TEXTURE_2D);glShadeModel(GL_FLAT);}voiddisplay(void){glClear(GLCOLORBUFFERBIT|GLDEPTHBUFFERBIT);/*設(shè)置紋理坐標(biāo)和物體幾何坐標(biāo)*/glBegin(GL_QUADS);glTexCoord2f(1.0,1.0);glVertex3f(-2.0,-1.0,0.0);glTexCoord2f(1.0,0.0);glVertex3f(-2.0,1.0,0.0);glTexCoord2f(0.0,0.0);glVertex3f(0.0,1.0,0.0);glTexCoord2f(0.0,1.0);glVertex3f(0.0,-1.0,0.0);glTexCoord2f(0.0,0.0);glVertex3f(1.0,-1.0,0.0);glTexCoord2f(0.0,1.0);glVertex3f(1.0,1.0,0.0);glTexCoord2f(1.0,1.0);glVertex3f(2.41421,1.0,-1.41421);glTexCoord2f(1.0,0.0);glVertex3f(2.41421,-1.0,-1.41421);glEnd();glutSwapBuffers();}voidreshapeGLsizeiw,GLsizeih){glViewport(0,0,w,h);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(60.0,1.0*(GLfloat)w/(GLfloat)h,1.0,30.0);glMatrixMode(GL_MODELVIEW);glLoadIdentity();glTranslatef(0.0,0.0,-3.6);}intmain(intargc,char**argv){//StandardGLUTinitializationglutInit(&argc,argv);glutInitDisplayMode(GLUTDOUBLE|GLUT_RGB|GLUT_DEPTH);glutInitWindowSize(500,500);glutInitWindowPosition(70,70);glutCreateWindow("Awhitecubewiththreecoloredlights");glutDisplayFunc(display);glutReshapeFunc(reshape);myinit();glutMainLoop();參照texture2.c的例子,在另外一個(gè)不同的立方體面上,增加類似的人工紋理;實(shí)驗(yàn)七參照教材20.6.2節(jié),實(shí)現(xiàn)完整的鍵盤回調(diào)函數(shù)平移功能,能對(duì)實(shí)驗(yàn)四中繪制的小房子進(jìn)行移動(dòng)交互。voidreshape(ntw,inth){glViewport(0,0,w,h);glMatrixMode(GLPROJECTION);glLoadIdentity();glOrtho(-3.0,3.0
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度汽車租賃及道路救援服務(wù)合同4篇
- 疫情期間便攜施工方案
- 建筑工程采購(gòu)分包合同(2篇)
- 2025年度個(gè)人門面出租合同及裝修設(shè)計(jì)服務(wù)4篇
- 2025年度個(gè)人醫(yī)療貸款債權(quán)轉(zhuǎn)讓與健康管理服務(wù)合同3篇
- 2025年度個(gè)人住宅門窗安全性能提升合同4篇
- 鋼塔施工方案
- 預(yù)制樁課程設(shè)計(jì)講解
- 鋼結(jié)構(gòu)課程設(shè)計(jì)加圖紙
- 銀杏主題課程設(shè)計(jì)
- 我的家鄉(xiāng)瓊海
- (2025)專業(yè)技術(shù)人員繼續(xù)教育公需課題庫(kù)(附含答案)
- 《互聯(lián)網(wǎng)現(xiàn)狀和發(fā)展》課件
- 【MOOC】計(jì)算機(jī)組成原理-電子科技大學(xué) 中國(guó)大學(xué)慕課MOOC答案
- 2024年上海健康醫(yī)學(xué)院?jiǎn)握新殬I(yè)適應(yīng)性測(cè)試題庫(kù)及答案解析
- 2024年湖北省武漢市中考語(yǔ)文適應(yīng)性試卷
- 品質(zhì)部組織架構(gòu)圖構(gòu)
- 汽車租賃行業(yè)利潤(rùn)分析
- 春節(jié)拜年的由來(lái)習(xí)俗來(lái)歷故事
- 通信電子線路(哈爾濱工程大學(xué))智慧樹(shù)知到課后章節(jié)答案2023年下哈爾濱工程大學(xué)
- 皮膚惡性黑色素瘤-疾病研究白皮書
評(píng)論
0/150
提交評(píng)論