Pages: 1
  Print  
Author Topic: How do I use DLL inside ENIGMA?  (Read 1313 times)
Offline (Unknown gender) Darkstar2
Posted on: April 29, 2014, 07:25:43 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
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 ?


Logged
Offline (Male) Goombert
Reply #1 Posted on: April 29, 2014, 07:31:25 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
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.
« Last Edit: April 29, 2014, 07:33:19 PM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #2 Posted on: April 29, 2014, 07:51:22 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
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 ?

« Last Edit: April 29, 2014, 07:56:03 PM by Darkstar2 » Logged
Offline (Male) Goombert
Reply #3 Posted on: April 29, 2014, 08:15:05 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
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.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #4 Posted on: May 01, 2014, 10:54:42 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
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.
Logged
Pages: 1
  Print