Results 1 to 10 of 11

Thread: Convert from c++ to Pascal

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Wink

    Hi,

    iStream is a record type. I don't create it!

    I have another c++ code!!!!!
    Then...

    C++
    Code:
    struct Stream {
        float *vertices;
        uint verticesCount;
    };
    
    Array <Stream> streams;
    
    void flip(const int index, const uint c0, const uint c1){
        
        for (uint i = 0; i < streams[index].verticesCount; i++){
            float *src = streams[index].vertices + i * 2;
    
            float temp = src[c0];
            src[c0] = src[c1];
            src[c1] = temp;
        }
    }
    Pascal
    Code:
      Stream = record
        vertices: array of single;
        verticesCount: longword;
      end;
    
      streams = array of Stream;
    
    procedure flip(const index: integer; const c0, c1: longword);
    var
      i: intger;
    begin  
        for i := 0 to streams[index].verticesCount-1 do
        begin
            float *src = streams[index].vertices + i * 2; <-- from this
    
            float temp = src[c0];
            src[c0] = src[c1];
            src[c1] = temp;
        end;
    end;
    Thanks
    Sesilla

  2. #2
    Code:
    var src: PFloatArray;
    var temp: Single;
    ...
    src := PFloatArray(@streams[index].vertices[i * 2]);
    temp := src^[c0];
    src^[c0] := src^[c1];
    src^[c1] := temp;

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
  •