Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: McCloud on September 15, 2005, 01:22:42 AM

Title: DLL support for WME?
Post by: McCloud on September 15, 2005, 01:22:42 AM
Hi all,

I was reading through the documention for WME last night, and came across dlls and that WME supports it.  It says that other languages could be used to develope dlls but have not been tested with WME.  I use Visual Basic 6 and have created a few dll's for use with DirectMusic sometime ago, it's pretty much a class that wraps up all the complicated calls to DirectX and simplify it into simple calls.  Does any one know if I will be able to call my dll from WME?  I tried once and it said there was a script error but I couldn't find what there error was.  I click the log tab in WME's main screen and it's blank.  Do you have to declare it in a certain script file in order for it to work properly?  I would like to make the dll calls available anywhere in the game.

The values that would need to be passed to the dll would be a filename(string) to the audio source to be used, hWnd(Long) for the window handle and some other intergers and longs for the tracks and positions.

I havn't worked much with dlls, but I thought it would be cool if I could get them to work with WME.  And if I can do it with VB6, which I'm most familer with, that would be awsome.  Just need a little direction.

Thanks
-McCloud
Title: Re: DLL support for WME?
Post by: Nihil on September 15, 2005, 07:16:34 AM
I haven't dealt with DLL-creation myself yet, so I don't know if it works with other languages, but there are some other things to care for as mentioned in the docs: the dll-name must start with wme_, and you need to export the three functions mentioned there. And I don't know if it's mandatory to include the header-files that are in the plugin-folder?

And I don't know if it's so easily possible to call DirectMusic-functions via a Dll from WME.

I guess Mnemonic and Metamorphium can tell you more about this :-)
Title: Re: DLL support for WME?
Post by: Mnemonic on September 15, 2005, 07:52:30 AM
There are two ways of using DLLs in WME. You can either call individual functions from "normal" DLL libraries, in that case you need to declare the DLL functions in every script you're going to call them from. It's described in the "Calling external DLL libraries from WME scripts" chapter in the docs. I believe that's what McCloud had on his mind.

Second way is creating specialized plugin DLLs, which appear as a new scripting objects in WME. These DLLs need to be named wme_*.dll and they have to export those three mandatory functions. That's what nihil is talking about.

Unfortunately, I'm not sure Visual Basic 6 is capable of generating "normal" windows DLLs. I think it can only create OCX library, which is a specialized DLL that cannot be used from WME. But then again, I don't know much about VB so I may be wrong...
Title: Re: DLL support for WME?
Post by: Nihil on September 15, 2005, 08:58:24 AM
Oh, right, I totally forgot about the "old" DLLs.
Is it possible to use Dx-functions and so on with them?
Title: Re: DLL support for WME?
Post by: Mnemonic on September 15, 2005, 11:51:17 AM
Is it possible to use Dx-functions and so on with them?
Well, not really. DirectX uses mostly COM interfaces, and the DLL functions only allow you to query these interfaces. You'd have to write some kind of wrapper in your DLL (I guess that's what McCloud did).


McCloud: I've been told VB6 indeed cannot create normal DLLs, so I'm afraid that's not a way to go... One would have to use C or Delphi for this purpose.
Title: Re: DLL support for WME?
Post by: McCloud on September 15, 2005, 11:11:13 PM
Thanks for the input guys.  At least now I want waste any more time on it.  I would think that VB.NET could do it, but unfortunatly I have a beta version of .NET and it always crashes on me.  I've tried a few times to use my VB6 DLL, it seems I can declare the dll, but when I make a call to one of it's functions, there is a script error.  Man, I got really excited for a moment too.  Anyway, again, thanks for your help.

-McCloud
Title: Re: DLL support for WME?
Post by: Jerrot on September 16, 2005, 11:55:35 AM
Thanks for the input guys.  At least now I want waste any more time on it.  I would think that VB.NET could do it, but unfortunatly I have a beta version of .NET and it always crashes on me.  I've tried a few times to use my VB6 DLL, it seems I can declare the dll, but when I make a call to one of it's functions, there is a script error.  Man, I got really excited for a moment too.  Anyway, again, thanks for

What does the script error say though?
Title: Re: DLL support for WME?
Post by: McCloud on September 17, 2005, 02:31:09 AM
I'm at work now, but it just says script error, see log.  When I hit the log tab there is nothing there, I found some log files though, but I can't track which one the error is comming from and there's so much information to search through, i couldn't find it. I look again though and see.

-McCloud
Title: Re: DLL support for WME?
Post by: McCloud on September 22, 2005, 01:11:16 AM
Man,

I couldn't find that error for nothing.  I've already started working on something else, but if I come across it I'll be sure to post it here.
Title: Re: DLL support for WME?
Post by: Mnemonic on September 22, 2005, 08:01:30 AM
In theory, with the new COM plugin (http://forum.dead-code.org/index.php?topic=1161) Banbury released today, it should be possible to use Visual Basic COM DLLs.
Title: Re: DLL support for WME?
Post by: McCloud on September 22, 2005, 12:38:20 PM
That's awsome!  I'll try it out when I get some time.  I'm on a bit of a learning curve right now as the ONLY programing language I've known until now is visual basic.   So it's taking me sometime to learn the WME Script.   It's really weird to me.  VB would be like english to me, but WME script seems like a different form of english.  It's like I can understand it's stucture, but the way things are declared and the way some functions and statements are used are a little different.  I keep thinking VB when I'm doing WME script, but I'm learning. 

Thankyou so much for following up on this for me.

-McCloud