aboutsummaryrefslogtreecommitdiff
path: root/generic/Map.c
diff options
context:
space:
mode:
authorlecoanet2007-01-26 09:28:39 +0000
committerlecoanet2007-01-26 09:28:39 +0000
commit73f90db03816d4e70e4fff5cc630668f44be1af3 (patch)
tree397ec85ecf77a2606d41e0bb08fc6d9473e42570 /generic/Map.c
parenta34cb808fda14b436101d71da77cf3786ea294e6 (diff)
downloadtkzinc-73f90db03816d4e70e4fff5cc630668f44be1af3.zip
tkzinc-73f90db03816d4e70e4fff5cc630668f44be1af3.tar.gz
tkzinc-73f90db03816d4e70e4fff5cc630668f44be1af3.tar.bz2
tkzinc-73f90db03816d4e70e4fff5cc630668f44be1af3.tar.xz
Added experimental code for filling maps (do not support arcs). Contributed by Intuilab.
Diffstat (limited to 'generic/Map.c')
-rw-r--r--generic/Map.c75
1 files changed, 68 insertions, 7 deletions
diff --git a/generic/Map.c b/generic/Map.c
index 0ceb966..fd61709 100644
--- a/generic/Map.c
+++ b/generic/Map.c
@@ -1309,6 +1309,28 @@ Draw(ZnItem item)
*/
#ifdef GL
static void
+MapRenderVectors(ZnTriStrip *tristrip)
+{
+ unsigned int i, j, num_points;
+ ZnPoint *points;
+
+ for (i = 0; i < tristrip->num_strips; i++) {
+ num_points = tristrip->strips[i].num_points;
+ points = tristrip->strips[i].points;
+ if (tristrip->strips[i].fan) {
+ glBegin(GL_TRIANGLE_FAN);
+ }
+ else {
+ glBegin(GL_TRIANGLE_STRIP);
+ }
+ for (j = 0; j < num_points; j++, points++) {
+ glVertex2d(points->x, points->y);
+ }
+ glEnd();
+ }
+}
+
+static void
Render(ZnItem item)
{
ZnWInfo *wi = item->wi;
@@ -1333,15 +1355,54 @@ Render(ZnItem item)
alpha = ZnComposeAlpha(alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
if (map->filled) {
- if (ZnListSize(map->vectors) || ZnListSize(map->arcs)) {
- /* TODO_GL: Need to have a tesselated polygon then
- * fill it either using ZnRenderTile or solid.
- */
- if (map->fill_pattern != ZnUnspecifiedImage) {
- /* Fill stippled */
+ //
+ // TODO: This code doesn't handle pattern/tile and filled
+ // arcs are not supported. The tesselation data is not
+ // cached for future reuse, it is redone for each render
+ // pass.
+ // Render only vectors
+ if (ZnListSize(map->vectors)) {
+ ZnTriStrip tristrip;
+ GLdouble v[3];
+ ZnCombineData *cdata, *cnext;
+
+ line_width = 1.0;
+ glLineWidth(line_width);
+ ZnSetLineStyle(wi, ZN_LINE_SIMPLE);
+ cnt = ZnListSize(map->vectors);
+ points = ZnListArray(map->vectors);
+
+ /* Init our TriStrip */
+ tristrip.num_strips = 0;
+ tristrip.strips = NULL;
+
+ /* Start tessellation */
+ gluTessProperty(ZnTesselator.tess, GLU_TESS_BOUNDARY_ONLY, (GLdouble) GL_FALSE);
+ gluTessBeginPolygon(ZnTesselator.tess, &tristrip);
+ gluTessBeginContour(ZnTesselator.tess);
+
+ for (i =0; i < cnt; i += 2) {
+ v[0] = points[i].x;
+ v[1] = points[i].y;
+ v[2] = 0;
+ gluTessVertex(ZnTesselator.tess, v, &points[i]);
}
- else {
+
+ gluTessEndContour(ZnTesselator.tess);
+ gluTessEndPolygon(ZnTesselator.tess);
+
+ cdata = ZnTesselator.combine_list;
+ while (cdata) {
+ ZnTesselator.combine_length--;
+ cnext = cdata->next;
+ ZnFree(cdata);
+ cdata = cnext;
}
+ ZnTesselator.combine_list = NULL;
+
+ /* Render our vectors*/
+ MapRenderVectors(&tristrip);
+ ZnTriFree(&tristrip);
}
}
else { /* Not filled */