2023年计算机图形学实验报告2.pdf

上传人:文*** 文档编号:91245239 上传时间:2023-05-24 格式:PDF 页数:48 大小:3.14MB
返回 下载 相关 举报
2023年计算机图形学实验报告2.pdf_第1页
第1页 / 共48页
2023年计算机图形学实验报告2.pdf_第2页
第2页 / 共48页
点击查看更多>>
资源描述

《2023年计算机图形学实验报告2.pdf》由会员分享,可在线阅读,更多相关《2023年计算机图形学实验报告2.pdf(48页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、计算机图形学实验报告姓名:学号:班 级:专业:计算机科学与技术完 毕 日 期:202 3.1.3目录实验一 OpenGL图形编程.31.实验目的.32.实验内容.33.实验代码与实验结果.4(1)画矩形.4 画点.6(3)画直线.7(4)画等边三角形.8实验二 直线绘制实验.91.实验目的和实验内容.92.实验代码和实验结果.9 掌握数值微分算法编程绘制直线.9(2)掌握中点画线算法编程绘制直线.12 掌握Bresenham算法编程绘制直线.13实验三圆绘制实验.151.实验目的和实验内容.152.实验代码实验结果.15 实现八分法画圆程序.15(2)实 现 Bresenham 算法绘制圆.1

2、8 实现中点Bresenham算法绘制椭圆.21实验四填充算法实验.251.实验目的.252.实验内容.263.实验代码和实验结果.27实验五裁剪算法实验.371.实验目的和实验内容.372.实验代码和实验结果.37实验一 O penG L图形编程1.实验目的点的绘制直线的绘制(3)多边形面的绘制2.实验内容点的绘制glB egi n(GL_ POINTS);g IVer t ex3 f(0.Of,0 .Of,0 .Of);g 1 Ver t ex3 f(1 O.Of,0.0 f,0.O f);glE n d();点的属性(大小)vo i d gl P o i nt Si z e (GL f

3、lo a t si z e);直线的绘制模式G L _ L I NESGL_ L I NE_ STRIPG L _ L I N E _ L O O P直线的属性线宽vo i d g 1 L i neWi d th (G L f lo a t wi dt h )线型glEna b 1 e(GU L INE_ S T I P P L E);g 1 L i n e S ti pple(GLi n t fa cto r,GL u s h o rtp a t t e r n);三角形面的绘制G L _T R I ANGLESGUTRIANGLE_ STRIPGL_ TRIANGLE_ FAN四边形面的绘

4、制G L QUADSG L _Q U A DS_ STRIP多边形面的绘制(GL_ P OLYG 0 N)多边形面的绘制规则所有多边形都必须是平面的。多边形的边沿决不能相交,并且多边形必须是凸的。解决:对于非凸多边形,可以把它分割成几个凸多边形(通常是三角形),再将它绘制出来。3.实验代码与实验结果画矩形#i nc 1 u d e v o i d I ni t i a l(vo i d)glC lea rC o lo r(l.0 f,1.0 f,1 .0 f,1.Of);glMa t r i xMo d e(GL_ PROJEC T I O N);o gl u 0 rth o 2 D(0 .0

5、,2 0 0.0,0.0,1 5 0.0);)vo i d Di spla y(v o i d)glC lea r(G L _ C O L O R_ B UFFER B I T);g 1 C o lo r 3 f(1.Of,0 .Of,0.0 f);。g 1 Re c t f(5 0.Of,1 0 0.Of,1 5 0.Of,5 0.0 f);o g 1 Flush ();i nt ma i n(i n t a rgc,ch a r a rgv )o glutln i t(&a rgc,a rgv);glut I n i tDi s p la y M o de(GLUT_ S INGLE I

6、G L U T_R G B);glut I ni t Wi ndo wSi z e(4 0 0,3 0 0 );o glutlni tW i ndo wPo si ti o n(1 0 0,1 2 0);g l u t C re at e Wi nd o w(矩 形 );0 g 1 ut D i spla y F u n c(D i spla y);o I ni ti a l();o g 1 utM a i nLo o p();r e tu r n 0;画点glPo i n t Si z e(3 );glB eg i n(GL POINTS);glC o 1 o r3 f(l.Of,0 .0

7、f,0 .Of);g l V e r tex 2 i (1 0 ,1 4 0);g 1 Vertex 2 i (1 0 0,7 5);。g 1 Vertex2 i (1 9 0,1 0);glEnd();目 回 冈矩形画直线g IPo i n t S i z e(3 );g 1 B eg i n(G L _ L I NE_ L0 0 P);glC o lo r 3 f(1 .0 f,0.Of,O.Of);g 1 V e rte x 2 i (2 0,1 0);g 1 V er t ex2 i (6 0,5 0);cglVerte x 2 i(2 0,5 0);eg 1 Ver t ex2 i(

8、6 0,1 0);恰 1 Vertex2 i(4 0,7 0);glEnd();矩形目|回冈画等边三角形gl Po i ntSi z e(3);glB eg i n(GL_ TRIANGLE S);glC o 1 o r3 f(1 .Of,0.Of,0.Of);glVert e x 2 i (2 0,1 0);g 1 Verte x 2 i (6 0,1 0);必g 1 V e rte x 2 f(4 0.0,4 4.6 4);实验二直线绘制实验1.实验目的和实验内容(1)掌握数值微分算法编程绘制直线(2)掌握中点画线算法编程绘制直线(3)掌握B r e s enh a m算法编程绘制直线2.

