Hi all. See if you can help me.
FirstQuestionI have a function in C for a dll.
DllImport float sum (float a, float b)
{
return a + b;
}
How do I give to that function float values from RGSS?
My code in RGSS (i cant use '
f' or '
d' as param):
n = Win32API.new ('test', 'sum', 'ii', 'i')
a = 5.10
b = 8.90
n.call p (a, b)
Last QuestionI defined a point class in RGSS
class Point # by Newold
#--------------------------------------------------------------------------
attr_accessor :x
attr_accessor :y
#--------------------------------------------------------------------------
def initialize(x=0,y=0)
@x = x; @y = y
end
#--------------------------------------------------------------------------
end
in dll i defined this struct:
struct point
{
float x;
float y;
};
How do I give to a function a point from RGSS? i want say, If i have this point in RGSS => Point.new(150,150), how i pass this point to a function in c as struct point.
For your first question, try using a pointer. Replace "i" with "p" and try that. I dunno if it'll work but it might. As for your second question, you could try to pack the variable in Ruby, then pass it to your DLL, then unpack it in your C side.
That should actually work. But you should make the arguments in the C function also pointers so that there are no problems.
DllImport float sum (float a, float b)
{
return a + b;
}