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.

DLL Talk / Guide To Writing Plug-ins

Author
Message
IanM
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Nov 2011 00:39 Edited at: 19th Nov 2011 17:06
I have built up a set of notes over the years contains bits and pieces about writing plug-ins - it's part due time that I shared the details with the wider community.

This is definitely a work-in-progress - it doesn't contain anywhere near the amount of things that I have in my notes. I plan to expand this document bit by bit until it contains comprehensive coverage of the art of writing plug-ins for DBPro.

If you have a request for additional details, simply ask and I'll consider writing something about it.

[EDIT]
Oops, forgot to mention that comments on the style, layout and ordering of sections will also be gratefully accepted too.

19 Nov 2011 - Version 0.2 is now available, with some examples.

Attachments

Login to view attachments
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 12th Nov 2011 03:02
Cool, it's about time something like this existed, and I can't think of anyone more qualified to write it!

I'd like to know more about the "A" type character. You say it means a recursive call? Does that mean it calls a function of the same name for every argument you pass in?

Yeah I know, there's a lot of more basic stuff to cover first but I was just interested Some stuff about how to receive and return strings and floats would probably be good, as well as a bit about why it's actually necessary. Oh yeah, and it might be good to tell people where they can find the DBPro source code, it seems not many people even know it's open source and it can be quite useful.

When it gets a bit bigger it might also be useful to have a FAQs sections which links to the relevent parts of the document as a kind of reference.

[b]
Hotline
11
Years of Service
User Offline
Joined: 22nd Aug 2008
Location:
Posted: 12th Nov 2011 14:00
IanM
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Nov 2011 01:58
Quote: "I'd like to know more about the "A" type character. You say it means a recursive call? Does that mean it calls a function of the same name for every argument you pass in?"

Yes. Actually, a better name for it is variadic rather than recursive. I'll put a section in the document covering it with a simple example.

Following your suggestion, I'm currently rewriting the first major section of the document to explain all of the basics too - I was going to skip it originally, because most of the important stuff is in the tech document in the help files. It may as well be all in one place though.

IanM
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th Nov 2011 17:09
I've added a new section about writing plug-ins from scratch, what all the parameter/return types are, and how to use (the majority of) them.

Note that the code is NOT as I would write it. At this point I'm trying to not have too much C++ stuff cloud the issues - that will come in a later section, covering program structure, using STL, handling exceptions etc.

Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 19th Nov 2011 23:47 Edited at: 19th Nov 2011 23:49
I've just read the new version, all looks good The unhelpful error message when using variadic commands does actually show the name of the command which is unused by the compiler, so theoretically you could put a much more helpful message there

Also, I didn't think the dependency system allowed dependencies on user DLLs? I'm sure I've tried doing it in the past and it had no effect. Has it changed?

[b]
IanM
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Nov 2011 00:32
Quote: "The unhelpful error message when using variadic commands does actually show the name of the command which is unused by the compiler, so theoretically you could put a much more helpful message there"

I hadn't thought about where the name it displays comes from - I'll update with that detail. Thanks

Quote: "Also, I didn't think the dependency system allowed dependencies on user DLLs?"

It does work - I use it myself, and have done since I became aware of the mechanism.

For example, plug-in number 26 which provides callbacks during the SYNC process depends upon plug-in number 20 (function pointers):


There are no commands from the function pointer plug-in included in that code, but if you check, you'll see that the plug-in is automatically included during compilation. All the code for getting the function pointer from the name is in plug-in 20.

Excerpts from plug-in 26:


(Function calls GetFunctionPtrByName and IsValidFunctionPtr are exported functions from plug-in 20).

Booma
10
Years of Service
User Offline
Joined: 29th Mar 2009
Location:
Posted: 26th Nov 2011 10:53
Very useful information about callbacks and rendering sequence, Thank's
Weave
12
Years of Service
User Offline
Joined: 26th Sep 2006
Location:
Posted: 20th Dec 2011 16:24
Recently wrote my first dll to add two numbers, have downloaded your pdf, thanks.

Would it be possible to write a dll that returns a value for sound files sound volumes as they play like a Level Meter say, as it gets very complex an issue considering licenses to do so and the complex nature of ogg file data?

Any pointers to do so simply would be great if anyone knows any?

Hope you don`t mind my asking.

Thanks
IanM
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Dec 2011 17:44
Quote: "Would it be possible to write a dll that returns a value for sound files sound volumes as they play like a Level Meter say, as it gets very complex an issue considering licenses to do so and the complex nature of ogg file data?"

Yes.

The DBPro Sound plug-in contains a function called GetSoundBuffer that returns a pointer to the DirectX IDirectSoundBuffer object - you can query that to find out the current play position within the buffer.

There's a function in there called GetSound that can be used to access DBPro's internal sound objects (this is a very thin wrapper containing the status of the sound).

There's a function called GetSoundData which can be used to access the sound data itself.

Take a look at the source code for yourself: http://code.google.com/p/darkbasicpro/source/browse/trunk/+darkbasicpro+--username+LeeBamberTGC/Dark+Basic+Pro+SDK/Shared/Sound/

Robert The Robot
12
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 2nd Jan 2012 20:49
This is fantastic, there's a lot of stuff in there I had no idea was even possible. Just one question, are the DirectX runtime fuinctions (D3DDeviceLost, etc) supposed to work with the DBP command "Set Display Mode"?

I have a plugin to put 1000 images on screen per call, but after a call to "Set Display Mode" my custom sprites disappear:



I've modified my plugin code to produce error messages but these are never seen (except, as you say, when fullscreen is Alt-Tabbed out)


Is there a reason for this? I know I could just create a D3D sprite object at the start of DGSpriteDraw and release at the end, but that seems a waste of time to me. Any ideas how I could get this working?

We spend our lives chasing dreams. Dark Basic lets us catch some of them.
Matty H
10
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 13th Jan 2012 21:11 Edited at: 13th Jan 2012 21:13
Great resource IanM, thanks.

Quote: "DBPro Type C++ Type Microsoft Alternative
boolean bool bool
byte unsigned char BYTE
word unsigned short WORD
dword unsigned long DWORD
integer int
float float (as an argument)
string char* or const char* LPSTR or LPCSTR
double float double
double integer long long __int64 or LONGLONG"


If we are using 'unsigned int' then do we export that as DWORD? My thinking is 'unsigned int' and 'unsigned long' will be the same thing?

EDIT: Sorry your table looks confusing on here(no spaces), if anyone needs to know, you can get the pdf from the top post which properly lists all the types etc

IanM
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Jan 2012 22:19
unsigned int and unsigned long are different types as far as C++ in concerned, but they just happen to have exactly the same representation, so yes you can use DWORD/unsigned long instead.

Matty H
10
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 14th Jan 2012 19:08
Thanks IanM.

basjak
9
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 26th Jan 2012 00:55 Edited at: 26th Jan 2012 02:36
am trying to make a DLL using visual C++ express edition 2010 but, all dlls I tried myself don't seem to be seen using 'load dll' command. however, no crash happen.

is it me who's doing wrong or i must use c++ express edition 2008.
IanM
Retired Moderator
16
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Jan 2012 20:40
I suspect that you have forgotten to export your functions - if not, I'll need to see an example project (code included) to see what's wrong.

Also remember that the express editions don't have a resource editor (although I think you can still compile resources), so you'll need to use a third-party resource editor to build a full plug-in.

Login to post a reply

Server time is: 2019-08-24 02:10:41
Your offset time is: 2019-08-24 02:10:41