OpenGL计算机图形学梁友栋裁剪算法实验代码及运行结果.doc
(10页)
本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦!
14.9 积分
.《计算机图形学实验》报告任课教师:钱文华春季学期实验:梁友栋裁剪实验时间:11月17日实验地点:信息学院2204实验目的:掌握梁友栋裁剪程序代码:#include #include #include #include class wcPt2D{public: GLfloat x,y; void setCoords(GLfloat xCoord,GLfloat yCoord){x=xCoord;y=yCoord;} GLfloat getx() const{return x;} GLfloat gety() const{return y;}};inline GLint round(const GLfloat a){return GLint(a+0.5);}void setPixel(int x,int y){ glBegin(GL_POINTS); glVertex2i(x,y); glEnd();}void init(){ glClearColor(1.0,1.0,1.0,0.0); glMatrixMode (GL_PROJECTION); gluOrtho2D(-200.0,200.0,-200.0,200.0);}void lineBres(GLfloat x0,GLfloat y0,GLfloat xEnd,GLfloat yEnd){ int dx = fabs(xEnd - x0),dy = fabs(yEnd - y0); int p = 2*dy - dx; int twoDy = 2*dy,twoDyMinusDx = 2*(dy - dx); int x,y; if(x0>xEnd){ x = xEnd; y = yEnd; xEnd = x0; } else{ x = x0; y = y0; } setPixel(x,y); while(x*u1) *u1 = r; } else if(p>0.0){ r = q/p; if(r
天天文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:OpenGL计算机图形学梁友栋裁剪算法实验代码及运行结果.doc
链接地址: /p-48955676.html