Results 1 to 6 of 6

Thread: DLLs and arrays of vectors

  1. #1

    DLLs and arrays of vectors

    ok, im making a procedure that needs a list of vertices. currently its defined as follows

    procedure ProcedureName(const aVertices: TAVectorArray); cdecl;

    where

    TVector3f = array[0..2] of single;
    TAffineVector = TVector3f;
    TAVectorArray = Array of TAffineVector;

    and im doing

    for LLoop := 0 to High(aVertices) -1 do


    if another language (say c++) uses this procedure, it wont work will it?

    so i have to have size of array and the stride of each vertex?

    ive *used* procedures before that use that method but i wouldnt be sure what to do with the stride with copying the data to a buffer. any ideas?




    the procedure i used before is defined as follows

    function NewtonCreateConvexHull( const newtonWorld : PNewtonWorld; count : int; vertexCloud : PFloat; strideInBytes : int; offsetMatrix : PFloat) : PNewtonCollision; cdecl;

    where

    Float = Single;
    PFloat = ^Float;
    Int = Integer;

  2. #2

    DLLs and arrays of vectors

    can't really help much, but just thought I would point out that your for loop should be

    [pascal]
    for LLoop := 0 to High(aVertices) do
    [/pascal]

    The -1 is not needed unless you specifically want it to stop before the last item.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  3. #3

    DLLs and arrays of vectors

    well passing dynamic arrays in and out dlls is not a good thing

    In this case you should stay as plain as possible, but you don't need stride. Stride is needed if you have useful data interleaved with unuseful.

    Just declare a pointer instead of an array, and pass the size along:


    PAffineVector=^TAffineVector;

    procedure ProcedureName(aVertices: PAffineVector; size:integer); cdecl;

    Then inside the procedure you can fetch "size" vertices out of the pointer. You can both cast the pointer as a fake array or increment it (i don't remember if typed pointers support inc() or if you need to do that manually).

    BTW i usually access dynamic arrays size with "length(array)". I think this is the official way.
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  4. #4

    DLLs and arrays of vectors

    thanks

  5. #5

    DLLs and arrays of vectors

    Quote Originally Posted by {MSX}
    "length(array)". I think this is the official way.
    When using length() with arrays, then you do need to use - 1, because the length given is 1 based, but when using High() that is not needed.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #6

    DLLs and arrays of vectors

    Typed pointers are INCed by the size of the underlaying type. For dynamic record types this might be a bit confusing as they are as big as the largest subpart of them.
    The more complex a system is, the smaller the bugs get; the smaller the bugs are, the more often they appear.

Bookmarks

Posting Permissions

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