Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: vgAppendPathData and float pointers

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    8

    vgAppendPathData and float pointers

    So I've got OpenVG (via ShivaVG) rendering the SVG tiger IF I use the float[] arrays it defines. However, I wrote a simple SVG loader (loads in only paths and only move to and cubic curves) and if I pass my float pointer (float *blah = new[dataCount] , it just hangs the application in vgAppendPathData.

    (Edit: I've verified that my data is valid several times, including putting it into a compile time array. Additionally, the vgGetError() function returns VG_NO_ERROR after creating and appending the path)

    The reference also uses a compile time array, so it's no help. I was planning on cleaning up my load function and releasing what I have (at the very least as a working example of getting ShivaVG set up with SDL, not that that was terribly difficult), but this issue has me stuck. So whoever helps me will be the first to see the code

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

    Re: vgAppendPathData and float pointers

    Needless to say, it *should* work... Whether ShivaVG can do it or not, I don't know... I don't use it (I've had some bad experiences with it).

    Try checking the following:
    - vgCreatePath() is called and includes the capability to appendpathdata (why this is even an option I don't know...)
    - make sure that vgCreatePath() is created with floating point number format.
    - make sure your pointer is word aligned ((int)pointer & 3).
    - make sure that your stream of VG commands is valid and matches your data.
    - make sure you're not doing something silly like passing a pointer to a pointer (instead of a pointer) or something similar.
    - double check that your scale value is valid [not 0 or #INF] (in vgCreatePath()).

    If all that fails, post the exact the exact code snippet and I'll see if I spot anything else. Good Luck.

  3. #3
    Junior Member
    Join Date
    Dec 2008
    Posts
    8

    Re: vgAppendPathData and float pointers

    I've checked most of those items. I checked the word alignment of the pointer (I'm assuming you mean that (int)point & 3 will return 0 or 1 being not word aligned and word aligned, respectively) and it is apparently not word aligned. I guess I'm just a noob in this area, but I'm having trouble finding anything regarding this. Do you think you could elaborate? I'm guessing this is probably my issue.

    Edit: Well I've searched some and uncovered some mildly helpful documents. I'm still unsure how to fix it in a way that isn't a ridiculous hack, however.

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

    Re: vgAppendPathData and float pointers

    Quote Originally Posted by n00854180t
    I've checked most of those items. I checked the word alignment of the pointer (I'm assuming you mean that (int)point & 3 will return 0 or 1 being not word aligned and word aligned, respectively) and it is apparently not word aligned. I guess I'm just a noob in this area, but I'm having trouble finding anything regarding this. Do you think you could elaborate? I'm guessing this is probably my issue.

    Edit: Well I've searched some and uncovered some mildly helpful documents. I'm still unsure how to fix it in a way that isn't a ridiculous hack, however.
    It will actually return 0,1,2,or 3 - only 0 is good - the rest are bad. Since you're using the new operator though on a float, I highly doubt that it's an alignment issue (the compiler should do that for you).
    Post the snippet.

    If I had to guess, and you're causing a crash, I'd guess you're doing something like:
    - allocating some array (let's call it 'data') of floats
    the doing something like
    vgAppendPathData(path, num_cmds, &cmds, &data);
    but arrays in C/C++ are auto-magically passed as pointers, so the line should read:
    vgAppendPathData(path, num_cmds, cmds, data);
    [the extra & operator would give a address of where the pointer to the data is stored, instead of a pointer to the data itself]

    Again - I have no way of knowing what you're doing wrong without seeing the relevant bits of code.

  5. #5
    Junior Member
    Join Date
    Dec 2008
    Posts
    8

    Re: vgAppendPathData and float pointers

    Ah, then that's not the issue. It doesn't actually crash, for one thing. It returns success status codes after the vgAppendPathData call, then just hangs when I try to draw the path.

    I'll post snippets later tonight when I'm off work.

    I know I'm definitely not passing it as a ** (pointer pointer), my call looks like vgAppendPathData( path, commandCount, cmds, data ). (cmds is a byte pointer in this case, and data is a float pointer).

  6. #6
    Junior Member
    Join Date
    Dec 2008
    Posts
    8

    Re: vgAppendPathData and float pointers

    Well, I found the issue. It was my bug. However, I'm getting some output I don't really understand. Whenever I have a stroke on a path, it essentially just fills the inside of the path with the color for that stroke. If the stroke width is set to 0, the background color shows through correctly (it's drawing both, the fill then the stroke, but the stroke is covering the same exact area as the fill, but with its own color).

    My setup for the stroke/fill paint is essentially stock, I set them before drawing in the regular manner....

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

    Re: vgAppendPathData and float pointers

    Glad you found the bug. What was it if you don't mind me asking?

    About your new issue - I'm guessing your stroke width is too large - IIRC by default is 4. So, for example, you draw your path in some normalized coordinates space like [0..1], then your stroke width will be so huge it'll look like a fill. Just set the stroke width smaller ("width / scale_factor" type of thing [or try like 0.01 to test the theory]).

  8. #8
    Junior Member
    Join Date
    Dec 2008
    Posts
    8

    Re: vgAppendPathData and float pointers

    Well I had a bug in my parsing code. When parsing each pair of values, I wasn't incrementing the index to put the data at by 2 instead of 1, so it was filling only half the array and leaving the rest of the points at essentially float_max, so when it was hanging, I assume it was attempting to rasterize all the way to those positions.

    I'm really not sure what range OpenVG uses. The value from Inkscape in SVG is something like 1.7. Thing is, I would expect to see a very large stroke color on the outside of the path? Currently it *only* covers the area
    of the fill, it doesn't extend outside it, which if it was just the width being too great I would expect to see.

    Edit: Also, where is the 0,0 point of the coordinates in OpenVG? That is, which corner is it? It's hard to get my objects centered without knowing more explicitly than I do at the moment.

    I greatly appreciate your help Ivo!


    Edit: I've done some testing after getting home today. Even with a stroke width of 0.17, the stroke covers *exactly* the area that the fill does. It isn't even straddling the path in the right fashion, since even if it covered all of the fill area, it would still be a larger rect.

    Upon further testing, it appears that no matter what path I put in, it ends up outputting a square or a quad of roughly the same dimensions. It happens regardless of whether or not the actual path is open or closed, fill or no fill. It doesn't happen if the amount of segments/commands is only 2 (i.e., a moveto and a lineto work). I've attached a screenshot with the input path and the output render.
    Attached Images Attached Images

  9. #9
    Junior Member
    Join Date
    Dec 2008
    Posts
    8

    Re: vgAppendPathData and float pointers

    Fixed! I had commented out where I was setting the stencil buffer up for SDL.

    Edit: Blah. New problem: it only renders the *last* path, despite the fact that I only clear once per render (at the start) and do a loop of vgDrawPaths after. :/ Yikes.

    Also, not sure why, but the rendering quality on my paths is terrible. Not like the reference app at all (appears to be no antialiasing at all). I've tried setting the rendering quality without result.

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

    Re: vgAppendPathData and float pointers

    VG's coordinate system has (0,0) in the bottom left corner.

    As for your new problem.... you are creating a separate path for each path your are trying to render, right? Ah well - nothing you wont fix with a little debugging I'm sure.

    As for rendering quality... I have not used ShivaVG much - the little I did use it, left me rather unimpressed. For anti-aliasing you may have to make sure multi-sampling is turned on when you create the window (if Shiva supports it at all) [also might not hurt to make sure you vgSeti() your VG_RENDERING_QUALITY is set to faster(default?) or better]. If you're running windows, I recommend you trying to find Hybrid's old Rasteroid software renderer or using AmanithVG for now to do your developing on. If it is a problem with ShivaVG, hopefully someone will fix it by the time you're ready for release.

Page 1 of 2 12 LastLast

Similar Threads

  1. Pointers to Pointers
    By IRWolfie- in forum OpenCL
    Replies: 2
    Last Post: 04-05-2011, 05:00 PM
  2. Pointers to arrays
    By IRWolfie- in forum OpenCL
    Replies: 4
    Last Post: 03-29-2011, 06:23 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
  •