9、实验代码和实验结果掌握数值微分算法编程绘制直线#i n elude#i n cl u d e vo i d Ini t i a l(vo i d)g 1 C lea r C o lo r(1.0 f,1.Of,1.0 f,L O f);o g 1 M a t r i x M o d e(G U P R O J EC TION);g 1 u O r t h o 2 D(0.0 ,2 0 0.0,0.0,1 5 0.0);v o i d D i s p la y(vo i d)g 1 C lea r(GL_ C 0 L O R B U F FER_ B IT);glC o 1 o r 3 f(1

10、.Of,0.Of,0 .Of);。g IPo i n t S i z e(3 );i nt d x,dy,ep s 1,k;flo a t x,y,xln c re,ylncre;dnt x 0 =1 0;o i nt y0=1 0;o i nt xl=2 0;o i n t yl=8 0;o d x=xl-xO;o dy=yl-y 0;o x=x0 ;y=yO;i f(a b s(dx)a b s(d y)s epsl=a b s(dx);o else。eps 1 =a b s(d y);xlncre=(fl o a t)d x/(fl o a t)ep s 1;o ylnc r e=(fl

11、o a t)dy/(flo a t)e psi;0 fo r(k=0 ;k x 1)x=x 1;x l=x O ;x0=x;o y=yl;yl=yO;yO=y;)o x=x 0;y=y0;。d x=xl x 0;dy=y 1 y 0;d=dx 2*dy;U plncre=2*d x-2*d y;o D o wnln ere=2*dy;w h i le(x X +;i f(d 0)。y+;8 d+=UpIncre;)g e Ise。d+=Do w n Inc r e;)。g IFlush O;亘 叵掌握Bresenh a m 算法编程绘制直线vo i d D i spla y(vo i d)gl

12、 C lea r(GL_ C OLOR_ B UF F E R_ B I T);o glC o 1 o r3 f(1.0 f,0.Of,0.0 f);glPo i ntS i z e(3);i n t x,y,dx,dy,e;i nt x0 =l 0 ;i nt y0=1 0;i nt x 1=8 0;o i n t yl=2 0 ;d x=xl-x0;My=y 1-y 0 ;e=-dx;x=x 0;y=y0;a wh i le(x 0)6 /+;必 e=e-2*dx;06。g IFlush ();实验三 圆绘制实验1.实验目的和实验内容(1)实现八分法画圆程序(2)实 现 B re s en

13、h a m算法绘制圆(3)实现中点B r e s e n h a m算法绘制椭圆2.实验代码实验结果实现八分法画圆程序#i n elude#i n c lude vo i d Ini t i a 1 (v o i d)glC le a rC o 1 o r(1 .Of,1 .Of,1.Of,1 .0 f);o g 1 Ma tri xM o d e(GL_ PR0 J EC TION);o gluO r t h o 2 D(0.0,2 0 0.0,0.0,1 5 0.0);v o i d pu t pi xel(i nt x,i n t y)8 x+=2 0;y+=2 0;。glB e g i

14、 n(GL_ POINTS);g 1 Verte x 2 i (x,y);。glEnd();vo i d C i rcl e Po i n t(i nt x,i n t y)gpu t p i x el(x,y);gputpi x e 1 (y,x);p u tpi x e 1 (y,x);put p i x e l (-x,y);叩ut p i x e 1 (x,-y);p u tpi xel(-y,-x);gpu t pi xel(y,-x);s put p i x e 1(x,-y);)vo i d Di s p la y(v o i d)o glC 1 ea r(G L_ C 0 L0

15、 R_ B UFFER_ B I T);o g IC o lo r3 f(1.Of,0.Of,0.O f);g IPo i nt S i z e ;o C i rcleP o i n t(5,2);g IFlush ();i n t ma i n(i nt a rgc,c h a r*a rgv )g 1 ut I n i t(&a rg c,a r g v);glutlni t D i s pl a yMo de(GLUTSINGLE|GLUT_ RGB);g 1 ut I ni tWi ndo wSi z e(4 0 0,3 0 0);glu t In i tW i n d o wPo s

16、i t i o n(1 0 0,1 2 0);glut C rea teWi n d o w(矩形”);o g 1 u t D i spla y F unc(D i s pl a y);I n i t i a 1 ();o glutM a i nLo o p();r e turn 0 ;毛走形ICZJ II B l|w 3 w|实现 B re s e n h am 算法绘制圆#i n c 1 ude#i nclude vo i d Ini t i a 1 (v o i d)g IC lea rC o lo r(1.Of,1.Of,1 .0 f,1.Of);g l M a t r i x M o

17、 d e(G L _ P R O J E C T I O N);gl uOr t h o 2 D(0.0,2 0 0.0,0.0,1 5 0.0 );)v o i d putpi xel(i nt x,i nt y)8 x+=7 5;y+=7 5;o glB egi n(GL_ POINTS);gglV e rt e x2 i (x,y);。g 1 E n d();vo i d C i r c 1 ePo i n t(i n t x,i n t y)gput p i x e 1 (x,y);。put p i xel(y,x);putp i xel(-y,x);pu t p i xel(x,y)

18、;叩utpi xe 1 (x,y);。putp i xel(-y,x);。pu t p i xe 1 (y,-x);wputpi xel(x,-y);v o i d M i dB ressenh a mC i rc 1 e(i nt r)i n t x,y,d;x=0;y=r;d=1 -r;wh i 1 e(x=y)C i rclePo i n t(x,y);o o i f(d 0)d+=x*x+3;。e Is e o d+=2*(x-y)+5 ;oooy x+;)vo i d Di s p la y(vo i d)吆1 C le a r(G L _ C OLOR_ B UFFE R _ B

19、I T);gl C o lo r 3 f(1 .Of,0.Of,0.0 f);o glPo i ntSi z e(3);M i d B re s s e nh a mC i r c 1 e(5 0 );o gl F lu s h ();i nt ma i n(i n t a rgc,ch a r*a rgv)o glutlni t(&a rgc,a r g v);o glutlni tDi spla yMo d e(GLUT_ SINGLE|GLUTg lut I ni tWi ndo wS i z e(4 0 0 ,3 0 0 );RGB);o glut I ni t W i nd o wP

20、 o s i t i o n(1 0 0,1 2 0);o g lutC rea t e Wi ndo w(矩形);o gl u tDi s pl a yFu n c(D i sp 1 a y);Ini ti a l();。g lutMa i nL o o p();return 0;实现中点B r es e n ham算法绘制椭圆#i nclu d e#i n elude vo i d I ni ti a 1 (vo i d)g IC lea rC o lo rd.Of,1.0 f,1 .0 f,1.Of);o glMa tri x M o d e(G L _ P R 0JEC TION);g

