Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Threading support in DBP

Author
Message
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Dec 2013 02:28 Edited at: 13th Dec 2013 02:30
I've asked here mainly because this forum gets viewed first and more before the DLL thread does, so I don't mind that this post gets moved eventually.

The reason is, I asked here donkeys ago http://forum.thegamecreators.com/?m=forum_view&t=200005&b=18 how to call a DBP function from my own DLL. To which I got a total of 'zero' responses. Nobody knew.

A lot of people now have a dual core or even a pc/laptop that has threading capabilities, and I'd like to add support, at the programmers risk of course, to use those extra threads/cores.

The idea I want to put together, is for the DBP coder, to run a function on a separate thread. And for the coder to have a DBP function to be called at intervals on a thread of it's own on a timer. ALL AT THE CODERS RISK OF COURSE. While I work on this DBP plugin, I will make sure all necessary checks will be put in place in case of a crash. ie. destruction safety...

Threading will allow DBP coders to have one core/thread to process an image while other cores/threads process setting up something else. Used safely and with the necessary checks DBP can run mega sweet on dual core cpu's and above.

Can anybody tell me how to call a dbp function from my own DLL and pass parameters to it please?

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 13th Dec 2013 04:28
In Matrix1's Utility Plug-ins there is the command "call function name".
You can call any DBPro function from your dll using this command.
Running it on a separate thread is not safe.
If you access any DBPro resources from another thread it will crash.
If you need the C++ files to be able to call Matrix1's dll I can
email them to you I don't want to post them on the forums.


[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 13th Dec 2013 06:16
You could try DBLibWrapper which should do all the tedious grunt work for you.

Brightside_
12
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 13th Dec 2013 10:25 Edited at: 13th Dec 2013 10:28
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 13th Dec 2013 11:44
The built-in functions of DBPro doesn't really support threading (what if you were to create an object during rendering for example; if you have a half-filled vertex buffer and / or haven't gotten around to update it to its new, smaller size yet, your program would likely crash with an access violation).
That said, you can have threads for certain other things, like culling, physics etc. and only update the graphics (dbp core) from those threads when it is safe to do so (using a locking mechanism).

Quote: "Can anybody tell me how to call a dbp function from my own DLL and pass parameters to it please?"

You would implement and export this function from your dll:

Its input argument is a pointer to the GlobStruct (search for it). From there you will get a set of HMODULE handles to the internal libraries that you can then access the functions from. Like Kevin suggested you can use my library wrapper for easing that up a bit; you'd just change the HMODULE declaration in the .cpp files for the corresponding one from the globstruct.
Note that the globstruct will only expose the core libraries however; you can't access other third party dll's.


"Why do programmers get Halloween and Christmas mixed up?"
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Dec 2013 12:17
@Stab in the Dark Software - I should have those files myself somewhere so I will check through them for those functions which I have missed. If I have lost them, then I certainly will be in touch. Thank you.

@Kevin Picone - Now that does look interesting because along the way I might need the use of other DBP DLL's (plugins) and not just to be restricted with what I can call from my own DLL. As mentioned to Stab in the Dark Software, the library that I used to use is great but with no access to other plug-ins.

@Brightside_ - I remember seeing the thread were IanM writes out a list of what not to do's. I'm fully aware that multi-threading in DBP is seriously the AT THE USERS RISK. There are plenty of things that can be split into other threads though which is why I want to use this.

I've played with threading a lot with code on Linux and Windows and I'm starting to get familiar with what you can and cannot do.

Obviously I will post back with some results. Thanks guys.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 16th Dec 2013 16:40
I need to practice this with STYX some more... curious to see where the great WLGfx gets with this! especially with his new kit!

Login to post a reply

Server time is: 2026-07-08 03:47:35
Your offset time is: 2026-07-08 03:47:35