ENIGMA Forums

Outsourcing saves money => Programming Help => Topic started by: Darkstar2 on April 29, 2014, 07:25:43 pm

Title: How do I use DLL inside ENIGMA?
Post by: Darkstar2 on April 29, 2014, 07:25:43 pm
Can I use DLL libraries inside my projects ?
If so how do I do that ?

I am eventually thinking of making custom functions in C++ and make them as DLL and call them from GML.

Remember I was talking that I wanted to write a custom library to handle individual external resources
files where I can store encrypted levels, sounds, video, etc. etc. etc.  I could do that as scripts inside LGM, but I want to do those in C++ and create a DLL from it, and call the functions from GML.

Example function

Sound1=ExtResource("Sounds.res","intro.wav");

This would call the function I made in C++
which will handle all this automatically (calling an embedded index file in the res file and extract the right file).

If this can be done could someone guide me with
a very simple example?

Thanks.

ALSO if I use this method, according to the current license, do I also have to provide the source code for the DLL/ C++ ? or it is not necessary, only have to provide the EGM file ?


Title: Re: How do I use DLL inside ENIGMA?
Post by: Goombert on April 29, 2014, 07:31:25 pm
You actually, don't even have to do that, you can just place a folder inside the extensions folder in enigma-dev/ENIGMAsystem/SHELL/Universal_System/Extensions. Then you just add the source files and an about.ey descriptor, place all of your extension functions in namespace enigma_user

For instance, take a look at the date and time extension.
https://github.com/enigma-dev/enigma-dev/tree/master/ENIGMAsystem/SHELL/Universal_System/Extensions/DateTime
It's pretty simple to understand really, easier than GM too because you don't actually have to create a million scripts for each function. It will also work cross platform because it does not rely on a DLL, but just a lib as if you were programming in anything else.
Title: Re: How do I use DLL inside ENIGMA?
Post by: Darkstar2 on April 29, 2014, 07:51:22 pm
Looks far too confusing and more complicated than just using scripts, how would I know how to edit the required files so that it "plugs" into LGM ?

Or I could simply make the custom C++ library accept arguments and pass them from my scripts in LGM through execute file or shellexec ?

Title: Re: How do I use DLL inside ENIGMA?
Post by: Goombert on April 29, 2014, 08:15:05 pm
No that makes absolutely no sense why you would want to use scripts. You literally just write the functions you want to add to a source and header file, the header file should be included from a generic include.h for all extensions, and just make sure your functions are in namespace enigma_user, it's not complicated at all, it's extremely less complicated than GM.
Title: Re: How do I use DLL inside ENIGMA?
Post by: TheExDeus on May 01, 2014, 10:54:42 am
DLL's in theory should work just like in GM. So just google a tutorial on dll's in GM.

But there is a chance the dll functions ain't working in ENIGMA. Had this before.