opengl鼠标绘制直线及圆图元算法.ppt
《opengl鼠标绘制直线及圆图元算法.ppt》由会员分享,可在线阅读,更多相关《opengl鼠标绘制直线及圆图元算法.ppt(12页珍藏版)》请在三一文库上搜索。
1、opengl鼠标绘制直线及圆,opengl鼠标绘制直线及圆介绍,图形学的重要算法使用鼠标左键、右键操作。 opengl鼠标绘制包括直线DDA算法,Bresenham算法,OpenGL画法,以及圆,椭圆的画法。 此外,此程序还可用于三角形的平移、旋转、缩放操作。,源代码 头文件介绍,#include 测试传入表达式的真假值 #include 包含数学函数 #include 包含输入输出流 #include 包含数据结构和算法的模板 #include 将解压opengl文件放入程序中 using namespace std; 配合#include 注释:可以将#include 替换成#includ
2、e ,typedef vector list; vector ls, cs; int old_x, old_y, new_x, new_y, cx, cy, cr; int mouse_type; /* breseman画线算法 */ void line(int x1, int y1, int x2, int y2) glBegin(GL_POINTS); if (x1=x2 if (dx=dy) ,利用breseman算法,进行画直线的子文件编辑。,定义:直线的终点起点,圆的圆心和半径。,/* 中点圆算法 */ void circle(int cx, int cy, int r) int x
3、=0, y=r; float p=1.25-r; while (x=y) glBegin(GL_POINTS); glVertex2i(cx+x, cy+y); glVertex2i(cx-x, cy+y); glVertex2i(cx-x, cy-y); glVertex2i(cx+x, cy-y); glVertex2i(cx+y, cy+x); glVertex2i(cx-y, cy+x); glVertex2i(cx-y, cy-x); glVertex2i(cx+y, cy-x); glEnd(); if (p0) +x; p+=2*x+1; else p+=2*x-2*y+5; +
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- opengl 鼠标 绘制 直线 圆图元 算法
链接地址:https://www.31doc.com/p-2202363.html