Archived

This topic is now archived and is closed to further replies.

Drath

Tutorial DLL?

Recommended Posts

Drath    138
Is there anyway to create a dll out of one of the lessons or does one exist. What I mean by is a dll that you could call a specific function and the dll would create the OpenGL window, another to make the scene and another to and polys, lights, etc. Does anyone know of a DLL like this or how to make one? Thanks...

Share this post


Link to post
Share on other sites
Drath    138
Hmm...
Thanks but it doesnt help much. The dll is virtually blank.
I was wondering more on how to convert the Lesson 2 source to dll (because this introduces poly). I could later add such things as custon points and lights and textures but I just want to start basic. I want to build it for use in a program called "Jamagic", avalible from www.clickteam.com . It is a bit like dark basic, blitz basic etc but it uses a java-script type of coding and is a lot more powerful. I want to create a window within the program then render things to it using the dll, retriving the window using user32.dll.

Does anyone have any idea?

Thanks...

Share this post


Link to post
Share on other sites
Drath    138
Suddenly...
I got a flash of inspiration...
I created an empty dll and imported the lesson 2 cpp. I ran it on Jamagic for fun but ofcourse nothing happened! What functions should I export so I can run it with my app?

Thanks...

Share this post


Link to post
Share on other sites
Drath    138
I completed my DLL taken from lesson 2. It is incredibly easy to do. Just create an empty dll, import a lesons cpp file, then create a .def file in the recources folder and add to it:
EXPORTS
WinMain

Then build and run!

Share this post


Link to post
Share on other sites
Cobra    122
Nicely done.
( u wouldnt happen to be able to make that source available would you? hehe. Dll''s and OpenGL have never been very friendly to me lol )

Share this post


Link to post
Share on other sites
Cobra    122
I managed to create the dll.... that''s never been a problem, but calling it from the exe im not too sure on :/

I imported lesson 2 btw.. just like you did.

*trundles off to see if he can link it in.*

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
There are two methods for calling dll functions from an exe. Static linkage and dynamic linkage.

Static linkage requires creating a .lib file for the linker to use when linking the various .obj files to form the .exe. To create a .lib file change the settings on your compiler. To include the .lib file in the linkage, change your makefile or change the settings on your ide. Static linkage is how the core windows dlls are typically used by an .exe - Kernel32.dll for example. The benefit is less coding hassle. The downside is having to create your own .lib file and having to instruct the linker to link it to your .exe.

Dynamic linkage requires foreknowledge of the signatures of the functions you want to call. These are typically set up as pointers to functions - sometimes typedefed too. For example:

typedef returntype (*pfn)(args)

Then the library has to be loaded using LoadLibrary. Then using the handle returned from LoadLibrary call GetProcAddress thusly:

targetfunctionpointer func = GetProcAddress(hLib, "targetfunctin";

And when you''re done with it all call FreeLibrary. The benefit of this approach is that if the dll is missing you can bail out gracefully. The downside is the setup prep and takedown.

This is a very general sketch, but more than enough for a google query.

Share this post


Link to post
Share on other sites
Drath    138
I am going to create a dll where you can change the polygons during run time in a seperateprogram. It should be easy. I will just implant the ''while(!done)'' loop into my program and add some functions. I will find a place to load it to when I''m done.

Share this post


Link to post
Share on other sites
aSe    122
I have a DLL tutorial up at my site, www.coldcity.com. It''s designed for people who don''t like all the crap that VC++ generates, and shows you how to knock up a DLL in VC++ that you can then use from VC++ or VB... might be helpful.

-=aSe=-

Share this post


Link to post
Share on other sites