21、lu0 rth o 2 D(0.0,2 0 0.0,0.0 ,1 5 0.0);v oid pu t pi xel(i nt x,i nt y)4+=1 0 0 ;y+=7 5 ;o glB e g i n(G L P O I NT S);8 gl V e r t ex2 i (x,y);g g l E n d();vo i d Mi dB ressenh a mEli p se(i nt a,i nt b)i n t x,y;a flo a t d 1 ,d 2 ;x=0;y=b;d 1 =b*b+a*a*(-b+0.2 5);6 putpi xel(x,y);pu t pi xe 1 (-

22、x,-y);p utpi xel(-x,y);putpi x e 1(x,-y);w h i le(b*b*(x+1 )V a*a*(y 0.5)gi f(d 1 0)。i f(d2 e 1 sed 2 +=a*a*(-2 *y+3);0y;o p u tpi x e 1 (x,y);叩utpi x e 1 (-x,-y);。p u tpi x e 1 (-x,y);p u t pi xel(x,y);vo i d D i spla y(v o i d)glC lea r(GL_ C OLO R _ B U F F E R B I T);glC o lo r3 f(1.Of,0.Of,0.O

23、f);0 glp o i n t S i z e(3);M i d B re s s e n h a mEl i p se(8 0,6 0);o glFl u s h ();i nt ma i n(i n t a r g c,ch a r*a r gv )o g 1 u t I n i t(&a r gc,a r g v);g 1 u t I n i t D i sp 1 a yMo de(GLUT_ S I N G LE|GLUT_ RG B);gl u tlni tWi n do wS i z e(4 0 0,3 0 0);o glutln i tWi n d o w P o s i ti

24、 o n(1 0 0,1 2 0);glu t C r ea t eWi ndo w(矩 形 );o g l u tDi spla y Func(Di s p 1 a y);In i t i a 1 ();。glutMa i nLo o p();ret u rn 0;实验四填充算法实验1.实验目的掌握用扫描线种子填充法实现扫描线种子填充算法填充任一多边形区域的程序2.实验内容(1)堆栈库tti nclude 实现了堆栈操作struc t Po i n tGLi n t x;GLi n t y;);std::s t a ck s tk;struct Po i nt p o i n t 1 ;st

25、k.po p(po i ntl);/po p从栈中弹出最上面的元素并取得它stk.pu s h (p o i ntl);/压入一个元素stk.em p t y();判空po i n t 1 =stk.to p();取得栈最上面元素,但不弹出,仍在栈中(2)获取像素颜色typ e def flo a t C o lo r 3;Col or c;glR e a dPi xe 1 s(cur_ p o i nt.x,c ur_po i n t.y,1,1,GL_ RGB,GL_ FL0 AT,c);/3.实验代码和实验结果#i n elude#i n c lude#i ncl u de#i ncl

26、u de#i n clu d e#i n c lu d e ty p e d e f flo a t C o lo r 3;s t r u ct Po i n t|G L i nt x;G L i nt y;);st d::sta ck stk;vo i d i n i t(vo i d)|o glC lea rC o lo r(1.0,1 .0,1.0,0.0 );g 1 Ma tr i xMo de(GL_ PROJEC T I ON);o glu0 rth o 2 D(0.0,4 0 0.0,0.0,4 0 0.0 );/种子像素坐标vo i d setPi x el(P o i n t

27、 c u r _ po i n t)喑IB egi n(GL_ P0 INTS);glVert e x 2 i (cu r _ po i n t.x,c ur_ p o i n t.y);0 g 1 End();g 1 Flush ();v o i d getP i x e 1 (P o i n t cur_ po i n t,C o l o r c)(glR e a dP i x e 1 s(cur_ p o i nt.x,c u r _ po i nt.y,1,1,GL_ RGB,GL_ FL0 AT,c);b o o l rgb C o 1 o rEqua l(C o lo r cl,C

28、 o 1 o r c2)(i f(a b s(cl 0-c2 0)0.0 0 1 )|I (a b s(c 1 1-c2 l)0.0 0 1)|(a b s(cl 2 -c2 2)0.0 0 1)sre t u r n 0;els e i f(di recti o n-0)g c ur_ po i nt.x+;o e 1 s e8 c u r_ po i nt.x一;ge t Pi xel(c u r _po i nt,i nte r i o r C o lo r);8 co lmt+;return c o u n t;i nt i s Pix e IV a lid(Poin t cur_ p

29、 oint,Color f i 1ICo 1 or,C o 1 or bo r derCo l o r)|Co 1 o r int e r iorColor;g e t P ixel(cur_point,i nter i orC o lo r);oi f(!(r g bCol o rEqua 1 (interiorC o 1 o r,b o r derC o1 o r)&!(r g bCo 1 or E qual(i n teri o rC o lor,f ill Colo r)。re t urn 1;oelseret u rn 0;v oid S e a r c hLineNewSee d(

30、int x Left,in t x Ri g h t,int y,C o lor f i UColor,Co 1 or borderColor)(。i n t x t=x Left;int seed_ 1 e f t=-1;Po i nt temp_ point;P o int s eed_point;wh i le(x t 二xR i gh t)。s ee d=;。temp_ p o i n t.x=xt;temp_ po i nt.y=y;w h i l e (xt=x R i gh t)。i f(i sP i xe 1 V al id (temp_ po i nt,f i llC o l

31、 o r,b o rde r C o lo r)g o s e ed_ 1 eft=t e mp_ po i n t.x;g b rea k;0 o。e 1 s e 8 0 Xt+;8 t e m p jpo i n t.x=xt;00 oowh i 1 e(x t 二xRi gh t)。i f(i s Pi x e 1 Va 1 i d(t e mp_ po i n t,f i 1 1 C olo r,b o rderC o lo r)xt+;8 temp_ p o i nt.x=x t;0。e 1 s e s 8 b r ea k;stk.p o p ();8c o unt=F i l 1

32、 L in e Regi o n(se e d_ po i nt,fi llC o 1o r,b o rder C o 1 o r,0);。ri gh t=s e ed_ po i n t.x+c o unt-1 ;8 t emp_p o i n t.x=seed_ p o i nt.x-1;temp_ po i n t.y=see d _po i n t.y;0 co u n t=F i 1 ILi ne R eg i o n(t e mp_ po i nt,f i 1 IC olo r,b o r d e r C o l o r,1);o 1 ef t=se e d_ po i nt,x-

33、co u n t;。S e a rch Li n eNe w See d(left,ri gh t,s e e d_po in t.y-1,f i UC o l o r,b o r d e rC o lo r);o Sea r c h L i n e N ewSeed(left,ri gh t,seed_ p o i nt.y+1 ,fi llC o lo r,b o r d erC o 1 or);)return;vo i d my D r a w(vo i d)|o glC 1 ea r(GL_ C OLOR_ B UFFER_ B IT);g I C o 1 o r3 f(0.0,0 .

34、0,0.0);oglBeg i n(GL_LINE_L00P);g 1 Vertex2f(2 0.Of,8 0.Of);glVe r t ex2f(3 0.0 f,95.0 f);oglV e rte x 2 f(50.Of,9 5.Of);glVert e x2f(60.0 f,80.0 f);glVertex2f(7 0.Of,95.Of);oglV e r t ex2 f(9 0.0 f,95.O f);glVert ex2f(100.0 f,8 0.0 f);oglVe r t e x 2 f(6 0.0 f,30.O f);oglEndO;int x=60,y=60;st r uct

35、 Poin t s eed_point=65,6 5);Col o r fillCo 1 o r,bo r de r C o lo r;ofillColor:0=1.0;fillColorl=0.0;fi 1 lColor2=0.0;b o r d er C olo r 0=0.0;bor d erColor l=0.0;borde r Color 2=0.0;st k.pus h(s e e d p o in t);s canLine(see d _p o in t,fi 1 IC o 1 or,borde r Color);glFlu s h ();vo i d m a i n(i nt

36、a rgc,ch a r*a rg v)|。g lutl n i t(&a rg c,a r gv);o glu t I ni tDi s p la yMo de(GLUT_ SINGLE|GLUT_ RGB);glutlni tWi n d o wPo si t i o n(5 0,1 0 0 );o g 1 utlni tWi ndo wSi z e(4 0 0,4 0 0 );glutC r e a t eWi n do w(b i a nji e,z);i n i t();gl u tDi s pla yFu n c(m y Dra w);o g 1 u tMa i nLo o p()

37、;“bianjieI d II 回 IE3bl实验五裁剪算法实验1.实验目的和实验内容掌握用C o h enSuth erla n d法淘汰直线2.实验代码和实验结果#i n elude#i n c 1 u d e tti nclude c o nst w i n Left B i tC o de=0 xl;co nst wi nR i gh t B i t C o d e=0 x 2 ;co n s t w i n B o tt o mB i t C o de=0 x 4;co nst w i nT o p B i t C o de=0 x8;cl a ss w cPt2 D pub li

38、c:GLf 1 o a t x,y;i nli ne i n t i nsi d e(i n t c o de)r e tu r n i n t(!c o d e);i n li ne i n t rejec t(i nt co d e 1,i nt c o de 2 )r e tur n i nt(co del&co de2);i nli n e i n t a c cep t(i n t c o del,i n t co d e 2)(r e t u r n i n t(!(co d e 1|co d e 2);G L u b yte e n c o de(w cPt2 D p t,wcP

39、t 2 D w i nMi n,w c Pt2 D wi nM a x)o G L u b y te co de=0 x0 0 ;i f(pt.x wi nMa x.x)8 co d e=co de+wi n R i gh tB i tC o d e;。i f(pt.y w i nMa x.y)。co de=co de I w i nTo pB i tC o de;o re t ur n(co de);vo i d s wa pPts(wc P t 2 D*pl,wcPt2 D*p2)w c P t 2 D tmp;t m p =*pl;*p l=*p2;p 2 =tmp;vo i d s w

40、a p C o des(GLub y t e*c l,G L ub yt e 火 c 2 )GLub yte t mp;t m p=*cl;o*c l=*c 2 ;o*c2=tmp;vo i d d r a w_ pi xel(i nt i x,i nt i y/*,i n t va l u e*/)(glB eg i n(GL_ POINTS);glVe r t e x2 i (i x,i y);。g 1 End();i nt i nli n e ro und(c o n st f l o a t a )。r etu r n i n t(a+0.5);vo i d li n eD D A(i

41、 nt xO,i nt yO,i nt x_ e n d,i nt y_ end,do u b le a,d o ub le b,d o u b l e c)gl C o lo r3 f(a,b,c);i nt dx=x_ end-xO;6 i nt dy=y _ e nd-y 0;i nt ste p s,k;f l oat xlnc r emen t,yi n e r e ment,x=xO,y=y0;o i f(a b s(dx)a b s(d y)。s t eps=a b s(d x);e 1 s es t e p s=a b s(d y);o xlncrem e nt=f lo a

42、t(d x)/f 1 o a t(step s);o y 1 n c r e ment=f lo a t(d y)/f l o a t (s teps);d r a w_ pi x e 1 (ro und(x),r o un d(y);o f o r(k=0;k dr a w_ p i xel(r o u nd(x),ro und(y);vo i d li neC li pC o h Su t h(wcPt 2 D wi nMi n,wc P t2 Dwi nMa x,w c Pt2 D p 1,wcP t 2 D p2)GLub y t e co del,c o d e 2;GLi n t

43、do ne=f a 1 s e,plo t L i ne=f a 1 se;o GLflo a t m;3 Vh i le(!d o n e)。co de 1 =enco de(pl,w i n Mi n,w i nMa x);o co d e 2=en c o de(p 2,w i nMi n,w i nMa x);。i f(a c cept(c o del,c o d e2)do ne=tr u e;g plo tLi ne=t r u e;e 1 se。i f(rej e c t(c o d el,c o d e2)。d o ne=t rue;o else f(i n s i d e(c

44、o del)g o sw a pP t s(&pl,&p2);。w a pC o de s(&co d e 1 ,&co de2);6 0 j8 i f(p2.x!=p 1 .x)8 m=(p2.y-pl.y)/(p 2 .x-p 1 .x);。i f(co d el&w i nLe f tB i tC o d e)个 1.y+=(wi nMi n.x-p 1.x);必 p 1 .x=w i nMi n.x;6 j8 e 1 sei f(co de 1&wi nRi gh tB i tC o de)必 pl.y+=(wi nMa x.xpl.x)*m;。pl.x=w i nM a x.x;0

45、0 o e 1 se8 Mi f(co del&wi nB o t t o mB i t C o d e)g 8 i f(p2.x!=pl.x)8 。叩 1 .x+=(wi nMi n.y p 1 .y)/m;。8 。pl.y=w i nMi n.y;6 o e 1 seo o o i f(c o d e 1&wi nTo pB i tC o d e)i f(p2.x!=p 1 .x)/pl.x+=(w i nMa x.y-pl.y)/m;。pl.y=w i nMa x.y;8 。0 b e)i f(plo tLi ne)li ne DDA(r o und(pl.x),r o u n d(pl

46、.y),r ound(p 2 .x),ro und(p2.y),0 .0,0.0 ,1.0);v o i d di sp 1 a y()g 1 C lea r(GL_ C 0L 0R_ B UFFER_ B I T);w cPt2 D w i nMi n,wi nMa x,p 1 ,p2,q 1,q 2 ,t 1 ,t2,ml,m 2 ;。裁剪窗口w i nMi n.x=8 0;o wi nMi n.y=1 0 0 ;o wi nM a x.x=2 9 0 ;wi n Ma x.y=5 0 0;o /*li neDDA(8 0,1 0 0,8 0,4 5 0 ,1.0,0.0,0.0 );li

47、 neDDA(8 0,1 0 0,2 9 0,1 0 0,1.0,0.0,0.0);li neDDA(2 9 0,1 0 0,2 9 0,4 5 0,1 .0,0.0,0.0);o 1 i n eDDA(8 0,4 5 0 ,2 9 0,4 5 0,1.。/文/全图w i nMi n.x=0;o wi nMi n.y=0 ;师 i nMa x.x=5 0 0;wi nMa x.y=5 0 0;*/pl.x=0 ;叩1.y=0 ;叩2.x=4 0 0;叩2.y=4 0 0;q 1 .x=0;ql.y=0;o q2.x=1 0 0;q 2.y=4 0 0;0 tl.x=1 0 0;t 1 .y=4

48、 0 0;。t 2,x=4 0 0 ;0,0.0,0.0);*/比 2 .y=4 0 0;o ml.x=3 0 0;0 ml.y=2 0 0 ;o m2.x=1 0 0;m2.y=4 0 0 ;/只显示裁剪框内的线段1 i n eC 1 ipCo h Su t h(winMi n,w inMax,p 1,p 2);o 1 ineC 1 i pCohSuth(winMin,winMa x,ql,q2);1 ine C lipCoh S uth(w i n M i n,w i n M ax,t 1,t 2);ol i neC 1 i pCohSuth(wi n Min,wi nMax,ml,m 2

49、);显示裁剪框和待裁剪线段/*1 i n e D D A(3 00,2 0 0,100,4 0 0,0.0,0.0,1.0);4ineDDA(0,0,10 0,4 0 0,0.0,0.0,1.0);li neDDA(1 00,4 0 0,400,40 0,0.0,0.0,1.0);olineDD A(0,0,400,4 00,0.0,0.0,1.0);*/g 1 F l u s h ();v oid m y i n i t()glC 1 earColo r(0.8,1.0,1.0,1.0);/g 1 C o lor3f(0.0,0.0,1.0);。g IP ointS i ze(1.0);g

50、1 Mat r i xM o de(GL P RO JECT IO N);og 1 Loadld e n tity();gl u O r tho2D(0.0,5 0 0.0,0.0,500.0);g IViewport(0,0,200,5 00);v oid mai n(in t arg c,cha r*argv)g 1 utln i t(&a rgc,arg v);gl u tin i tD i s p 1 ayM o d e (GLUT_ S I NGLE|G LUT_RG B);og 1 utlnitWi n dow S i z e(500,5 0 0);。g 1 utln i tWin

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com