Results 1 to 5 of 5

Thread: A simple question

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Posts
    13

    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...

  2. #2
    Senior Member
    Join Date
    Feb 2006
    Posts
    115

    Re: A simple question

    Quote Originally Posted by tinuhp
    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);

  3. #3
    Junior Member
    Join Date
    Oct 2007
    Posts
    13
    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.....

  4. #4
    Quote Originally Posted by tinuhp

    2: If so,when I use the following code to draw my quadratic curve at origin only, I dont see anything...
    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.
    AmanithVG Lead Programmer

  5. #5
    Junior Member
    Join Date
    Oct 2007
    Posts
    13
    Yes. I am using AmanithVG ....
    Thanks for the reply.....

Similar Threads

  1. Simple question about clFinish()
    By vincentfpgarcia in forum OpenCL
    Replies: 7
    Last Post: 02-05-2013, 08:56 AM
  2. hello! A simple question
    By yxyybbs in forum OpenSL ES - General
    Replies: 1
    Last Post: 07-19-2011, 08:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •