From: Matthew Fernandez Date: Sat, 14 Jan 2023 05:21:09 +0000 (-0800) Subject: smyrna: use a double for 'global_z' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f7e6f938dc032e4462f56b52caaf9cebdb0c3b9;p=graphviz smyrna: use a double for 'global_z' Most of the calculations with this and uses of it are with doubles. So making it a double as well avoids losing intermediate precision. Squashes 5 -Wfloat-conversion warnings. --- diff --git a/cmd/smyrna/draw.c b/cmd/smyrna/draw.c index 6bfcf6bf7..59386b7ed 100644 --- a/cmd/smyrna/draw.c +++ b/cmd/smyrna/draw.c @@ -181,7 +181,7 @@ static void DrawEllipse(sdot_op* o, int param) //convert degrees into radians float degInRad = (float) (i * DEG2RAD); glVertex3f((GLfloat) (x + cos(degInRad) * xradius), - (GLfloat) (y + sin(degInRad) * yradius), view->Topview->global_z); + (GLfloat) (y + sin(degInRad) * yradius), (GLfloat)view->Topview->global_z); } glEnd(); } @@ -233,7 +233,7 @@ static void DrawPolyline(sdot_op* o, int param) for (size_t i = 0; i < op->u.polyline.cnt; ++i) { glVertex3f((GLfloat) op->u.polyline.pts[i].x - dx, (GLfloat) op->u.polyline.pts[i].y - dy, - (GLfloat) op->u.polyline.pts[i].z + view->Topview->global_z); + (GLfloat)(op->u.polyline.pts[i].z + view->Topview->global_z)); } glEnd(); } @@ -404,7 +404,7 @@ void drawCircle(float x, float y, float radius, float zdepth) float degInRad = (float) (i * DEG2RAD); glVertex3f((GLfloat) (x + cos(degInRad) * radius), (GLfloat) (y + sin(degInRad) * radius), - (GLfloat) zdepth + view->Topview->global_z); + (GLfloat)(zdepth + view->Topview->global_z)); } glEnd(); diff --git a/cmd/smyrna/smyrnadefs.h b/cmd/smyrna/smyrnadefs.h index 4cb9d6808..4939689ed 100644 --- a/cmd/smyrna/smyrnadefs.h +++ b/cmd/smyrna/smyrnadefs.h @@ -257,7 +257,7 @@ typedef struct float minedgelen; float fitin_zoom; xdot* xDot; - float global_z; + double global_z; attr_list* attributes;/*attribute list*/ topviewcache cache; diff --git a/cmd/smyrna/topviewfuncs.c b/cmd/smyrna/topviewfuncs.c index 8eda2813f..6dabb9a10 100644 --- a/cmd/smyrna/topviewfuncs.c +++ b/cmd/smyrna/topviewfuncs.c @@ -71,7 +71,7 @@ static void set_boundaries(Agraph_t * g) view->bdyBottom = bottom; } -static void draw_xdot(xdot* x,float base_z) +static void draw_xdot(xdot* x, double base_z) { sdot_op *op; if (!x) @@ -318,7 +318,7 @@ static void renderNodes(Agraph_t * g) x=parseXdotwithattrs(g); if (x) { - draw_xdot(x,-0.2f); + draw_xdot(x, -0.2); freeXDot (x); } for (v = agfstnode(g); v; v = agnxtnode(g, v)) @@ -326,7 +326,7 @@ static void renderNodes(Agraph_t * g) if(!object_color(v,&c)) continue; x=parseXdotwithattrs(v); - draw_xdot(x,-0.1f); + draw_xdot(x, -0.1); if(x) freeXDot (x); diff --git a/lib/glcomp/glcompfont.c b/lib/glcomp/glcompfont.c index a763e85fe..65fcf12bc 100644 --- a/lib/glcomp/glcompfont.c +++ b/lib/glcomp/glcompfont.c @@ -121,8 +121,8 @@ glCompFont *glNewFontFromParent(glCompObj * o, char *text) } /*texture base 3d text rendering*/ -void glCompDrawText3D(glCompFont * f,GLfloat x,GLfloat y,GLfloat z,GLfloat w,GLfloat h) -{ +void glCompDrawText3D(glCompFont *f, GLfloat x, GLfloat y, double z, GLfloat w, + GLfloat h) { glEnable(GL_BLEND); // Turn Blending On glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); diff --git a/lib/glcomp/glcompfont.h b/lib/glcomp/glcompfont.h index e282ccab2..1562473ce 100644 --- a/lib/glcomp/glcompfont.h +++ b/lib/glcomp/glcompfont.h @@ -32,7 +32,8 @@ extern "C" { void glDeleteFont(glCompFont * f); void glCompDrawText(glCompFont * f,GLfloat x,GLfloat y); void glCompRenderText(glCompFont * f, glCompObj * parentObj); - void glCompDrawText3D(glCompFont * f,GLfloat x,GLfloat y,GLfloat z,GLfloat w,GLfloat h); + void glCompDrawText3D(glCompFont *f, GLfloat x, GLfloat y, double z, + GLfloat w, GLfloat h); #ifdef __cplusplus }