资源简介
通用扫描线填充算法OpenGL glut实现
代码片段和文件信息
//通用扫描线填充算法
//袁国武改写调试。2008年4月10日
#include
#include
#include
#define NULL 0 //C++中没有NULL这个符号常量,这里用宏定义
#define WINDOW_HEIGHT 400 //定义窗口高为400
#define WINDOW_WIDTH 400 //定义窗口宽为400
struct dcPt { //dcPt实际上是一个点的结构体
int x;
int y;
};
void setPixel(GLint xGLint y) //用OpenGL函数改写setPixel
{
glBegin(GL_POINTS);
glVertex2i(x y);
glEnd();
}
//以下完全来自ppt,未做任何修改
typedef struct tEdge {
int yUpper;
float xIntersect dxPerScan;
struct tEdge * next;
} Edge;
/* Inserts edge into list in order of increasing xIntersect field. */
void insertEdge (Edge * list Edge * edge)
{
Edge * p * q = list;
p = q->next;
while (p != NULL) {
if (edge->xIntersect < p->xIntersect)
p = NULL;
else {
q = p;
p = p->next;
}
}
edge->next = q->next;
q->next = edge;
}
/* For an index return y-coordinate
of next nonhorizontal line */
int yNext (int k int cnt dcPt * pts)
{
int j;
if ((k+1) > (cnt-1))
j = 0;
else
j = k + 1;
while (pts[k].y == pts[j].y)
if ((j+1) > (cnt-1))
j = 0;
else
j++;
return (pts[j].y);
}
/* Store lower-y coordinate and inverse slope for each edge. Adjust and store upper-y coordinate for edges that are the lower member of a monotically increasing or decreasing pair of edges */
void makeEdgeRec
(dcPt lower dcPt upper int yComp Edge * edge Edge * edges[])
{
edge->dxPerScan =
(float) (upper.x - lower.x) / (upper.y - lower.y);
edge->xIntersect = lower.x;
if (upper.y < yComp)
edge->yUpper = upper.y - 1;
else
edge->yUpper = upper.y;
insertEdge (edges[lower.y] edge);
}
void buildEdgeList (int cnt dcPt * pts Edge * edges[])
{
Edge * edge;
dcPt v1 v2;
int i yPrev = pts[cnt - 2].y;
v1.x = pts[cnt-1].x; v1.y = pts[cnt-1].y;
for (i=0; i v2 = pts[i];
if (v1.y != v2.y) { /* nonhorizontal line */
edge = (Edge *) malloc (sizeof (Edge));
if (v1.y < v2.y) /* up-going edge */
makeEdgeRec (v1 v2 yNext (i cnt pts) edge edges);
else /* down-going edge */
makeEdgeRec (v2 v1 yPrev edge edges);
}
yPrev = v1.y;
v1 = v2;
}
}
void buildActiveList (int scan Edge * active Edge * edges[])
{
Edge * p * q;
p = edges[scan]->next;
while (p) {
q = p->next;
insertEdge (active p);
p = q;
}
}
void fillScan (int scan Edge * active)
{
Edge * p1 * p2;
int i;
p1 = active->next;
while (p1) {
p2 = p1->next;
for (i=p1->xIntersect; ixIntersect; i++)
setPixel ((int) i scan);
p1 = p2->next;
}
}
void deleteAfter (Edge * q)
{
Edge * p = q->next;
q->next = p->next;
free (p);
}
/* Delete completed edges. Update ‘xIntersect‘ field for others */
void updateActiveList (int scan Edge * active)
{
Ed
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5591 2009-04-13 10:02 scanFill\scanFill.cpp
文件 45056 2009-04-13 10:03 scanFill\scanFill.exe
目录 0 2008-04-09 11:25 scanFill
----------- --------- ---------- ----- ----
50647 3
相关资源
- 泛滥填充种子填充算法OpenGl glut实现
- USB Dongle驱动
- glfw-3.2.1 OpenGL用
- OpenGL三维图形系统开发与实用技术 基
- Anylogic基于主体建模教程
- vs配置opengl所需glut库
- OpenGl 飞机在蓝天飞行 纹理贴图 地形
- 鼎新Tiptop5.x Erp 数据库表结构手册
- 3D世界的QT+opengl实现
- osg源码EagleEye,实现类似鹰眼图的效果
- 中点画圆的算法
- Firebug Lite for Google Chrome
- opengl20面体
- gl studio 面板制作教程
- 内存测试HA_MemTest35_WGL
- glut工具包
-
singleob
ject.zip - flowtaglayout相关源码 直接copy到项目中
- opengl纹理贴图
- google earth web api
- GLTools-Freeglut.zipopengl超级宝典V5
- google snappy 压缩算法 源码dll 及delphi
- VIEW3DS.exe
- 新增wifi dongle.pdf
- freeimage库的一个小
- 高斯低通滤波器(GLPF)
- 对象克隆、复制工具
- gnu global for windows
- Eagle 9.2.2 windows版本 破解补丁 V1.0
- OpenGL动态小车
评论
共有 条评论