Recieve More Than One Value From Dll Function |
This is a Q&A forum for advanced GML users ONLY. Moderators will remove inappropriate topics. Make sure that you READ these rules prior to posting: Advanced Users Forum Rules
![]() ![]() |
Recieve More Than One Value From Dll Function |
Nov 6 2009, 04:13 PM
Post
#1
|
|
|
GMC Member Group: GMC Member Posts: 708 Joined: 12-September 06 From: Australia Member No.: 59285 |
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).
|
|
|
|
Nov 6 2009, 04:42 PM
Post
#2
|
|
|
Yesterdays games Group: GMC Member Posts: 614 Joined: 7-December 08 From: Sweden Member No.: 124474 |
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. |
|
|
|
Nov 6 2009, 06:10 PM
Post
#3
|
|
|
GMC Member Group: GMC Member Posts: 708 Joined: 12-September 06 From: Australia Member No.: 59285 |
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.
|
|
|
|
Nov 7 2009, 10:47 AM
Post
#4
|
|
|
GMC Member Group: GMC Member Posts: 633 Joined: 2-January 08 From: Canada Member No.: 96633 |
you could also return multiple numbers stored in one (a 32bit number breaks into 4 8 bit numbers (0-256))
|
|
|
|
Nov 7 2009, 11:08 AM
Post
#5
|
|
|
GMC Member Group: GMC Member Posts: 708 Joined: 12-September 06 From: Australia Member No.: 59285 |
|
|
|
|
Nov 7 2009, 11:38 AM
Post
#6
|
|
|
GMC Member Group: Local Moderators Posts: 17797 Joined: 25-April 04 Member No.: 8750 |
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). |
|
|
|
Nov 7 2009, 01:04 PM
Post
#7
|
|
|
GMC Member Group: GMC Member Posts: 916 Joined: 9-October 03 From: Sydney, Australia Member No.: 234 |
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
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 22nd November 2009 - 11:46 AM |