资源描述:
《计算机图形学实验报告一.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、《计算机图形学》实验报告一、实验要求1、练习使用GDI函数绘出基本几何元素,如点、线、矩形、圆、椭圆、多边形、圆弧等、并能够用颜色填充2、练习使用GDI函数显示图像3、使用opengl函数写一个控制台程序,要求输出一些简单的二维图形:如线(实线、虚线)、四边形、多边形、圆、六面体、球、圆锥、茶壶等。二、实验目的1.掌握Window图形编程的基本方法;2.学会使用基本绘图函数和WindowGDI对象;三、实验环境Windows系统,vs2017四、实验内容与步骤1、练习使用GDI函数绘出基本几何元素,如点、线、矩形、圆、椭圆、多边形、圆弧等、并能够用颜色填充//线pDC->MoveTo(100
2、,50);pDC->LineTo(200,100);pDC->SelectObject(&pOldPen1);//矩形pDC->Rectangle(250,50,550,175);pDC->SelectObject(&pOldPen2);pDC->SelectObject(&pOldBrush);pen2.DeleteObject();//圆pDC->SelectObject(&pen2);pDC->Ellipse(50,120,150,220);pDC->SelectObject(&pOldBrush);//椭圆pDC->SelectObject(&pen2);pDC->Ellipse(6
3、00,100,1025,325);pDC->SelectObject(&pOldBrush);//多边形pDC->SelectObject(&pen2);pDC->SelectObject(&pen2);CPointlpPoint[5];lpPoint[0]=CPoint(200,200);lpPoint[1]=CPoint(100,300);lpPoint[2]=CPoint(150,400);lpPoint[3]=CPoint(250,400);lpPoint[4]=CPoint(300,300);pDC->Polygon(lpPoint,5);//圆弧pDC->SelectObject
4、(&pen2);pDC->SelectObject(&pen2);pDC->Arc(450,200,650,550,50,50,600,900);1、练习使用GDI函数显示图像3.使用opengl函数写一个控制台程序,要求输出一些简单的二维图形:如线(实线、虚线)、四边形、多边形、圆、六面体、球、圆锥、茶壶等。voiddisplay(void){glClearColor(1.0f,1.0f,1.0f,1.0f);glClear(GL_COLOR_BUFFER_BIT
5、GL_DEPTH_BUFFER_BIT);glColor3f(1.0,0.0,0.0);glLineWidth(3.0);//
6、线glBegin(GL_LINES);glVertex2f(-0.75,0.9);glVertex2f(-0.25,0.9);glEnd();//虚线glLineStipple(1,0x00FF);glEnable(GL_LINE_STIPPLE);glBegin(GL_LINES);glVertex2f(-0.75,0.8);glVertex2f(-0.25,0.8);glEnd();glLineStipple(2,0x00FF);glBegin(GL_LINES);glVertex2f(-0.75,0.7);glVertex2f(-0.25,0.7);glEnd();glLineStip
7、ple(1,0x0C0F);glBegin(GL_LINES);glVertex2f(-0.75,0.6);glVertex2f(-0.25,0.6);glEnd();glLineStipple(3,0x0C0F);glBegin(GL_LINES);glVertex2f(-0.75,0.5);glVertex2f(-0.25,0.5);glEnd();glLineStipple(1,0xAAAA);glBegin(GL_LINES);glVertex2f(-0.75,0.4);glVertex2f(-0.25,0.4);glEnd();glLineStipple(2,0xAAAA);glB
8、egin(GL_LINES);glVertex2f(-0.75,0.3);glVertex2f(-0.25,0.3);glEnd();glLineStipple(3,0xAAAA);glBegin(GL_LINES);glVertex2f(-0.75,0.2);glVertex2f(-0.25,0.2);glEnd();glLineStipple(4,0xAAAA);glBegin(GL_LINES);glV