Jump to content

Graphics() called in a dll


Rick
 Share

Recommended Posts

Has anyone ever tried calling Graphics() from a dll? It seems to crash my program when I have a dll that has a function that calls Graphics() and I load that dll from a simple lua script:

 

assert(package.loadlib("C:\\Program Files\\Leadwerks Engine SDK\\Models\\Entities\\Pi\\Pi-Cube\\Rick.dll", "luaopen_test"))()
Rick.Init()

 

That's the entire lua script. I'm running it stand alone just like that. Init() ends up running:

 

void CreateGraphics()
{
MessageBoxA(0, "Before Graphics()", "dll", 0);
int ret = Graphics(800, 600);

if(ret == 0)
	MessageBoxA(0, "Failed to load graphics", "dll", 0);

MessageBoxA(0, "After Graphics()", "dll", 0);
}

static int Init(lua_State* L)
{
Initialize();

CreateGraphics();

return 0;
}

 

Yet SciTE bombs and I never get a message box after "Before Graphics()".

 

 

SciTE's debug window says "engine.dll failed to load." I'm not sure why that would be though. There is no other details. The engine.dll is in the same directory as my custom dll. So not sure why it would fail to load it. I mean dll's can use other dlls right?

Link to comment
Share on other sites

All of your DLLs, content, etc. usually needs to be in the same directory or be relatively loaded from the invoker (in this case the Lua script).

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

Well I just figured that since my custom dll is the one that is loading the engine.dll that the engine.dll would need to be in the directory as my custom dll and not the main program that called my custom dll.

 

That's not that far fetched of thinking. Since my custom dll is the one that is using engine.dll and not the lua interpreter.

Link to comment
Share on other sites

You can also have dlls in the system path. I have for example "c:\program files\leadwerks engine sdk" in the path, and never need to copy newton.dll, jointlib.dll and engine.dll to those 3 billion folders of my test programs :)

Saves a lot of harddisk space and manual updating each time the engine is updated.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...