Calling BMax function from c files...

BlitzMax Forums/BlitzMax Beginners Area/Calling BMax function from c files...

GregBUG(Posted 2007) [#1]
Hi!!

it's possible to call a standard BlitzMax function (ex. drawimage) from a function defined in an external c source?

if yes... how can it be done?

i'm try to do some optimization to my library and i want to try to convert some functions in external c function and see if there are some little preformace improvments!

thanks.
Gianluca.


SpaceAce(Posted 2007) [#2]
Check out this thread from the Blitzmax Programming forum: http://www.blitzmax.com/Community/posts.php?topic=66910

SpaceAce


verfum(Posted 2007) [#3]
GregBUG: "it's possible to call a standard BlitzMax function (ex. drawimage) from a function defined in an external c source?"

Well, the answer is yes. It just depends on what you what to gain from this. I've managed to call some BlitzMax functions directly from a linked 'C' dll by using a function pointer, but not all of them.

For instance, see the functions I've managed to call directly using the link that SpaceAce kindly provided.

www.blitzmax.com/Community/posts.php?topic=66910


In this example, Cls, DrawLine, Flip and KeyHit can be called directly from 'C' functions, but Graphics can't (possibly due to misunderstanding with the function prototype).

I've not yet found a method of directly calling BlitxMax functions (from C) that take strings as their arguments. You have to write a small wrapper to convert the the pointer from a C-style string to a blitz string, e.g.




GregBUG(Posted 2007) [#4]
thanks!!! testing now...