Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #4595

Sharing data between ruby and a custom dll with Win32API

From "futar C." <bourinax@yopmail.com>
Newsgroups comp.lang.ruby
Subject Sharing data between ruby and a custom dll with Win32API
Date 2011-05-16 05:30 -0500
Organization Service de news de lacave.net
Message-ID <5daf6b7d2acef28191055cb217178954@ruby-forum.com> (permalink)

Show all headers | View raw


Hi All,

I'm building a ruby plugin for SketchUp. I created a havok dll (havok is
a physic engine) and I need to share/pass data between ruby and the dll.
So far I had no problem to send data from ruby to the dll, but I can't
figure out the other way.

SketchUp 8 uses ruby 1.8.6, so I use the same Win32API version.

Here is my ruby code:

def get_matrix(index)

 matrix = Array.new(16,0.1)
 matrix2 = @getKaplaMatrix.call(index,matrix.pack("f*"))
 matrix3 = matrix2.unpack("f*")
 # puts "HELLO HELLO HELLO"
 # puts matrix3
 if (matrix3.size() != 16)
  puts "WRONG ARRAY"
 else
  puts "ARRAY OK"
 end
 return matrix3

end

Here is my dll code:

DECLDIR float* getKaplaMatrix (int indice, float* matrix)
{
  float* kaplaMatrix = havokUtilities->getKaplaMatrix(indice);

  for(int i=0 ; i < 16; i++)
  {
    matrix[i] = kaplaMatrix[i];
  }
  matrix[14]/= 2;
  matrix[13]/= 2;
  matrix[12]/= 2;

  return(matrix);
}

I'm trying to send a 4x4 matrix (stored in a [16] array) from the dll to
ruby, but I always get errors because some returned arrays are too
short. I did some tests and found that then there is an "integer"
(declared as "1.0") in the array, the value after the "integer" are
lost...

The result is that among all the arrays I send to ruby, some of then are
of the wrong dimension (because some matrix have some zeros values for
example). I have not the slightest idea of why this is
happening...

Thx

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Sharing data between ruby and a custom dll with Win32API "futar C." <bourinax@yopmail.com> - 2011-05-16 05:30 -0500
  Re: Sharing data between ruby and a custom dll with Win32API Su Zhang <zhangsu@live.com> - 2011-05-17 15:00 -0500
  Re: Sharing data between ruby and a custom dll with Win32API "futar C." <bourinax@yopmail.com> - 2011-05-18 06:24 -0500

csiph-web