[mapserver-commits] r8548 - sandbox/graphics
svn at osgeo.org
svn at osgeo.org
Fri Feb 13 01:27:11 EST 2009
Author: toby
Date: 2009-02-13 01:27:10 -0500 (Fri, 13 Feb 2009)
New Revision: 8548
Modified:
sandbox/graphics/mapogl.cpp
sandbox/graphics/mapoglrenderer.cpp
sandbox/graphics/mapoglrenderer.h
sandbox/graphics/maprendering.c
sandbox/graphics/mapserver.h
Log:
Opengl now supports tiled polygons. Modified vtable to support tiled
polygons with outlines.
Modified: sandbox/graphics/mapogl.cpp
===================================================================
--- sandbox/graphics/mapogl.cpp 2009-02-13 06:14:00 UTC (rev 8547)
+++ sandbox/graphics/mapogl.cpp 2009-02-13 06:27:10 UTC (rev 8548)
@@ -42,22 +42,10 @@
renderer->renderPolylineTile(p, width, (ogl_cache*)tile);
}
-void msDrawPolygonTiledOgl(imageObj *img, shapeObj *p, void *tile)
+void msDrawPolygonTiledOgl(imageObj *img, shapeObj *p, colorObj *oc, double outlineWidth, void *tile)
{
- // cairo_renderer *r = getCairoRenderer(img);
- // cairo_pattern_t *pattern = cairo_pattern_create_for_surface(tile);
- // cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
- // int i,j;
- // cairo_set_source(r->cr, pattern);
- // for (i = 0; i < p->numlines; i++) {
- // lineObj *l = &(p->line[i]);
- // cairo_move_to(r->cr, l->point[0].x, l->point[0].y);
- // for (j = 1; j < l->numpoints; j++) {
- // cairo_line_to(r->cr, l->point[j].x, l->point[j].y);
- // }
- // //cairo_close_path(r->cr);
- // }
- // cairo_fill(r->cr);
+ OglRenderer* renderer = getOglRenderer(img);
+ renderer->renderPolygon(p, NULL, oc, outlineWidth, (ogl_cache*)tile);
}
void msRenderPixmapOgl(imageObj *img, double x, double y, symbolObj *symbol,
@@ -221,7 +209,7 @@
void msStartNewLayerOgl(imageObj *img, double opacity)
{
- getOglRenderer(img)->setTransparency(1.0 - opacity);
+ getOglRenderer(img)->setTransparency(opacity/100);
}
void msCloseNewLayerOgl(imageObj *img, double opacity)
Modified: sandbox/graphics/mapoglrenderer.cpp
===================================================================
--- sandbox/graphics/mapoglrenderer.cpp 2009-02-13 06:14:00 UTC (rev 8547)
+++ sandbox/graphics/mapoglrenderer.cpp 2009-02-13 06:27:10 UTC (rev 8548)
@@ -248,7 +248,7 @@
void OglRenderer::setColor(colorObj *color)
{
- if (color)
+ if (color && MS_VALID_COLOR(*color))
{
glColor4d((double) color->red / 255, (double) color->green / 255, (double) color->blue / 255, transparency);
}
@@ -528,7 +528,7 @@
glEnd();
}
-void OglRenderer::renderPolygon(shapeObj *p, colorObj *color, colorObj *outlinecolor, double outlinewidth, int lineCap, int joinStyle)
+void OglRenderer::renderPolygon(shapeObj *p, colorObj *color, colorObj *outlinecolor, double outlinewidth, ogl_cache* tile, int lineCap, int joinStyle)
{
/*
OpenGL cannot draw complex polygons so we need to use a Tessallator to draw the polygon using a GL_TRIANGLE_FAN
@@ -537,37 +537,49 @@
Reports need for a combine callback.
*/
+ double texWidth = 0;
+ double texHeight = 0;
+ if (tile)
+ {
+ glBindTexture(GL_TEXTURE_2D, tile->texture); // Select Our Texture
+ texWidth = tile->width;
+ texHeight = tile->height;
+ }
+
context->makeCurrent();
std::vector<GLdouble*> pointers;
- if (color != NULL && MS_VALID_COLOR(*color))
+ setColor(color);
+
+ gluTessBeginPolygon(tess, NULL );
+ for (int j = 0; j < p->numlines; j++)
{
- setColor(color);
-
- gluTessBeginPolygon(tess, NULL );
- for (int j = 0; j < p->numlines; j++)
+ gluTessBeginContour(tess);
+ for (int i = 0; i < p->line[j].numpoints; i++)
{
- gluTessBeginContour(tess);
- for (int i = 0; i < p->line[j].numpoints; i++)
- {
- // create temp array and place
- GLdouble* dbls = new GLdouble[3];
- pointers.push_back(dbls);
- dbls[0] = p->line[j].point[i].x;
- dbls[1] = p->line[j].point[i].y;
- dbls[2] = 0.0;
- gluTessVertex(tess, dbls, dbls);
- }
- gluTessEndContour(tess);
+ // create temp array and place
+ GLdouble* dbls = new GLdouble[5];
+ pointers.push_back(dbls);
+ dbls[0] = p->line[j].point[i].x;
+ dbls[1] = p->line[j].point[i].y;
+ dbls[2] = 0.0;
+ dbls[3] = texWidth;
+ dbls[4] = texHeight;
+ gluTessVertex(tess, dbls, dbls);
+ }
+ gluTessEndContour(tess);
- }
- gluTessEndPolygon(tess);
- // destroy temp arrays
- for (std::vector<GLdouble*>::iterator iter = pointers.begin(); iter
- != pointers.end(); iter++)
- {
- delete[] *iter;
- }
}
+ gluTessEndPolygon(tess);
+
+ // destroy temp arrays
+ for (std::vector<GLdouble*>::iterator iter = pointers.begin(); iter
+ != pointers.end(); iter++)
+ {
+ delete[] *iter;
+ }
+
+ glBindTexture(GL_TEXTURE_2D, 0); // Select Our Texture
+
if (outlinecolor != NULL && MS_VALID_COLOR(*outlinecolor) && outlinewidth > 0)
{
renderPolyline(p, outlinecolor, outlinewidth, 0, NULL, lineCap,
@@ -770,16 +782,18 @@
GLfloat weight[4], void** dataOut, void* polygon_data)
{
GLdouble *vertex;
- vertex = (GLdouble *) malloc(6 * sizeof(GLdouble));
+ vertex = (GLdouble *) malloc(5 * sizeof(GLdouble));
vertex[0] = coords[0];
vertex[1] = coords[1];
vertex[2] = coords[2];
- vertex[3] = vertex[4] = vertex[5] = 0;
+ vertex[3] = vertex_data[0][3];
+ vertex[4] = vertex_data[0][4];
*dataOut = vertex;
}
void vertexCallback(GLdouble *vertex)
{
+ if (vertex[3] > 0) glTexCoord2d(vertex[0]/vertex[3], vertex[1]/vertex[4]);
glVertex3dv(vertex);
}
Modified: sandbox/graphics/mapoglrenderer.h
===================================================================
--- sandbox/graphics/mapoglrenderer.h 2009-02-13 06:14:00 UTC (rev 8547)
+++ sandbox/graphics/mapoglrenderer.h 2009-02-13 06:27:10 UTC (rev 8548)
@@ -28,7 +28,7 @@
GLubyte* gd2ogl(gdImagePtr img);
void renderPolyline(shapeObj *p,colorObj *c, double width, int patternlength, int* pattern, int lineCap = MS_CJC_ROUND, int joinStyle = MS_CJC_ROUND, colorObj *outlinecolor = NULL, double outlinewidth = 0);
- void renderPolygon(shapeObj*, colorObj *color, colorObj *outlinecolor, double outlinewidth, int lineCap=MS_CJC_ROUND, int joinStyle=MS_CJC_ROUND);
+ void renderPolygon(shapeObj*, colorObj *color, colorObj *outlinecolor, double outlinewidth, ogl_cache* tile = NULL, int lineCap=MS_CJC_ROUND, int joinStyle=MS_CJC_ROUND);
void renderGlyphs(double x, double y, colorObj *color, colorObj *outlinecolor, double size, char* font, char *thechars, double angle, colorObj *shadowcolor, double shdx, double shdy);
void renderPixmap(symbolObj *symbol, double x, double y, double angle, double scale);
void renderEllipse(double x, double y, double angle, double w, double h, colorObj *color, colorObj *outlinecolor, double outlinewidth);
Modified: sandbox/graphics/maprendering.c
===================================================================
--- sandbox/graphics/maprendering.c 2009-02-13 06:14:00 UTC (rev 8547)
+++ sandbox/graphics/maprendering.c 2009-02-13 06:27:10 UTC (rev 8548)
@@ -30,7 +30,7 @@
tile = r->createTileVector(symbol, scale, angle, c,bc,oc, width);
break;
case MS_SYMBOL_ELLIPSE:
- tile = r->createTileEllipse(scale * symbol->sizex, scale * width, angle, c, bc, oc, scale * style->outlinewidth);
+ tile = r->createTileEllipse(scale * symbol->sizex, scale * symbol->sizey, angle, c, bc, oc, scale * style->outlinewidth);
break;
case MS_SYMBOL_TRUETYPE: {
char* font = msLookupHashTable(&(symbolset->fontset->fonts), symbol->font);
@@ -344,6 +344,7 @@
colorObj c = style->color;
colorObj oc = style->outlinecolor;
colorObj bc = style->backgroundcolor;
+ double ow = style->outlinewidth == 0 ? 1.0 : style->outlinewidth;
c.alpha = MS_NINT(style->opacity*2.55);
oc.alpha = bc.alpha = c.alpha;
if (style->symbol >= symbolset->numsymbols || style->symbol < 0)
@@ -406,10 +407,13 @@
}
void *tile;
switch(symbol->type) {
+ case MS_SYMBOL_TRUETYPE:
+ case MS_SYMBOL_PIXMAP:
+ case MS_SYMBOL_ELLIPSE:
case MS_SYMBOL_VECTOR:
tile = getTile(image,symbolset,style,scaling,width,angle_radians);
}
- r->renderPolygonTiled(image,offsetPolygon,tile);
+ r->renderPolygonTiled(image,offsetPolygon, &oc, ow, tile);
}
if (style->offsety == -99) {
Modified: sandbox/graphics/mapserver.h
===================================================================
--- sandbox/graphics/mapserver.h 2009-02-13 06:14:00 UTC (rev 8547)
+++ sandbox/graphics/mapserver.h 2009-02-13 06:27:10 UTC (rev 8548)
@@ -2349,7 +2349,7 @@
imageObj* msImageCreateOgl(int width, int height, outputFormatObj *format, colorObj* bg);
int msSaveImageOgl(imageObj *img, char *filename, outputFormatObj *format);
void msDrawPolygonOgl(imageObj *img, shapeObj *p,colorObj *c, colorObj *oc, double outlineWidth);
-void msDrawPolygonTiledOgl(imageObj *img, shapeObj *p, void *tile);
+void msDrawPolygonTiledOgl(imageObj *img, shapeObj *p, colorObj *oc, double outlineWidth, void *tile);
void msDrawLineTiledOgl(imageObj *img, shapeObj *p, double width, void* tile);
void msRenderGlyphsOgl(imageObj *img,double x, double y, colorObj *color, colorObj *outlinecolor,
double size, char *font, char *thechars, double angle,
@@ -2401,7 +2401,7 @@
imageObj* msImageCreateCairo(int width, int height, outputFormatObj *format, colorObj* bg);
int msSaveImageCairo(imageObj *img, char *filename, outputFormatObj *format);
void msDrawPolygonCairo(imageObj *img, shapeObj *p,colorObj *c, colorObj *oc, double outlineWidth);
- void msDrawPolygonTiledCairo(imageObj *img, shapeObj *p, void *tile);
+ void msDrawPolygonTiledCairo(imageObj *img, shapeObj *p, colorObj *oc, double outlineWidth, void *tile);
void msRenderGlyphsCairo(imageObj *img,double x, double y, colorObj *color, colorObj *outlinecolor,
double size, char *font, char *thechars, double angle,
colorObj *shadowcolor, double shdx, double shdy,
@@ -2457,7 +2457,7 @@
double width, int patternlength, int* pattern);
void (*renderPolygon)(imageObj *img, shapeObj *p, colorObj *c,
colorObj *oc, double outlineWidth);
- void (*renderPolygonTiled)(imageObj *img, shapeObj *p, void *tile);
+ void (*renderPolygonTiled)(imageObj *img, shapeObj *p, colorObj *oc, double outlineWidth, void *tile);
void (*renderLineTiled)(imageObj *img, shapeObj *p, double width, void* tile);
void (*renderGlyphs)(imageObj *img, double x, double y,
More information about the mapserver-commits
mailing list