Help - Search - Members - Calendar
Full Version: Recieve More Than One Value From Dll Function
Game Maker Community > Working with Game Maker > Advanced Users Only
tidus97
hey guys. i do alot of calculating outside of gamemaker. however, because i can only return a double or char* from my functions, i find myself going back and forward between dll + gamemaker to gather all the values i need for that step of the game. this is pretty heavy on the system - i've got C++ doing my heavy lifting (data storage etc) with a DLL but because i need to search for values, say, 4 or 5 times over instead of being able to return them back to GM in one go i loose alot of performance. as it stands, the "native" arrays that come with GM are faster than my DLL. infact, i see a performance loss at significant performance drop all the way up at 1000~ instances, compared to the DLL which results in a significant drop at only 320. so i was wondering how you guys delt with this..do u all really just pass back a single value at a time? + a little offtopic but is the link between DLL's and gamemaker going to be strengthened in the future? (support for passing things like arrays for example).
StarTrek
QUOTE (tidus97 @ Nov 6 2009, 05:13 PM) *
hey guys. i do alot of calculating outside of gamemaker. however, because i can only return a double or char* from my functions, i find myself going back and forward between dll + gamemaker to gather all the values i need for that step of the game. this is pretty heavy on the system - i've got C++ doing my heavy lifting (data storage etc) with a DLL but because i need to search for values, say, 4 or 5 times over instead of being able to return them back to GM in one go i loose alot of performance. as it stands, the "native" arrays that come with GM are faster than my DLL. infact, i see a performance loss at significant performance drop all the way up at 1000~ instances, compared to the DLL which results in a significant drop at only 320. so i was wondering how you guys delt with this..do u all really just pass back a single value at a time? + a little offtopic but is the link between DLL's and gamemaker going to be strengthened in the future? (support for passing things like arrays for example).

One way would be to return a string, then split that string into other values. Else you could use this http://gmc.yoyogames.com/index.php?showtopic=429267 but I dont know anything about that.
tidus97
hmm dont know how much more all that extra weight would help with what i currently got. i've slimmed it down as much as possible (not size-wise, obviously, i mean how much of a performance impact it has) and GML is somehow the clear winner. my DLL holds a lot of objects along with all of their settings in maps, and manipulates them there too (does all the maths, retrieves values, etc). where as the GML version handles all the data with GM's default arrays...it receives a tiny bit of help from a dll to solve 4 larger functions. GML can keep track of + draw etc 700 objects, with 1 or 2 fps loss, where as the DLL only method comes in at 600. either maps are really slow, or external_call's are slow or something. i dont know. tongue.gif will look at slimming my code down even more + using vectors maybe instead of maps. see how all that goes.
brett14
you could also return multiple numbers stored in one (a 32bit number breaks into 4 8 bit numbers (0-256))
tidus97
QUOTE (brett14 @ Nov 7 2009, 09:47 PM) *
you could also return multiple numbers stored in one (a 32bit number breaks into 4 8 bit numbers (0-256))

example please?
ragarnak
If you have enough data to be returned you could put all of it in a single in a certain way encoded string and read it into a data-structure. For example with "ds_list_read(...)"

Yes, it would only work (be benificial) when largish ammounts of data need to be returned (the encoding of the string and decoding by the above command does take its time).
39ster
Use http://gmc.yoyogames.com/index.php?showtopic=429267 (gmapi). You an use it to fill a ds_list or return a new ds_list
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.