A simple question

How to draw a quadratic curve using OpenVG…

I used the following code:

VGPath path;

VGubyte segments[] = {VG_QUAD_TO_ABS};
VGfloat coords[] = { 100,100,
150,200,
200,100
};
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
vgAppendPathData(path,1,segments,coords);
vgDrawPath( path, VG_STROKE_PATH );
vgDestroyPath( path );

I get nothing…
When I change the 2nd parameter to 2 ,I get some curve which I cannot understand…

When I am drawing only a single path why should I give 2 in the parameter…
Expecting Reply…

VG_QUAD_TO expects only 2 coordinates not 3. The first coordinate is given by the current position. The start position on a new path is always (0,0) so you were actually drawing a quad with the 3 points: (0,0),(100,100), and (150,200) instead of the one you were expecting. Thus you should add a VG_MOVE_TO_ABS to your command stream by:

VGubyte segments = {VG_MOVE_TO_ABS, VG_QUAD_TO_ABS};
VGfloat coords = { 100,100, 150,200,200,100};
vgAppendPathData(path,2,segments,coords);

Thanks for the reply …
It worked…
And I have doubts yet…

1:We need three control points to draw a quad curve…
a starting point,an ending point and an internal control point
But QUAD_TO expects only 2 points …
Actually what are these two points…
Are they internal control point and ending point …

2:If so,when I use the following code to draw my quadratic curve at origin only,
I dont see anything…

VGPath path;

VGubyte segments[] = {VG_QUAD_TO_ABS};
VGfloat coords[] = {150,200,200,100};
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
vgAppendPathData(path,1,segments,coords);
vgDrawPath( path, VG_STROKE_PATH );
vgDestroyPath( path );

Expecting Reply…

If you are using AmanithVG, there was an already known bug related to paths made of a single command without an initial move_to.
The next public release will contain the patch.

Yes. I am using AmanithVG …
Thanks for the reply…